Changeset 142042 in webkit


Ignore:
Timestamp:
Feb 6, 2013 3:08:59 PM (11 years ago)
Author:
leviw@chromium.org
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.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r142034 r142042  
     12013-02-06  Levi Weintraub  <leviw@chromium.org>
     2
     3        Negative text indents can break RenderBlock's inline maximum preferred width calculation
     4        https://bugs.webkit.org/show_bug.cgi?id=108973
     5
     6        Reviewed by Emil A Eklund.
     7
     8        * fast/css/negative-text-indent-in-inline-block-expected.html: Added.
     9        * fast/css/negative-text-indent-in-inline-block.html: Added.
     10
    1112013-02-06  Zan Dobersek  <zdobersek@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r142033 r142042  
     12013-02-06  Levi Weintraub  <leviw@chromium.org>
     2
     3        Negative text indents can break RenderBlock's inline maximum preferred width calculation
     4        https://bugs.webkit.org/show_bug.cgi?id=108973
     5
     6        Reviewed by Emil A Eklund.
     7
     8        Change two quirks about to how we calculate a block's inline preferred width with
     9        text-indent.
     10
     11        First, re-use text-indent that's first applied to floats on text that follows it.
     12        This matches Layout, as otherwise we can prematurely wrap text when there's a negative
     13        margin on a block starting with a float. This also matches FireFox.
     14
     15        Second, correct how the max preferred width is calculated in the presence of a negative
     16        text-indent. If the text-indent is more negative than the first text line break, we
     17        update the value to be the remainder. Previously, we added this remaining negative value
     18        to subsequent minimum and maximum preferred width calculations (until the remainder was
     19        gone). This is wrong for the max preferred width, as we're adding the negative value more
     20        than once, and leads to a max preferred width that's smaller than our line.
     21
     22        Test: fast/css/negative-text-indent-in-inline-block.html
     23
     24        * rendering/RenderBlock.cpp:
     25        (WebCore::RenderBlock::computeInlinePreferredLogicalWidths):
     26
    1272013-02-06  Mark Lam  <mark.lam@apple.com>
    228
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r142015 r142042  
    58715871
    58725872    InlineMinMaxIterator childIterator(this);
    5873     bool addedTextIndent = false; // Only gets added in once.
     5873
     5874    // Only gets added to the max preffered width once.
     5875    bool addedTextIndent = false;
     5876    // Signals the text indent was more negative than the min preferred width
     5877    bool hasRemainingNegativeTextIndent = false;
     5878
    58745879    LayoutUnit textIndent = minimumValueForLength(styleToUse->textIndent(), cw, view());
    58755880    RenderObject* prevFloat = 0;
     
    59775982                // Add in text-indent.  This is added in only once.
    59785983                LayoutUnit ti = 0;
    5979                 if (!addedTextIndent) {
     5984                if (!addedTextIndent && !child->isFloating()) {
    59805985                    ti = textIndent;
    59815986                    childMin += ti.ceilToFloat();
     
    60576062                // Add in text-indent.  This is added in only once.
    60586063                float ti = 0;
    6059                 if (!addedTextIndent) {
     6064                if (!addedTextIndent || hasRemainingNegativeTextIndent) {
    60606065                    ti = textIndent.ceilToFloat();
     6066                    childMin += ti;
     6067                    beginMin += ti;
    60616068                   
    6062                     childMin += ti;
    6063                     childMax += ti;
    6064                     beginMin += ti;
    6065                     beginMax += ti;
     6069                    // It the text indent negative and larger than the child minimum, we re-use the remainder
     6070                    // in future minimum calculations, but using the negative value again on the maximum
     6071                    // will lead to under-counting the max pref width.
     6072                    if (!addedTextIndent) {
     6073                        childMax += ti;
     6074                        beginMax += ti;
     6075                        addedTextIndent = true;
     6076                    }
    60666077                   
    6067                     if (childMin < 0)
     6078                    if (childMin < 0) {
    60686079                        textIndent = childMin;
    6069                     else
    6070                         addedTextIndent = true;
     6080                        hasRemainingNegativeTextIndent = true;
     6081                    }
    60716082                }
    60726083               
Note: See TracChangeset for help on using the changeset viewer.