Changeset 224273 in webkit


Ignore:
Timestamp:
Nov 1, 2017 12:57:02 AM (6 years ago)
Author:
Antti Koivisto
Message:

Remove empty continuations in RenderObject::removeFromParentAndDestroyCleaningUpAnonymousWrappers
https://bugs.webkit.org/show_bug.cgi?id=179014

Reviewed by Geoff Garen.

Source/WebCore:

Treat continuation similarly to other anonymous wrappers. This makes things more understandable
and allows removal of some questionable code in RenderBlock::takeChild.

The patch also makes continuation chain a double linked so we can efficiently remove single
continuations from the chain. It also gets rid of algorithms that recurse in continuation chain.

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::firstChildInContinuation):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::styleDidChange):

Don't add and remove continuations from the chain when updating style. Prevent recursion by walking
the chain only in the (non-continuation) head renderer.

(WebCore::RenderBlock::dropAnonymousBoxChild):

Make a member function.

(WebCore::RenderBlock::takeChild):

Remove code that destroyed empty continuations and caused the parent to destroy itself.
Empty continuations are now removed by RenderObject::removeFromParentAndDestroyCleaningUpAnonymousWrappers.

  • rendering/RenderBlock.h:
  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::ContinuationChainNode::ContinuationChainNode):
(WebCore::RenderBoxModelObject::ContinuationChainNode::~ContinuationChainNode):
(WebCore::RenderBoxModelObject::ContinuationChainNode::insertAfter):

Track continuations with double linked lists.

(WebCore::continuationChainNodeMap):
(WebCore::RenderBoxModelObject::willBeDestroyed):

Don't recurse to destroy continuation chain.
Destroy all continuations iteratively if this is the head of the chain.
When destroying a continuation renderer simply remove it from the chain.

(WebCore::RenderBoxModelObject::continuation const):
(WebCore::RenderBoxModelObject::insertIntoContinuationChainAfter):
(WebCore::RenderBoxModelObject::removeFromContinuationChain):
(WebCore::RenderBoxModelObject::ensureContinuationChainNode):
(WebCore::continuationMap): Deleted.
(WebCore::RenderBoxModelObject::setContinuation): Deleted.

  • rendering/RenderBoxModelObject.h:
  • rendering/RenderElement.cpp:

(WebCore::RenderElement::RenderElement):
(WebCore::RenderElement::removeAnonymousWrappersForInlinesIfNecessary):

Make this a function of the parent renderer itself instead of getting 'parent()' as first operation and
then using it.
Don't remove continuations (isAnonymousBlockContinuation() test gives wrong result for the last continuation of the chain).

(WebCore::RenderElement::styleDidChange):

removeAnonymousWrappersForInlinesIfNecessary is no function of the parent.

(WebCore::RenderElement::updateOutlineAutoAncestor):

  • rendering/RenderElement.h:

(WebCore::RenderElement::hasContinuationChainNode const):
(WebCore::RenderElement::setHasContinuationChainNode):
(WebCore::RenderElement::hasContinuation const): Deleted.
(WebCore::RenderElement::setHasContinuation): Deleted.

  • rendering/RenderInline.cpp:

(WebCore::RenderInline::styleDidChange):

Don't add and remove continuations from the chain when updating style. Prevent recursion by walking
the chain only in the (non-continuation) head renderer.

(WebCore::RenderInline::addChildIgnoringContinuation):

Remove the old continuation from the chain. splitFlow() will add it back into the right place.

(WebCore::RenderInline::splitInlines):
(WebCore::RenderInline::addChildToContinuation):
(WebCore::RenderInline::childBecameNonInline):

Remove the old continuation from the chain. splitFlow() will add it back into the right place.

  • rendering/RenderInline.h:
  • rendering/RenderObject.cpp:

(WebCore::RenderObject::propagateRepaintToParentWithOutlineAutoIfNeeded const):
(WebCore::RenderObject::outputRenderObject const):
(WebCore::findDestroyRootIncludingAnonymous):

Allow anonymous continuations as destroy roots.

(WebCore::RenderObject::removeFromParentAndDestroyCleaningUpAnonymousWrappers):

Removing a continuation may leave behind unnecessary anonymous sibling wrappers.
Call removeAnonymousWrappersForInlinesIfNecessary() on parent after removal to get rid of them.

LayoutTests:

  • fast/ruby/float-overhang-from-ruby-text-expected.txt:
  • platform/mac/fast/ruby/rubyDOM-remove-rt1-expected.txt:
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r224271 r224273  
     12017-11-01  Antti Koivisto  <antti@apple.com>
     2
     3        Remove empty continuations in RenderObject::removeFromParentAndDestroyCleaningUpAnonymousWrappers
     4        https://bugs.webkit.org/show_bug.cgi?id=179014
     5
     6        Reviewed by Geoff Garen.
     7
     8        * fast/ruby/float-overhang-from-ruby-text-expected.txt:
     9        * platform/mac/fast/ruby/rubyDOM-remove-rt1-expected.txt:
     10
    1112017-10-31  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/LayoutTests/fast/ruby/float-overhang-from-ruby-text-expected.txt

    r94991 r224273  
    1818        RenderRuby (inline) {RUBY} at (0,0) size 100x50
    1919          RenderRubyRun (anonymous) at (0,0) size 100x50
    20             RenderRubyBase (anonymous) at (0,0) size 100x50
    21               RenderText {#text} at (0,0) size 100x50
    22                 text run at (0,0) width 100: "aa"
     20            RenderText {#text} at (0,0) size 100x50
     21              text run at (0,0) width 100: "aa"
    2322        RenderText {#text} at (0,0) size 0x0
  • trunk/LayoutTests/platform/mac/fast/ruby/rubyDOM-remove-rt1-expected.txt

    r177774 r224273  
    2525                text run at (30,0) width 47: "HTML"
    2626          RenderRubyRun (anonymous) at (259,10) size 9x18
    27             RenderRubyBase (anonymous) at (0,0) size 8x18
    28               RenderText {#text} at (0,0) size 8x18
    29                 text run at (0,0) width 8: "5"
     27            RenderText {#text} at (0,0) size 8x18
     28              text run at (0,0) width 8: "5"
    3029        RenderText {#text} at (267,10) size 38x18
    3130          text run at (267,10) width 38: " spec."
  • trunk/Source/WebCore/ChangeLog

    r224269 r224273  
     12017-11-01  Antti Koivisto  <antti@apple.com>
     2
     3        Remove empty continuations in RenderObject::removeFromParentAndDestroyCleaningUpAnonymousWrappers
     4        https://bugs.webkit.org/show_bug.cgi?id=179014
     5
     6        Reviewed by Geoff Garen.
     7
     8        Treat continuation similarly to other anonymous wrappers. This makes things more understandable
     9        and allows removal of some questionable code in RenderBlock::takeChild.
     10
     11        The patch also makes continuation chain a double linked so we can efficiently remove single
     12        continuations from the chain. It also gets rid of algorithms that recurse in continuation chain.
     13
     14        * accessibility/AccessibilityRenderObject.cpp:
     15        (WebCore::firstChildInContinuation):
     16        * rendering/RenderBlock.cpp:
     17        (WebCore::RenderBlock::styleDidChange):
     18
     19            Don't add and remove continuations from the chain when updating style. Prevent recursion by walking
     20            the chain only in the (non-continuation) head renderer.
     21
     22        (WebCore::RenderBlock::dropAnonymousBoxChild):
     23
     24            Make a member function.
     25
     26        (WebCore::RenderBlock::takeChild):
     27
     28            Remove code that destroyed empty continuations and caused the parent to destroy itself.
     29            Empty continuations are now removed by RenderObject::removeFromParentAndDestroyCleaningUpAnonymousWrappers.
     30
     31        * rendering/RenderBlock.h:
     32        * rendering/RenderBoxModelObject.cpp:
     33        (WebCore::RenderBoxModelObject::ContinuationChainNode::ContinuationChainNode):
     34        (WebCore::RenderBoxModelObject::ContinuationChainNode::~ContinuationChainNode):
     35        (WebCore::RenderBoxModelObject::ContinuationChainNode::insertAfter):
     36
     37            Track continuations with double linked lists.
     38
     39        (WebCore::continuationChainNodeMap):
     40        (WebCore::RenderBoxModelObject::willBeDestroyed):
     41
     42            Don't recurse to destroy continuation chain.
     43            Destroy all continuations iteratively if this is the head of the chain.
     44            When destroying a continuation renderer simply remove it from the chain.
     45
     46        (WebCore::RenderBoxModelObject::continuation const):
     47        (WebCore::RenderBoxModelObject::insertIntoContinuationChainAfter):
     48        (WebCore::RenderBoxModelObject::removeFromContinuationChain):
     49        (WebCore::RenderBoxModelObject::ensureContinuationChainNode):
     50        (WebCore::continuationMap): Deleted.
     51        (WebCore::RenderBoxModelObject::setContinuation): Deleted.
     52        * rendering/RenderBoxModelObject.h:
     53        * rendering/RenderElement.cpp:
     54        (WebCore::RenderElement::RenderElement):
     55        (WebCore::RenderElement::removeAnonymousWrappersForInlinesIfNecessary):
     56
     57            Make this a function of the parent renderer itself instead of getting 'parent()' as first operation and
     58            then using it.
     59            Don't remove continuations (isAnonymousBlockContinuation() test gives wrong result for the last continuation of the chain).
     60
     61        (WebCore::RenderElement::styleDidChange):
     62
     63            removeAnonymousWrappersForInlinesIfNecessary is no function of the parent.
     64
     65        (WebCore::RenderElement::updateOutlineAutoAncestor):
     66        * rendering/RenderElement.h:
     67        (WebCore::RenderElement::hasContinuationChainNode const):
     68        (WebCore::RenderElement::setHasContinuationChainNode):
     69        (WebCore::RenderElement::hasContinuation const): Deleted.
     70        (WebCore::RenderElement::setHasContinuation): Deleted.
     71        * rendering/RenderInline.cpp:
     72        (WebCore::RenderInline::styleDidChange):
     73
     74            Don't add and remove continuations from the chain when updating style. Prevent recursion by walking
     75            the chain only in the (non-continuation) head renderer.
     76
     77        (WebCore::RenderInline::addChildIgnoringContinuation):
     78
     79            Remove the old continuation from the chain. splitFlow() will add it back into the right place.
     80
     81        (WebCore::RenderInline::splitInlines):
     82        (WebCore::RenderInline::addChildToContinuation):
     83        (WebCore::RenderInline::childBecameNonInline):
     84
     85            Remove the old continuation from the chain. splitFlow() will add it back into the right place.
     86
     87        * rendering/RenderInline.h:
     88        * rendering/RenderObject.cpp:
     89        (WebCore::RenderObject::propagateRepaintToParentWithOutlineAutoIfNeeded const):
     90        (WebCore::RenderObject::outputRenderObject const):
     91        (WebCore::findDestroyRootIncludingAnonymous):
     92
     93            Allow anonymous continuations as destroy roots.
     94
     95        (WebCore::RenderObject::removeFromParentAndDestroyCleaningUpAnonymousWrappers):
     96
     97            Removing a continuation may leave behind unnecessary anonymous sibling wrappers.
     98            Call removeAnonymousWrappersForInlinesIfNecessary() on parent after removal to get rid of them.
     99
    11002017-10-31  Said Abou-Hallawa  <sabouhallawa@apple.com>
    2101
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r224260 r224273  
    164164static inline RenderObject* firstChildInContinuation(RenderInline& renderer)
    165165{
    166     auto continuation = renderer.continuation();
     166    auto* continuation = renderer.continuation();
    167167
    168168    while (continuation) {
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r224150 r224273  
    436436
    437437    auto& newStyle = style();
    438     if (!isAnonymousBlock()) {
     438    if (!isAnonymousBlock() && !isContinuation()) {
    439439        // Ensure that all of our continuation blocks pick up the new style.
    440         for (RenderBlock* currCont = blockElementContinuation(); currCont; currCont = currCont->blockElementContinuation()) {
    441             RenderBoxModelObject* nextCont = currCont->continuation();
    442             currCont->setContinuation(0);
     440        for (RenderBlock* currCont = blockElementContinuation(); currCont; currCont = currCont->blockElementContinuation())
    443441            currCont->setStyle(RenderStyle::clone(newStyle));
    444             currCont->setContinuation(nextCont);
    445         }
    446442    }
    447443
     
    819815}
    820816
    821 void RenderBlock::dropAnonymousBoxChild(RenderBlock& parent, RenderBlock& child)
    822 {
    823     parent.setNeedsLayoutAndPrefWidthsRecalc();
    824     parent.setChildrenInline(child.childrenInline());
     817void RenderBlock::dropAnonymousBoxChild(RenderBlock& child)
     818{
     819    setNeedsLayoutAndPrefWidthsRecalc();
     820    setChildrenInline(child.childrenInline());
    825821    RenderObject* nextSibling = child.nextSibling();
    826822
    827     auto toBeDeleted = parent.takeChildInternal(child, child.hasLayer() ? NotifyChildren : DontNotifyChildren);
    828     child.moveAllChildrenTo(&parent, nextSibling, child.hasLayer());
     823    auto toBeDeleted = takeChildInternal(child, child.hasLayer() ? NotifyChildren : DontNotifyChildren);
     824    child.moveAllChildrenTo(this, nextSibling, child.hasLayer());
    829825    // Delete the now-empty block's lines and nuke it.
    830826    child.deleteLines();
     
    894890        // The removal has knocked us down to containing only a single anonymous
    895891        // box. We can pull the content right back up into our box.
    896         dropAnonymousBoxChild(*this, downcast<RenderBlock>(*child));
     892        dropAnonymousBoxChild(downcast<RenderBlock>(*child));
    897893    } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymousBlock())) && canDropAnonymousBlockChild()) {
    898894        // It's possible that the removal has knocked us down to a single anonymous
     
    910906            }
    911907            if (dropAnonymousBlock)
    912                 dropAnonymousBoxChild(*this, anonBlock);
     908                dropAnonymousBoxChild(anonBlock);
    913909        }
    914910    }
     
    918914        if (childrenInline())
    919915            deleteLines();
    920 
    921         // If we are an empty anonymous block in the continuation chain,
    922         // we need to remove ourself and fix the continuation chain.
    923         if (!beingDestroyed() && isAnonymousBlockContinuation() && !oldChild.isListMarker()) {
    924             auto containingBlockIgnoringAnonymous = containingBlock();
    925             while (containingBlockIgnoringAnonymous && containingBlockIgnoringAnonymous->isAnonymousBlock())
    926                 containingBlockIgnoringAnonymous = containingBlockIgnoringAnonymous->containingBlock();
    927             for (RenderObject* current = this; current; current = current->previousInPreOrder(containingBlockIgnoringAnonymous)) {
    928                 if (!is<RenderBoxModelObject>(current) || downcast<RenderBoxModelObject>(*current).continuation() != this)
    929                     continue;
    930                 // Found our previous continuation. We just need to point it to
    931                 // |this|'s next continuation.
    932                 auto* nextContinuation = continuation();
    933                 if (is<RenderInline>(*current))
    934                     downcast<RenderInline>(*current).setContinuation(nextContinuation);
    935                 else if (is<RenderBlock>(*current))
    936                     downcast<RenderBlock>(*current).setContinuation(nextContinuation);
    937                 else
    938                     ASSERT_NOT_REACHED();
    939                 break;
    940             }
    941             setContinuation(nullptr);
    942             // FIXME: This is dangerous.
    943             removeFromParentAndDestroy();
    944         }
    945916    }
    946917    return takenChild;
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r223072 r224273  
    193193    RenderBlock* blockElementContinuation() const;
    194194
    195     using RenderBoxModelObject::continuation;
    196     using RenderBoxModelObject::setContinuation;
    197 
    198195    static RenderPtr<RenderBlock> createAnonymousWithParentRendererAndDisplay(const RenderBox& parent, EDisplay = BLOCK);
    199196    RenderPtr<RenderBlock> createAnonymousBlock(EDisplay = BLOCK) const;
    200     static void dropAnonymousBoxChild(RenderBlock& parent, RenderBlock& child);
     197    void dropAnonymousBoxChild(RenderBlock& child);
    201198
    202199    RenderPtr<RenderBox> createAnonymousBoxWithSameTypeAs(const RenderBox&) const override;
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r223194 r224273  
    7878// <b><i><p>Hello</p></i></b>. In this example the <i> will have a block as
    7979// its continuation but the <b> will just have an inline as its continuation.
    80 typedef HashMap<const RenderBoxModelObject*, WeakPtr<RenderBoxModelObject>> ContinuationMap;
    81 static ContinuationMap& continuationMap()
    82 {
    83     static NeverDestroyed<ContinuationMap> map;
     80
     81struct RenderBoxModelObject::ContinuationChainNode {
     82    WeakPtr<RenderBoxModelObject> renderer;
     83    ContinuationChainNode* previous { nullptr };
     84    ContinuationChainNode* next { nullptr };
     85
     86    ContinuationChainNode(RenderBoxModelObject&);
     87    ~ContinuationChainNode();
     88
     89    void insertAfter(ContinuationChainNode&);
     90
     91    WTF_MAKE_FAST_ALLOCATED;
     92};
     93
     94RenderBoxModelObject::ContinuationChainNode::ContinuationChainNode(RenderBoxModelObject& renderer)
     95    : renderer(makeWeakPtr(renderer))
     96{
     97}
     98
     99RenderBoxModelObject::ContinuationChainNode::~ContinuationChainNode()
     100{
     101    if (next) {
     102        ASSERT(previous);
     103        ASSERT(next->previous == this);
     104        next->previous = previous;
     105    }
     106    if (previous) {
     107        ASSERT(previous->next == this);
     108        previous->next = next;
     109    }
     110}
     111
     112void RenderBoxModelObject::ContinuationChainNode::insertAfter(ContinuationChainNode& after)
     113{
     114    ASSERT(!previous);
     115    ASSERT(!next);
     116    if ((next = after.next)) {
     117        ASSERT(next->previous = &after);
     118        next->previous = this;
     119    }
     120    previous = &after;
     121    after.next = this;
     122}
     123
     124typedef HashMap<const RenderBoxModelObject*, std::unique_ptr<RenderBoxModelObject::ContinuationChainNode>> ContinuationChainNodeMap;
     125static ContinuationChainNodeMap& continuationChainNodeMap()
     126{
     127    static NeverDestroyed<ContinuationChainNodeMap> map;
    84128    return map;
    85129}
     
    188232void RenderBoxModelObject::willBeDestroyed()
    189233{
    190     if (hasContinuation()) {
    191         continuation()->removeFromParentAndDestroy();
    192         setContinuation(nullptr);
    193     }
     234    if (continuation() && !isContinuation()) {
     235        removeAndDestroyAllContinuations();
     236        ASSERT(!continuation());
     237    }
     238    if (hasContinuationChainNode())
     239        removeFromContinuationChain();
    194240
    195241    // If this is a first-letter object with a remaining text fragment then the
     
    24482494RenderBoxModelObject* RenderBoxModelObject::continuation() const
    24492495{
    2450     if (!hasContinuation())
     2496    if (!hasContinuationChainNode())
    24512497        return nullptr;
    2452     return continuationMap().get(this).get();
    2453 }
    2454 
    2455 void RenderBoxModelObject::setContinuation(RenderBoxModelObject* continuation)
    2456 {
    2457     ASSERT(!continuation || continuation->isContinuation());
    2458     if (continuation)
    2459         continuationMap().set(this, makeWeakPtr(continuation));
    2460     else if (hasContinuation())
    2461         continuationMap().remove(this);
    2462     setHasContinuation(!!continuation);
     2498
     2499    auto& continuationChainNode = *continuationChainNodeMap().get(this);
     2500    if (!continuationChainNode.next)
     2501        return nullptr;
     2502    return continuationChainNode.next->renderer.get();
     2503}
     2504
     2505void RenderBoxModelObject::insertIntoContinuationChainAfter(RenderBoxModelObject& afterRenderer)
     2506{
     2507    ASSERT(isContinuation());
     2508    ASSERT(!continuationChainNodeMap().contains(this));
     2509
     2510    auto& after = afterRenderer.ensureContinuationChainNode();
     2511    ensureContinuationChainNode().insertAfter(after);
     2512}
     2513
     2514void RenderBoxModelObject::removeFromContinuationChain()
     2515{
     2516    ASSERT(hasContinuationChainNode());
     2517    ASSERT(continuationChainNodeMap().contains(this));
     2518    setHasContinuationChainNode(false);
     2519    continuationChainNodeMap().remove(this);
     2520}
     2521
     2522auto RenderBoxModelObject::ensureContinuationChainNode() -> ContinuationChainNode&
     2523{
     2524    setHasContinuationChainNode(true);
     2525    return *continuationChainNodeMap().ensure(this, [&] {
     2526        return std::make_unique<ContinuationChainNode>(*this);
     2527    }).iterator->value;
     2528}
     2529
     2530void RenderBoxModelObject::removeAndDestroyAllContinuations()
     2531{
     2532    ASSERT(!isContinuation());
     2533    ASSERT(hasContinuationChainNode());
     2534    ASSERT(continuationChainNodeMap().contains(this));
     2535    auto& continuationChainNode = *continuationChainNodeMap().get(this);
     2536    while (continuationChainNode.next)
     2537        continuationChainNode.next->renderer->removeFromParentAndDestroy();
     2538    removeFromContinuationChain();
    24632539}
    24642540
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r222556 r224273  
    236236
    237237    RenderBoxModelObject* continuation() const;
     238   
     239    void insertIntoContinuationChainAfter(RenderBoxModelObject&);
     240    void removeFromContinuationChain();
    238241
    239242    virtual LayoutRect paintRectToClipOutFromBorder(const LayoutRect&) { return LayoutRect(); };
     
    257260    InterpolationQuality chooseInterpolationQuality(GraphicsContext&, Image&, const void*, const LayoutSize&);
    258261
    259     void setContinuation(RenderBoxModelObject*);
    260 
    261262    LayoutRect localCaretRectForEmptyElement(LayoutUnit width, LayoutUnit textIndentOffset);
    262263
     
    302303    RenderBlock* containingBlockForAutoHeightDetection(Length logicalHeight) const;
    303304
     305    struct ContinuationChainNode;
     306
    304307private:
     308    ContinuationChainNode& ensureContinuationChainNode();
     309    void removeAndDestroyAllContinuations();
     310
    305311    LayoutUnit computedCSSPadding(const Length&) const;
    306312   
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r224150 r224273  
    102102    , m_hasPausedImageAnimations(false)
    103103    , m_hasCounterNodeMap(false)
    104     , m_hasContinuation(false)
     104    , m_hasContinuationChainNode(false)
    105105    , m_isContinuation(false)
    106106    , m_hasValidCachedFirstLineStyle(false)
     
    962962void RenderElement::removeAnonymousWrappersForInlinesIfNecessary()
    963963{
    964     RenderBlock& parentBlock = downcast<RenderBlock>(*parent());
    965     if (!parentBlock.canDropAnonymousBlockChild())
     964    // FIXME: Move to RenderBlock.
     965    if (!is<RenderBlock>(*this))
     966        return;
     967    RenderBlock& thisBlock = downcast<RenderBlock>(*this);
     968    if (!thisBlock.canDropAnonymousBlockChild())
    966969        return;
    967970
     
    971974    // FIXME: We should also handle split inlines here - we exclude them at the moment by returning
    972975    // if we find a continuation.
    973     RenderObject* current = parent()->firstChild();
    974     while (current && ((current->isAnonymousBlock() && !downcast<RenderBlock>(*current).isAnonymousBlockContinuation()) || current->style().isFloating() || current->style().hasOutOfFlowPosition()))
     976    RenderObject* current = firstChild();
     977    while (current && ((current->isAnonymousBlock() && !downcast<RenderBlock>(*current).isContinuation()) || current->style().isFloating() || current->style().hasOutOfFlowPosition()))
    975978        current = current->nextSibling();
    976979
     
    979982
    980983    RenderObject* next;
    981     for (current = parent()->firstChild(); current; current = next) {
     984    for (current = firstChild(); current; current = next) {
    982985        next = current->nextSibling();
    983986        if (current->isAnonymousBlock())
    984             parentBlock.dropAnonymousBoxChild(parentBlock, downcast<RenderBlock>(*current));
     987            thisBlock.dropAnonymousBoxChild(downcast<RenderBlock>(*current));
    985988    }
    986989}
     
    10111014
    10121015    if (s_noLongerAffectsParentBlock)
    1013         removeAnonymousWrappersForInlinesIfNecessary();
     1016        parent()->removeAnonymousWrappersForInlinesIfNecessary();
    10141017
    10151018    SVGRenderSupport::styleChanged(*this, oldStyle);
     
    21532156        downcast<RenderElement>(child).updateOutlineAutoAncestor(hasOutlineAuto);
    21542157    }
    2155     if (hasContinuation())
    2156         downcast<RenderBoxModelObject>(*this).continuation()->updateOutlineAutoAncestor(hasOutlineAuto);
     2158    if (is<RenderBoxModelObject>(*this)) {
     2159        if (auto* continuation = downcast<RenderBoxModelObject>(*this).continuation())
     2160            continuation->updateOutlineAutoAncestor(hasOutlineAuto);
     2161    }
    21572162}
    21582163
  • trunk/Source/WebCore/rendering/RenderElement.h

    r223569 r224273  
    222222    virtual void updateAnonymousChildStyle(const RenderObject&, RenderStyle&) const { };
    223223
    224     bool hasContinuation() const { return m_hasContinuation; }
     224    void removeAnonymousWrappersForInlinesIfNecessary();
     225
     226    bool hasContinuationChainNode() const { return m_hasContinuationChainNode; }
    225227    bool isContinuation() const { return m_isContinuation; }
    226228    void setIsContinuation() { m_isContinuation = true; }
     
    265267    bool renderInlineAlwaysCreatesLineBoxes() const { return m_renderInlineAlwaysCreatesLineBoxes; }
    266268
    267     void setHasContinuation(bool b) { m_hasContinuation = b; }
     269    void setHasContinuationChainNode(bool b) { m_hasContinuationChainNode = b; }
    268270
    269271    void setRenderBlockHasMarginBeforeQuirk(bool b) { m_renderBlockHasMarginBeforeQuirk = b; }
     
    304306    // normal flow object.
    305307    void handleDynamicFloatPositionChange();
    306     void removeAnonymousWrappersForInlinesIfNecessary();
    307308
    308309    bool shouldRepaintForStyleDifference(StyleDifference) const;
     
    337338    unsigned m_hasPausedImageAnimations : 1;
    338339    unsigned m_hasCounterNodeMap : 1;
    339     unsigned m_hasContinuation : 1;
     340    unsigned m_hasContinuationChainNode : 1;
    340341    unsigned m_isContinuation : 1;
    341342    mutable unsigned m_hasValidCachedFirstLineStyle : 1;
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r223127 r224273  
    190190    auto& newStyle = style();
    191191    RenderInline* continuation = inlineElementContinuation();
    192     if (continuation) {
    193         for (RenderInline* currCont = continuation; currCont; currCont = currCont->inlineElementContinuation()) {
    194             RenderBoxModelObject* nextCont = currCont->continuation();
    195             currCont->setContinuation(nullptr);
     192    if (continuation && !isContinuation()) {
     193        for (RenderInline* currCont = continuation; currCont; currCont = currCont->inlineElementContinuation())
    196194            currCont->setStyle(RenderStyle::clone(newStyle));
    197             currCont->setContinuation(nextCont);
    198         }
    199195        // If an inline's in-flow positioning has changed and it is part of an active continuation as a descendant of an anonymous containing block,
    200196        // then any descendant blocks will need to change their in-flow positioning accordingly.
     
    345341        newBox->setIsContinuation();
    346342        RenderBoxModelObject* oldContinuation = continuation();
    347         setContinuation(newBox.get());
     343        if (oldContinuation)
     344            oldContinuation->removeFromContinuationChain();
     345        newBox->insertIntoContinuationChainAfter(*this);
    348346
    349347        splitFlow(beforeChild, WTFMove(newBox), WTFMove(newChild), oldContinuation);
     
    418416        rendererToMove = nextSibling;
    419417    }
    420     cloneInline->setContinuation(oldCont);
    421418    // Hook |clone| up as the continuation of the middle block.
    422     middleBlock->setContinuation(cloneInline.get());
     419    cloneInline->insertIntoContinuationChainAfter(*middleBlock);
     420    if (oldCont)
     421        oldCont->insertIntoContinuationChainAfter(*cloneInline);
    423422
    424423    // We have been reparented and are now under the fromBlock.  We need
     
    444443
    445444            // Hook the clone up as a continuation of |curr|.
    446             RenderInline& currentInline = downcast<RenderInline>(*current);
    447             oldCont = currentInline.continuation();
    448             currentInline.setContinuation(cloneInline.get());
    449             cloneInline->setContinuation(oldCont);
     445            cloneInline->insertIntoContinuationChainAfter(*current);
    450446
    451447            // Now we need to take all of the children starting from the first child
    452448            // *after* currentChild and append them all to the clone.
    453             for (auto* current = currentChild->nextSibling(); current;) {
    454                 auto* next = current->nextSibling();
    455                 auto childToMove = currentInline.takeChildInternal(*current, NotifyChildren);
     449            for (auto* sibling = currentChild->nextSibling(); sibling;) {
     450                auto* next = sibling->nextSibling();
     451                auto childToMove = current->takeChildInternal(*sibling, NotifyChildren);
    456452                cloneInline->addChildIgnoringContinuation(WTFMove(childToMove));
    457                 current->setNeedsLayoutAndPrefWidthsRecalc();
    458                 current = next;
     453                sibling->setNeedsLayoutAndPrefWidthsRecalc();
     454                sibling = next;
    459455            }
    460456        }
     
    577573        while (parent && parent->parent() && parent->parent()->isAnonymous()) {
    578574            // The ancestor candidate needs to be inside the continuation.
    579             if (parent->hasContinuation())
     575            if (parent->isContinuation())
    580576                break;
    581577            parent = parent->parent();
     
    13801376    newBox->setIsContinuation();
    13811377    RenderBoxModelObject* oldContinuation = continuation();
    1382     setContinuation(newBox.get());
     1378    if (oldContinuation)
     1379        oldContinuation->removeFromContinuationChain();
     1380    newBox->insertIntoContinuationChainAfter(*this);
    13831381    RenderObject* beforeChild = child.nextSibling();
    13841382    auto removedChild = takeChildInternal(child, NotifyChildren);
  • trunk/Source/WebCore/rendering/RenderInline.h

    r223127 r224273  
    8787    void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) final;
    8888    void paintOutline(PaintInfo&, const LayoutPoint&);
    89 
    90     using RenderBoxModelObject::continuation;
    91     using RenderBoxModelObject::setContinuation;
    9289
    9390    bool alwaysCreateLineBoxes() const { return renderInlineAlwaysCreatesLineBoxes(); }
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r224177 r224273  
    825825        ASSERT(rendererHasOutlineAutoAncestor
    826826            || renderer->outlineStyleForRepaint().outlineStyleIsAuto()
    827             || (is<RenderElement>(*renderer) && downcast<RenderElement>(*renderer).hasContinuation()));
     827            || (is<RenderBoxModelObject>(*renderer) && downcast<RenderBoxModelObject>(*renderer).isContinuation()));
    828828        if (renderer == &repaintContainer && rendererHasOutlineAutoAncestor)
    829829            repaintRectNeedsConverting = true;
     
    11761176    if (is<RenderBoxModelObject>(*this)) {
    11771177        auto& renderer = downcast<RenderBoxModelObject>(*this);
    1178         if (renderer.hasContinuation())
     1178        if (renderer.continuation())
    11791179            stream << " continuation->(" << renderer.continuation() << ")";
    11801180    }
     
    14671467        if (destroyRootParent->isRenderFragmentedFlow())
    14681468            break;
    1469         // FIXME: Destroy continuations here too.
    1470         if (destroyRootParent->isContinuation())
    1471             break;
    14721469        bool destroyingOnlyChild = destroyRootParent->firstChild() == destroyRoot && destroyRootParent->lastChild() == destroyRoot;
    14731470        if (!destroyingOnlyChild)
     
    14911488        downcast<RenderTableRow>(destroyRoot).collapseAndDestroyAnonymousSiblingRows();
    14921489
    1493     destroyRoot.removeFromParentAndDestroy();
     1490    auto& destroyRootParent = *destroyRoot.parent();
     1491    destroyRootParent.removeAndDestroyChild(destroyRoot);
     1492    destroyRootParent.removeAnonymousWrappersForInlinesIfNecessary();
    14941493    // WARNING: |this| is deleted here.
    14951494}
Note: See TracChangeset for help on using the changeset viewer.