Title: [136411] trunk
Revision
136411
Author
[email protected]
Date
2012-12-03 10:21:57 -0800 (Mon, 03 Dec 2012)

Log Message

Text Autosizing: don't autosize horizontal menu items implemented via floating list items
https://bugs.webkit.org/show_bug.cgi?id=103840

Patch by Anton Vayvod <[email protected]> on 2012-12-03
Reviewed by Kenneth Rohde Christiansen.

Floating list items are often used to implement horizontal menus. Currently, text autosizing
disregards such elements as autosizing containers. List items are often then autosized as part
of a bigger cluster (usually the whole page) and look too big.
This change turns floating list items into autosizing clusters so they are autosized separately
resulting in no font size multiplication for menu items implemented in this manner.

Source/WebCore:

Test: fast/text-autosizing/cluster-list-item.html

* rendering/TextAutosizer.cpp:
(WebCore::TextAutosizer::isAutosizingContainer): Returns true for floating list items; split the
condition logically.

LayoutTests:

* fast/text-autosizing/cluster-list-item-expected.html: Renamed from LayoutTests/fast/text-autosizing/list-item-out-of-flow-expected.html.
* fast/text-autosizing/cluster-list-item.html: Renamed from LayoutTests/fast/text-autosizing/list-item-out-of-flow.html; added case for a floating list item.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (136410 => 136411)


--- trunk/LayoutTests/ChangeLog	2012-12-03 18:18:22 UTC (rev 136410)
+++ trunk/LayoutTests/ChangeLog	2012-12-03 18:21:57 UTC (rev 136411)
@@ -1,3 +1,19 @@
+2012-12-03  Anton Vayvod  <[email protected]>
+
+        Text Autosizing: don't autosize horizontal menu items implemented via floating list items
+        https://bugs.webkit.org/show_bug.cgi?id=103840
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Floating list items are often used to implement horizontal menus. Currently, text autosizing 
+        disregards such elements as autosizing containers. List items are often then autosized as part
+        of a bigger cluster (usually the whole page) and look too big.
+        This change turns floating list items into autosizing clusters so they are autosized separately
+        resulting in no font size multiplication for menu items implemented in this manner.
+
+        * fast/text-autosizing/cluster-list-item-expected.html: Renamed from LayoutTests/fast/text-autosizing/list-item-out-of-flow-expected.html.
+        * fast/text-autosizing/cluster-list-item.html: Renamed from LayoutTests/fast/text-autosizing/list-item-out-of-flow.html; added case for a floating list item.
+
 2012-12-03  Tony Chang  <[email protected]>
 
         [mathml] Improve performance of nested sup or sub elements

Copied: trunk/LayoutTests/fast/text-autosizing/cluster-list-item-expected.html (from rev 136410, trunk/LayoutTests/fast/text-autosizing/list-item-out-of-flow-expected.html) (0 => 136411)


--- trunk/LayoutTests/fast/text-autosizing/cluster-list-item-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/cluster-list-item-expected.html	2012-12-03 18:21:57 UTC (rev 136411)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+html { font-size: 16px; }
+body { width: 800px; margin: 0; overflow-y: hidden; }
+</style>
+
+</head>
+<body>
+
+<ul style="width: 400px">
+	<li style="width: 600px; font-size: 1.25rem">
+		This element is only autosized to 20px computed font size (16 * 400/320), since we don't want list items to be autosized differently from each other, and the width of UL tag is used for autosizing.<br>
+		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+	</li>
+	<li style="font-size: 1.25rem">
+		This element is autosized to computed font size of 20px similarly to the first list item.<br>
+		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+	</li>
+	<li style="float: left; width: 800px; font-size: 2.5rem">
+		This list element becomes a separate autosizing cluster since it's floating. Hence its computed font size is 40px (16 * 400 / 320).<br>
+		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+	</li>
+	<li style="position: absolute; margin-top: 280px; width: 800px; font-size: 2.5rem">
+		This list element becomes a separate autosizing cluster since it's positioned out of the list flow. Hence its computed font size is 40px (16 * 400 / 320).<br>
+		Margin is added so it doesn't overlap with the previous element.<br>
+		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+	</li>
+</ul>	
+</body>
+</head>
\ No newline at end of file

Copied: trunk/LayoutTests/fast/text-autosizing/cluster-list-item.html (from rev 136410, trunk/LayoutTests/fast/text-autosizing/list-item-out-of-flow.html) (0 => 136411)


--- trunk/LayoutTests/fast/text-autosizing/cluster-list-item.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text-autosizing/cluster-list-item.html	2012-12-03 18:21:57 UTC (rev 136411)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+
+<meta name="viewport" content="width=800">
+<style>
+html { font-size: 16px; }
+body { width: 800px; margin: 0; overflow-y: hidden; }
+</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>
+
+<ul style="width: 400px">
+	<li style="width: 600px">
+		This element is only autosized to 20px computed font size (16 * 400/320), since we don't want list items to be autosized differently from each other, and the width of UL tag is used for autosizing.<br>
+		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+	</li>
+	<li>
+		This element is autosized to computed font size of 20px similarly to the first list item.<br>
+		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+	</li>
+	<li style="float: left; width: 800px">
+		This list element becomes a separate autosizing cluster since it's floating. Hence its computed font size is 40px (16 * 400 / 320).<br>
+		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+	</li>
+	<li style="position: absolute; margin-top: 280px; width: 800px">
+		This list element becomes a separate autosizing cluster since it's positioned out of the list flow. Hence its computed font size is 40px (16 * 400 / 320).<br>
+		Margin is added so it doesn't overlap with the previous element.<br>
+		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+	</li>
+</ul>	
+</body>
+</head>
\ No newline at end of file

Deleted: trunk/LayoutTests/fast/text-autosizing/list-item-out-of-flow-expected.html (136410 => 136411)


--- trunk/LayoutTests/fast/text-autosizing/list-item-out-of-flow-expected.html	2012-12-03 18:18:22 UTC (rev 136410)
+++ trunk/LayoutTests/fast/text-autosizing/list-item-out-of-flow-expected.html	2012-12-03 18:21:57 UTC (rev 136411)
@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-
-<meta name="viewport" content="width=800">
-<style>
-html { font-size: 16px; }
-body { width: 800px; margin: 0; overflow-y: hidden; }
-</style>
-
-</head>
-<body>
-
-<ul style="width: 400px">
-	<li style="width: 600px; font-size: 1.25rem">
-		This element is only autosized to 20px computed font size (16 * 400/320), since we don't want list items to be autosized differently from each other, and the width of UL tag is used for autosizing.<br>
-		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-	</li>
-	<li style="position: absolute; width: 800px; font-size: 2.5rem">
-		This list element becomes a separate autosizing cluster since it's positioned out of the list flow. Hence its computed font size is 40px (16 * 400 / 320).<br>
-		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-	</li>
-	<li style="font-size: 1.25rem">
-		This element is autosized to computed font size of 20px similarly to the first list item.<br>
-		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-	</li>
-</ul>	
-</body>
-</head>
\ No newline at end of file

Deleted: trunk/LayoutTests/fast/text-autosizing/list-item-out-of-flow.html (136410 => 136411)


--- trunk/LayoutTests/fast/text-autosizing/list-item-out-of-flow.html	2012-12-03 18:18:22 UTC (rev 136410)
+++ trunk/LayoutTests/fast/text-autosizing/list-item-out-of-flow.html	2012-12-03 18:21:57 UTC (rev 136411)
@@ -1,38 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-
-<meta name="viewport" content="width=800">
-<style>
-html { font-size: 16px; }
-body { width: 800px; margin: 0; overflow-y: hidden; }
-</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>
-
-<ul style="width: 400px">
-	<li style="width: 600px">
-		This element is only autosized to 20px computed font size (16 * 400/320), since we don't want list items to be autosized differently from each other, and the width of UL tag is used for autosizing.<br>
-		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-	</li>
-	<li style="position: absolute; width: 800px">
-		This list element becomes a separate autosizing cluster since it's positioned out of the list flow. Hence its computed font size is 40px (16 * 400 / 320).<br>
-		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-	</li>
-	<li>
-		This element is autosized to computed font size of 20px similarly to the first list item.<br>
-		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-	</li>
-</ul>	
-</body>
-</head>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (136410 => 136411)


--- trunk/Source/WebCore/ChangeLog	2012-12-03 18:18:22 UTC (rev 136410)
+++ trunk/Source/WebCore/ChangeLog	2012-12-03 18:21:57 UTC (rev 136411)
@@ -1,3 +1,22 @@
+2012-12-03  Anton Vayvod  <[email protected]>
+
+        Text Autosizing: don't autosize horizontal menu items implemented via floating list items
+        https://bugs.webkit.org/show_bug.cgi?id=103840
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Floating list items are often used to implement horizontal menus. Currently, text autosizing 
+        disregards such elements as autosizing containers. List items are often then autosized as part
+        of a bigger cluster (usually the whole page) and look too big.
+        This change turns floating list items into autosizing clusters so they are autosized separately
+        resulting in no font size multiplication for menu items implemented in this manner.
+
+        Test: fast/text-autosizing/cluster-list-item.html
+
+        * rendering/TextAutosizer.cpp:
+        (WebCore::TextAutosizer::isAutosizingContainer): Returns true for floating list items; split the
+        condition logically.
+
 2012-12-03  Viatcheslav Ostapenko  <[email protected]>
 
         Optimization in image decoding

Modified: trunk/Source/WebCore/rendering/TextAutosizer.cpp (136410 => 136411)


--- trunk/Source/WebCore/rendering/TextAutosizer.cpp	2012-12-03 18:18:22 UTC (rev 136410)
+++ trunk/Source/WebCore/rendering/TextAutosizer.cpp	2012-12-03 18:21:57 UTC (rev 136411)
@@ -205,10 +205,13 @@
     // enable/disable Text Autosizing.
     // - Must not be inline, as different multipliers on one line looks terrible.
     // - Must not be list items, as items in the same list should look consistent (*).
-    // * except for those list items positioned out of the list's flow.
-    return renderer->isRenderBlock()
-        && !renderer->isInline()
-        && (!renderer->isListItem() || renderer->isOutOfFlowPositioned());
+    // - Must not be normal list items, as items in the same list should look
+    //   consistent, unless they are floating or position:absolute/fixed.
+    if (!renderer->isRenderBlock() || renderer->isInline())
+        return false;
+    if (renderer->isListItem())
+        return renderer->isFloating() || renderer->isOutOfFlowPositioned();
+    return true;
 }
 
 bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to