Title: [142042] trunk
Revision
142042
Author
le...@chromium.org
Date
2013-02-06 15:08:59 -0800 (Wed, 06 Feb 2013)

Log Message

Negative text indents can break RenderBlock's inline maximum preferred width calculation
https://bugs.webkit.org/show_bug.cgi?id=108973

Reviewed by Emil A Eklund.

Source/WebCore:

Change two quirks about to how we calculate a block's inline preferred width with
text-indent.

First, re-use text-indent that's first applied to floats on text that follows it.
This matches Layout, as otherwise we can prematurely wrap text when there's a negative
margin on a block starting with a float. This also matches FireFox.

Second, correct how the max preferred width is calculated in the presence of a negative
text-indent. If the text-indent is more negative than the first text line break, we
update the value to be the remainder. Previously, we added this remaining negative value
to subsequent minimum and maximum preferred width calculations (until the remainder was
gone). This is wrong for the max preferred width, as we're adding the negative value more
than once, and leads to a max preferred width that's smaller than our line.

Test: fast/css/negative-text-indent-in-inline-block.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::computeInlinePreferredLogicalWidths):

LayoutTests:

* fast/css/negative-text-indent-in-inline-block-expected.html: Added.
* fast/css/negative-text-indent-in-inline-block.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (142041 => 142042)


--- trunk/LayoutTests/ChangeLog	2013-02-06 23:06:56 UTC (rev 142041)
+++ trunk/LayoutTests/ChangeLog	2013-02-06 23:08:59 UTC (rev 142042)
@@ -1,3 +1,13 @@
+2013-02-06  Levi Weintraub  <le...@chromium.org>
+
+        Negative text indents can break RenderBlock's inline maximum preferred width calculation
+        https://bugs.webkit.org/show_bug.cgi?id=108973
+
+        Reviewed by Emil A Eklund.
+
+        * fast/css/negative-text-indent-in-inline-block-expected.html: Added.
+        * fast/css/negative-text-indent-in-inline-block.html: Added.
+
 2013-02-06  Zan Dobersek  <zdober...@igalia.com>
 
         Unreviewed GTK gardening.

Added: trunk/LayoutTests/fast/css/negative-text-indent-in-inline-block-expected.html (0 => 142042)


--- trunk/LayoutTests/fast/css/negative-text-indent-in-inline-block-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/negative-text-indent-in-inline-block-expected.html	2013-02-06 23:08:59 UTC (rev 142042)
@@ -0,0 +1,32 @@
+<html>
+<head>
+<style>
+.inlineBlock {
+  display: inline-block;
+  border: solid black 1px;
+  text-indent: -30px;
+}
+
+#ltr > div {
+  padding-left: 30px;
+}
+
+#rtl {
+	direction: rtl;
+}
+
+#rtl > div {
+  padding-right: 30px;
+}
+</style>
+</head>
+<body>
+<p>None of the inline text boxes below should have wrapping text.</p>
+<div id="ltr">
+<div class="inlineBlock">This here</div>
+<div class="inlineBlock">This here</div>
+</div>
+<div id="rtl">
+<div class="inlineBlock">This here</div>
+<div class="inlineBlock">This here</div>
+</div>

Added: trunk/LayoutTests/fast/css/negative-text-indent-in-inline-block.html (0 => 142042)


--- trunk/LayoutTests/fast/css/negative-text-indent-in-inline-block.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/negative-text-indent-in-inline-block.html	2013-02-06 23:08:59 UTC (rev 142042)
@@ -0,0 +1,49 @@
+<html>
+<head>
+<style>
+.inlineBlock {
+  display: inline-block;
+  border: solid black 1px;
+  text-indent: -30px;
+}
+
+#float {
+  float: left;
+  margin-left: -20px;
+  visibility: hidden;
+}
+
+#floatRTL {
+  float: right;
+  margin-right: -20px;
+  visibility: hidden;
+}
+
+#ltr > div {
+  padding-left: 30px;
+}
+
+#rtl {
+	direction: rtl;
+}
+
+#rtl > div {
+  padding-right: 30px;
+}
+
+</style>
+</head>
+<body>
+<p>None of the inline text boxes below should have wrapping text.</p>
+<div id="ltr">
+<div class="inlineBlock"><span>This here</span>
+</div>
+<div class="inlineBlock"><input type="checkbox" id="float" /> 
+This here</div>
+</div>
+<div id="rtl">
+<div class="inlineBlock"><span>This here</span>
+</div>
+<div class="inlineBlock"><input type="checkbox" id="floatRTL" /> 
+This here</div>
+</div>

Modified: trunk/Source/WebCore/ChangeLog (142041 => 142042)


--- trunk/Source/WebCore/ChangeLog	2013-02-06 23:06:56 UTC (rev 142041)
+++ trunk/Source/WebCore/ChangeLog	2013-02-06 23:08:59 UTC (rev 142042)
@@ -1,3 +1,29 @@
+2013-02-06  Levi Weintraub  <le...@chromium.org>
+
+        Negative text indents can break RenderBlock's inline maximum preferred width calculation
+        https://bugs.webkit.org/show_bug.cgi?id=108973
+
+        Reviewed by Emil A Eklund.
+
+        Change two quirks about to how we calculate a block's inline preferred width with
+        text-indent.
+
+        First, re-use text-indent that's first applied to floats on text that follows it.
+        This matches Layout, as otherwise we can prematurely wrap text when there's a negative
+        margin on a block starting with a float. This also matches FireFox.
+
+        Second, correct how the max preferred width is calculated in the presence of a negative
+        text-indent. If the text-indent is more negative than the first text line break, we
+        update the value to be the remainder. Previously, we added this remaining negative value
+        to subsequent minimum and maximum preferred width calculations (until the remainder was
+        gone). This is wrong for the max preferred width, as we're adding the negative value more
+        than once, and leads to a max preferred width that's smaller than our line.
+
+        Test: fast/css/negative-text-indent-in-inline-block.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::computeInlinePreferredLogicalWidths):
+
 2013-02-06  Mark Lam  <mark....@apple.com>
 
         Fix broken release builds, greening the bots.

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (142041 => 142042)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-02-06 23:06:56 UTC (rev 142041)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-02-06 23:08:59 UTC (rev 142042)
@@ -5870,7 +5870,12 @@
     autoWrap = oldAutoWrap = styleToUse->autoWrap();
 
     InlineMinMaxIterator childIterator(this);
-    bool addedTextIndent = false; // Only gets added in once.
+
+    // Only gets added to the max preffered width once.
+    bool addedTextIndent = false;
+    // Signals the text indent was more negative than the min preferred width
+    bool hasRemainingNegativeTextIndent = false;
+
     LayoutUnit textIndent = minimumValueForLength(styleToUse->textIndent(), cw, view());
     RenderObject* prevFloat = 0;
     bool isPrevChildInlineFlow = false;
@@ -5976,7 +5981,7 @@
 
                 // Add in text-indent.  This is added in only once.
                 LayoutUnit ti = 0;
-                if (!addedTextIndent) {
+                if (!addedTextIndent && !child->isFloating()) {
                     ti = textIndent;
                     childMin += ti.ceilToFloat();
                     childMax += ti.ceilToFloat();
@@ -6056,18 +6061,24 @@
 
                 // Add in text-indent.  This is added in only once.
                 float ti = 0;
-                if (!addedTextIndent) {
+                if (!addedTextIndent || hasRemainingNegativeTextIndent) {
                     ti = textIndent.ceilToFloat();
-                    
                     childMin += ti;
-                    childMax += ti;
                     beginMin += ti;
-                    beginMax += ti;
                     
-                    if (childMin < 0)
+                    // It the text indent negative and larger than the child minimum, we re-use the remainder
+                    // in future minimum calculations, but using the negative value again on the maximum
+                    // will lead to under-counting the max pref width.
+                    if (!addedTextIndent) {
+                        childMax += ti;
+                        beginMax += ti;
+                        addedTextIndent = true;
+                    }
+                    
+                    if (childMin < 0) {
                         textIndent = childMin;
-                    else
-                        addedTextIndent = true;
+                        hasRemainingNegativeTextIndent = true;
+                    }
                 }
                 
                 // If we have no breakable characters at all,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to