Title: [128927] trunk
Revision
128927
Author
[email protected]
Date
2012-09-18 13:40:56 -0700 (Tue, 18 Sep 2012)

Log Message

Text Autosizing: Ignore constrained heights in certain circumstances.
https://bugs.webkit.org/show_bug.cgi?id=96848

Patch by John Mellor <[email protected]> on 2012-09-18
Reviewed by Julien Chaffraix.

Source/WebCore:

Ignore constrained heights on html and body elements, as some sites
(e.g. wikipedia) set height:100% on these, without intending to
constrain the height of descendants.

Also ignore constrained heights on ancestors of floats and out-of-flow
positioned elements with no height set, since the height of these is
determined independently from their ancestors.

Test: fast/text-autosizing/constrained-height-body.html
      fast/text-autosizing/constrained-out-of-flow.html
      fast/text-autosizing/constrained-then-float-ancestors.html
      fast/text-autosizing/constrained-then-position-absolute-ancestors.html
      fast/text-autosizing/constrained-then-position-fixed-ancestors.html

* rendering/TextAutosizer.cpp:
(WebCore::contentHeightIsConstrained):

    Adjusted constrainedness algorithm.

LayoutTests:

Added 3 tests, updated 2, and removed 1. See below.

* fast/text-autosizing/constrained-height-body-expected.html: Added.
* fast/text-autosizing/constrained-height-body.html: Added.

    Checks that constrained height html & body are ignored.

* fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors-expected.html: Removed.
* fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html: Removed.

    Removed because this situation is no longer possible now that
    heightless position:absolute elements are always unconstrained.

* fast/text-autosizing/constrained-out-of-flow-expected.html: Added.
* fast/text-autosizing/constrained-out-of-flow.html: Added.

    Checks that floats and out-of-flow positioned elements do not ignore
    constraints on themselves.

* fast/text-autosizing/constrained-then-float-ancestors-expected.html: Added.
* fast/text-autosizing/constrained-then-float-ancestors.html: Added.

    Checks that floats ignore constraints on ancestors.

* fast/text-autosizing/constrained-then-position-absolute-ancestors-expected.html:
* fast/text-autosizing/constrained-then-position-absolute-ancestors.html:

    Added position:relative to emphasize that the ancestor's constrained
    height is actually being ignored, not just skipped over; and updated
    explanation.

* fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html:
* fast/text-autosizing/constrained-then-position-fixed-ancestors.html:

    Updated explanation (since the test still passes, but for a
    different reason).

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (128926 => 128927)


--- trunk/LayoutTests/ChangeLog	2012-09-18 20:35:21 UTC (rev 128926)
+++ trunk/LayoutTests/ChangeLog	2012-09-18 20:40:56 UTC (rev 128927)
@@ -1,3 +1,47 @@
+2012-09-18  John Mellor  <[email protected]>
+
+        Text Autosizing: Ignore constrained heights in certain circumstances.
+        https://bugs.webkit.org/show_bug.cgi?id=96848
+
+        Reviewed by Julien Chaffraix.
+
+        Added 3 tests, updated 2, and removed 1. See below.
+
+        * fast/text-autosizing/constrained-height-body-expected.html: Added.
+        * fast/text-autosizing/constrained-height-body.html: Added.
+
+            Checks that constrained height html & body are ignored.
+
+        * fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors-expected.html: Removed.
+        * fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html: Removed.
+
+            Removed because this situation is no longer possible now that
+            heightless position:absolute elements are always unconstrained.
+
+        * fast/text-autosizing/constrained-out-of-flow-expected.html: Added.
+        * fast/text-autosizing/constrained-out-of-flow.html: Added.
+
+            Checks that floats and out-of-flow positioned elements do not ignore
+            constraints on themselves.
+
+        * fast/text-autosizing/constrained-then-float-ancestors-expected.html: Added.
+        * fast/text-autosizing/constrained-then-float-ancestors.html: Added.
+
+            Checks that floats ignore constraints on ancestors.
+
+        * fast/text-autosizing/constrained-then-position-absolute-ancestors-expected.html:
+        * fast/text-autosizing/constrained-then-position-absolute-ancestors.html:
+
+            Added position:relative to emphasize that the ancestor's constrained
+            height is actually being ignored, not just skipped over; and updated
+            explanation.
+
+        * fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html:
+        * fast/text-autosizing/constrained-then-position-fixed-ancestors.html:
+
+            Updated explanation (since the test still passes, but for a
+            different reason).
+
 2012-09-18  Alexey Proskuryakov  <[email protected]>
 
         Layout Test svg/dom/SVGScriptElement/script-change-externalResourcesRequired-while-loading.svg is failing

Added: trunk/LayoutTests/fast/text-autosizing/constrained-height-body-expected.html (0 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-height-body-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-height-body-expected.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html style="height: 100%">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+html { font-size: 16px; }
+body { width: 800px; margin: 0; }
+</style>
+
+</head>
+<body style="height: 100%">
+
+<div style="font-size: 2.5rem">
+    This text should be autosized to 40px computed font-size, since the constrained height on the html and body elements gets ignored (a hack to fix some sites that appear to set this accidentally).
+</div>
+
+</body>
+</html>
\ No newline at end of file

Copied: trunk/LayoutTests/fast/text-autosizing/constrained-height-body.html (from rev 128924, trunk/LayoutTests/fast/text-autosizing/constrained-then-position-fixed-ancestors.html) (0 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-height-body.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-height-body.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html style="height: 100%">
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+html { font-size: 16px; }
+body { width: 800px; margin: 0; }
+</style>
+
+<script>
+if (window.internals) {
+    window.internals.settings.setTextAutosizingEnabled(true);
+    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+} else if (window.console && console.warn) {
+    console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP.");
+}
+</script>
+
+</head>
+<body style="height: 100%">
+
+<div>
+	This text should be autosized to 40px computed font-size, since the constrained height on the html and body elements gets ignored (a hack to fix some sites that appear to set this accidentally).
+</div>
+
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text-autosizing/constrained-out-of-flow-expected.html (0 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-out-of-flow-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-out-of-flow-expected.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+html { font-size: 16px; }
+body { width: 800px; margin: 0; }
+</style>
+
+</head>
+<body>
+
+<div style="max-height: 500px; float: left">
+    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (the float:left doesn't affect this).
+</div>
+
+<div style="max-height: 500px; position: absolute; top: 200px">
+    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (the position:absolute doesn't affect this).
+</div>
+
+<div style="max-height: 500px; position: fixed; top: 400px">
+    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (the position:fixed doesn't affect this).
+</div>
+
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text-autosizing/constrained-out-of-flow.html (0 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-out-of-flow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-out-of-flow.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+html { font-size: 16px; }
+body { width: 800px; margin: 0; }
+</style>
+
+<script>
+if (window.internals) {
+    window.internals.settings.setTextAutosizingEnabled(true);
+    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+} else if (window.console && console.warn) {
+    console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP.");
+}
+</script>
+
+</head>
+<body>
+
+<div style="max-height: 500px; float: left">
+    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (the float:left doesn't affect this).
+</div>
+
+<div style="max-height: 500px; position: absolute; top: 200px">
+    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (the position:absolute doesn't affect this).
+</div>
+
+<div style="max-height: 500px; position: fixed; top: 400px">
+    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (the position:fixed doesn't affect this).
+</div>
+
+</body>
+</html>
\ No newline at end of file

Copied: trunk/LayoutTests/fast/text-autosizing/constrained-then-float-ancestors-expected.html (from rev 128924, trunk/LayoutTests/fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html) (0 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-then-float-ancestors-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-then-float-ancestors-expected.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+html { font-size: 16px; }
+body { width: 800px; margin: 0; }
+</style>
+
+</head>
+<body>
+
+<div style="max-height: 500px">
+    <div style="float: left">
+        <div style="font-size: 2.5rem">
+            This text should be autosized to 40px computed font-size, since the parent is float:left so the height is considered to be unconstrained (ancestors of the parent are ignored).
+        </div>
+    </div>
+</div>
+
+</body>
+</html>
\ No newline at end of file

Copied: trunk/LayoutTests/fast/text-autosizing/constrained-then-float-ancestors.html (from rev 128924, trunk/LayoutTests/fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html) (0 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-then-float-ancestors.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-then-float-ancestors.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+html { font-size: 16px; }
+body { width: 800px; margin: 0; }
+</style>
+
+<script>
+if (window.internals) {
+    window.internals.settings.setTextAutosizingEnabled(true);
+    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
+} else if (window.console && console.warn) {
+    console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP.");
+}
+</script>
+
+</head>
+<body>
+
+<div style="max-height: 500px">
+    <div style="float: left">
+        <div>
+            This text should be autosized to 40px computed font-size, since the parent is float:left so the height is considered to be unconstrained (ancestors of the parent are ignored).
+        </div>
+    </div>
+</div>
+
+</body>
+</html>
\ No newline at end of file

Deleted: trunk/LayoutTests/fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors-expected.html (128926 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors-expected.html	2012-09-18 20:35:21 UTC (rev 128926)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors-expected.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -1,23 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-
-<meta name="viewport" content="width=800">
-<style type="text/css">
-html { font-size: 16px; }
-body { width: 800px; margin: 0; }
-</style>
-
-</head>
-<body>
-
-<div style="max-height: 500px; position: relative">
-    <div style="overflow-y: auto">
-        <div style="position: absolute">
-            This text should not be autosized (its computed font-size should remain 16px), as unlike constrained-then-overflow-ancestors.html, this block's position:absolute means that its containing block is its position:relative grandparent (skipping its position:static parent with overflow-y:auto), so it does get constrained by the max-height on its grandparent (the parent has no effect).
-        </div>
-    </div>
-</div>
-
-</body>
-</html>
\ No newline at end of file

Deleted: trunk/LayoutTests/fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html (128926 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html	2012-09-18 20:35:21 UTC (rev 128926)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -1,32 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-
-<meta name="viewport" content="width=800">
-<style type="text/css">
-html { font-size: 16px; }
-body { width: 800px; margin: 0; }
-</style>
-
-<script type="text/_javascript_">
-if (window.internals) {
-    window.internals.settings.setTextAutosizingEnabled(true);
-    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
-} else if (window.console && console.warn) {
-    console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP.");
-}
-</script>
-
-</head>
-<body>
-
-<div style="max-height: 500px; position: relative">
-    <div style="overflow-y: auto">
-        <div style="position: absolute">
-            This text should not be autosized (its computed font-size should remain 16px), as unlike constrained-then-overflow-ancestors.html, this block's position:absolute means that its containing block is its position:relative grandparent (skipping its position:static parent with overflow-y:auto), so it does get constrained by the max-height on its grandparent (the parent has no effect).
-        </div>
-    </div>
-</div>
-
-</body>
-</html>
\ No newline at end of file

Modified: trunk/LayoutTests/fast/text-autosizing/constrained-then-position-absolute-ancestors-expected.html (128926 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-then-position-absolute-ancestors-expected.html	2012-09-18 20:35:21 UTC (rev 128926)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-then-position-absolute-ancestors-expected.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -3,7 +3,7 @@
 <head>
 
 <meta name="viewport" content="width=800">
-<style type="text/css">
+<style>
 html { font-size: 16px; }
 body { width: 800px; margin: 0; }
 </style>
@@ -11,10 +11,10 @@
 </head>
 <body>
 
-<div style="max-height: 500px">
+<div style="max-height: 500px; position: relative">
     <div style="position: absolute">
         <div style="font-size: 2.5rem">
-            This text should be autosized to 40px computed font-size, since the parent is position:absolute hence the parent's containing block is not the position:static grandparent, but instead the root element, so it is not constrained by the max-height of its grandparent.
+            This text should be autosized to 40px computed font-size, since the parent is position:absolute so the height is considered to be unconstrained (ancestors of the parent are ignored, even if they have position:relative).
         </div>
     </div>
 </div>

Modified: trunk/LayoutTests/fast/text-autosizing/constrained-then-position-absolute-ancestors.html (128926 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-then-position-absolute-ancestors.html	2012-09-18 20:35:21 UTC (rev 128926)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-then-position-absolute-ancestors.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -3,12 +3,12 @@
 <head>
 
 <meta name="viewport" content="width=800">
-<style type="text/css">
+<style>
 html { font-size: 16px; }
 body { width: 800px; margin: 0; }
 </style>
 
-<script type="text/_javascript_">
+<script>
 if (window.internals) {
     window.internals.settings.setTextAutosizingEnabled(true);
     window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
@@ -20,10 +20,10 @@
 </head>
 <body>
 
-<div style="max-height: 500px">
+<div style="max-height: 500px; position: relative">
     <div style="position: absolute">
         <div>
-            This text should be autosized to 40px computed font-size, since the parent is position:absolute hence the parent's containing block is not the position:static grandparent, but instead the root element, so it is not constrained by the max-height of its grandparent.
+            This text should be autosized to 40px computed font-size, since the parent is position:absolute so the height is considered to be unconstrained (ancestors of the parent are ignored, even if they have position:relative).
         </div>
     </div>
 </div>

Modified: trunk/LayoutTests/fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html (128926 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html	2012-09-18 20:35:21 UTC (rev 128926)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -3,7 +3,7 @@
 <head>
 
 <meta name="viewport" content="width=800">
-<style type="text/css">
+<style>
 html { font-size: 16px; }
 body { width: 800px; margin: 0; }
 </style>
@@ -14,7 +14,7 @@
 <div style="max-height: 500px">
     <div style="position: fixed">
         <div style="font-size: 2.5rem">
-            This text should be autosized to 40px computed font-size, since the parent is position:fixed hence the parent's containing block is not the position:static grandparent, but instead the root element, so it is not constrained by the max-height of its grandparent.
+            This text should be autosized to 40px computed font-size, since the parent is position:fixed so the height is considered to be unconstrained (ancestors of the parent are ignored).
         </div>
     </div>
 </div>

Modified: trunk/LayoutTests/fast/text-autosizing/constrained-then-position-fixed-ancestors.html (128926 => 128927)


--- trunk/LayoutTests/fast/text-autosizing/constrained-then-position-fixed-ancestors.html	2012-09-18 20:35:21 UTC (rev 128926)
+++ trunk/LayoutTests/fast/text-autosizing/constrained-then-position-fixed-ancestors.html	2012-09-18 20:40:56 UTC (rev 128927)
@@ -3,12 +3,12 @@
 <head>
 
 <meta name="viewport" content="width=800">
-<style type="text/css">
+<style>
 html { font-size: 16px; }
 body { width: 800px; margin: 0; }
 </style>
 
-<script type="text/_javascript_">
+<script>
 if (window.internals) {
     window.internals.settings.setTextAutosizingEnabled(true);
     window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
@@ -23,7 +23,7 @@
 <div style="max-height: 500px">
     <div style="position: fixed">
         <div>
-            This text should be autosized to 40px computed font-size, since the parent is position:fixed hence the parent's containing block is not the position:static grandparent, but instead the root element, so it is not constrained by the max-height of its grandparent.
+            This text should be autosized to 40px computed font-size, since the parent is position:fixed so the height is considered to be unconstrained (ancestors of the parent are ignored).
         </div>
     </div>
 </div>

Modified: trunk/Source/WebCore/ChangeLog (128926 => 128927)


--- trunk/Source/WebCore/ChangeLog	2012-09-18 20:35:21 UTC (rev 128926)
+++ trunk/Source/WebCore/ChangeLog	2012-09-18 20:40:56 UTC (rev 128927)
@@ -1,3 +1,29 @@
+2012-09-18  John Mellor  <[email protected]>
+
+        Text Autosizing: Ignore constrained heights in certain circumstances.
+        https://bugs.webkit.org/show_bug.cgi?id=96848
+
+        Reviewed by Julien Chaffraix.
+
+        Ignore constrained heights on html and body elements, as some sites
+        (e.g. wikipedia) set height:100% on these, without intending to
+        constrain the height of descendants.
+
+        Also ignore constrained heights on ancestors of floats and out-of-flow
+        positioned elements with no height set, since the height of these is
+        determined independently from their ancestors.
+
+        Test: fast/text-autosizing/constrained-height-body.html
+              fast/text-autosizing/constrained-out-of-flow.html
+              fast/text-autosizing/constrained-then-float-ancestors.html
+              fast/text-autosizing/constrained-then-position-absolute-ancestors.html
+              fast/text-autosizing/constrained-then-position-fixed-ancestors.html
+
+        * rendering/TextAutosizer.cpp:
+        (WebCore::contentHeightIsConstrained):
+
+            Adjusted constrainedness algorithm.
+
 2012-09-18  Tommy Widenflycht  <[email protected]>
 
         MediaStream API: Create a flag to enable PeerConnection00

Modified: trunk/Source/WebCore/rendering/TextAutosizer.cpp (128926 => 128927)


--- trunk/Source/WebCore/rendering/TextAutosizer.cpp	2012-09-18 20:35:21 UTC (rev 128926)
+++ trunk/Source/WebCore/rendering/TextAutosizer.cpp	2012-09-18 20:40:56 UTC (rev 128927)
@@ -86,8 +86,13 @@
         RenderStyle* style = container->style();
         if (style->overflowY() >= OSCROLL)
             return false;
-        if (style->height().isSpecified() || style->maxHeight().isSpecified())
-            return true;
+        if (style->height().isSpecified() || style->maxHeight().isSpecified()) {
+            // Some sites (e.g. wikipedia) set their html and/or body elements to height:100%,
+            // without intending to constrain the height of the content within them.
+            return !container->isRoot() && !container->isBody();
+        }
+        if (container->isFloatingOrOutOfFlowPositioned())
+            return false;
     }
     return false;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to