2011-07-08 Simon Fraser <simon.fraser@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Jul 2011 00:43:14 +0000 (00:43 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Jul 2011 00:43:14 +0000 (00:43 +0000)
        Clean up RenderWidget::destroy() to share more code
        https://bugs.webkit.org/show_bug.cgi?id=64138

        Reviewed by James Robinson.

        RenderWidget::destroy() copied code from various other
        destroy() methods, which made code maintenance in this
        area very risky.

        Fix by adding a virtual willBeDestroyed() method, which
        replaces most instances of destroy(). Now, only RenderWidget
        and RenderObject implement destroy(), and each just calls
        willBeDestroyed(). Code duplication is averted.

        No behavior change, so no tests.

        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::willBeDestroyed):
        * rendering/RenderBlock.h:
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::willBeDestroyed):
        * rendering/RenderBox.h:
        * rendering/RenderBoxModelObject.cpp:
        (WebCore::RenderBoxModelObject::willBeDestroyed):
        * rendering/RenderBoxModelObject.h:
        * rendering/RenderFullScreen.cpp:
        (RenderFullScreenPlaceholder::willBeDestroyed):
        (RenderFullScreen::willBeDestroyed):
        * rendering/RenderFullScreen.h:
        * rendering/RenderInline.cpp:
        (WebCore::RenderInline::willBeDestroyed):
        * rendering/RenderInline.h:
        * rendering/RenderListItem.cpp:
        (WebCore::RenderListItem::willBeDestroyed):
        * rendering/RenderListItem.h:
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::willBeDestroyed):
        (WebCore::RenderObject::destroy):
        * rendering/RenderObject.h:
        * rendering/RenderReplaced.cpp:
        (WebCore::RenderReplaced::willBeDestroyed):
        * rendering/RenderReplaced.h:
        * rendering/RenderTableCell.cpp:
        (WebCore::RenderTableCell::willBeDestroyed):
        * rendering/RenderTableCell.h:
        * rendering/RenderTableRow.cpp:
        (WebCore::RenderTableRow::willBeDestroyed):
        * rendering/RenderTableRow.h:
        * rendering/RenderTableSection.cpp:
        (WebCore::RenderTableSection::willBeDestroyed):
        * rendering/RenderTableSection.h:
        * rendering/RenderText.cpp:
        (WebCore::RenderText::willBeDestroyed):
        * rendering/RenderText.h:
        * rendering/RenderTextFragment.cpp:
        (WebCore::RenderTextFragment::willBeDestroyed):
        * rendering/RenderTextFragment.h:
        * rendering/RenderWidget.cpp:
        (WebCore::RenderWidget::willBeDestroyed):
        (WebCore::RenderWidget::destroy):
        * rendering/RenderWidget.h:
        * rendering/svg/RenderSVGBlock.cpp:
        (WebCore::RenderSVGBlock::willBeDestroyed):
        * rendering/svg/RenderSVGBlock.h:
        * rendering/svg/RenderSVGInline.cpp:
        (WebCore::RenderSVGInline::willBeDestroyed):
        * rendering/svg/RenderSVGInline.h:
        * rendering/svg/RenderSVGInlineText.cpp:
        (WebCore::RenderSVGInlineText::willBeDestroyed):
        * rendering/svg/RenderSVGInlineText.h:
        * rendering/svg/RenderSVGModelObject.cpp:
        (WebCore::RenderSVGModelObject::willBeDestroyed):
        * rendering/svg/RenderSVGModelObject.h:
        * rendering/svg/RenderSVGResourceContainer.cpp:
        (WebCore::RenderSVGResourceContainer::willBeDestroyed):
        * rendering/svg/RenderSVGResourceContainer.h:
        * rendering/svg/RenderSVGRoot.cpp:
        (WebCore::RenderSVGRoot::willBeDestroyed):
        * rendering/svg/RenderSVGRoot.h:
        * rendering/svg/SVGResourcesCache.h:

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

42 files changed:
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderFullScreen.cpp
Source/WebCore/rendering/RenderFullScreen.h
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderInline.h
Source/WebCore/rendering/RenderListItem.cpp
Source/WebCore/rendering/RenderListItem.h
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/RenderReplaced.h
Source/WebCore/rendering/RenderTableCell.cpp
Source/WebCore/rendering/RenderTableCell.h
Source/WebCore/rendering/RenderTableRow.cpp
Source/WebCore/rendering/RenderTableRow.h
Source/WebCore/rendering/RenderTableSection.cpp
Source/WebCore/rendering/RenderTableSection.h
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/RenderText.h
Source/WebCore/rendering/RenderTextFragment.cpp
Source/WebCore/rendering/RenderTextFragment.h
Source/WebCore/rendering/RenderWidget.cpp
Source/WebCore/rendering/RenderWidget.h
Source/WebCore/rendering/svg/RenderSVGBlock.cpp
Source/WebCore/rendering/svg/RenderSVGBlock.h
Source/WebCore/rendering/svg/RenderSVGInline.cpp
Source/WebCore/rendering/svg/RenderSVGInline.h
Source/WebCore/rendering/svg/RenderSVGInlineText.cpp
Source/WebCore/rendering/svg/RenderSVGInlineText.h
Source/WebCore/rendering/svg/RenderSVGModelObject.cpp
Source/WebCore/rendering/svg/RenderSVGModelObject.h
Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp
Source/WebCore/rendering/svg/RenderSVGResourceContainer.h
Source/WebCore/rendering/svg/RenderSVGRoot.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.h
Source/WebCore/rendering/svg/SVGResourcesCache.h

index 7ec62af..5b93b0d 100644 (file)
@@ -1,3 +1,86 @@
+2011-07-08  Simon Fraser  <simon.fraser@apple.com>
+
+        Clean up RenderWidget::destroy() to share more code
+        https://bugs.webkit.org/show_bug.cgi?id=64138
+
+        Reviewed by James Robinson.
+
+        RenderWidget::destroy() copied code from various other
+        destroy() methods, which made code maintenance in this
+        area very risky.
+        
+        Fix by adding a virtual willBeDestroyed() method, which
+        replaces most instances of destroy(). Now, only RenderWidget
+        and RenderObject implement destroy(), and each just calls
+        willBeDestroyed(). Code duplication is averted.
+        
+        No behavior change, so no tests.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::willBeDestroyed):
+        * rendering/RenderBlock.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::willBeDestroyed):
+        * rendering/RenderBox.h:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::willBeDestroyed):
+        * rendering/RenderBoxModelObject.h:
+        * rendering/RenderFullScreen.cpp:
+        (RenderFullScreenPlaceholder::willBeDestroyed):
+        (RenderFullScreen::willBeDestroyed):
+        * rendering/RenderFullScreen.h:
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::willBeDestroyed):
+        * rendering/RenderInline.h:
+        * rendering/RenderListItem.cpp:
+        (WebCore::RenderListItem::willBeDestroyed):
+        * rendering/RenderListItem.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::willBeDestroyed):
+        (WebCore::RenderObject::destroy):
+        * rendering/RenderObject.h:
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::willBeDestroyed):
+        * rendering/RenderReplaced.h:
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::willBeDestroyed):
+        * rendering/RenderTableCell.h:
+        * rendering/RenderTableRow.cpp:
+        (WebCore::RenderTableRow::willBeDestroyed):
+        * rendering/RenderTableRow.h:
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::willBeDestroyed):
+        * rendering/RenderTableSection.h:
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::willBeDestroyed):
+        * rendering/RenderText.h:
+        * rendering/RenderTextFragment.cpp:
+        (WebCore::RenderTextFragment::willBeDestroyed):
+        * rendering/RenderTextFragment.h:
+        * rendering/RenderWidget.cpp:
+        (WebCore::RenderWidget::willBeDestroyed):
+        (WebCore::RenderWidget::destroy):
+        * rendering/RenderWidget.h:
+        * rendering/svg/RenderSVGBlock.cpp:
+        (WebCore::RenderSVGBlock::willBeDestroyed):
+        * rendering/svg/RenderSVGBlock.h:
+        * rendering/svg/RenderSVGInline.cpp:
+        (WebCore::RenderSVGInline::willBeDestroyed):
+        * rendering/svg/RenderSVGInline.h:
+        * rendering/svg/RenderSVGInlineText.cpp:
+        (WebCore::RenderSVGInlineText::willBeDestroyed):
+        * rendering/svg/RenderSVGInlineText.h:
+        * rendering/svg/RenderSVGModelObject.cpp:
+        (WebCore::RenderSVGModelObject::willBeDestroyed):
+        * rendering/svg/RenderSVGModelObject.h:
+        * rendering/svg/RenderSVGResourceContainer.cpp:
+        (WebCore::RenderSVGResourceContainer::willBeDestroyed):
+        * rendering/svg/RenderSVGResourceContainer.h:
+        * rendering/svg/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::willBeDestroyed):
+        * rendering/svg/RenderSVGRoot.h:
+        * rendering/svg/SVGResourcesCache.h:
+
 2011-07-08  Adam Barth  <abarth@webkit.org>
 
         Unreviewed, rolling out r90662.
index 33acfc2..11d26c1 100644 (file)
@@ -149,7 +149,7 @@ RenderBlock::~RenderBlock()
     }
 }
 
-void RenderBlock::destroy()
+void RenderBlock::willBeDestroyed()
 {
     // Mark as being destroyed to avoid trouble with merges in removeChild().
     m_beingDestroyed = true;
@@ -191,7 +191,7 @@ void RenderBlock::destroy()
 
     m_lineBoxes.deleteLineBoxes(renderArena());
 
-    RenderBox::destroy();
+    RenderBox::willBeDestroyed();
 }
 
 void RenderBlock::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
index 95591fc..06c7582 100644 (file)
@@ -72,7 +72,6 @@ public:
     const RenderObjectChildList* children() const { return &m_children; }
     RenderObjectChildList* children() { return &m_children; }
 
-    virtual void destroy();
     bool beingDestroyed() const { return m_beingDestroyed; }
 
     // These two functions are overridden for inline-block.
@@ -249,7 +248,10 @@ public:
 #ifndef NDEBUG
     void showLineTreeAndMark(const InlineBox* = 0, const char* = 0, const InlineBox* = 0, const char* = 0, const RenderObject* = 0) const;
 #endif
+
 protected:
+    virtual void willBeDestroyed();
+
     // These functions are only used internally to manipulate the render tree structure via remove/insert/appendChildNode.
     // Since they are typically called only to move objects around within anonymous blocks (which only have layers in
     // the case of column spans), the default for fullRemoveInsert is false rather than true.
index 92fdfba..a5e9099 100644 (file)
@@ -193,22 +193,19 @@ void RenderBox::setMarginAfter(LayoutUnit margin)
     }
 }
 
-void RenderBox::destroy()
+void RenderBox::willBeDestroyed()
 {
-    // A lot of the code in this function is just pasted into
-    // RenderWidget::destroy. If anything in this function changes,
-    // be sure to fix RenderWidget::destroy() as well.
-    if (hasOverrideSize())
-        gOverrideSizeMap->remove(this);
+    clearOverrideSize();
 
     if (style() && (style()->logicalHeight().isPercent() || style()->logicalMinHeight().isPercent() || style()->logicalMaxHeight().isPercent()))
         RenderBlock::removePercentHeightDescendant(this);
+
     // If the following assertion fails, logicalHeight()/logicalMinHeight()/
     // logicalMaxHeight() values are changed from a percent value to a non-percent
     // value during laying out. It causes a use-after-free bug.
     ASSERT(!RenderBlock::hasPercentHeightDescendant(this));
 
-    RenderBoxModelObject::destroy();
+    RenderBoxModelObject::willBeDestroyed();
 }
 
 void RenderBox::removeFloatingOrPositionedChildFromBlockLists()
index 41a6eaa..f295847 100644 (file)
@@ -239,8 +239,6 @@ public:
     virtual void paint(PaintInfo&, const LayoutPoint&);
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
 
-    virtual void destroy();
-
     virtual int minPreferredLogicalWidth() const;
     virtual int maxPreferredLogicalWidth() const;
 
@@ -411,6 +409,8 @@ public:
     virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicRatio */, bool& /* isPercentageIntrinsicSize */) const { }
 
 protected:
+    virtual void willBeDestroyed();
+
     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     virtual void updateBoxModelInfoFromStyle();
index 7113ea5..2db4629 100644 (file)
@@ -268,7 +268,7 @@ void RenderBoxModelObject::destroyLayer()
     m_layer = 0;
 }
 
-void RenderBoxModelObject::destroy()
+void RenderBoxModelObject::willBeDestroyed()
 {
     // This must be done before we destroy the RenderObject.
     if (m_layer)
@@ -277,8 +277,8 @@ void RenderBoxModelObject::destroy()
     // A continuation of this RenderObject should be destroyed at subclasses.
     ASSERT(!continuation());
 
-    // RenderObject::destroy calls back to destroyLayer() for layer destruction
-    RenderObject::destroy();
+    // RenderObject::willBeDestroyed calls back to destroyLayer() for layer destruction
+    RenderObject::willBeDestroyed();
 }
 
 bool RenderBoxModelObject::hasSelfPaintingLayer() const
index 14c03da..2bb6135 100644 (file)
@@ -48,8 +48,6 @@ public:
     RenderBoxModelObject(Node*);
     virtual ~RenderBoxModelObject();
     
-    virtual void destroy();
-
     LayoutUnit relativePositionOffsetX() const;
     LayoutUnit relativePositionOffsetY() const;
     LayoutSize relativePositionOffset() const { return LayoutSize(relativePositionOffsetX(), relativePositionOffsetY()); }
@@ -127,13 +125,16 @@ public:
     virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const = 0;
     virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const = 0;
 
-    // Called by RenderObject::destroy() (and RenderWidget::destroy()) and is the only way layers should ever be destroyed
+    // Called by RenderObject::willBeDestroyed() and is the only way layers should ever be destroyed
     void destroyLayer();
 
     void highQualityRepaintTimerFired(Timer<RenderBoxModelObject>*);
 
     virtual void setSelectionState(SelectionState s);
+
 protected:
+    virtual void willBeDestroyed();
+
     void calculateBackgroundImageGeometry(const FillLayer*, const IntRect& paintRect, IntRect& destRect, IntPoint& phase, IntSize& tileSize);
     void getBorderEdgeInfo(class BorderEdge[], bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
     bool borderObscuresBackgroundEdge(const FloatSize& contextScale) const;
index 514abe8..18dbc9f 100644 (file)
@@ -45,14 +45,14 @@ public:
     }
 private:
     virtual bool isRenderFullScreenPlaceholder() const { return true; }
-    virtual void destroy();
+    virtual void willBeDestroyed();
     RenderFullScreen* m_owner;
 };
 
-void RenderFullScreenPlaceholder::destroy()
+void RenderFullScreenPlaceholder::willBeDestroyed()
 {
     m_owner->setPlaceholder(0);
-    RenderBlock::destroy();
+    RenderBlock::willBeDestroyed();
 }
 
 RenderFullScreen::RenderFullScreen(Node* node) 
@@ -62,7 +62,7 @@ RenderFullScreen::RenderFullScreen(Node* node)
     setReplaced(false); 
 }
 
-void RenderFullScreen::destroy()
+void RenderFullScreen::willBeDestroyed()
 {
     if (m_placeholder) {
         remove();
@@ -76,7 +76,7 @@ void RenderFullScreen::destroy()
     if (document() && document()->fullScreenRenderer() == this)
         document()->fullScreenRendererDestroyed();
 
-    RenderDeprecatedFlexibleBox::destroy();
+    RenderDeprecatedFlexibleBox::willBeDestroyed();
 }
 
 PassRefPtr<RenderStyle> RenderFullScreen::createFullScreenStyle()
index d468461..6f4c783 100644 (file)
@@ -34,7 +34,6 @@ namespace WebCore {
 class RenderFullScreen : public RenderDeprecatedFlexibleBox {
 public:
     RenderFullScreen(Node*);
-    virtual void destroy();
     virtual bool isRenderFullScreen() const { return true; }
     virtual const char* renderName() const { return "RenderFullScreen"; }
 
@@ -43,6 +42,9 @@ public:
     void createPlaceholder(PassRefPtr<RenderStyle>, const IntRect& frameRect);
 
     static PassRefPtr<RenderStyle> createFullScreenStyle();
+
+private:
+    virtual void willBeDestroyed();
     
 protected:
     RenderBlock* m_placeholder;
index c9a4eb2..7083d7b 100644 (file)
@@ -53,7 +53,7 @@ RenderInline::RenderInline(Node* node)
     setChildrenInline(true);
 }
 
-void RenderInline::destroy()
+void RenderInline::willBeDestroyed()
 {
 #ifndef NDEBUG
     // Make sure we do not retain "this" in the continuation outline table map of our containing blocks.
@@ -105,7 +105,7 @@ void RenderInline::destroy()
 
     m_lineBoxes.deleteLineBoxes(renderArena());
 
-    RenderBoxModelObject::destroy();
+    RenderBoxModelObject::willBeDestroyed();
 }
 
 RenderInline* RenderInline::inlineElementContinuation() const
index f28461f..2c291d1 100644 (file)
@@ -35,8 +35,6 @@ class RenderInline : public RenderBoxModelObject {
 public:
     explicit RenderInline(Node*);
 
-    virtual void destroy();
-
     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
 
     virtual LayoutUnit marginLeft() const;
@@ -86,6 +84,8 @@ public:
     void updateAlwaysCreateLineBoxes();
 
 protected:
+    virtual void willBeDestroyed();
+
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
 
 private:
index 2e34945..7a9915d 100644 (file)
@@ -66,13 +66,13 @@ void RenderListItem::styleDidChange(StyleDifference diff, const RenderStyle* old
     }
 }
 
-void RenderListItem::destroy()
+void RenderListItem::willBeDestroyed()
 {    
     if (m_marker) {
         m_marker->destroy();
         m_marker = 0;
     }
-    RenderBlock::destroy();
+    RenderBlock::willBeDestroyed();
 }
 
 static bool isList(Node* node)
index a05ba7d..e56efff 100644 (file)
@@ -54,7 +54,7 @@ private:
 
     virtual bool isListItem() const { return true; }
     
-    virtual void destroy();
+    virtual void willBeDestroyed();
 
     virtual bool isEmpty() const;
     virtual void paint(PaintInfo&, const LayoutPoint&);
index 1b927d6..fd24df7 100644 (file)
@@ -2052,7 +2052,7 @@ bool RenderObject::isSelectionBorder() const
     return st == SelectionStart || st == SelectionEnd || st == SelectionBoth;
 }
 
-void RenderObject::destroy()
+void RenderObject::willBeDestroyed()
 {
     // Destroy any leftover anonymous children.
     RenderObjectChildList* children = virtualChildren();
@@ -2074,10 +2074,6 @@ void RenderObject::destroy()
     }
     animation()->cancelAnimations(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.
-
     remove();
 
     // If this renderer had a parent, remove should have destroyed any counters
@@ -2094,6 +2090,11 @@ void RenderObject::destroy()
         setHasLayer(false);
         toRenderBoxModelObject(this)->destroyLayer();
     }
+}
+
+void RenderObject::destroy()
+{
+    willBeDestroyed();
     arenaDelete(renderArena(), this);
 }
 
index 5d43ce2..6e42891 100644 (file)
@@ -801,6 +801,7 @@ protected:
 
     void adjustRectForOutlineAndShadow(IntRect&) const;
 
+    virtual void willBeDestroyed();
     void arenaDelete(RenderArena*, void* objectBase);
 
     virtual IntRect outlineBoundsForRepaint(RenderBoxModelObject* /*repaintContainer*/, IntPoint* /*cachedOffsetToRepaintContainer*/ = 0) const { return IntRect(); }
index cab23ee..8b06c71 100644 (file)
@@ -57,12 +57,12 @@ RenderReplaced::~RenderReplaced()
 {
 }
 
-void RenderReplaced::destroy()
+void RenderReplaced::willBeDestroyed()
 {
     if (!documentBeingDestroyed() && parent())
         parent()->dirtyLinesFromChangedChild(this);
 
-    RenderBox::destroy();
+    RenderBox::willBeDestroyed();
 }
 
 void RenderReplaced::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
index 4971895..e809f40 100644 (file)
@@ -32,12 +32,12 @@ public:
     RenderReplaced(Node*, const IntSize& intrinsicSize);
     virtual ~RenderReplaced();
 
-    virtual void destroy();
-
     virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
     virtual LayoutUnit computeReplacedLogicalHeight() const;
 
 protected:
+    virtual void willBeDestroyed();
+
     virtual void layout();
 
     virtual IntSize intrinsicSize() const;
index 40d5b01..5a551db 100644 (file)
@@ -54,11 +54,11 @@ RenderTableCell::RenderTableCell(Node* node)
     updateFromElement();
 }
 
-void RenderTableCell::destroy()
+void RenderTableCell::willBeDestroyed()
 {
     RenderTableSection* recalcSection = parent() ? section() : 0;
 
-    RenderBlock::destroy();
+    RenderBlock::willBeDestroyed();
 
     if (recalcSection)
         recalcSection->setNeedsCellRecalc();
index ea8b7e3..c0c6436 100644 (file)
@@ -137,7 +137,7 @@ private:
 
     virtual bool isTableCell() const { return true; }
 
-    virtual void destroy();
+    virtual void willBeDestroyed();
 
     virtual void computeLogicalWidth();
 
index 02360c6..ba31ff6 100644 (file)
@@ -43,11 +43,11 @@ RenderTableRow::RenderTableRow(Node* node)
     setInline(false);   // our object is not Inline
 }
 
-void RenderTableRow::destroy()
+void RenderTableRow::willBeDestroyed()
 {
     RenderTableSection* recalcSection = section();
     
-    RenderBox::destroy();
+    RenderBox::willBeDestroyed();
     
     if (recalcSection)
         recalcSection->setNeedsCellRecalc();
index a88de10..4233b40 100644 (file)
@@ -49,7 +49,7 @@ private:
 
     virtual bool isTableRow() const { return true; }
 
-    virtual void destroy();
+    virtual void willBeDestroyed();
 
     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
     virtual void layout();
index fd544b5..f8966f5 100644 (file)
@@ -74,11 +74,11 @@ RenderTableSection::~RenderTableSection()
     clearGrid();
 }
 
-void RenderTableSection::destroy()
+void RenderTableSection::willBeDestroyed()
 {
     RenderTable* recalcTable = table();
     
-    RenderBox::destroy();
+    RenderBox::willBeDestroyed();
     
     // recalc cell info because RenderTable has unguarded pointers
     // stored that point to this RenderTableSection.
index b9ad61e..9f1f406 100644 (file)
@@ -126,7 +126,7 @@ private:
 
     virtual bool isTableSection() const { return true; }
 
-    virtual void destroy();
+    virtual void willBeDestroyed();
 
     virtual void layout();
 
index 5918728..8d529c0 100644 (file)
@@ -193,10 +193,10 @@ void RenderText::removeAndDestroyTextBoxes()
     deleteTextBoxes();
 }
 
-void RenderText::destroy()
+void RenderText::willBeDestroyed()
 {
     removeAndDestroyTextBoxes();
-    RenderObject::destroy();
+    RenderObject::willBeDestroyed();
 }
 
 void RenderText::extractTextBox(InlineTextBox* box)
index 3393553..d09e1f1 100644 (file)
@@ -48,8 +48,6 @@ public:
     void attachTextBox(InlineTextBox*);
     void removeTextBox(InlineTextBox*);
 
-    virtual void destroy();
-
     StringImpl* text() const { return m_text.impl(); }
     String textWithoutTranscoding() const;
 
@@ -131,6 +129,8 @@ public:
     void removeAndDestroyTextBoxes();
 
 protected:
+    virtual void willBeDestroyed();
+
     virtual void styleWillChange(StyleDifference, const RenderStyle*) { }
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
 
index 9181487..17c9d7b 100644 (file)
@@ -68,11 +68,11 @@ void RenderTextFragment::styleDidChange(StyleDifference diff, const RenderStyle*
     }
 }
 
-void RenderTextFragment::destroy()
+void RenderTextFragment::willBeDestroyed()
 {
     if (m_firstLetter)
         m_firstLetter->destroy();
-    RenderText::destroy();
+    RenderText::willBeDestroyed();
 }
 
 void RenderTextFragment::setTextInternal(PassRefPtr<StringImpl> text)
index c251f81..54b307e 100644 (file)
@@ -39,8 +39,6 @@ public:
 
     virtual bool isTextFragment() const { return true; }
 
-    virtual void destroy();
-
     unsigned start() const { return m_start; }
     unsigned end() const { return m_end; }
 
@@ -54,6 +52,8 @@ protected:
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
 
 private:
+    virtual void willBeDestroyed();
+
     virtual void setTextInternal(PassRefPtr<StringImpl>);
     virtual UChar previousCharacter() const;
     RenderBlock* blockForAccompanyingFirstLetter() const;
index e1405ea..175feba 100644 (file)
@@ -108,47 +108,24 @@ RenderWidget::RenderWidget(Node* node)
     view()->addWidget(this);
 }
 
-void RenderWidget::destroy()
+void RenderWidget::willBeDestroyed()
 {
-    // We can't call the base class's destroy because we don't
-    // want to unconditionally delete ourselves (we're ref-counted).
-    // So the code below includes copied and pasted contents of
-    // both RenderBox::destroy() and RenderObject::destroy().
-    // Fix originally made for <rdar://problem/4228818>.
-
-    animation()->cancelAnimations(this);
-
     if (RenderView* v = view())
         v->removeWidget(this);
-
     
     if (AXObjectCache::accessibilityEnabled()) {
         document()->axObjectCache()->childrenChanged(this->parent());
         document()->axObjectCache()->remove(this);
     }
 
-    if (!documentBeingDestroyed() && parent()) 
-        parent()->dirtyLinesFromChangedChild(this);
-
-    remove();
-
-    if (m_hasCounterNodeMap)
-        RenderCounter::destroyCounterNodes(this);
-
     setWidget(0);
 
-    // removes from override size map
-    if (hasOverrideSize())
-        clearOverrideSize();
-
-    if (style() && (style()->logicalHeight().isPercent() || style()->logicalMinHeight().isPercent() || style()->logicalMaxHeight().isPercent()))
-        RenderBlock::removePercentHeightDescendant(this);
+    RenderReplaced::willBeDestroyed();
+}
 
-    if (hasLayer()) {
-        layer()->clearClipRects();
-        setHasLayer(false);
-        destroyLayer();
-    }
+void RenderWidget::destroy()
+{
+    willBeDestroyed();
 
     // Grab the arena from node()->document()->renderArena() before clearing the node pointer.
     // Clear the node before deref-ing, as this may be deleted when deref is called.
index f359cac..d391387 100644 (file)
@@ -65,6 +65,7 @@ protected:
 private:
     virtual bool isWidget() const { return true; }
 
+    virtual void willBeDestroyed();
     virtual void destroy();
     virtual void setSelectionState(SelectionState);
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
index a1011f3..2233c5e 100644 (file)
@@ -74,10 +74,10 @@ void RenderSVGBlock::absoluteRects(Vector<LayoutRect>&, const LayoutPoint&)
     ASSERT_NOT_REACHED();
 }
 
-void RenderSVGBlock::destroy()
+void RenderSVGBlock::willBeDestroyed()
 {
     SVGResourcesCache::clientDestroyed(this);
-    RenderBlock::destroy();
+    RenderBlock::willBeDestroyed();
 }
 
 void RenderSVGBlock::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
index a50c90c..78a6b41 100644 (file)
@@ -38,7 +38,7 @@ private:
 
     virtual void absoluteRects(Vector<LayoutRect>&, const LayoutPoint& accumulatedOffset);
 
-    virtual void destroy();
+    virtual void willBeDestroyed();
     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     virtual void updateFromElement();
index 44b34ef..3a7d72a 100644 (file)
@@ -93,13 +93,13 @@ void RenderSVGInline::absoluteQuads(Vector<FloatQuad>& quads)
         quads.append(localToAbsoluteQuad(FloatRect(textBoundingBox.x() + box->x(), textBoundingBox.y() + box->y(), box->logicalWidth(), box->logicalHeight())));
 }
 
-void RenderSVGInline::destroy()
+void RenderSVGInline::willBeDestroyed()
 {
     if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this))
         textRenderer->setNeedsPositioningValuesUpdate();
 
     SVGResourcesCache::clientDestroyed(this);
-    RenderInline::destroy();
+    RenderInline::willBeDestroyed();
 }
 
 void RenderSVGInline::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
index f5ef6a1..ab1c86f 100644 (file)
@@ -53,7 +53,7 @@ public:
 private:
     virtual InlineFlowBox* createInlineFlowBox();
 
-    virtual void destroy();
+    virtual void willBeDestroyed();
     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     virtual void updateFromElement();
index 6b27ab1..5bcc5b2 100644 (file)
@@ -71,12 +71,12 @@ RenderSVGInlineText::RenderSVGInlineText(Node* n, PassRefPtr<StringImpl> string)
 {
 }
 
-void RenderSVGInlineText::destroy()
+void RenderSVGInlineText::willBeDestroyed()
 {
     if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this))
         textRenderer->setNeedsPositioningValuesUpdate();
 
-    RenderText::destroy();
+    RenderText::willBeDestroyed();
 }
 
 void RenderSVGInlineText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
index 5ca2bed..18be859 100644 (file)
@@ -48,7 +48,7 @@ public:
 private:
     virtual const char* renderName() const { return "RenderSVGInlineText"; }
 
-    virtual void destroy();
+    virtual void willBeDestroyed();
     virtual void styleDidChange(StyleDifference, const RenderStyle*);
 
     // FIXME: We need objectBoundingBox for DRT results and filters at the moment.
index 989696a..7a8147f 100644 (file)
@@ -81,10 +81,10 @@ void RenderSVGModelObject::absoluteQuads(Vector<FloatQuad>& quads)
     quads.append(localToAbsoluteQuad(strokeBoundingBox()));
 }
 
-void RenderSVGModelObject::destroy()
+void RenderSVGModelObject::willBeDestroyed()
 {
     SVGResourcesCache::clientDestroyed(this);
-    RenderObject::destroy();
+    RenderObject::willBeDestroyed();
 }
 
 void RenderSVGModelObject::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
index ca6cf65..1d5df93 100644 (file)
@@ -58,13 +58,14 @@ public:
     virtual void absoluteRects(Vector<LayoutRect>&, const LayoutPoint& accumulatedOffset);
     virtual void absoluteQuads(Vector<FloatQuad>&);
 
-    virtual void destroy();
-
     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&, bool* wasFixed = 0) const;
     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     virtual void updateFromElement();
 
+protected:
+    virtual void willBeDestroyed();
+
 private:
     // This method should never be called, SVG uses a different nodeAtPoint method
     bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
index 79e8e1e..74d5d69 100644 (file)
@@ -56,10 +56,10 @@ void RenderSVGResourceContainer::layout()
     RenderSVGHiddenContainer::layout();
 }
 
-void RenderSVGResourceContainer::destroy()
+void RenderSVGResourceContainer::willBeDestroyed()
 {
     SVGResourcesCache::resourceDestroyed(this);
-    RenderSVGHiddenContainer::destroy();
+    RenderSVGHiddenContainer::willBeDestroyed();
 }
 
 void RenderSVGResourceContainer::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
index d98a83a..7ecccc2 100644 (file)
@@ -33,7 +33,6 @@ public:
     virtual ~RenderSVGResourceContainer();
 
     virtual void layout();
-    virtual void destroy();
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
 
     virtual bool isSVGResourceContainer() const { return true; }
@@ -61,6 +60,7 @@ private:
     void removeClient(RenderObject*);
 
 private:
+    virtual void willBeDestroyed();
     void registerResource();
 
     AtomicString m_id;
index 412c410..470f0d7 100644 (file)
@@ -313,10 +313,10 @@ void RenderSVGRoot::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
         paintOutline(paintInfo.context, LayoutRect(borderBoxOriginInContainer, size()));
 }
 
-void RenderSVGRoot::destroy()
+void RenderSVGRoot::willBeDestroyed()
 {
     SVGResourcesCache::clientDestroyed(this);
-    RenderBox::destroy();
+    RenderBox::willBeDestroyed();
 }
 
 void RenderSVGRoot::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
index eac4193..5c1b895 100644 (file)
@@ -64,7 +64,7 @@ private:
     virtual void layout();
     virtual void paint(PaintInfo&, const LayoutPoint&);
 
-    virtual void destroy();
+    virtual void willBeDestroyed();
     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     virtual void updateFromElement();
index bc73f4d..897c184 100644 (file)
@@ -53,7 +53,7 @@ public:
     // Called from all SVG renderers updateFromElement() methods.
     static void clientUpdatedFromElement(RenderObject*, const RenderStyle* newStyle);
 
-    // Called from RenderSVGResourceContainer::destroy().
+    // Called from RenderSVGResourceContainer::willBeDestroyed().
     static void resourceDestroyed(RenderSVGResourceContainer*);
 
 private: