Fix remove() so that it is equivalent to calling removeChild on the
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Aug 2006 23:19:34 +0000 (23:19 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Aug 2006 23:19:34 +0000 (23:19 +0000)
        parent.  This involved moving three operations that remove did.

        (1) Move the accessibility object cache removal into the destroy methods,
        since this really should just happen when a render object is going away.

        (2) removeFromObjectLists shifted into removeChild, which means it will
        now be called more often (this is a correct change).  Note that there is
        also now a new guard on removeFromObjectLists so that it won't do any
        work unless the document is not being destroyed.

        (3) The big one.  deleteLineBoxWrapper was not getting called to clean up
        the line box tree.  This moved right into RenderContainer's removeChildNode so
        that it is now done even in the lowest level RenderContainer removal primitive.

        Reviewed by beth

        * rendering/RenderContainer.cpp:
        (WebCore::RenderContainer::removeChildNode):
        (WebCore::RenderContainer::removeChild):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::removeFromObjectLists):
        (WebCore::RenderObject::destroy):
        * rendering/RenderObject.h:
        (WebCore::RenderObject::remove):
        * rendering/RenderWidget.cpp:
        (WebCore::RenderWidget::destroy):

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

WebCore/ChangeLog
WebCore/rendering/RenderContainer.cpp
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderObject.h
WebCore/rendering/RenderWidget.cpp

index 55f672f182d7bb257185679b337287483379d209..e08ee7cefd0842ab8b6e29716865f955f54d6c80 100644 (file)
@@ -1,3 +1,33 @@
+2006-08-04  David Hyatt  <hyatt@apple.com>
+
+        Fix remove() so that it is equivalent to calling removeChild on the
+        parent.  This involved moving three operations that remove did.
+
+        (1) Move the accessibility object cache removal into the destroy methods,
+        since this really should just happen when a render object is going away.
+
+        (2) removeFromObjectLists shifted into removeChild, which means it will
+        now be called more often (this is a correct change).  Note that there is
+        also now a new guard on removeFromObjectLists so that it won't do any
+        work unless the document is not being destroyed.
+
+        (3) The big one.  deleteLineBoxWrapper was not getting called to clean up
+        the line box tree.  This moved right into RenderContainer's removeChildNode so
+        that it is now done even in the lowest level RenderContainer removal primitive.
+
+        Reviewed by beth
+
+        * rendering/RenderContainer.cpp:
+        (WebCore::RenderContainer::removeChildNode):
+        (WebCore::RenderContainer::removeChild):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::removeFromObjectLists):
+        (WebCore::RenderObject::destroy):
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::remove):
+        * rendering/RenderWidget.cpp:
+        (WebCore::RenderWidget::destroy):
+
 2006-08-04  David Hyatt  <hyatt@apple.com>
 
         Back out the fix for list marker crashes.  The actual bug here is that
index 69cae5d48b0934695c4d9f2d047ea38eff1816e0..94863fa22a1a4ae7c9e94e8e00f65d14550c0a7d 100644 (file)
@@ -170,6 +170,9 @@ RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild)
         oldChild->setNeedsLayoutAndMinMaxRecalc();
         oldChild->repaint();
         
+        // If we have a line box wrapper, delete it.
+        oldChild->deleteLineBoxWrapper();
+
         // Keep our layer hierarchy updated.
         oldChild->removeLayers(enclosingLayer());
         
@@ -211,6 +214,11 @@ RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild)
 
 void RenderContainer::removeChild(RenderObject* oldChild)
 {
+    // We do this here instead of in removeChildNode, since the only extremely low-level uses of remove/appendChildNode
+    // cannot affect the positioned object list, and the floating object list is irrelevant (since the list gets cleared on
+    // layout anyway).
+    oldChild->removeFromObjectLists();
+    
     removeChildNode(oldChild);
 }
 
index c218b700833814f272ee293ebc2565970f688642..e62261138ff7c9dcde4699805428f7147920d483 100644 (file)
@@ -2343,6 +2343,9 @@ bool RenderObject::isSelectionBorder() const
 
 void RenderObject::removeFromObjectLists()
 {
+    if (documentBeingDestroyed())
+        return;
+
     if (isFloating()) {
         RenderBlock* outermostBlock = containingBlock();
         for (RenderBlock* p = outermostBlock; p && !p->isRenderView(); p = p->containingBlock()) {
@@ -2369,18 +2372,6 @@ RenderArena* RenderObject::renderArena() const
     return doc ? doc->renderArena() : 0;
 }
 
-void RenderObject::remove()
-{
-    document()->axObjectCache()->remove(this);
-
-    removeFromObjectLists();
-
-    if (parent())
-        parent()->removeChild(this);
-    
-    deleteLineBoxWrapper();
-}
-
 bool RenderObject::documentBeingDestroyed() const
 {
     return !document()->renderer();
@@ -2388,6 +2379,8 @@ bool RenderObject::documentBeingDestroyed() const
 
 void RenderObject::destroy()
 {
+    document()->axObjectCache()->remove(this);
+
     // By default no ref-counting. RenderWidget::destroy() doesn't call
     // this function because it needs to do ref-counting. If anything
     // in this function changes, be sure to fix RenderWidget::destroy() as well. 
index 26774186fd56bafa55fd0fcac368a3c4c0b08404..debf53fa6d79f37f21e23abeab42f0005c58e4ed 100644 (file)
@@ -882,7 +882,7 @@ protected:
 
     virtual IntRect viewRect() const;
 
-    void remove();
+    void remove() { if (parent()) parent()->removeChild(this); }
 
     void invalidateVerticalPositions();
     short getVerticalPosition(bool firstLine) const;
index 886e6a9899c4ae318710ed6dca53e272d8093fc6..3587cd310c2cec94187d6996728bd3259c000ce6 100644 (file)
@@ -24,6 +24,7 @@
 #include "config.h"
 #include "RenderWidget.h"
 
+#include "AXObjectCache.h" 
 #include "Document.h"
 #include "Element.h"
 #include "EventNames.h"
@@ -70,6 +71,8 @@ void RenderWidget::destroy()
     if (RenderView *c = view())
         c->removeWidget(this);
 
+    document()->axObjectCache()->remove(this);
+
     remove();
 
     if (m_widget) {