Title: [139473] branches/chromium/1364
Revision
139473
Author
k...@chromium.org
Date
2013-01-11 11:43:49 -0800 (Fri, 11 Jan 2013)

Log Message

Merge 138111
> Text Autosizing: containers wider than their enclosing clusters should be autosized as separate clusters
> https://bugs.webkit.org/show_bug.cgi?id=103627
> 
> Patch by Anton Vayvod <avay...@chromium.org> on 2012-12-18
> Reviewed by Julien Chaffraix.
> 
> Source/WebCore:
> 
> Some blocks of texts might be wider than their parent clusters and need to be autosized separately.
> 
> isAutosizingCluster() now checks for the width of the container being greater than the width of the lowest
> common ancestor of the text nodes of the enclosing cluster. This block containing all text is passed to all
> tree traversal methods.
> An overloaded version is added for cases when we don't have the lowest common ancestor yet.
> 
> The change fixes several cases covered by existing tests.
> 
> * rendering/TextAutosizer.cpp:
> (WebCore::TextAutosizer::processSubtree):
> 
>     Calls processCluster with a new number of arguments.
> 
> (WebCore::TextAutosizer::processCluster):
> 
>     Passes block containing all text nodes into processContainer. Assertion removed since it can no longer be
>     checked without passing an additional parameter (the parent block containing all text) to the function
>     for the sake of this assertion only.
> 
> (WebCore::TextAutosizer::processContainer):
> 
>     |parentBlockContainingAllText| parameter passed into isAutosizingCluster.
> 
> (WebCore::TextAutosizer::isAutosizingCluster(const RenderBlock*, const RenderBlock*)):
> 
>     The overloaded method that is used when the render block checked is already known to be an autosizing
>     container and there's full information necessary to determine if it's a cluster like the parent block
>     containing all text within the enclosing cluster.
>     Considers a block a cluster if it is wider than its parent block containing all text within enclosing
>     cluster.
> 
> (WebCore::TextAutosizer::isAutosizingCluster(const RenderObject*)):
> 
>     The overloaded method that checks for the given object to be an autosizing container first (for
>     convenience of the caller) and doesn't require information about the parent cluster. Used when such
>     information is not available, for example, in the process of retrieving the information for the parent
>     cluster or when looking for the root cluster in the tree.
> 
> (WebCore::TextAutosizer::clusterShouldBeAutosized):
> 
>     Passes new parameter to measureDescendantTextWidth.
> 
> (WebCore::TextAutosizer::measureDescendantTextWidth):
> 
>     Uses blockContainingAllText parameter to pass to isAutosizingCluster.
> 
> (WebCore::TextAutosizer::findDeepestBlockContainingAllText):
> 
>     Assertion removed since it can no longer be checked without passing an additional parameter (the
>     parent block containing all text) to the function for the sake of this assertion only.
> 
> (WebCore::TextAutosizer::findFirstTextLeafNotInCluster):
>     Uses shorter isAutosizingCluster call.
> 
> LayoutTests:
> 
> Modified existing tests to reflect the new autosizing approach to handling of the elements that are
> wider than the lowest common ancestor of the text nodes of the enclosing autosizing cluster.
> 
> * fast/text-autosizing/cluster-wide-in-narrow-expected.html:
> * fast/text-autosizing/cluster-wide-in-narrow.html:
> * fast/text-autosizing/wide-child-expected.html:
> * fast/text-autosizing/wide-child.html:
> * fast/text-autosizing/wide-in-narrow-overflow-scroll-expected.html:
> * fast/text-autosizing/wide-in-narrow-overflow-scroll.html:

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

Modified Paths

Diff

Modified: branches/chromium/1364/LayoutTests/ChangeLog (139472 => 139473)


--- branches/chromium/1364/LayoutTests/ChangeLog	2013-01-11 19:41:17 UTC (rev 139472)
+++ branches/chromium/1364/LayoutTests/ChangeLog	2013-01-11 19:43:49 UTC (rev 139473)
@@ -1,5 +1,22 @@
-2012-12-21  Keishi Hattori  <kei...@webkit.org>
+2012-12-18  Anton Vayvod  <avay...@chromium.org>
 
+        Text Autosizing: containers wider than their enclosing clusters should be autosized as separate clusters
+        https://bugs.webkit.org/show_bug.cgi?id=103627
+
+        Reviewed by Julien Chaffraix.
+
+        Modified existing tests to reflect the new autosizing approach to handling of the elements that are
+        wider than the lowest common ancestor of the text nodes of the enclosing autosizing cluster.
+
+        * fast/text-autosizing/cluster-wide-in-narrow-expected.html:
+        * fast/text-autosizing/cluster-wide-in-narrow.html:
+        * fast/text-autosizing/wide-child-expected.html:
+        * fast/text-autosizing/wide-child.html:
+        * fast/text-autosizing/wide-in-narrow-overflow-scroll-expected.html:
+        * fast/text-autosizing/wide-in-narrow-overflow-scroll.html:
+
+2012-12-18  Filip Pizlo  <fpi...@apple.com>
+
         Fix typing zero into multiple field input
         https://bugs.webkit.org/show_bug.cgi?id=105501
 

Modified: branches/chromium/1364/LayoutTests/fast/text-autosizing/cluster-wide-in-narrow-expected.html (139472 => 139473)


--- branches/chromium/1364/LayoutTests/fast/text-autosizing/cluster-wide-in-narrow-expected.html	2013-01-11 19:41:17 UTC (rev 139472)
+++ branches/chromium/1364/LayoutTests/fast/text-autosizing/cluster-wide-in-narrow-expected.html	2013-01-11 19:43:49 UTC (rev 139473)
@@ -17,13 +17,13 @@
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
     </div>
 
-    <div style="width: 800px; font-size: 1.25rem">
-        This text should be autosized to just 20px computed font-size (16 * 400/320), since despite its width:800px it is part of the 400px wide root cluster.<br>
+    <div style="width: 600px; font-size: 1.875rem">
+        This text should be autosized to 30px computed font-size (16 * 600/320), since its width:600px makes it wider than the lowest common ancestor of its enclosing cluster, hence it will itself become a cluster.<br>
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
     </div>
 
     <div style="font-size: 1.25rem">
-        This text should similarly be autosized to 20px.<br>
+        This text should be autosized to 20px computed font-size (16 * 400 / 320), since it's not an autosizing cluster itself and its parent element is the enclosing autosizing cluster which is 400px wide.<br>
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
     </div>
 </div>

Modified: branches/chromium/1364/LayoutTests/fast/text-autosizing/cluster-wide-in-narrow.html (139472 => 139473)


--- branches/chromium/1364/LayoutTests/fast/text-autosizing/cluster-wide-in-narrow.html	2013-01-11 19:41:17 UTC (rev 139472)
+++ branches/chromium/1364/LayoutTests/fast/text-autosizing/cluster-wide-in-narrow.html	2013-01-11 19:43:49 UTC (rev 139473)
@@ -26,13 +26,13 @@
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
     </div>
 
-    <div style="width: 800px">
-        This text should be autosized to just 20px computed font-size (16 * 400/320), since despite its width:800px it is part of the 400px wide root cluster.<br>
+    <div style="width: 600px">
+        This text should be autosized to 30px computed font-size (16 * 600/320), since its width:600px makes it wider than the lowest common ancestor of its enclosing cluster, hence it will itself become a cluster.<br>
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
     </div>
 
     <div>
-        This text should similarly be autosized to 20px.<br>
+        This text should be autosized to 20px computed font-size (16 * 400 / 320), since it's not an autosizing cluster itself and its parent element is the enclosing autosizing cluster which is 400px wide.<br>
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
     </div>
 </div>

Modified: branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-child-expected.html (139472 => 139473)


--- branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-child-expected.html	2013-01-11 19:41:17 UTC (rev 139472)
+++ branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-child-expected.html	2013-01-11 19:43:49 UTC (rev 139473)
@@ -12,11 +12,10 @@
 <body>
 
 <div style="width: 320px; font-size: 1rem">
-	This text should not be autosized, as this div is the lowest common ancestor of the root cluster, and this div is narrow.<br>
+    This text should not be autosized, as this div is the lowest common ancestor of the root cluster, and this div is narrow.<br>
     Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-	<div style="width: 800px">
-    	This text should not be autosized since it doesn't affect the width of the parent block which is used to calculate the autosizing multiplier.<br>
-    	FIXME: Ideally this text should be autosized. Will need to be fixed later.<br>
+    <div style="width: 800px; font-size: 2.5rem">
+        This text should be autosized to 40px computed font size (16 * 800/320) since it's wider than the lowest common ancestor of its enclosing cluster so it becomes a cluster itself.<br>
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
     </div>
 </div>

Modified: branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-child.html (139472 => 139473)


--- branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-child.html	2013-01-11 19:41:17 UTC (rev 139472)
+++ branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-child.html	2013-01-11 19:43:49 UTC (rev 139473)
@@ -24,8 +24,7 @@
     This text should not be autosized, as this div is the lowest common ancestor of the root cluster, and this div is narrow.<br>
     Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
     <div style="width: 800px">
-    	This text should not be autosized since it doesn't affect the width of the parent block which is used to calculate the autosizing multiplier.<br>
-    	FIXME: Ideally this text should be autosized. Will need to be fixed later.<br>
+        This text should be autosized to 40px computed font size (16 * 800/320) since it's wider than the lowest common ancestor of its enclosing cluster so it becomes a cluster itself.<br>
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
     </div>
 </div>

Modified: branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-in-narrow-overflow-scroll-expected.html (139472 => 139473)


--- branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-in-narrow-overflow-scroll-expected.html	2013-01-11 19:41:17 UTC (rev 139472)
+++ branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-in-narrow-overflow-scroll-expected.html	2013-01-11 19:43:49 UTC (rev 139473)
@@ -12,17 +12,17 @@
 <body>
 
 <div style="width: 400px">
-  <div style="overflow-x: scroll">
-    <div style="width: 800px; font-size: 1.25rem">
-        This text should be autosized to 20px computed font size (16 * 400/320), since this is part of the root cluster, whose text descendants are all contained within the 400px wide grandparent of this div.<br>
-        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+    <div style="overflow-x: scroll">
+        <div style="width: 800px; font-size: 2.5rem">
+            This text should be autosized to 40px computed font size (16 * 800/320) since it's wider than the lowest common ancestor of  its enclosing cluster so it becomes a cluster itself.<br>
+            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+        </div>
     </div>
-  </div>
 
-  <div style="font-size: 1.25rem">
+    <div style="font-size: 1.25rem">
         This text should be autosized to 20px computed font size (16 * 400/320).<br>
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-  </div>
+    </div>
 </div>
 
 </body>

Modified: branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-in-narrow-overflow-scroll.html (139472 => 139473)


--- branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-in-narrow-overflow-scroll.html	2013-01-11 19:41:17 UTC (rev 139472)
+++ branches/chromium/1364/LayoutTests/fast/text-autosizing/wide-in-narrow-overflow-scroll.html	2013-01-11 19:43:49 UTC (rev 139473)
@@ -21,17 +21,17 @@
 <body>
 
 <div style="width: 400px">
-  <div style="overflow-x: scroll">
-    <div style="width: 800px">
-        This text should be autosized to 20px computed font size (16 * 400/320), since this is part of the root cluster, whose text descendants are all contained within the 400px wide grandparent of this div.<br>
-        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+    <div style="overflow-x: scroll">
+        <div style="width: 800px">
+            This text should be autosized to 40px computed font size (16 * 800/320) since it's wider than the lowest common ancestor of  its enclosing cluster so it becomes a cluster itself.<br>
+            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+        </div>
     </div>
-  </div>
 
-  <div>
+    <div>
         This text should be autosized to 20px computed font size (16 * 400/320).<br>
         Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-  </div>
+    </div>
 </div>
 
 </body>

Modified: branches/chromium/1364/Source/WebCore/ChangeLog (139472 => 139473)


--- branches/chromium/1364/Source/WebCore/ChangeLog	2013-01-11 19:41:17 UTC (rev 139472)
+++ branches/chromium/1364/Source/WebCore/ChangeLog	2013-01-11 19:43:49 UTC (rev 139473)
@@ -1,5 +1,67 @@
-2013-01-10  John Mellor  <joh...@chromium.org>
+2012-12-18  Anton Vayvod  <avay...@chromium.org>
 
+        Text Autosizing: containers wider than their enclosing clusters should be autosized as separate clusters
+        https://bugs.webkit.org/show_bug.cgi?id=103627
+
+        Reviewed by Julien Chaffraix.
+
+        Some blocks of texts might be wider than their parent clusters and need to be autosized separately.
+
+        isAutosizingCluster() now checks for the width of the container being greater than the width of the lowest
+        common ancestor of the text nodes of the enclosing cluster. This block containing all text is passed to all
+        tree traversal methods.
+        An overloaded version is added for cases when we don't have the lowest common ancestor yet.
+
+        The change fixes several cases covered by existing tests.
+
+        * rendering/TextAutosizer.cpp:
+        (WebCore::TextAutosizer::processSubtree):
+
+            Calls processCluster with a new number of arguments.
+
+        (WebCore::TextAutosizer::processCluster):
+
+            Passes block containing all text nodes into processContainer. Assertion removed since it can no longer be
+            checked without passing an additional parameter (the parent block containing all text) to the function
+            for the sake of this assertion only.
+
+        (WebCore::TextAutosizer::processContainer):
+
+            |parentBlockContainingAllText| parameter passed into isAutosizingCluster.
+
+        (WebCore::TextAutosizer::isAutosizingCluster(const RenderBlock*, const RenderBlock*)):
+
+            The overloaded method that is used when the render block checked is already known to be an autosizing
+            container and there's full information necessary to determine if it's a cluster like the parent block
+            containing all text within the enclosing cluster. 
+            Considers a block a cluster if it is wider than its parent block containing all text within enclosing
+            cluster.
+
+        (WebCore::TextAutosizer::isAutosizingCluster(const RenderObject*)):
+
+            The overloaded method that checks for the given object to be an autosizing container first (for
+            convenience of the caller) and doesn't require information about the parent cluster. Used when such
+            information is not available, for example, in the process of retrieving the information for the parent
+            cluster or when looking for the root cluster in the tree.
+
+        (WebCore::TextAutosizer::clusterShouldBeAutosized):
+
+            Passes new parameter to measureDescendantTextWidth.
+
+        (WebCore::TextAutosizer::measureDescendantTextWidth):
+
+            Uses blockContainingAllText parameter to pass to isAutosizingCluster.
+
+        (WebCore::TextAutosizer::findDeepestBlockContainingAllText):
+
+            Assertion removed since it can no longer be checked without passing an additional parameter (the
+            parent block containing all text) to the function for the sake of this assertion only.
+
+        (WebCore::TextAutosizer::findFirstTextLeafNotInCluster):
+            Uses shorter isAutosizingCluster call.
+
+2012-12-18  Alexey Proskuryakov  <a...@apple.com>
+
         Fix scale of screen.width, window.outerWidth and @media device-width when page scale not applied in compositor.
         https://bugs.webkit.org/show_bug.cgi?id=106460
 

Modified: branches/chromium/1364/Source/WebCore/rendering/TextAutosizer.cpp (139472 => 139473)


--- branches/chromium/1364/Source/WebCore/rendering/TextAutosizer.cpp	2013-01-11 19:41:17 UTC (rev 139472)
+++ branches/chromium/1364/Source/WebCore/rendering/TextAutosizer.cpp	2013-01-11 19:43:49 UTC (rev 139473)
@@ -26,6 +26,7 @@
 
 #include "Document.h"
 #include "InspectorInstrumentation.h"
+#include "IntSize.h"
 #include "RenderObject.h"
 #include "RenderStyle.h"
 #include "RenderText.h"
@@ -85,7 +86,7 @@
         container = container->containingBlock();
 
     RenderBlock* cluster = container;
-    while (cluster && (!isAutosizingContainer(cluster) || !isAutosizingCluster(cluster)))
+    while (cluster && !isAutosizingCluster(cluster))
         cluster = cluster->containingBlock();
 
     processCluster(cluster, container, layoutRoot, windowInfo);
@@ -94,36 +95,34 @@
 
 void TextAutosizer::processCluster(RenderBlock* cluster, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
 {
-    ASSERT(isAutosizingCluster(cluster));
-
     // Many pages set a max-width on their content. So especially for the
     // RenderView, instead of just taking the width of |cluster| we find
     // the lowest common ancestor of the first and last descendant text node of
     // the cluster (i.e. the deepest wrapper block that contains all the text),
     // and use its width instead.
-    const RenderBlock* lowestCommonAncestor = findDeepestBlockContainingAllText(cluster);
-    float commonAncestorWidth = lowestCommonAncestor->contentLogicalWidth();
+    const RenderBlock* blockContainingAllText = findDeepestBlockContainingAllText(cluster);
+    float textWidth = blockContainingAllText->contentLogicalWidth();
 
     float multiplier = 1;
-    if (clusterShouldBeAutosized(lowestCommonAncestor, commonAncestorWidth)) {
+    if (clusterShouldBeAutosized(blockContainingAllText, textWidth)) {
         int logicalWindowWidth = cluster->isHorizontalWritingMode() ? windowInfo.windowSize.width() : windowInfo.windowSize.height();
         int logicalLayoutWidth = cluster->isHorizontalWritingMode() ? windowInfo.minLayoutSize.width() : windowInfo.minLayoutSize.height();
         // Ignore box width in excess of the layout width, to avoid extreme multipliers.
-        float logicalClusterWidth = std::min<float>(commonAncestorWidth, logicalLayoutWidth);
+        float logicalClusterWidth = std::min<float>(textWidth, logicalLayoutWidth);
 
         multiplier = logicalClusterWidth / logicalWindowWidth;
         multiplier *= m_document->settings()->textAutosizingFontScaleFactor();
         multiplier = std::max(1.0f, multiplier);
     }
 
-    processContainer(multiplier, container, subtreeRoot, windowInfo);
+    processContainer(multiplier, container, blockContainingAllText, subtreeRoot, windowInfo);
 }
 
-void TextAutosizer::processContainer(float multiplier, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
+void TextAutosizer::processContainer(float multiplier, RenderBlock* container, const RenderBlock* blockContainingAllText, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
 {
     ASSERT(isAutosizingContainer(container));
 
-    float localMultiplier = containerShouldbeAutosized(container) ? multiplier: 1;
+    float localMultiplier = containerShouldBeAutosized(container) ? multiplier: 1;
 
     RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot);
     while (descendant) {
@@ -135,10 +134,10 @@
             // FIXME: Increase list marker size proportionately.
         } else if (isAutosizingContainer(descendant)) {
             RenderBlock* descendantBlock = toRenderBlock(descendant);
-            if (isAutosizingCluster(descendantBlock))
+            if (isAutosizingCluster(descendantBlock, blockContainingAllText))
                 processCluster(descendantBlock, descendantBlock, descendantBlock, windowInfo);
             else
-                processContainer(multiplier, descendantBlock, descendantBlock, windowInfo);
+                processContainer(multiplier, descendantBlock, blockContainingAllText, descendantBlock, windowInfo);
         }
         descendant = nextInPreOrderSkippingDescendantsOfContainers(descendant, subtreeRoot);
     }
@@ -196,14 +195,14 @@
     return true;
 }
 
-bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer)
+bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, const RenderBlock* parentBlockContainingAllText)
 {
     // "Autosizing clusters" are special autosizing containers within which we
     // want to enforce a uniform text size multiplier, in the hopes of making
     // the major sections of the page look internally consistent.
-    // All their descendents (including other autosizing containers) must share
+    // All their descendants (including other autosizing containers) must share
     // the same multiplier, except for subtrees which are themselves clusters,
-    // and some of their descendent containers might not be autosized at all
+    // and some of their descendant containers might not be autosized at all
     // (for example if their height is constrained).
     // Additionally, clusterShouldBeAutosized requires each cluster to contain a
     // minimum amount of text, without which it won't be autosized.
@@ -212,11 +211,14 @@
     // block formatting contexts (http://w3.org/TR/css3-box/#flow-root), since
     // flow roots correspond to box containers that behave somewhat
     // independently from their parent (for example they don't overlap floats).
-    // The definition of a flow flow root also conveniently includes most of the
+    // The definition of a flow root also conveniently includes most of the
     // ways that a box and its children can have significantly different width
     // from the box's parent (we want to avoid having significantly different
     // width blocks within a cluster, since the narrower blocks would end up
     // larger than would otherwise be necessary).
+    // Additionally, any containers that are wider than the |blockContainingAllText|
+    // of their enclosing cluster also become clusters, since they need special
+    // treatment due to their width.
     ASSERT(isAutosizingContainer(renderer));
 
     return renderer->isRenderView()
@@ -227,12 +229,19 @@
         || renderer->isFlexibleBoxIncludingDeprecated()
         || renderer->hasColumns()
         || renderer->containingBlock()->isHorizontalWritingMode() != renderer->isHorizontalWritingMode()
-        || renderer->style()->isDisplayReplacedType();
+        || renderer->style()->isDisplayReplacedType()
+        || (parentBlockContainingAllText
+            && renderer->contentLogicalWidth() > parentBlockContainingAllText->contentLogicalWidth());
     // FIXME: Tables need special handling to multiply all their columns by
     // the same amount even if they're different widths; so do hasColumns()
     // containers, and probably flexboxes...
 }
 
+bool TextAutosizer::isAutosizingCluster(const RenderObject* object)
+{
+    return isAutosizingContainer(object) && isAutosizingCluster(toRenderBlock(object), 0);
+}
+
 static bool contentHeightIsConstrained(const RenderBlock* container)
 {
     // FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box.
@@ -253,7 +262,7 @@
     return false;
 }
 
-bool TextAutosizer::containerShouldbeAutosized(const RenderBlock* container)
+bool TextAutosizer::containerShouldBeAutosized(const RenderBlock* container)
 {
     // Don't autosize block-level text that can't wrap (as it's likely to
     // expand sideways and break the page's layout).
@@ -263,7 +272,7 @@
     return !contentHeightIsConstrained(container);
 }
 
-bool TextAutosizer::clusterShouldBeAutosized(const RenderBlock* lowestCommonAncestor, float commonAncestorWidth)
+bool TextAutosizer::clusterShouldBeAutosized(const RenderBlock* blockContainingAllText, float blockWidth)
 {
     // Don't autosize clusters that contain less than 4 lines of text (in
     // practice less lines are required, since measureDescendantTextWidth
@@ -276,17 +285,17 @@
     // in and pan from side to side to read each line, since if there are very
     // few lines of text you'll only need to pan across once or twice.
     const float minLinesOfText = 4;
-    float minTextWidth = commonAncestorWidth * minLinesOfText;
+    float minTextWidth = blockWidth * minLinesOfText;
     float textWidth = 0;
-    measureDescendantTextWidth(lowestCommonAncestor, minTextWidth, textWidth);
+    measureDescendantTextWidth(blockContainingAllText, blockContainingAllText, minTextWidth, textWidth);
     if (textWidth >= minTextWidth)
         return true;
     return false;
 }
 
-void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth)
+void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, const RenderBlock* blockContainingAllText, float minTextWidth, float& textWidth)
 {
-    bool skipLocalText = !containerShouldbeAutosized(container);
+    bool skipLocalText = !containerShouldBeAutosized(container);
 
     RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container);
     while (descendant) {
@@ -294,8 +303,8 @@
             textWidth += toRenderText(descendant)->renderedTextLength() * descendant->style()->specifiedFontSize();
         } else if (isAutosizingContainer(descendant)) {
             RenderBlock* descendantBlock = toRenderBlock(descendant);
-            if (!isAutosizingCluster(descendantBlock))
-                measureDescendantTextWidth(descendantBlock, minTextWidth, textWidth);
+            if (!isAutosizingCluster(descendantBlock, blockContainingAllText))
+                measureDescendantTextWidth(descendantBlock, blockContainingAllText, minTextWidth, textWidth);
         }
         if (textWidth >= minTextWidth)
             return;
@@ -321,8 +330,6 @@
 
 const RenderBlock* TextAutosizer::findDeepestBlockContainingAllText(const RenderBlock* cluster)
 {
-    ASSERT(isAutosizingCluster(cluster));
-
     size_t firstDepth = 0;
     const RenderObject* firstTextLeaf = findFirstTextLeafNotInCluster(cluster, firstDepth, FirstToLast);
     if (!firstTextLeaf)
@@ -371,7 +378,7 @@
     ++depth;
     const RenderObject* child = (direction == FirstToLast) ? parent->firstChild() : parent->lastChild();
     while (child) {
-        if (!isAutosizingContainer(child) || !isAutosizingCluster(toRenderBlock(child))) {
+        if (!isAutosizingCluster(child)) {
             const RenderObject* leaf = findFirstTextLeafNotInCluster(child, depth, direction);
             if (leaf)
                 return leaf;

Modified: branches/chromium/1364/Source/WebCore/rendering/TextAutosizer.h (139472 => 139473)


--- branches/chromium/1364/Source/WebCore/rendering/TextAutosizer.h	2013-01-11 19:41:17 UTC (rev 139472)
+++ branches/chromium/1364/Source/WebCore/rendering/TextAutosizer.h	2013-01-11 19:43:49 UTC (rev 139473)
@@ -28,17 +28,14 @@
 
 #if ENABLE(TEXT_AUTOSIZING)
 
-#include "IntSize.h"
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
 class Document;
 class RenderBlock;
 class RenderObject;
-class RenderStyle;
 class RenderText;
 struct TextAutosizingWindowInfo;
 
@@ -63,22 +60,21 @@
     explicit TextAutosizer(Document*);
 
     void processCluster(RenderBlock* cluster, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
-    void processContainer(float multiplier, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
+    void processContainer(float multiplier, RenderBlock* container, const RenderBlock* blockContainingAllText, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
 
     void setMultiplier(RenderObject*, float);
 
     static bool isAutosizingContainer(const RenderObject*);
-    static bool isAutosizingCluster(const RenderBlock*);
+    static bool isAutosizingCluster(const RenderBlock*, const RenderBlock* parentBlockContainingAllText);
+    static bool isAutosizingCluster(const RenderObject*);
 
-    static bool containerShouldbeAutosized(const RenderBlock* container);
-    static bool clusterShouldBeAutosized(const RenderBlock* lowestCommonAncestor, float commonAncestorWidth);
-    static void measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth);
+    static bool containerShouldBeAutosized(const RenderBlock* container);
+    static bool clusterShouldBeAutosized(const RenderBlock* blockContainingAllText, float blockWidth);
+    static void measureDescendantTextWidth(const RenderBlock* container, const RenderBlock* blockContainingAllText, float minTextWidth, float& textWidth);
 
     // Use to traverse the tree of descendants, excluding descendants of containers (but returning the containers themselves).
-    static RenderObject* nextInPreOrderSkippingDescendantsOfContainers(const RenderObject* current, const RenderObject* stayWithin);
+    static RenderObject* nextInPreOrderSkippingDescendantsOfContainers(const RenderObject*, const RenderObject* stayWithin);
 
-    // Finds the lowest common ancestor of the first and the last descendant
-    // text node (excluding those belonging to other autosizing clusters).
     static const RenderBlock* findDeepestBlockContainingAllText(const RenderBlock* cluster);
 
     // Depending on the traversal direction specified, finds the first or the last leaf text node child that doesn't
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to