Changeset 237121 in webkit


Ignore:
Timestamp:
Oct 15, 2018, 10:25:42 AM (7 years ago)
Author:
Simon Fraser
Message:

RenderLayer::addChild() and removeChild() should take references
https://bugs.webkit.org/show_bug.cgi?id=190582

Reviewed by Zalan Bujtas.

Pass the layer to be added or removed as a reference; it's never null.

  • rendering/RenderElement.cpp:

(WebCore::addLayers):
(WebCore::RenderElement::removeLayers):
(WebCore::RenderElement::moveLayers):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::addChild):
(WebCore::RenderLayer::removeChild):
(WebCore::RenderLayer::insertOnlyThisLayer):
(WebCore::RenderLayer::removeOnlyThisLayer):

  • rendering/RenderLayer.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/Source/WebCore/ChangeLog

    r237119 r237121  
     12018-10-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        RenderLayer::addChild() and removeChild() should take references
     4        https://bugs.webkit.org/show_bug.cgi?id=190582
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Pass the layer to be added or removed as a reference; it's never null.
     9
     10        * rendering/RenderElement.cpp:
     11        (WebCore::addLayers):
     12        (WebCore::RenderElement::removeLayers):
     13        (WebCore::RenderElement::moveLayers):
     14        * rendering/RenderLayer.cpp:
     15        (WebCore::RenderLayer::addChild):
     16        (WebCore::RenderLayer::removeChild):
     17        (WebCore::RenderLayer::insertOnlyThisLayer):
     18        (WebCore::RenderLayer::removeOnlyThisLayer):
     19        * rendering/RenderLayer.h:
     20
    1212018-10-15  Yoshiaki Jitsukawa  <yoshiaki.jitsukawa@sony.com>
    222
  • TabularUnified trunk/Source/WebCore/rendering/RenderElement.cpp

    r236753 r237121  
    549549            newObject = nullptr;
    550550        }
    551         parentLayer->addChild(downcast<RenderLayerModelObject>(renderer).layer(), beforeChild);
     551        parentLayer->addChild(*downcast<RenderLayerModelObject>(renderer).layer(), beforeChild);
    552552        return;
    553553    }
     
    573573
    574574    if (hasLayer()) {
    575         parentLayer->removeChild(downcast<RenderLayerModelObject>(*this).layer());
     575        parentLayer->removeChild(*downcast<RenderLayerModelObject>(*this).layer());
    576576        return;
    577577    }
     
    590590        ASSERT(oldParent == layer->parent());
    591591        if (oldParent)
    592             oldParent->removeChild(layer);
    593         newParent->addChild(layer);
     592            oldParent->removeChild(*layer);
     593        newParent->addChild(*layer);
    594594        return;
    595595    }
  • TabularUnified trunk/Source/WebCore/rendering/RenderLayer.cpp

    r237117 r237121  
    376376}
    377377
    378 void RenderLayer::addChild(RenderLayer* child, RenderLayer* beforeChild)
     378void RenderLayer::addChild(RenderLayer& child, RenderLayer* beforeChild)
    379379{
    380380    RenderLayer* prevSibling = beforeChild ? beforeChild->previousSibling() : lastChild();
    381381    if (prevSibling) {
    382         child->setPreviousSibling(prevSibling);
    383         prevSibling->setNextSibling(child);
    384         ASSERT(prevSibling != child);
     382        child.setPreviousSibling(prevSibling);
     383        prevSibling->setNextSibling(&child);
     384        ASSERT(prevSibling != &child);
    385385    } else
    386         setFirstChild(child);
     386        setFirstChild(&child);
    387387
    388388    if (beforeChild) {
    389         beforeChild->setPreviousSibling(child);
    390         child->setNextSibling(beforeChild);
    391         ASSERT(beforeChild != child);
     389        beforeChild->setPreviousSibling(&child);
     390        child.setNextSibling(beforeChild);
     391        ASSERT(beforeChild != &child);
    392392    } else
    393         setLastChild(child);
    394 
    395     child->setParent(this);
    396 
    397     if (child->isNormalFlowOnly())
     393        setLastChild(&child);
     394
     395    child.setParent(this);
     396
     397    if (child.isNormalFlowOnly())
    398398        dirtyNormalFlowList();
    399399
    400     if (!child->isNormalFlowOnly() || child->firstChild()) {
     400    if (!child.isNormalFlowOnly() || child.firstChild()) {
    401401        // Dirty the z-order list in which we are contained. The stackingContext() can be null in the
    402402        // case where we're building up generated content layers. This is ok, since the lists will start
    403403        // off dirty in that case anyway.
    404         child->dirtyStackingContextZOrderLists();
    405     }
    406 
    407     child->updateDescendantDependentFlags();
    408     if (child->m_hasVisibleContent || child->m_hasVisibleDescendant)
     404        child.dirtyStackingContextZOrderLists();
     405    }
     406
     407    child.updateDescendantDependentFlags();
     408    if (child.m_hasVisibleContent || child.m_hasVisibleDescendant)
    409409        setAncestorChainHasVisibleDescendant();
    410410
    411     if (child->isSelfPaintingLayer() || child->hasSelfPaintingLayerDescendant())
     411    if (child.isSelfPaintingLayer() || child.hasSelfPaintingLayerDescendant())
    412412        setAncestorChainHasSelfPaintingLayerDescendant();
    413413
    414414#if ENABLE(CSS_COMPOSITING)
    415     if (child->hasBlendMode() || (child->hasNotIsolatedBlendingDescendants() && !child->isolatesBlending()))
     415    if (child.hasBlendMode() || (child.hasNotIsolatedBlendingDescendants() && !child.isolatesBlending()))
    416416        updateAncestorChainHasBlendingDescendants();
    417417#endif
    418418
    419     compositor().layerWasAdded(*this, *child);
    420 }
    421 
    422 RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild)
     419    compositor().layerWasAdded(*this, child);
     420}
     421
     422void RenderLayer::removeChild(RenderLayer& oldChild)
    423423{
    424424    if (!renderer().renderTreeBeingDestroyed())
    425         compositor().layerWillBeRemoved(*this, *oldChild);
     425        compositor().layerWillBeRemoved(*this, oldChild);
    426426
    427427    // remove the child
    428     if (oldChild->previousSibling())
    429         oldChild->previousSibling()->setNextSibling(oldChild->nextSibling());
    430     if (oldChild->nextSibling())
    431         oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling());
    432 
    433     if (m_first == oldChild)
    434         m_first = oldChild->nextSibling();
    435     if (m_last == oldChild)
    436         m_last = oldChild->previousSibling();
    437 
    438     if (oldChild->isNormalFlowOnly())
     428    if (oldChild.previousSibling())
     429        oldChild.previousSibling()->setNextSibling(oldChild.nextSibling());
     430    if (oldChild.nextSibling())
     431        oldChild.nextSibling()->setPreviousSibling(oldChild.previousSibling());
     432
     433    if (m_first == &oldChild)
     434        m_first = oldChild.nextSibling();
     435    if (m_last == &oldChild)
     436        m_last = oldChild.previousSibling();
     437
     438    if (oldChild.isNormalFlowOnly())
    439439        dirtyNormalFlowList();
    440     if (!oldChild->isNormalFlowOnly() || oldChild->firstChild()) {
     440    if (!oldChild.isNormalFlowOnly() || oldChild.firstChild()) {
    441441        // Dirty the z-order list in which we are contained. When called via the
    442442        // reattachment process in removeOnlyThisLayer, the layer may already be disconnected
    443443        // from the main layer tree, so we need to null-check the |stackingContext| value.
    444         oldChild->dirtyStackingContextZOrderLists();
    445     }
    446 
    447     oldChild->setPreviousSibling(nullptr);
    448     oldChild->setNextSibling(nullptr);
    449     oldChild->setParent(nullptr);
    450    
    451     oldChild->updateDescendantDependentFlags();
    452     if (oldChild->m_hasVisibleContent || oldChild->m_hasVisibleDescendant)
     444        oldChild.dirtyStackingContextZOrderLists();
     445    }
     446
     447    oldChild.setPreviousSibling(nullptr);
     448    oldChild.setNextSibling(nullptr);
     449    oldChild.setParent(nullptr);
     450   
     451    oldChild.updateDescendantDependentFlags();
     452    if (oldChild.m_hasVisibleContent || oldChild.m_hasVisibleDescendant)
    453453        dirtyAncestorChainVisibleDescendantStatus();
    454454
    455     if (oldChild->isSelfPaintingLayer() || oldChild->hasSelfPaintingLayerDescendant())
     455    if (oldChild.isSelfPaintingLayer() || oldChild.hasSelfPaintingLayerDescendant())
    456456        dirtyAncestorChainHasSelfPaintingLayerDescendantStatus();
    457457
    458458#if ENABLE(CSS_COMPOSITING)
    459     if (oldChild->hasBlendMode() || (oldChild->hasNotIsolatedBlendingDescendants() && !oldChild->isolatesBlending()))
     459    if (oldChild.hasBlendMode() || (oldChild.hasNotIsolatedBlendingDescendants() && !oldChild.isolatesBlending()))
    460460        dirtyAncestorChainHasBlendingDescendants();
    461461#endif
    462 
    463     return oldChild;
    464462}
    465463
     
    472470        ASSERT(parentLayer);
    473471        RenderLayer* beforeChild = parentLayer->reflectionLayer() != this ? renderer().parent()->findNextLayer(parentLayer, &renderer()) : nullptr;
    474         parentLayer->addChild(this, beforeChild);
     472        parentLayer->addChild(*this, beforeChild);
    475473    }
    476474
     
    502500    // The reflection layer should not be moved to the parent.
    503501    if (reflection())
    504         removeChild(reflectionLayer());
     502        removeChild(*reflectionLayer());
    505503
    506504    // Now walk our kids and reattach them to our parent.
     
    508506    while (current) {
    509507        RenderLayer* next = current->nextSibling();
    510         removeChild(current);
    511         m_parent->addChild(current, nextSib);
     508        removeChild(*current);
     509        m_parent->addChild(*current, nextSib);
    512510        current->setRepaintStatus(NeedsFullRepaint);
    513511        current = next;
     
    515513
    516514    // Remove us from the parent.
    517     m_parent->removeChild(this);
     515    m_parent->removeChild(*this);
    518516    renderer().destroyLayer();
    519517}
  • TabularUnified trunk/Source/WebCore/rendering/RenderLayer.h

    r237117 r237121  
    163163    }
    164164
    165     void addChild(RenderLayer* newChild, RenderLayer* beforeChild = nullptr);
    166     RenderLayer* removeChild(RenderLayer*);
     165    void addChild(RenderLayer& newChild, RenderLayer* beforeChild = nullptr);
     166    void removeChild(RenderLayer&);
    167167
    168168    void insertOnlyThisLayer();
Note: See TracChangeset for help on using the changeset viewer.