Changeset 133292 in webkit


Ignore:
Timestamp:
Nov 2, 2012 6:55:23 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Regression r130057: Improper preferred width calculation when an inline replaced object, wrapped in an inline flow, follows some text.
https://bugs.webkit.org/show_bug.cgi?id=99442

Patch by Arpita Bahuguna <arpitabahuguna@gmail.com> on 2012-11-02
Reviewed by Levi Weintraub.

Source/WebCore:

Extra width is displayed after an inline replaced object that follows some
text (not ending in a whitespace) within an inline-block. This is due to
the end width (endMin) of the text object being carried forward (via inlineMin)
and added onto the next line containing the inline replaced object.

This was caused as a regression to, or rather became apparent post the fix
http://trac.webkit.org/changeset/130057 which fixed the block's preferred
width when a renderInline with width contained an inline replaced object.

Test: fast/block/block-with-inline-replaced-child-following-text.html

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::computeInlinePreferredLogicalWidths):
Introduced another flag (shouldBreakLineAfterText) which is set when
our current Text line (object) does not end in a whitespace, thereby
implying that there could be more text following, for which the end width
needs to be carried forward onto the next line.

In case the following object instead turns out to be an Inline Replaced
object, we should terminate our previous line and reset this extra width.
This is now being handled by checking for the shouldBreakLineAfterText
flag while processing Inline Replaced objects.

Once set, shouldBreakLineAfterText shall be reset only if we get another
Text object that ends in a whitespace, signifying the termination of
that text line. For all other cases, we persist with this flag through
the block's inline contents.

LayoutTests:

  • fast/block/block-with-inline-replaced-child-following-text-expected.txt: Added.
  • fast/block/block-with-inline-replaced-child-following-text.html: Added.

Test added for verifying the width of the inline-block when an inline replaced
object follows some text object which does not end in a whitespace.

The correct width of our containing box in this case should be 94px which is
determined by the min-width of our text (using ahem font) which is 64px +
the padding - 30px.

Prior to this fix, the trailing end-width from the text (64px) would be carried
onto the next line containing the inline replaced object. This would then make
that line's width as 64px (end width of text) + 30 px (padding) + 50px (width
of our image object) making it 144px in total. This would then incorrectly
define the width of our containing box.

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r133287 r133292  
     12012-11-02  Arpita Bahuguna  <arpitabahuguna@gmail.com>
     2
     3        Regression r130057: Improper preferred width calculation when an inline replaced object, wrapped in an inline flow, follows some text.
     4        https://bugs.webkit.org/show_bug.cgi?id=99442
     5
     6        Reviewed by Levi Weintraub.
     7
     8        * fast/block/block-with-inline-replaced-child-following-text-expected.txt: Added.
     9        * fast/block/block-with-inline-replaced-child-following-text.html: Added.
     10        Test added for verifying the width of the inline-block when an inline replaced
     11        object follows some text object which does not end in a whitespace.
     12
     13        The correct width of our containing box in this case should be 94px which is
     14        determined by the min-width of our text (using ahem font) which is 64px +
     15        the padding - 30px.
     16
     17        Prior to this fix, the trailing end-width from the text (64px) would be carried
     18        onto the next line containing the inline replaced object. This would then make
     19        that line's width as 64px (end width of text) + 30 px (padding) + 50px (width
     20        of our image object) making it 144px in total. This would then incorrectly
     21        define the width of our containing box.
     22
    1232012-11-02  Raphael Kubo da Costa  <raphael.kubo.da.costa@intel.com>
    224
  • trunk/Source/WebCore/ChangeLog

    r133291 r133292  
     12012-11-02  Arpita Bahuguna  <arpitabahuguna@gmail.com>
     2
     3        Regression r130057: Improper preferred width calculation when an inline replaced object, wrapped in an inline flow, follows some text.
     4        https://bugs.webkit.org/show_bug.cgi?id=99442
     5
     6        Reviewed by Levi Weintraub.
     7
     8        Extra width is displayed after an inline replaced object that follows some
     9        text (not ending in a whitespace) within an inline-block. This is due to
     10        the end width (endMin) of the text object being carried forward (via inlineMin)
     11        and added onto the next line containing the inline replaced object.
     12
     13        This was caused as a regression to, or rather became apparent post the fix
     14        http://trac.webkit.org/changeset/130057 which fixed the block's preferred
     15        width when a renderInline with width contained an inline replaced object.
     16
     17        Test: fast/block/block-with-inline-replaced-child-following-text.html
     18
     19        * rendering/RenderBlock.cpp:
     20        (WebCore::RenderBlock::computeInlinePreferredLogicalWidths):
     21        Introduced another flag (shouldBreakLineAfterText) which is set when
     22        our current Text line (object) does not end in a whitespace, thereby
     23        implying that there could be more text following, for which the end width
     24        needs to be carried forward onto the next line.
     25
     26        In case the following object instead turns out to be an Inline Replaced
     27        object, we should terminate our previous line and reset this extra width.
     28        This is now being handled by checking for the shouldBreakLineAfterText
     29        flag while processing Inline Replaced objects.
     30
     31        Once set, shouldBreakLineAfterText shall be reset only if we get another
     32        Text object that ends in a whitespace, signifying the termination of
     33        that text line. For all other cases, we persist with this flag through
     34        the block's inline contents.
     35
    1362012-11-02  Eugene Klyuchnikov  <eustas.bug@gmail.com>
    237
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r132753 r133292  
    57935793    RenderObject* prevFloat = 0;
    57945794    bool isPrevChildInlineFlow = false;
     5795    bool shouldBreakLineAfterText = false;
    57955796    while (RenderObject* child = childIterator.next()) {
    57965797        autoWrap = child->isReplaced() ? child->parent()->style()->autoWrap() :
     
    58815882
    58825883                bool canBreakReplacedElement = !child->isImage() || allowImagesToBreak;
    5883                 if ((canBreakReplacedElement && (autoWrap || oldAutoWrap) && !isPrevChildInlineFlow) || clearPreviousFloat) {
     5884                if ((canBreakReplacedElement && (autoWrap || oldAutoWrap) && (!isPrevChildInlineFlow || shouldBreakLineAfterText)) || clearPreviousFloat) {
    58845885                    updatePreferredWidth(m_minPreferredLogicalWidth, inlineMin);
    58855886                    inlineMin = 0;
     
    59085909                inlineMax += max<float>(0, childMax);
    59095910
    5910                 if (!autoWrap || !canBreakReplacedElement || isPrevChildInlineFlow) {
     5911                if (!autoWrap || !canBreakReplacedElement || (isPrevChildInlineFlow && !shouldBreakLineAfterText)) {
    59115912                    if (child->isFloating())
    59125913                        updatePreferredWidth(m_minPreferredLogicalWidth, childMin);
     
    60126013                        updatePreferredWidth(m_minPreferredLogicalWidth, inlineMin);
    60136014                        inlineMin = 0;
     6015                        shouldBreakLineAfterText = false;
    60146016                    } else {
    60156017                        updatePreferredWidth(m_minPreferredLogicalWidth, inlineMin);
    60166018                        inlineMin = endMin;
     6019                        shouldBreakLineAfterText = true;
    60176020                    }
    60186021                }
Note: See TracChangeset for help on using the changeset viewer.