Changeset 150527 in webkit


Ignore:
Timestamp:
May 22, 2013 11:59:38 AM (11 years ago)
Author:
robert@webkit.org
Message:

Need to Remove Anonymous Wrappers When All Children Become Inline
https://bugs.webkit.org/show_bug.cgi?id=115687

Reviewed by David Hyatt.

Source/WebCore:

Remove a simple subset of anonymous wrappers, i.e. anonymous blocks without continuations,
when a block becoming float or positioned removes the need for them.

Test: fast/block/remove-anonymous-wrappers-when-element-changes-to-float-or-positioned.html

  • rendering/RenderBlock.h:

(RenderBlock):

  • rendering/RenderObject.cpp:

(WebCore):
(WebCore::RenderObject::removeAnonymousWrappersFromLineIfNecessary):
(WebCore::RenderObject::styleWillChange):
(WebCore::RenderObject::styleDidChange):

  • rendering/RenderObject.h:

(RenderObject):

LayoutTests:

  • fast/block/remove-anonymous-wrappers-when-element-changes-to-float-or-positioned-expected.txt: Added.
  • fast/block/remove-anonymous-wrappers-when-element-changes-to-float-or-positioned.html: Added.
  • platform/qt/fast/block/float/float-not-removed-from-next-sibling2-expected.txt:
  • platform/qt/fast/dynamic/002-expected.txt:
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r150517 r150527  
     12013-05-22  Robert Hogan  <robert@webkit.org>
     2
     3        Need to Remove Anonymous Wrappers When All Children Become Inline
     4        https://bugs.webkit.org/show_bug.cgi?id=115687
     5
     6        Reviewed by David Hyatt.
     7
     8        * fast/block/remove-anonymous-wrappers-when-element-changes-to-float-or-positioned-expected.txt: Added.
     9        * fast/block/remove-anonymous-wrappers-when-element-changes-to-float-or-positioned.html: Added.
     10        * platform/qt/fast/block/float/float-not-removed-from-next-sibling2-expected.txt:
     11        * platform/qt/fast/dynamic/002-expected.txt:
     12
    1132013-05-22  Zoltan Arvai  <zarvai@inf.u-szeged.hu>
    214
  • trunk/LayoutTests/fast/block/float/float-not-removed-from-next-sibling2-expected.txt

    r85876 r150527  
    1515    RenderBlock (floating) {DIV} at (0,0) size 20x100
    1616      RenderImage {IMG} at (0,0) size 20x100 [bgcolor=#C0C0C0]
    17     RenderBlock (anonymous) at (0,0) size 20x0
    18       RenderInline {A} at (0,0) size 0x0
    19         RenderText {#text} at (0,0) size 0x0
     17    RenderInline {A} at (0,0) size 0x0
     18      RenderText {#text} at (0,0) size 0x0
    2019layer at (8,8) size 20x96
    2120  RenderBlock (positioned) {DIV} at (0,0) size 20x96
  • trunk/LayoutTests/platform/mac/fast/dynamic/002-expected.txt

    r145296 r150527  
    88          RenderText {#text} at (2,2) size 258x18
    99            text run at (2,2) width 258: "I should become a right-floating element."
    10         RenderBlock (anonymous) at (0,0) size 784x18
    11           RenderText {#text} at (0,0) size 393x18
    12             text run at (0,0) width 195: "This text should be on the left. "
    13             text run at (195,0) width 198: "The float should be to the right."
     10        RenderText {#text} at (0,0) size 393x18
     11          text run at (0,0) width 195: "This text should be on the left. "
     12          text run at (195,0) width 198: "The float should be to the right."
    1413      RenderBlock {DIV} at (0,18) size 784x30
    1514      RenderBlock {DIV} at (0,48) size 784x36
  • trunk/LayoutTests/platform/qt/fast/block/float/float-not-removed-from-next-sibling2-expected.txt

    r85882 r150527  
    1515    RenderBlock (floating) {DIV} at (0,0) size 20x100
    1616      RenderImage {IMG} at (0,0) size 20x100 [bgcolor=#C0C0C0]
    17     RenderBlock (anonymous) at (0,0) size 20x0
    18       RenderInline {A} at (0,0) size 0x0
    19         RenderText {#text} at (0,0) size 0x0
     17    RenderInline {A} at (0,0) size 0x0
     18      RenderText {#text} at (0,0) size 0x0
    2019layer at (8,8) size 20x100
    2120  RenderBlock (positioned) {DIV} at (0,0) size 20x100
  • trunk/LayoutTests/platform/qt/fast/dynamic/002-expected.txt

    r145350 r150527  
    88          RenderText {#text} at (2,2) size 244x19
    99            text run at (2,2) width 244: "I should become a right-floating element."
    10         RenderBlock (anonymous) at (0,0) size 784x19
    11           RenderText {#text} at (0,0) size 371x19
    12             text run at (0,0) width 184: "This text should be on the left. "
    13             text run at (184,0) width 187: "The float should be to the right."
     10        RenderText {#text} at (0,0) size 371x19
     11          text run at (0,0) width 184: "This text should be on the left. "
     12          text run at (184,0) width 187: "The float should be to the right."
    1413      RenderBlock {DIV} at (0,19) size 784x30
    1514      RenderBlock {DIV} at (0,49) size 784x38
  • trunk/Source/WebCore/ChangeLog

    r150525 r150527  
     12013-05-22  Robert Hogan  <robert@webkit.org>
     2
     3        Need to Remove Anonymous Wrappers When All Children Become Inline
     4        https://bugs.webkit.org/show_bug.cgi?id=115687
     5
     6        Reviewed by David Hyatt.
     7
     8        Remove a simple subset of anonymous wrappers, i.e. anonymous blocks without continuations,
     9        when a block becoming float or positioned removes the need for them.
     10
     11        Test: fast/block/remove-anonymous-wrappers-when-element-changes-to-float-or-positioned.html
     12
     13        * rendering/RenderBlock.h:
     14        (RenderBlock):
     15        * rendering/RenderObject.cpp:
     16        (WebCore):
     17        (WebCore::RenderObject::removeAnonymousWrappersFromLineIfNecessary):
     18        (WebCore::RenderObject::styleWillChange):
     19        (WebCore::RenderObject::styleDidChange):
     20        * rendering/RenderObject.h:
     21        (RenderObject):
     22
    1232013-05-22  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
    224
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r150312 r150527  
    280280    RenderBlock* createAnonymousColumnsBlock() const { return createAnonymousColumnsWithParentRenderer(this); }
    281281    RenderBlock* createAnonymousColumnSpanBlock() const { return createAnonymousColumnSpanWithParentRenderer(this); }
     282    static void collapseAnonymousBoxChild(RenderBlock* parent, RenderObject* child);
    282283
    283284    virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const OVERRIDE;
     
    603604    virtual void removeLeftoverAnonymousBlock(RenderBlock* child);
    604605
    605     static void collapseAnonymousBoxChild(RenderBlock* parent, RenderObject* child);
    606606    void moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, bool fullRemoveInsert);
    607607
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r150525 r150527  
    123123
    124124bool RenderObject::s_affectsParentBlock = false;
     125bool RenderObject::s_noLongerAffectsParentBlock = false;
    125126
    126127RenderObjectAncestorLineboxDirtySet* RenderObject::s_ancestorLineboxDirtySet = 0;
     
    16771678}
    16781679
     1680void RenderObject::removeAnonymousWrappersForInlinesIfNecessary()
     1681{
     1682    // We have changed to floated or out-of-flow positioning so maybe all our parent's
     1683    // children can be inline now. Bail if there are any block children left on the line,
     1684    // otherwise we can proceed to stripping solitary anonymous wrappers from the inlines.
     1685    // FIXME: We should also handle split inlines here - we exclude them at the moment by returning
     1686    // if we find a continuation.
     1687    RenderObject* curr = parent()->firstChild();
     1688    while (curr && ((curr->isAnonymousBlock() && !toRenderBlock(curr)->isAnonymousBlockContinuation()) || curr->style()->isFloating() || curr->style()->hasOutOfFlowPosition()))
     1689        curr = curr->nextSibling();
     1690
     1691    if (curr)
     1692        return;
     1693
     1694    curr = parent()->firstChild();
     1695    RenderBlock* parentBlock = toRenderBlock(parent());
     1696    while (curr) {
     1697        RenderObject* next = curr->nextSibling();
     1698        if (curr->isAnonymousBlock())
     1699            parentBlock->collapseAnonymousBoxChild(parentBlock, toRenderBlock(curr));
     1700        curr = next;
     1701    }
     1702}
     1703
    16791704void RenderObject::setAnimatableStyle(PassRefPtr<RenderStyle> style)
    16801705{
     
    18941919            && parent() && (parent()->isBlockFlow() || parent()->isRenderInline());
    18951920
     1921        s_noLongerAffectsParentBlock = ((!isFloating() && newStyle->isFloating()) || (!isOutOfFlowPositioned() && newStyle->hasOutOfFlowPosition()))
     1922            && parent() && parent()->isRenderBlock();
     1923
    18961924        // reset style flags
    18971925        if (diff == StyleDifferenceLayout || diff == StyleDifferenceLayoutPositionedMovementOnly) {
     
    19041932        setHasTransform(false);
    19051933        setHasReflection(false);
    1906     } else
     1934    } else {
    19071935        s_affectsParentBlock = false;
     1936        s_noLongerAffectsParentBlock = false;
     1937    }
    19081938
    19091939    if (view()->frameView()) {
     
    19601990        handleDynamicFloatPositionChange();
    19611991
     1992    if (s_noLongerAffectsParentBlock)
     1993        removeAnonymousWrappersForInlinesIfNecessary();
    19621994#if ENABLE(SVG)
    19631995    SVGRenderSupport::styleChanged(this);
  • trunk/Source/WebCore/rendering/RenderObject.h

    r150259 r150527  
    248248    // normal flow object.
    249249    void handleDynamicFloatPositionChange();
     250    void removeAnonymousWrappersForInlinesIfNecessary();
    250251   
    251252    // RenderObject tree manipulation
     
    11701171    // Store state between styleWillChange and styleDidChange
    11711172    static bool s_affectsParentBlock;
     1173    static bool s_noLongerAffectsParentBlock;
    11721174};
    11731175
Note: See TracChangeset for help on using the changeset viewer.