Virtualize createAnonymousBoxWithSameTypeAs.
authorinferno@chromium.org <inferno@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Apr 2012 21:32:55 +0000 (21:32 +0000)
committerinferno@chromium.org <inferno@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Apr 2012 21:32:55 +0000 (21:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83229

Reviewed by Julien Chaffraix.

This helps to use the same function to create anonymous
table parts and in the future extend to more classes
derived from RenderBox.

The current switch case situation was going to be messy as
we will need to mix cases that were very dependent on the
class, so it made sense to add a virtual function.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::splitAnonymousBlocksAroundChild):
(WebCore::RenderBlock::createAnonymousBoxWithSameTypeAs):
* rendering/RenderBlock.h:
(RenderBlock):
* rendering/RenderBox.h:
(WebCore::RenderBox::createAnonymousBoxWithSameTypeAs):
(RenderBox):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::splitFlow):
* rendering/RenderTable.h:
(WebCore::RenderTable::createAnonymousBoxWithSameTypeAs):
* rendering/RenderTableCell.h:
(WebCore::RenderTableCell::createAnonymousBoxWithSameTypeAs):
* rendering/RenderTableRow.h:
(WebCore::RenderTableRow::createAnonymousBoxWithSameTypeAs):
* rendering/RenderTableSection.h:
(WebCore::RenderTableSection::createAnonymousBoxWithSameTypeAs):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderTable.h
Source/WebCore/rendering/RenderTableCell.h
Source/WebCore/rendering/RenderTableRow.h
Source/WebCore/rendering/RenderTableSection.h

index ae4c166..adedc2c 100644 (file)
@@ -1,3 +1,37 @@
+2012-04-06  Abhishek Arya  <inferno@chromium.org>
+
+        Virtualize createAnonymousBoxWithSameTypeAs.
+        https://bugs.webkit.org/show_bug.cgi?id=83229
+
+        Reviewed by Julien Chaffraix.
+
+        This helps to use the same function to create anonymous
+        table parts and in the future extend to more classes
+        derived from RenderBox.
+
+        The current switch case situation was going to be messy as
+        we will need to mix cases that were very dependent on the
+        class, so it made sense to add a virtual function.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::splitAnonymousBlocksAroundChild):
+        (WebCore::RenderBlock::createAnonymousBoxWithSameTypeAs):
+        * rendering/RenderBlock.h:
+        (RenderBlock):
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::createAnonymousBoxWithSameTypeAs):
+        (RenderBox):
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::splitFlow):
+        * rendering/RenderTable.h:
+        (WebCore::RenderTable::createAnonymousBoxWithSameTypeAs):
+        * rendering/RenderTableCell.h:
+        (WebCore::RenderTableCell::createAnonymousBoxWithSameTypeAs):
+        * rendering/RenderTableRow.h:
+        (WebCore::RenderTableRow::createAnonymousBoxWithSameTypeAs):
+        * rendering/RenderTableSection.h:
+        (WebCore::RenderTableSection::createAnonymousBoxWithSameTypeAs):
+
 2012-04-06  Tim Horton  <timothy_horton@apple.com>
 
         [cg] REGRESSION (r101517): Animating the transform of a <rect> with shape-rendering: crispEdges leaves behind garbage
index 7133dbf..d243d0c 100755 (executable)
@@ -715,7 +715,7 @@ RenderObject* RenderBlock::splitAnonymousBlocksAroundChild(RenderObject* beforeC
         RenderBlock* blockToSplit = toRenderBlock(beforeChild->parent());
         if (blockToSplit->firstChild() != beforeChild) {
             // We have to split the parentBlock into two blocks.
-            RenderBlock* post = createAnonymousBlockWithSameTypeAs(blockToSplit);
+            RenderBlock* post = toRenderBlock(blockToSplit->createAnonymousBoxWithSameTypeAs(this));
             post->setChildrenInline(blockToSplit->childrenInline());
             RenderBlock* parentBlock = toRenderBlock(blockToSplit->parent());
             parentBlock->children()->insertChildNode(parentBlock, post, blockToSplit->nextSibling());
@@ -6675,13 +6675,13 @@ void RenderBlock::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& a
         inlineElementContinuation()->addFocusRingRects(rects, flooredLayoutPoint(additionalOffset + inlineElementContinuation()->containingBlock()->location() - location()));
 }
 
-RenderBlock* RenderBlock::createAnonymousBlockWithSameTypeAs(RenderBlock* otherAnonymousBlock) const
+RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const
 {
-    if (otherAnonymousBlock->isAnonymousColumnsBlock())
-        return createAnonymousColumnsBlock();
-    if (otherAnonymousBlock->isAnonymousColumnSpanBlock())
-        return createAnonymousColumnSpanBlock();
-    return createAnonymousBlock(otherAnonymousBlock->style()->display());
+    if (isAnonymousColumnsBlock())
+        return createAnonymousColumnsWithParentRenderer(parent);
+    if (isAnonymousColumnSpanBlock())
+        return createAnonymousColumnSpanWithParentRenderer(parent);
+    return createAnonymousWithParentRendererAndDisplay(parent, style()->display());
 }
 
 bool RenderBlock::hasNextPage(LayoutUnit logicalOffset, PageBoundaryRule pageBoundaryRule) const
index 8fc3511..efc98dd 100644 (file)
@@ -240,7 +240,7 @@ public:
     RenderBlock* createAnonymousColumnsBlock() const { return createAnonymousColumnsWithParentRenderer(this); }
     RenderBlock* createAnonymousColumnSpanBlock() const { return createAnonymousColumnSpanWithParentRenderer(this); }
 
-    RenderBlock* createAnonymousBlockWithSameTypeAs(RenderBlock* otherAnonymousBlock) const;
+    virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const OVERRIDE;
     
     static void appendRunsForObject(BidiRunList<BidiRun>&, int start, int end, RenderObject*, InlineBidiResolver&);
 
index 41d9c2a..4b0c000 100644 (file)
@@ -484,6 +484,12 @@ public:
         return false;
     }
 
+    virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject*) const
+    {
+        ASSERT_NOT_REACHED();
+        return 0;
+    }
+
 protected:
     virtual void willBeDestroyed();
 
index 301479b..06bc4f6 100644 (file)
@@ -426,7 +426,7 @@ void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox
         madeNewBeforeBlock = true;
     }
 
-    RenderBlock* post = block->createAnonymousBlockWithSameTypeAs(pre);
+    RenderBlock* post = toRenderBlock(pre->createAnonymousBoxWithSameTypeAs(block));
 
     RenderObject* boxFirst = madeNewBeforeBlock ? block->firstChild() : pre->nextSibling();
     if (madeNewBeforeBlock)
index 639459c..ab66ca8 100644 (file)
@@ -212,6 +212,10 @@ public:
     }
 
     static RenderTable* createAnonymousWithParentRenderer(const RenderObject*);
+    virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const OVERRIDE
+    {
+        return createAnonymousWithParentRenderer(parent);
+    }
 
 protected:
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
index d3a9ee9..51e9bf6 100644 (file)
@@ -139,6 +139,10 @@ public:
     void setCellWidthChanged(bool b = true) { m_cellWidthChanged = b; }
 
     static RenderTableCell* createAnonymousWithParentRenderer(const RenderObject*);
+    virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const OVERRIDE
+    {
+        return createAnonymousWithParentRenderer(parent);
+    }
 
 protected:
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
index 9b91e1b..927551b 100644 (file)
@@ -43,6 +43,10 @@ public:
     void paintOutlineForRowIfNeeded(PaintInfo&, const LayoutPoint&);
 
     static RenderTableRow* createAnonymousWithParentRenderer(const RenderObject*);
+    virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const OVERRIDE
+    {
+        return createAnonymousWithParentRenderer(parent);
+    }
 
 private:
     virtual RenderObjectChildList* virtualChildren() { return children(); }
index 1a3fe21..749a582 100644 (file)
@@ -163,6 +163,10 @@ public:
     int distributeExtraLogicalHeightToRows(int extraLogicalHeight);
 
     static RenderTableSection* createAnonymousWithParentRenderer(const RenderObject*);
+    virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const OVERRIDE
+    {
+        return createAnonymousWithParentRenderer(parent);
+    }
 
 protected:
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);