Diff
Modified: trunk/LayoutTests/ChangeLog (139434 => 139435)
--- trunk/LayoutTests/ChangeLog 2013-01-11 13:28:32 UTC (rev 139434)
+++ trunk/LayoutTests/ChangeLog 2013-01-11 13:56:37 UTC (rev 139435)
@@ -1,3 +1,22 @@
+2013-01-11 Anton Vayvod <[email protected]>
+
+ Text Autosizing - elements much narrower than its parent autosizing clusters should be autosized separately.
+ https://bugs.webkit.org/show_bug.cgi?id=105188
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Checked that a narrow autosizing container becomes an autosizing cluster.
+ Fixed other tests that used narrow descendant blocks.
+
+ * fast/text-autosizing/cluster-narrow-in-wide-expected.html:
+ * fast/text-autosizing/cluster-narrow-in-wide-ohidden-expected.html:
+ * fast/text-autosizing/cluster-narrow-in-wide-ohidden.html:
+ * fast/text-autosizing/cluster-narrow-in-wide.html:
+ * fast/text-autosizing/cluster-with-wide-lca-expected.html:
+ * fast/text-autosizing/cluster-with-wide-lca.html:
+ * fast/text-autosizing/narrow-child-expected.html:
+ * fast/text-autosizing/narrow-child.html:
+
2013-01-11 Antoine Quint <[email protected]>
Web Inspector: Option+Click on Node Expander Doesn't Work the First Time
Modified: trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-expected.html (139434 => 139435)
--- trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-expected.html 2013-01-11 13:28:32 UTC (rev 139434)
+++ trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-expected.html 2013-01-11 13:56:37 UTC (rev 139435)
@@ -11,14 +11,20 @@
</head>
<body>
-<div style="width: 400px; float: left; font-size: 1.25rem">
- This text should be autosized to just 20px computed font size (16 * 400/320), since the float:left causes this to be a new cluster, and it is only 400px wide.
+<div style="width: 600px; float: left; font-size: 1.875rem">
+ This text should be autosized to just 30px computed font size (16 * 600/320), since the float:left causes this to be a new cluster, and it is only 600px wide.
</div>
-<div style="width: 320px; font-size: 2.5rem">
- This text should be autosized to 40px computed font-size (16 * 800/320), since despite its width:320px it is part of the 800px wide root cluster.
+<div style="width: 320px">
+ This text should not be autosized, since because of its width:320px it becomes a separate cluster.<br>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
+<div style="width: 600px; font-size: 2.5rem">
+ This text should be autosized to 40px computed font size (16 * 800/320), since it's a part of the root cluster.<br>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+</div>
+
<div style="font-size: 2.5rem">
This text should similarly be autosized to 40px.<br>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Modified: trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-ohidden-expected.html (139434 => 139435)
--- trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-ohidden-expected.html 2013-01-11 13:28:32 UTC (rev 139434)
+++ trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-ohidden-expected.html 2013-01-11 13:56:37 UTC (rev 139435)
@@ -11,7 +11,7 @@
</head>
<body>
-<div style="width: 400px; overflow: hidden; font-size: 2.5rem">
+<div style="width: 600px; overflow: hidden; font-size: 2.5rem">
This text should be autosized to 40px computed font size (16 * 800/320), since the overflow:hidden does not cause this to be a new cluster, so it is part of the 800px wide root cluster.
</div>
Modified: trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-ohidden.html (139434 => 139435)
--- trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-ohidden.html 2013-01-11 13:28:32 UTC (rev 139434)
+++ trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide-ohidden.html 2013-01-11 13:56:37 UTC (rev 139435)
@@ -20,7 +20,7 @@
</head>
<body>
-<div style="width: 400px; overflow: hidden">
+<div style="width: 600px; overflow: hidden">
This text should be autosized to 40px computed font size (16 * 800/320), since the overflow:hidden does not cause this to be a new cluster, so it is part of the 800px wide root cluster.
</div>
Modified: trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide.html (139434 => 139435)
--- trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide.html 2013-01-11 13:28:32 UTC (rev 139434)
+++ trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide.html 2013-01-11 13:56:37 UTC (rev 139435)
@@ -20,14 +20,20 @@
</head>
<body>
-<div style="width: 400px; float: left">
- This text should be autosized to just 20px computed font size (16 * 400/320), since the float:left causes this to be a new cluster, and it is only 400px wide.
+<div style="width: 600px; float: left">
+ This text should be autosized to just 30px computed font size (16 * 600/320), since the float:left causes this to be a new cluster, and it is only 600px wide.
</div>
<div style="width: 320px">
- This text should be autosized to 40px computed font-size (16 * 800/320), since despite its width:320px it is part of the 800px wide root cluster.
+ This text should not be autosized, since because of its width:320px it becomes a separate cluster.<br>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
+<div style="width: 600px">
+ This text should be autosized to 40px computed font size (16 * 800/320), since it's a part of the root cluster.<br>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+</div>
+
<div>
This text should similarly be autosized to 40px.<br>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Modified: trunk/LayoutTests/fast/text-autosizing/cluster-with-wide-lca-expected.html (139434 => 139435)
--- trunk/LayoutTests/fast/text-autosizing/cluster-with-wide-lca-expected.html 2013-01-11 13:28:32 UTC (rev 139434)
+++ trunk/LayoutTests/fast/text-autosizing/cluster-with-wide-lca-expected.html 2013-01-11 13:56:37 UTC (rev 139435)
@@ -11,7 +11,7 @@
</head>
<body>
-<div style="width: 400px">
+<div style="width: 600px">
<div style="font-size: 2.5rem">
This text should be autosized to 40px computed font size (16 * 800/320) since the least common ancestor of all the cluster's text descendants is the BODY tag.
</div>
Modified: trunk/LayoutTests/fast/text-autosizing/cluster-with-wide-lca.html (139434 => 139435)
--- trunk/LayoutTests/fast/text-autosizing/cluster-with-wide-lca.html 2013-01-11 13:28:32 UTC (rev 139434)
+++ trunk/LayoutTests/fast/text-autosizing/cluster-with-wide-lca.html 2013-01-11 13:56:37 UTC (rev 139435)
@@ -20,7 +20,7 @@
</head>
<body>
-<div style="width: 400px">
+<div style="width: 600px">
<div>
This text should be autosized to 40px computed font size (16 * 800/320) since the least common ancestor of all the cluster's text descendants is the BODY tag.
</div>
Modified: trunk/LayoutTests/fast/text-autosizing/narrow-child-expected.html (139434 => 139435)
--- trunk/LayoutTests/fast/text-autosizing/narrow-child-expected.html 2013-01-11 13:28:32 UTC (rev 139434)
+++ trunk/LayoutTests/fast/text-autosizing/narrow-child-expected.html 2013-01-11 13:56:37 UTC (rev 139435)
@@ -12,10 +12,12 @@
<body>
<div style="font-size: 2.5rem">
- This text should all be autosized to 40px computed font-size, since although this has a narrow child block, the cluster will still be wide and need autosizing.
- <div style="width: 320px">
+ This text should be autosized to 40px computed font-size, since although this has a narrow child block, the cluster will still be wide and need autosizing.
+ <div style="width: 600px">
+ This text should be autosized to 40px computed font-size as it is a part of the same cluster as the parent div.<br>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
+ This text should be autosized to 40px computed font-size, similarly to the text at the top.<br>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
Modified: trunk/LayoutTests/fast/text-autosizing/narrow-child.html (139434 => 139435)
--- trunk/LayoutTests/fast/text-autosizing/narrow-child.html 2013-01-11 13:28:32 UTC (rev 139434)
+++ trunk/LayoutTests/fast/text-autosizing/narrow-child.html 2013-01-11 13:56:37 UTC (rev 139435)
@@ -21,10 +21,12 @@
<body>
<div>
- This text should all be autosized to 40px computed font-size, since although this has a narrow child block, the cluster will still be wide and need autosizing.
- <div style="width: 320px">
+ This text should be autosized to 40px computed font-size, since although this has a narrow child block, the cluster will still be wide and need autosizing.
+ <div style="width: 600px">
+ This text should be autosized to 40px computed font-size as it is a part of the same cluster as the parent div.<br>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
+ This text should be autosized to 40px computed font-size, similarly to the text at the top.<br>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
Modified: trunk/Source/WebCore/ChangeLog (139434 => 139435)
--- trunk/Source/WebCore/ChangeLog 2013-01-11 13:28:32 UTC (rev 139434)
+++ trunk/Source/WebCore/ChangeLog 2013-01-11 13:56:37 UTC (rev 139435)
@@ -1,3 +1,20 @@
+2013-01-11 Anton Vayvod <[email protected]>
+
+ Text Autosizing - elements much narrower than its parent autosizing clusters should be autosized separately.
+ https://bugs.webkit.org/show_bug.cgi?id=105188
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Some blocks of text might be narrower than their parent clusters and should be autosized separately.
+ This helps with autosizing for the pages implementing the sidebars as a narrow blocks of text with wide margins and
+ the main content being positioned atop this margin (or vice versa).
+
+ * rendering/TextAutosizer.cpp:
+ (WebCore::TextAutosizer::isContainerAutosizingCluster):
+
+ Returns true if the container is more than 200 pixels narrower than its parent cluster's lowest common
+ ancestor of all the text nodes.
+
2013-01-11 Andreas Kling <[email protected]>
Remove unused CSSSelector(QualifiedName) constructor.
Modified: trunk/Source/WebCore/rendering/TextAutosizer.cpp (139434 => 139435)
--- trunk/Source/WebCore/rendering/TextAutosizer.cpp 2013-01-11 13:28:32 UTC (rev 139434)
+++ trunk/Source/WebCore/rendering/TextAutosizer.cpp 2013-01-11 13:56:37 UTC (rev 139435)
@@ -238,11 +238,22 @@
// 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.
+ // Additionally, any containers that are wider or at least 200px narrower than
+ // the |blockContainingAllText| of their enclosing cluster also become clusters,
+ // since they need special treatment due to their width.
ASSERT(isAutosizingContainer(renderer));
+ // Upper limit on the difference between the width of the parent block containing all
+ // text and that of a narrow child before the child becomes a cluster.
+ const float maxWidthDifference = 200;
+
+ if (parentBlockContainingAllText) {
+ float contentWidth = renderer->contentLogicalWidth();
+ float clusterTextWidth = parentBlockContainingAllText->contentLogicalWidth();
+ if (contentWidth > clusterTextWidth || (clusterTextWidth - contentWidth) > maxWidthDifference)
+ return true;
+ }
+
return renderer->isRenderView()
|| renderer->isFloating()
|| renderer->isOutOfFlowPositioned()
@@ -251,9 +262,7 @@
|| renderer->isFlexibleBoxIncludingDeprecated()
|| renderer->hasColumns()
|| renderer->containingBlock()->isHorizontalWritingMode() != renderer->isHorizontalWritingMode()
- || renderer->style()->isDisplayReplacedType()
- || (parentBlockContainingAllText
- && renderer->contentLogicalWidth() > parentBlockContainingAllText->contentLogicalWidth());
+ || renderer->style()->isDisplayReplacedType();
// 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...