RenderElement::removeChild() should take child as a reference.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Oct 2013 12:40:09 +0000 (12:40 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Oct 2013 12:40:09 +0000 (12:40 +0000)
<https://webkit.org/b/122888>

We can't remove a child without a child to remove.

Reviewed by Antti Koivisto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157515 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderButton.cpp
Source/WebCore/rendering/RenderButton.h
Source/WebCore/rendering/RenderCounter.cpp
Source/WebCore/rendering/RenderCounter.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderMenuList.cpp
Source/WebCore/rendering/RenderMenuList.h
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderRuby.cpp
Source/WebCore/rendering/RenderRuby.h
Source/WebCore/rendering/RenderRubyRun.cpp
Source/WebCore/rendering/RenderRubyRun.h
Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp
Source/WebCore/rendering/mathml/RenderMathMLScripts.h
Source/WebCore/rendering/svg/RenderSVGContainer.cpp
Source/WebCore/rendering/svg/RenderSVGContainer.h
Source/WebCore/rendering/svg/RenderSVGInline.cpp
Source/WebCore/rendering/svg/RenderSVGInline.h
Source/WebCore/rendering/svg/RenderSVGRoot.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.h
Source/WebCore/rendering/svg/RenderSVGText.cpp
Source/WebCore/rendering/svg/RenderSVGText.h

index 559cda5..72df90f 100644 (file)
@@ -1,3 +1,12 @@
+2013-10-16  Andreas Kling  <akling@apple.com>
+
+        RenderElement::removeChild() should take child as a reference.
+        <https://webkit.org/b/122888>
+
+        We can't remove a child without a child to remove.
+
+        Reviewed by Antti Koivisto.
+
 2013-10-16  Antti Koivisto  <antti@apple.com>
 
         Move test for contained caret offset to RenderTextLineBoxes
index b4d7c7a..862f58c 100644 (file)
@@ -1045,9 +1045,9 @@ static bool canMergeAnonymousBlock(RenderBlock* anonymousBlock)
     return true;
 }
 
-static bool canMergeContiguousAnonymousBlocks(RenderObject* oldChild, RenderObject* previous, RenderObject* next)
+static bool canMergeContiguousAnonymousBlocks(RenderObject& oldChild, RenderObject* previous, RenderObject* next)
 {
-    if (oldChild->documentBeingDestroyed() || oldChild->isInline() || oldChild->virtualContinuation())
+    if (oldChild.documentBeingDestroyed() || oldChild.isInline() || oldChild.virtualContinuation())
         return false;
 
     if (previous) {
@@ -1085,7 +1085,7 @@ void RenderBlock::collapseAnonymousBoxChild(RenderBlock* parent, RenderBlock* ch
     RenderFlowThread* childFlowThread = child->flowThreadContainingBlock();
     CurrentRenderFlowThreadMaintainer flowThreadMaintainer(childFlowThread);
 
-    parent->removeChildInternal(child, child->hasLayer() ? NotifyChildren : DontNotifyChildren);
+    parent->removeChildInternal(*child, child->hasLayer() ? NotifyChildren : DontNotifyChildren);
     child->moveAllChildrenTo(parent, nextSibling, child->hasLayer());
     // Delete the now-empty block's lines and nuke it.
     child->deleteLineBoxTree();
@@ -1094,7 +1094,7 @@ void RenderBlock::collapseAnonymousBoxChild(RenderBlock* parent, RenderBlock* ch
     child->destroy();
 }
 
-void RenderBlock::removeChild(RenderObject* oldChild)
+void RenderBlock::removeChild(RenderObject& oldChild)
 {
     // No need to waste time in merging or removing empty anonymous blocks.
     // We can just bail out if our document is getting destroyed.
@@ -1109,8 +1109,8 @@ void RenderBlock::removeChild(RenderObject* oldChild)
     // If this child is a block, and if our previous and next siblings are
     // both anonymous blocks with inline content, then we can go ahead and
     // fold the inline content back together.
-    RenderObject* prev = oldChild->previousSibling();
-    RenderObject* next = oldChild->nextSibling();
+    RenderObject* prev = oldChild.previousSibling();
+    RenderObject* next = oldChild.nextSibling();
     bool canMergeAnonymousBlocks = canMergeContiguousAnonymousBlocks(oldChild, prev, next);
     if (canMergeAnonymousBlocks && prev && next) {
         prev->setNeedsLayoutAndPrefWidthsRecalc();
@@ -1130,7 +1130,7 @@ void RenderBlock::removeChild(RenderObject* oldChild)
             // Cache this value as it might get changed in setStyle() call.
             bool inlineChildrenBlockHasLayer = inlineChildrenBlock->hasLayer();
             inlineChildrenBlock->setStyle(newStyle);
-            removeChildInternal(inlineChildrenBlock, inlineChildrenBlockHasLayer ? NotifyChildren : DontNotifyChildren);
+            removeChildInternal(*inlineChildrenBlock, inlineChildrenBlockHasLayer ? NotifyChildren : DontNotifyChildren);
             
             // Now just put the inlineChildrenBlock inside the blockChildrenBlock.
             RenderObject* beforeChild = prev == inlineChildrenBlock ? blockChildrenBlock->firstChild() : nullptr;
@@ -1183,7 +1183,7 @@ void RenderBlock::removeChild(RenderObject* oldChild)
 
         // If we are an empty anonymous block in the continuation chain,
         // we need to remove ourself and fix the continuation chain.
-        if (!beingDestroyed() && isAnonymousBlockContinuation() && !oldChild->isListMarker()) {
+        if (!beingDestroyed() && isAnonymousBlockContinuation() && !oldChild.isListMarker()) {
             auto containingBlockIgnoringAnonymous = containingBlock();
             while (containingBlockIgnoringAnonymous && containingBlockIgnoringAnonymous->isAnonymousBlock())
                 containingBlockIgnoringAnonymous = containingBlockIgnoringAnonymous->containingBlock();
@@ -5032,7 +5032,7 @@ void RenderBlock::updateFirstLetterStyle(RenderObject* firstLetterBlock, RenderO
         while (RenderObject* child = firstLetter->firstChild()) {
             if (child->isText())
                 toRenderText(child)->removeAndDestroyTextBoxes();
-            firstLetter->removeChild(child);
+            firstLetter->removeChild(*child);
             newFirstLetter->addChild(child, 0);
         }
 
@@ -5045,7 +5045,7 @@ void RenderBlock::updateFirstLetterStyle(RenderObject* firstLetterBlock, RenderO
         }
         // To prevent removal of single anonymous block in RenderBlock::removeChild and causing
         // |nextSibling| to go stale, we remove the old first letter using removeChildNode first.
-        firstLetterContainer->removeChildInternal(firstLetter, NotifyChildren);
+        firstLetterContainer->removeChildInternal(*firstLetter, NotifyChildren);
         firstLetter->destroy();
         firstLetter = newFirstLetter;
         firstLetterContainer->addChild(firstLetter, nextSibling);
@@ -5105,7 +5105,7 @@ void RenderBlock::createFirstLetterRenderer(RenderObject* firstLetterBlock, Rend
             remainingText->textNode()->setRenderer(remainingText);
 
         firstLetterContainer->addChild(remainingText, currentTextChild);
-        firstLetterContainer->removeChild(currentTextChild);
+        firstLetterContainer->removeChild(*currentTextChild);
         remainingText->setFirstLetter(firstLetter);
         firstLetter->setFirstLetterRemainingText(remainingText);
         
index e5650a0..b9e6962 100644 (file)
@@ -120,7 +120,7 @@ public:
     virtual void deleteLineBoxTree();
 
     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) OVERRIDE;
-    virtual void removeChild(RenderObject*) OVERRIDE;
+    virtual void removeChild(RenderObject&) OVERRIDE;
 
     virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0);
 
index 3590cbb..be8530b 100644 (file)
@@ -2791,11 +2791,11 @@ void RenderBoxModelObject::moveChildTo(RenderBoxModelObject* toBoxModelObject, R
     if (fullRemoveInsert && (toBoxModelObject->isRenderBlock() || toBoxModelObject->isRenderInline())) {
         // Takes care of adding the new child correctly if toBlock and fromBlock
         // have different kind of children (block vs inline).
-        removeChildInternal(child, NotifyChildren);
+        removeChildInternal(*child, NotifyChildren);
         toBoxModelObject->addChild(child, beforeChild);
     } else {
         NotifyChildrenType notifyType = fullRemoveInsert ? NotifyChildren : DontNotifyChildren;
-        removeChildInternal(child, notifyType);
+        removeChildInternal(*child, notifyType);
         toBoxModelObject->insertChildInternal(child, beforeChild, notifyType);
     }
 }
index ad25c53..460de2d 100644 (file)
@@ -73,15 +73,15 @@ void RenderButton::addChild(RenderObject* newChild, RenderObject* beforeChild)
     m_inner->addChild(newChild, beforeChild);
 }
 
-void RenderButton::removeChild(RenderObject* oldChild)
+void RenderButton::removeChild(RenderObject& oldChild)
 {
     // m_inner should be the only child, but checking for direct children who
     // are not m_inner prevents security problems when that assumption is
     // violated.
-    if (oldChild == m_inner || !m_inner || oldChild->parent() == this) {
-        ASSERT(oldChild == m_inner || !m_inner);
+    if (&oldChild == m_inner || !m_inner || oldChild.parent() == this) {
+        ASSERT(&oldChild == m_inner || !m_inner);
         RenderFlexibleBox::removeChild(oldChild);
-        m_inner = 0;
+        m_inner = nullptr;
     } else
         m_inner->removeChild(oldChild);
 }
index e35e2a5..1ff40c6 100644 (file)
@@ -43,7 +43,7 @@ public:
     virtual bool canBeSelectionLeaf() const OVERRIDE;
 
     virtual void addChild(RenderObject* newChild, RenderObject *beforeChild = 0) OVERRIDE;
-    virtual void removeChild(RenderObject*) OVERRIDE;
+    virtual void removeChild(RenderObject&) OVERRIDE;
     virtual void removeLeftoverAnonymousBlock(RenderBlock*) OVERRIDE { }
     virtual bool createsAnonymousWrapper() const OVERRIDE { return true; }
 
index 155a083..856807e 100644 (file)
@@ -502,16 +502,16 @@ void RenderCounter::destroyCounterNode(RenderObject* owner, const AtomicString&
     // map associated with a renderer, so there is no risk in leaking the map.
 }
 
-void RenderCounter::rendererRemovedFromTree(RenderObject* renderer)
+void RenderCounter::rendererRemovedFromTree(RenderObject& renderer)
 {
-    if (!renderer->view().hasRenderCounters())
+    if (!renderer.view().hasRenderCounters())
         return;
-    RenderObject* currentRenderer = renderer->lastLeafChild();
+    RenderObject* currentRenderer = renderer.lastLeafChild();
     if (!currentRenderer)
-        currentRenderer = renderer;
+        currentRenderer = &renderer;
     while (true) {
         destroyCounterNodes(currentRenderer);
-        if (currentRenderer == renderer)
+        if (currentRenderer == &renderer)
             break;
         currentRenderer = currentRenderer->previousInPreOrder();
     }
index 2edc7ff..eae39f2 100644 (file)
@@ -37,7 +37,7 @@ public:
     static void destroyCounterNodes(RenderObject*);
     static void destroyCounterNode(RenderObject*, const AtomicString& identifier);
     static void rendererSubtreeAttached(RenderObject*);
-    static void rendererRemovedFromTree(RenderObject*);
+    static void rendererRemovedFromTree(RenderObject&);
     static void rendererStyleChanged(RenderObject*, const RenderStyle* oldStyle, const RenderStyle* newStyle);
 
     void updateCounter();
index 6a2849b..5917b1d 100644 (file)
@@ -487,7 +487,7 @@ void RenderElement::addChild(RenderObject* newChild, RenderObject* beforeChild)
 #endif
 }
 
-void RenderElement::removeChild(RenderObject* oldChild)
+void RenderElement::removeChild(RenderObject& oldChild)
 {
     removeChildInternal(oldChild, NotifyChildren);
 }
@@ -561,59 +561,59 @@ void RenderElement::insertChildInternal(RenderObject* newChild, RenderObject* be
         cache->childrenChanged(this);
 }
 
-void RenderElement::removeChildInternal(RenderObject* oldChild, NotifyChildrenType notifyChildren)
+void RenderElement::removeChildInternal(RenderObject& oldChild, NotifyChildrenType notifyChildren)
 {
     ASSERT(canHaveChildren() || canHaveGeneratedChildren());
-    ASSERT(oldChild->parent() == this);
+    ASSERT(oldChild.parent() == this);
 
-    if (oldChild->isFloatingOrOutOfFlowPositioned())
-        toRenderBox(oldChild)->removeFloatingOrPositionedChildFromBlockLists();
+    if (oldChild.isFloatingOrOutOfFlowPositioned())
+        toRenderBox(oldChild).removeFloatingOrPositionedChildFromBlockLists();
 
     // So that we'll get the appropriate dirty bit set (either that a normal flow child got yanked or
     // that a positioned child got yanked). We also repaint, so that the area exposed when the child
     // disappears gets repainted properly.
-    if (!documentBeingDestroyed() && notifyChildren == NotifyChildren && oldChild->everHadLayout()) {
-        oldChild->setNeedsLayoutAndPrefWidthsRecalc();
+    if (!documentBeingDestroyed() && notifyChildren == NotifyChildren && oldChild.everHadLayout()) {
+        oldChild.setNeedsLayoutAndPrefWidthsRecalc();
         // We only repaint |oldChild| if we have a RenderLayer as its visual overflow may not be tracked by its parent.
-        if (oldChild->isBody())
+        if (oldChild.isBody())
             view().repaintRootContents();
         else
-            oldChild->repaint();
+            oldChild.repaint();
     }
 
     // If we have a line box wrapper, delete it.
-    if (oldChild->isBox())
-        toRenderBox(oldChild)->deleteLineBoxWrapper();
-    else if (oldChild->isLineBreak())
-        toRenderLineBreak(oldChild)->deleteInlineBoxWrapper();
+    if (oldChild.isBox())
+        toRenderBox(oldChild).deleteLineBoxWrapper();
+    else if (oldChild.isLineBreak())
+        toRenderLineBreak(oldChild).deleteInlineBoxWrapper();
 
     // If oldChild is the start or end of the selection, then clear the selection to
     // avoid problems of invalid pointers.
     // FIXME: The FrameSelection should be responsible for this when it
     // is notified of DOM mutations.
-    if (!documentBeingDestroyed() && oldChild->isSelectionBorder())
+    if (!documentBeingDestroyed() && oldChild.isSelectionBorder())
         view().clearSelection();
 
     if (!documentBeingDestroyed() && notifyChildren == NotifyChildren)
-        oldChild->willBeRemovedFromTree();
+        oldChild.willBeRemovedFromTree();
 
     // WARNING: There should be no code running between willBeRemovedFromTree and the actual removal below.
     // This is needed to avoid race conditions where willBeRemovedFromTree would dirty the tree's structure
     // and the code running here would force an untimely rebuilding, leaving |oldChild| dangling.
 
-    if (oldChild->previousSibling())
-        oldChild->previousSibling()->setNextSibling(oldChild->nextSibling());
-    if (oldChild->nextSibling())
-        oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling());
+    if (oldChild.previousSibling())
+        oldChild.previousSibling()->setNextSibling(oldChild.nextSibling());
+    if (oldChild.nextSibling())
+        oldChild.nextSibling()->setPreviousSibling(oldChild.previousSibling());
 
-    if (m_firstChild == oldChild)
-        m_firstChild = oldChild->nextSibling();
-    if (m_lastChild == oldChild)
-        m_lastChild = oldChild->previousSibling();
+    if (m_firstChild == &oldChild)
+        m_firstChild = oldChild.nextSibling();
+    if (m_lastChild == &oldChild)
+        m_lastChild = oldChild.previousSibling();
 
-    oldChild->setPreviousSibling(0);
-    oldChild->setNextSibling(0);
-    oldChild->setParent(0);
+    oldChild.setPreviousSibling(nullptr);
+    oldChild.setNextSibling(nullptr);
+    oldChild.setParent(nullptr);
 
     // rendererRemovedFromTree walks the whole subtree. We can improve performance
     // by skipping this step when destroying the entire tree.
index 20bd4d8..0272c56 100644 (file)
@@ -59,7 +59,7 @@ public:
     virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const { return true; }
     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0) { return addChild(newChild, beforeChild); }
-    virtual void removeChild(RenderObject*);
+    virtual void removeChild(RenderObject&);
 
     // The following functions are used when the render tree hierarchy changes to make sure layers get
     // properly added and removed. Since containership can be implemented by any subclass, and since a hierarchy
@@ -71,7 +71,7 @@ public:
 
     enum NotifyChildrenType { NotifyChildren, DontNotifyChildren };
     void insertChildInternal(RenderObject*, RenderObject* beforeChild, NotifyChildrenType);
-    void removeChildInternal(RenderObject*, NotifyChildrenType);
+    void removeChildInternal(RenderObject&, NotifyChildrenType);
 
     virtual RenderElement* hoverAncestor() const;
 
index 1cf0aae..41b5ee1 100644 (file)
@@ -366,7 +366,7 @@ void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock,
     while (o) {
         RenderObject* tmp = o;
         o = tmp->nextSibling();
-        removeChildInternal(tmp, NotifyChildren);
+        removeChildInternal(*tmp, NotifyChildren);
         cloneInline->addChildIgnoringContinuation(tmp, 0);
         tmp->setNeedsLayoutAndPrefWidthsRecalc();
     }
@@ -408,7 +408,7 @@ void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock,
             while (o) {
                 RenderObject* tmp = o;
                 o = tmp->nextSibling();
-                inlineCurr->removeChildInternal(tmp, NotifyChildren);
+                inlineCurr->removeChildInternal(*tmp, NotifyChildren);
                 cloneInline->addChildIgnoringContinuation(tmp, 0);
                 tmp->setNeedsLayoutAndPrefWidthsRecalc();
             }
@@ -429,7 +429,7 @@ void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock,
     while (o) {
         RenderObject* tmp = o;
         o = tmp->nextSibling();
-        fromBlock->removeChildInternal(tmp, NotifyChildren);
+        fromBlock->removeChildInternal(*tmp, NotifyChildren);
         toBlock->insertChildInternal(tmp, nullptr, NotifyChildren);
     }
 }
@@ -474,7 +474,7 @@ void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox
         while (o) {
             RenderObject* no = o;
             o = no->nextSibling();
-            block->removeChildInternal(no, NotifyChildren);
+            block->removeChildInternal(*no, NotifyChildren);
             pre->insertChildInternal(no, nullptr, NotifyChildren);
             no->setNeedsLayoutAndPrefWidthsRecalc();
         }
@@ -1275,7 +1275,7 @@ void RenderInline::childBecameNonInline(RenderObject* child)
     RenderBoxModelObject* oldContinuation = continuation();
     setContinuation(newBox);
     RenderObject* beforeChild = child->nextSibling();
-    removeChildInternal(child, NotifyChildren);
+    removeChildInternal(*child, NotifyChildren);
     splitFlow(beforeChild, newBox, child, oldContinuation);
 }
 
index 691dd71..f5db828 100644 (file)
@@ -144,9 +144,9 @@ void RenderMenuList::addChild(RenderObject* newChild, RenderObject* beforeChild)
         cache->childrenChanged(this);
 }
 
-void RenderMenuList::removeChild(RenderObject* oldChild)
+void RenderMenuList::removeChild(RenderObject& oldChild)
 {
-    if (oldChild == m_innerBlock || !m_innerBlock) {
+    if (&oldChild == m_innerBlock || !m_innerBlock) {
         RenderFlexibleBox::removeChild(oldChild);
         m_innerBlock = 0;
     } else
index 98491ac..ff9e2ad 100644 (file)
@@ -64,7 +64,7 @@ private:
     virtual bool isMenuList() const OVERRIDE { return true; }
 
     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) OVERRIDE;
-    virtual void removeChild(RenderObject*) OVERRIDE;
+    virtual void removeChild(RenderObject&) OVERRIDE;
     virtual bool createsAnonymousWrapper() const OVERRIDE { return true; }
 
     virtual void updateFromElement() OVERRIDE;
index e0807f1..2c66345 100644 (file)
@@ -205,7 +205,7 @@ void RenderObject::setParent(RenderElement* parent)
 void RenderObject::removeFromParent()
 {
     if (parent())
-        parent()->removeChild(this);
+        parent()->removeChild(*this);
 }
 
 RenderObject* RenderObject::nextInPreOrder() const
@@ -1651,7 +1651,7 @@ void RenderObject::handleDynamicFloatPositionChange()
             // An anonymous block must be made to wrap this inline.
             RenderBlock* block = toRenderBlock(parent())->createAnonymousBlock();
             parent()->insertChildInternal(block, this, RenderElement::NotifyChildren);
-            parent()->removeChildInternal(this, RenderElement::NotifyChildren);
+            parent()->removeChildInternal(*this, RenderElement::NotifyChildren);
             block->insertChildInternal(this, nullptr, RenderElement::NotifyChildren);
         }
     }
index 931a2fa..4a29b0c 100644 (file)
@@ -100,11 +100,13 @@ static RenderRubyRun* lastRubyRun(const RenderElement* ruby)
     return child && child->isRubyRun() ? toRenderRubyRun(child) : 0;
 }
 
-static inline RenderRubyRun* findRubyRunParent(RenderObject* child)
+static inline RenderRubyRun& findRubyRunParent(RenderObject& child)
 {
-    while (child && !child->isRubyRun())
-        child = child->parent();
-    return toRenderRubyRun(child);
+    RenderObject* ancestor = &child;
+    while (ancestor && !ancestor->isRubyRun())
+        ancestor = ancestor->parent();
+    ASSERT(ancestor);
+    return toRenderRubyRun(*ancestor);
 }
 
 //=== ruby as inline object ===
@@ -189,28 +191,27 @@ void RenderRubyAsInline::addChild(RenderObject* child, RenderObject* beforeChild
     lastRun->addChild(child);
 }
 
-void RenderRubyAsInline::removeChild(RenderObject* child)
+void RenderRubyAsInline::removeChild(RenderObject& child)
 {
     // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
     // just use the normal remove method.
-    if (child->parent() == this) {
-        ASSERT(child->isRubyRun() || child->isBeforeContent() || child->isAfterContent() || isAnonymousRubyInlineBlock(child));
+    if (child.parent() == this) {
+        ASSERT(child.isRubyRun() || child.isBeforeContent() || child.isAfterContent() || isAnonymousRubyInlineBlock(&child));
         RenderInline::removeChild(child);
         return;
     }
     // If the child's parent is an anoymous block (must be generated :before/:after content)
     // just use the block's remove method.
-    if (isAnonymousRubyInlineBlock(child->parent())) {
-        ASSERT(child->isBeforeContent() || child->isAfterContent());
-        child->parent()->removeChild(child);
-        removeChild(child->parent());
+    if (isAnonymousRubyInlineBlock(child.parent())) {
+        ASSERT(child.isBeforeContent() || child.isAfterContent());
+        child.parent()->removeChild(child);
+        removeChild(*child.parent());
         return;
     }
 
     // Otherwise find the containing run and remove it from there.
-    RenderRubyRun* run = findRubyRunParent(child);
-    ASSERT(run);
-    run->removeChild(child);
+    RenderRubyRun& run = findRubyRunParent(child);
+    run.removeChild(child);
 }
 
 //=== ruby as block object ===
@@ -295,28 +296,27 @@ void RenderRubyAsBlock::addChild(RenderObject* child, RenderObject* beforeChild)
     lastRun->addChild(child);
 }
 
-void RenderRubyAsBlock::removeChild(RenderObject* child)
+void RenderRubyAsBlock::removeChild(RenderObject& child)
 {
     // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
     // just use the normal remove method.
-    if (child->parent() == this) {
-        ASSERT(child->isRubyRun() || child->isBeforeContent() || child->isAfterContent() || isAnonymousRubyInlineBlock(child));
+    if (child.parent() == this) {
+        ASSERT(child.isRubyRun() || child.isBeforeContent() || child.isAfterContent() || isAnonymousRubyInlineBlock(&child));
         RenderBlock::removeChild(child);
         return;
     }
     // If the child's parent is an anoymous block (must be generated :before/:after content)
     // just use the block's remove method.
-    if (isAnonymousRubyInlineBlock(child->parent())) {
-        ASSERT(child->isBeforeContent() || child->isAfterContent());
-        child->parent()->removeChild(child);
-        removeChild(child->parent());
+    if (isAnonymousRubyInlineBlock(child.parent())) {
+        ASSERT(child.isBeforeContent() || child.isAfterContent());
+        child.parent()->removeChild(child);
+        removeChild(*child.parent());
         return;
     }
 
     // Otherwise find the containing run and remove it from there.
-    RenderRubyRun* run = findRubyRunParent(child);
-    ASSERT(run);
-    run->removeChild(child);
+    RenderRubyRun& run = findRubyRunParent(child);
+    run.removeChild(child);
 }
 
 } // namespace WebCore
index 3ad0643..519224e 100644 (file)
@@ -57,7 +57,7 @@ public:
     virtual ~RenderRubyAsInline();
 
     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE;
-    virtual void removeChild(RenderObject* child) OVERRIDE;
+    virtual void removeChild(RenderObject& child) OVERRIDE;
 
 protected:
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
@@ -77,7 +77,7 @@ public:
     Element& element() const { return toElement(nodeForNonAnonymous()); }
 
     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE;
-    virtual void removeChild(RenderObject* child) OVERRIDE;
+    virtual void removeChild(RenderObject& child) OVERRIDE;
 
 protected:
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
index 58e39bf..ceb2f7c 100644 (file)
@@ -136,7 +136,7 @@ void RenderRubyRun::addChild(RenderObject* child, RenderObject* beforeChild)
             // in order to avoid automatic removal of the ruby run in case there is no
             // other child besides the old ruby text.
             RenderBlock::addChild(child, beforeChild);
-            RenderBlock::removeChild(beforeChild);
+            RenderBlock::removeChild(*beforeChild);
             newRun->addChild(beforeChild);
         } else if (hasRubyBase()) {
             // Insertion before a ruby base object.
@@ -156,11 +156,11 @@ void RenderRubyRun::addChild(RenderObject* child, RenderObject* beforeChild)
     }
 }
 
-void RenderRubyRun::removeChild(RenderObject* child)
+void RenderRubyRun::removeChild(RenderObject& child)
 {
     // If the child is a ruby text, then merge the ruby base with the base of
     // the right sibling run, if possible.
-    if (!beingDestroyed() && !documentBeingDestroyed() && child->isRubyText()) {
+    if (!beingDestroyed() && !documentBeingDestroyed() && child.isRubyText()) {
         RenderRubyBase* base = rubyBase();
         RenderObject* rightNeighbour = nextSibling();
         if (base && rightNeighbour && rightNeighbour->isRubyRun()) {
@@ -184,14 +184,14 @@ void RenderRubyRun::removeChild(RenderObject* child)
         // Check if our base (if any) is now empty. If so, destroy it.
         RenderBlock* base = rubyBase();
         if (base && !base->firstChild()) {
-            RenderBlock::removeChild(base);
+            RenderBlock::removeChild(*base);
             base->deleteLineBoxTree();
             base->destroy();
         }
 
         // If any of the above leaves the run empty, destroy it as well.
         if (isEmpty()) {
-            parent()->removeChild(this);
+            parent()->removeChild(*this);
             deleteLineBoxTree();
             destroy();
         }
index 167d3a9..bd743bc 100644 (file)
@@ -58,7 +58,7 @@ public:
 
     virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const;
     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
-    virtual void removeChild(RenderObject* child);
+    virtual void removeChild(RenderObject&) OVERRIDE;
 
     virtual RenderBlock* firstLineBlock() const;
     virtual void updateFirstLetter();
index 795863a..c730864 100644 (file)
@@ -196,17 +196,17 @@ void RenderMathMLScripts::addChildInternal(bool doNotRestructure, RenderObject*
     wrapper->addChildInternal(false, child, wrapper->firstChild());
 }
 
-void RenderMathMLScripts::removeChildInternal(bool doNotRestructure, RenderObject* child)
+void RenderMathMLScripts::removeChildInternal(bool doNotRestructure, RenderObject& child)
 {
     if (doNotRestructure) {
         RenderMathMLBlock::removeChild(child);
         return;
     }
 
-    ASSERT(isPrescript(child));
+    ASSERT(isPrescript(&child));
 
-    RenderObject* previousSibling = child->previousSibling();
-    RenderObject* nextSibling = child->nextSibling();
+    RenderObject* previousSibling = child.previousSibling();
+    RenderObject* nextSibling = child.nextSibling();
     ASSERT(previousSibling);
 
     if (nextSibling && !isPrescript(previousSibling) && !isPrescript(nextSibling)) {
@@ -215,7 +215,7 @@ void RenderMathMLScripts::removeChildInternal(bool doNotRestructure, RenderObjec
         ASSERT(nextWrapper->m_kind == RenderMathMLScriptsWrapper::SubSupPair && !nextWrapper->isEmpty());
         if ((previousWrapper->m_kind == RenderMathMLScriptsWrapper::Base && previousWrapper->isEmpty()) || (previousWrapper->m_kind == RenderMathMLScriptsWrapper::SubSupPair && !previousWrapper->firstChild()->nextSibling())) {
             RenderObject* script = nextWrapper->firstChild();
-            nextWrapper->removeChildInternal(false, script);
+            nextWrapper->removeChildInternal(false, *script);
             previousWrapper->addChildInternal(true, script);
         }
     }
@@ -235,7 +235,7 @@ void RenderMathMLScripts::addChild(RenderObject* child, RenderObject* beforeChil
     fixAnonymousStyles();
 }
 
-void RenderMathMLScripts::removeChild(RenderObject* child)
+void RenderMathMLScripts::removeChild(RenderObject& child)
 {
     if (beingDestroyed() || documentBeingDestroyed()) {
         // The renderer is being destroyed so we remove the child normally.
@@ -394,7 +394,7 @@ void RenderMathMLScriptsWrapper::addChildInternal(bool doNotRestructure, RenderO
         // The old base (if any) becomes a script ; the new child becomes either the base or an <mprescripts> separator.
         RenderObject* oldBase = firstChild();
         if (oldBase)
-            RenderMathMLBlock::removeChild(oldBase);
+            RenderMathMLBlock::removeChild(*oldBase);
         if (isPrescript(child))
             parentNode->addChildInternal(true, child, sibling);
         else
@@ -413,15 +413,15 @@ void RenderMathMLScriptsWrapper::addChildInternal(bool doNotRestructure, RenderO
         else {
             // We insert the <mprescripts> in the middle of a subSup pair so we must split that pair.
             RenderObject* sibling = nextSibling();
-            parentNode->removeChildInternal(true, this);
+            parentNode->removeChildInternal(true, *this);
             parentNode->addChildInternal(true, child, sibling);
 
             RenderObject* script = firstChild();
-            RenderMathMLBlock::removeChild(script);
+            RenderMathMLBlock::removeChild(*script);
             parentNode->addChildInternal(false, script, child);
 
             script = beforeChild;
-            RenderMathMLBlock::removeChild(script);
+            RenderMathMLBlock::removeChild(*script);
             parentNode->addChildInternal(false, script, sibling);
             destroy();
         }
@@ -443,7 +443,7 @@ void RenderMathMLScriptsWrapper::addChildInternal(bool doNotRestructure, RenderO
     for (RenderObject* previousSibling = subSupPair->previousSibling(); subSupPair != this; previousSibling = previousSibling->previousSibling()) {
         RenderMathMLScriptsWrapper* previousSubSupPair = toRenderMathMLScriptsWrapper(previousSibling);
         RenderObject* script = previousSubSupPair->lastChild();
-        previousSubSupPair->removeChildInternal(true, script);
+        previousSubSupPair->removeChildInternal(true, *script);
         subSupPair->addChildInternal(true, script, subSupPair->firstChild());
         subSupPair = toRenderMathMLScriptsWrapper(previousSibling);
     }
@@ -461,7 +461,7 @@ void RenderMathMLScriptsWrapper::addChild(RenderObject* child, RenderObject* bef
     parentNode->fixAnonymousStyles();
 }
 
-void RenderMathMLScriptsWrapper::removeChildInternal(bool doNotRestructure, RenderObject* child)
+void RenderMathMLScriptsWrapper::removeChildInternal(bool doNotRestructure, RenderObject& child)
 {
     if (doNotRestructure) {
         RenderMathMLBlock::removeChild(child);
@@ -478,7 +478,7 @@ void RenderMathMLScriptsWrapper::removeChildInternal(bool doNotRestructure, Rend
             // If there are postscripts, the first one becomes the base.
             RenderMathMLScriptsWrapper* wrapper = toRenderMathMLScriptsWrapper(sibling);
             RenderObject* script = wrapper->firstChild();
-            wrapper->removeChildInternal(false, script);
+            wrapper->removeChildInternal(false, *script);
             RenderMathMLBlock::addChild(script);
         }
         return;
@@ -490,19 +490,19 @@ void RenderMathMLScriptsWrapper::removeChildInternal(bool doNotRestructure, Rend
     for (RenderObject* nextSibling = subSupPair->nextSibling(); nextSibling && !isPrescript(nextSibling); nextSibling = nextSibling->nextSibling()) {
         RenderMathMLScriptsWrapper* nextSubSupPair = toRenderMathMLScriptsWrapper(nextSibling);
         RenderObject* script = nextSubSupPair->firstChild();
-        nextSubSupPair->removeChildInternal(true, script);
+        nextSubSupPair->removeChildInternal(true, *script);
         subSupPair->addChildInternal(true, script);
         subSupPair = toRenderMathMLScriptsWrapper(nextSibling);
     }
 
     // We remove the last subSup pair if it became empty.
     if (subSupPair->isEmpty()) {
-        parentNode->removeChildInternal(true, subSupPair);
+        parentNode->removeChildInternal(true, *subSupPair);
         subSupPair->destroy();
     }
 }
 
-void RenderMathMLScriptsWrapper::removeChild(RenderObject* child)
+void RenderMathMLScriptsWrapper::removeChild(RenderObject& child)
 {
     if (beingDestroyed() || documentBeingDestroyed()) {
         // The renderer is being destroyed so we remove the child normally.
@@ -511,9 +511,7 @@ void RenderMathMLScriptsWrapper::removeChild(RenderObject* child)
     }
 
     RenderMathMLScripts* parentNode = toRenderMathMLScripts(parent());
-
     removeChildInternal(false, child);
-
     parentNode->fixAnonymousStyles();
 }
 
index 85c6414..0101361 100644 (file)
@@ -43,7 +43,7 @@ public:
     enum WrapperType { Base, SubSupPair };
 
     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE;
-    virtual void removeChild(RenderObject*) OVERRIDE;
+    virtual void removeChild(RenderObject&) OVERRIDE;
 
 private:
     RenderMathMLScriptsWrapper(Document& document, WrapperType kind)
@@ -55,7 +55,7 @@ private:
     static RenderMathMLScriptsWrapper* createAnonymousWrapper(RenderMathMLScripts* renderObject, WrapperType);
 
     void addChildInternal(bool normalInsertion, RenderObject* child, RenderObject* beforeChild = 0);
-    void removeChildInternal(bool normalRemoval, RenderObject* child);
+    void removeChildInternal(bool normalRemoval, RenderObject& child);
 
     virtual const char* renderName() const { return m_kind == Base ? "Base Wrapper" : "SubSupPair Wrapper"; }
 
@@ -99,7 +99,7 @@ friend class RenderMathMLScriptsWrapper;
 public:
     explicit RenderMathMLScripts(Element&);
     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE;
-    virtual void removeChild(RenderObject*) OVERRIDE;
+    virtual void removeChild(RenderObject&) OVERRIDE;
     
     virtual RenderMathMLOperator* unembellishedOperator();
     virtual int firstLineBoxBaseline() const OVERRIDE;
@@ -109,7 +109,7 @@ protected:
     
 private:
     void addChildInternal(bool normalInsertion, RenderObject* child, RenderObject* beforeChild = 0);
-    void removeChildInternal(bool normalRemoval, RenderObject* child);
+    void removeChildInternal(bool normalRemoval, RenderObject& child);
 
     virtual bool isRenderMathMLScripts() const OVERRIDE { return true; }
     void fixAnonymousStyleForSubSupPair(RenderObject* subSupPair, bool isPostScript);
index 5b659db..04d7f16 100644 (file)
@@ -95,9 +95,9 @@ void RenderSVGContainer::addChild(RenderObject* child, RenderObject* beforeChild
     SVGResourcesCache::clientWasAddedToTree(child, child->style());
 }
 
-void RenderSVGContainer::removeChild(RenderObject* child)
+void RenderSVGContainer::removeChild(RenderObject& child)
 {
-    SVGResourcesCache::clientWillBeRemovedFromTree(child);
+    SVGResourcesCache::clientWillBeRemovedFromTree(&child);
     RenderSVGModelObject::removeChild(child);
 }
 
index 6c0808b..1cc7fb7 100644 (file)
@@ -52,7 +52,7 @@ protected:
     virtual void layout() OVERRIDE;
 
     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE FINAL;
-    virtual void removeChild(RenderObject*) OVERRIDE FINAL;
+    virtual void removeChild(RenderObject&) OVERRIDE FINAL;
     virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) OVERRIDE FINAL;
 
     virtual FloatRect objectBoundingBox() const OVERRIDE FINAL { return m_objectBoundingBox; }
index 3acf7b7..77f1d3b 100644 (file)
@@ -128,9 +128,9 @@ void RenderSVGInline::addChild(RenderObject* child, RenderObject* beforeChild)
         textRenderer->subtreeChildWasAdded(child);
 }
 
-void RenderSVGInline::removeChild(RenderObject* child)
+void RenderSVGInline::removeChild(RenderObject& child)
 {
-    SVGResourcesCache::clientWillBeRemovedFromTree(child);
+    SVGResourcesCache::clientWillBeRemovedFromTree(&child);
 
     RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this);
     if (!textRenderer) {
@@ -138,7 +138,7 @@ void RenderSVGInline::removeChild(RenderObject* child)
         return;
     }
     Vector<SVGTextLayoutAttributes*, 2> affectedAttributes;
-    textRenderer->subtreeChildWillBeRemoved(child, affectedAttributes);
+    textRenderer->subtreeChildWillBeRemoved(&child, affectedAttributes);
     RenderInline::removeChild(child);
     textRenderer->subtreeChildWasRemoved(affectedAttributes);
 }
index 6073b58..5a47e81 100644 (file)
@@ -62,7 +62,7 @@ private:
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE FINAL;
 
     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE FINAL;
-    virtual void removeChild(RenderObject*) OVERRIDE FINAL;
+    virtual void removeChild(RenderObject&) OVERRIDE FINAL;
 };
 
 }
index b654bc9..aa2c0d7 100644 (file)
@@ -332,9 +332,9 @@ void RenderSVGRoot::addChild(RenderObject* child, RenderObject* beforeChild)
     SVGResourcesCache::clientWasAddedToTree(child, child->style());
 }
 
-void RenderSVGRoot::removeChild(RenderObject* child)
+void RenderSVGRoot::removeChild(RenderObject& child)
 {
-    SVGResourcesCache::clientWillBeRemovedFromTree(child);
+    SVGResourcesCache::clientWillBeRemovedFromTree(&child);
     RenderReplaced::removeChild(child);
 }
 
index 73729db..caf095d 100644 (file)
@@ -83,7 +83,7 @@ private:
     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle) OVERRIDE;
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) OVERRIDE;
-    virtual void removeChild(RenderObject*) OVERRIDE;
+    virtual void removeChild(RenderObject&) OVERRIDE;
 
     virtual const AffineTransform& localToParentTransform() const OVERRIDE;
 
index afcc4ae..55cdf95 100644 (file)
@@ -543,13 +543,13 @@ void RenderSVGText::addChild(RenderObject* child, RenderObject* beforeChild)
     subtreeChildWasAdded(child);
 }
 
-void RenderSVGText::removeChild(RenderObject* child)
+void RenderSVGText::removeChild(RenderObject& child)
 {
-    SVGResourcesCache::clientWillBeRemovedFromTree(child);
+    SVGResourcesCache::clientWillBeRemovedFromTree(&child);
 
     Vector<SVGTextLayoutAttributes*, 2> affectedAttributes;
     FontCachePurgePreventer fontCachePurgePreventer;
-    subtreeChildWillBeRemoved(child, affectedAttributes);
+    subtreeChildWillBeRemoved(&child, affectedAttributes);
     RenderSVGBlock::removeChild(child);
     subtreeChildWasRemoved(affectedAttributes);
 }
index 425040b..6b5ef90 100644 (file)
@@ -82,7 +82,7 @@ private:
     virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0) const OVERRIDE;
     virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const OVERRIDE;
     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
-    virtual void removeChild(RenderObject*) OVERRIDE;
+    virtual void removeChild(RenderObject&) OVERRIDE;
     virtual void willBeDestroyed() OVERRIDE;
 
     virtual FloatRect objectBoundingBox() const { return frameRect(); }