Title: [143928] branches/chromium/1410/Source/WebCore/rendering/TextAutosizer.cpp
Revision
143928
Author
pe...@chromium.org
Date
2013-02-25 08:46:59 -0800 (Mon, 25 Feb 2013)

Log Message

Merge 142534
> [Text Autosizing] Collect narrow descendants and process them separately. Refactoring for
> a change to follow.
> https://bugs.webkit.org/show_bug.cgi?id=109054
> 
> Preparational change to combine narrow descendants of the same autosizing cluster into
> groups by the width difference between the descendant and the block containing all text of
> the parent autosizing cluster. The groups will be autosized with the same multiplier.
> 
> For example, on sites with a sidebar, sometimes the paragraphs next to the sidebar will have
> a large margin individually applied (via a CSS selector), causing them all to individually
> appear narrower than their enclosing blockContainingAllText. Rather than making each of
> these paragraphs into a separate cluster, we eventually want to be able to merge them back
> together into one (or a few) descendant clusters.
> 
> Patch by Anton Vayvod <avay...@chromium.org> on 2013-02-11
> Reviewed by Julien Chaffraix.
> 
> No behavioral changes thus no new tests or test changes.
> 
> * rendering/TextAutosizer.cpp:
> (TextAutosizingClusterInfo): Vector of narrow descendants.
> (WebCore::TextAutosizer::processCluster): Process narrow descendants separately.
> (WebCore::TextAutosizer::processContainer):
> 
>     Remember narrow descendants of the parent cluster for later processing.

TBR=commit-qu...@webkit.org
Review URL: https://codereview.chromium.org/12315083

Modified Paths

Diff

Modified: branches/chromium/1410/Source/WebCore/rendering/TextAutosizer.cpp (143927 => 143928)


--- branches/chromium/1410/Source/WebCore/rendering/TextAutosizer.cpp	2013-02-25 16:09:49 UTC (rev 143927)
+++ branches/chromium/1410/Source/WebCore/rendering/TextAutosizer.cpp	2013-02-25 16:46:59 UTC (rev 143928)
@@ -37,6 +37,7 @@
 
 #include <algorithm>
 #include <wtf/StdLibExtras.h>
+#include <wtf/Vector.h>
 
 namespace WebCore {
 
@@ -47,6 +48,7 @@
     IntSize minLayoutSize;
 };
 
+// Represents cluster related data. Instances should not persist between calls to processSubtree.
 struct TextAutosizingClusterInfo {
     explicit TextAutosizingClusterInfo(RenderBlock* root)
         : root(root)
@@ -61,6 +63,10 @@
     // Upper limit on the difference between the width of the cluster's block containing all
     // text and that of a narrow child before the child becomes a separate cluster.
     float maxAllowedDifferenceFromTextWidth;
+
+    // Descendants of the cluster that are narrower than the block containing all text and must be
+    // processed together.
+    Vector<TextAutosizingClusterInfo> narrowDescendants;
 };
 
 
@@ -150,6 +156,12 @@
     }
 
     processContainer(multiplier, container, clusterInfo, subtreeRoot, windowInfo);
+
+    Vector<TextAutosizingClusterInfo>& narrowDescendants = clusterInfo.narrowDescendants;
+    for (size_t i = 0; i < narrowDescendants.size(); ++i) {
+        TextAutosizingClusterInfo& descendantClusterInfo = narrowDescendants[i];
+        processCluster(descendantClusterInfo, descendantClusterInfo.root, descendantClusterInfo.root, windowInfo);
+    }
 }
 
 void TextAutosizer::processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo& clusterInfo, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
@@ -168,9 +180,13 @@
             // FIXME: Increase list marker size proportionately.
         } else if (isAutosizingContainer(descendant)) {
             RenderBlock* descendantBlock = toRenderBlock(descendant);
-            if (isAutosizingCluster(descendantBlock, clusterInfo)) {
-                TextAutosizingClusterInfo descendantClusterInfo(descendantBlock);
+            TextAutosizingClusterInfo descendantClusterInfo(descendantBlock);
+            if (isWiderDescendant(descendantBlock, clusterInfo) || isIndependentDescendant(descendantBlock))
                 processCluster(descendantClusterInfo, descendantBlock, descendantBlock, windowInfo);
+            else if (isNarrowDescendant(descendantBlock, clusterInfo)) {
+                // Narrow descendants are processed together later to be able to apply the same multiplier
+                // to each of them if necessary.
+                clusterInfo.narrowDescendants.append(descendantClusterInfo);
             } else
                 processContainer(multiplier, descendantBlock, clusterInfo, descendantBlock, windowInfo);
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to