⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 130663 in webkit


Ignore:
Timestamp:
Oct 8, 2012, 11:44:03 AM (14 years ago)
Author:
robert@webkit.org
Message:

Border, margin and padding of an inline's inline ancestors counted twice
​https://bugs.webkit.org/show_bug.cgi?id=63074

Reviewed by David Hyatt.

Source/WebCore:

In a line such as '<span><span><img>Text' the border, padding and margin belonging
to the two spans was counted twice by RenderBlockLineLayout::nextLineBreak(): once
when adding the width of the <img> object to the line, and a second time when adding
the 'Text'. The result was that nextLineBreak() now had a length for the line that
exceeded the line's maximum length and inserted a bogus line break.

This all happened because the helper function that is used to add in the border etc.
from inline ancestors was crawling up the tree each time. It doesn't need to do that, it
should stop crawling up the tree when the current object is not the first or last sibling below a parent.

Test: fast/inline/bpm-inline-ancestors.html

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::shouldAddBorderPaddingMargin): Broke this check out into a helper function so that it
can help inlineLogicalWidth() return early and also treat empty RenderTexts the same as no previous/next
sibling on the line. This ensures that collapsed leading space does not interfere with the decision to
crawl up the ancestors accumulating border, padding, and margin.
(WebCore):
(WebCore::inlineLogicalWidth): Return early once the current child is no longer on the edge of its line -
this ensures the border, padding and margin of ancestors is not counted twice.

LayoutTests:

  • fast/inline/bpm-inline-ancestors-expected.html: Added.
  • fast/inline/bpm-inline-ancestors.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r130662 r130663  
     12012-10-08  Robert Hogan  <robert@webkit.org>
     2
     3        Border, margin and padding of an inline's inline ancestors counted twice
     4        https://bugs.webkit.org/show_bug.cgi?id=63074
     5
     6        Reviewed by David Hyatt.
     7
     8        * fast/inline/bpm-inline-ancestors-expected.html: Added.
     9        * fast/inline/bpm-inline-ancestors.html: Added.
     10
    1112012-10-08  Sudarsana Nagineni  <sudarsana.nagineni@intel.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r130657 r130663  
     12012-10-08  Robert Hogan  <robert@webkit.org>
     2
     3        Border, margin and padding of an inline's inline ancestors counted twice
     4        https://bugs.webkit.org/show_bug.cgi?id=63074
     5
     6        Reviewed by David Hyatt.
     7
     8        In a line such as '<span><span><img>Text' the border, padding and margin belonging
     9        to the two spans was counted twice by RenderBlockLineLayout::nextLineBreak(): once
     10        when adding the width of the <img> object to the line, and a second time when adding
     11        the 'Text'. The result was that nextLineBreak() now had a length for the line that
     12        exceeded the line's maximum length and inserted a bogus line break.
     13
     14        This all happened because the helper function that is used to add in the border etc.
     15        from inline ancestors was crawling up the tree each time. It doesn't need to do that, it
     16        should stop crawling up the tree when the current object is not the first or last sibling below a parent.
     17
     18        Test: fast/inline/bpm-inline-ancestors.html
     19
     20        * rendering/RenderBlockLineLayout.cpp:
     21        (WebCore::shouldAddBorderPaddingMargin): Broke this check out into a helper function so that it
     22        can help inlineLogicalWidth() return early and also treat empty RenderTexts the same as no previous/next
     23        sibling on the line. This ensures that collapsed leading space does not interfere with the decision to
     24        crawl up the ancestors accumulating border, padding, and margin.
     25        (WebCore):
     26        (WebCore::inlineLogicalWidth): Return early once the current child is no longer on the edge of its line -
     27        this ensures the border, padding and margin of ancestors is not counted twice.
     28
    1292012-10-08  Mike West  <mkwst@chromium.org>
    230
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r130612 r130663  
    291291}
    292292
     293static bool shouldAddBorderPaddingMargin(RenderObject* child, bool &checkSide)
     294{
     295    if (!child || (child->isText() && !toRenderText(child)->textLength()))
     296        return true;
     297    checkSide = false;
     298    return checkSide;
     299}
     300
    293301static LayoutUnit inlineLogicalWidth(RenderObject* child, bool start = true, bool end = true)
    294302{
    … …  
    298306    while (parent->isRenderInline() && lineDepth++ < cMaxLineDepth) {
    299307        RenderInline* parentAsRenderInline = toRenderInline(parent);
    300         if (start && !child->previousSibling())
     308        if (start && shouldAddBorderPaddingMargin(child->previousSibling(), start))
    301309            extraWidth += borderPaddingMarginStart(parentAsRenderInline);
    302         if (end && !child->nextSibling())
     310        if (end && shouldAddBorderPaddingMargin(child->nextSibling(), end))
    303311            extraWidth += borderPaddingMarginEnd(parentAsRenderInline);
     312        if (!start && !end)
     313            return extraWidth;
    304314        child = parent;
    305315        parent = child->parent();
Note: See TracChangeset for help on using the changeset viewer.