Modified: trunk/Source/WebCore/ChangeLog (161336 => 161337)
--- trunk/Source/WebCore/ChangeLog 2014-01-06 09:49:21 UTC (rev 161336)
+++ trunk/Source/WebCore/ChangeLog 2014-01-06 10:39:36 UTC (rev 161337)
@@ -1,5 +1,27 @@
2014-01-06 Andreas Kling <[email protected]>
+ RenderBlock::clone() should return RenderPtr.
+ <https://webkit.org/b/126513>
+
+ Reviewed by Antti Koivisto.
+
+ * rendering/RenderBlock.h:
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::clone):
+
+ Tweaked to return RenderPtr<RenderBlock>.
+
+ (WebCore::RenderBlock::splitBlocks):
+
+ Store cloned RenderBlocks in RenderPtrs. Use leakPtr() to sink
+ them into ownership-taking APIs that still use raw pointers.
+
+ * rendering/RenderPtr.h:
+
+ Add a simple static_pointer_cast for RenderPtr&&.
+
+2014-01-06 Andreas Kling <[email protected]>
+
RenderInline::clone() should return RenderPtr.
<https://webkit.org/b/126514>
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (161336 => 161337)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2014-01-06 09:49:21 UTC (rev 161336)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2014-01-06 10:39:36 UTC (rev 161337)
@@ -504,15 +504,14 @@
return 0;
}
-RenderBlock* RenderBlock::clone() const
+RenderPtr<RenderBlock> RenderBlock::clone() const
{
- RenderBlock* cloneBlock;
+ RenderPtr<RenderBlock> cloneBlock;
if (isAnonymousBlock()) {
- cloneBlock = createAnonymousBlock();
+ cloneBlock = RenderPtr<RenderBlock>(createAnonymousBlock());
cloneBlock->setChildrenInline(childrenInline());
} else {
- auto cloneRenderer = element()->createElementRenderer(style());
- cloneBlock = toRenderBlock(cloneRenderer.leakPtr());
+ cloneBlock = static_pointer_cast<RenderBlock>(element()->createElementRenderer(style()));
cloneBlock->initializeStyle();
// This takes care of setting the right value of childrenInline in case
@@ -529,7 +528,7 @@
RenderObject* beforeChild, RenderBoxModelObject* oldCont)
{
// Create a clone of this inline.
- RenderBlock* cloneBlock = clone();
+ RenderPtr<RenderBlock> cloneBlock = clone();
if (!isAnonymousBlock())
cloneBlock->setContinuation(oldCont);
@@ -543,11 +542,11 @@
// Now take all of the children from beforeChild to the end and remove
// them from |this| and place them in the clone.
- moveChildrenTo(cloneBlock, beforeChild, 0, true);
+ moveChildrenTo(cloneBlock.get(), beforeChild, 0, true);
// Hook |clone| up as the continuation of the middle block.
if (!cloneBlock->isAnonymousBlock())
- middleBlock->setContinuation(cloneBlock);
+ middleBlock->setContinuation(cloneBlock.get());
// We have been reparented and are now under the fromBlock. We need
// to walk up our block parent chain until we hit the containing anonymous columns block.
@@ -562,11 +561,11 @@
RenderBlock* blockCurr = toRenderBlock(curr);
// Create a new clone.
- RenderBlock* cloneChild = cloneBlock;
+ RenderPtr<RenderBlock> cloneChild = std::move(cloneBlock);
cloneBlock = blockCurr->clone();
// Insert our child clone as the first child.
- cloneBlock->addChildIgnoringContinuation(cloneChild, 0);
+ cloneBlock->addChildIgnoringContinuation(cloneChild.leakPtr(), 0);
// Hook the clone up as a continuation of |curr|. Note we do encounter
// anonymous blocks possibly as we walk up the block chain. When we split an
@@ -574,13 +573,13 @@
// actually split a real element.
if (!blockCurr->isAnonymousBlock()) {
oldCont = blockCurr->continuation();
- blockCurr->setContinuation(cloneBlock);
+ blockCurr->setContinuation(cloneBlock.get());
cloneBlock->setContinuation(oldCont);
}
// Now we need to take all of the children starting from the first child
// *after* currChild and append them all to the clone.
- blockCurr->moveChildrenTo(cloneBlock, currChildNextSibling, 0, true);
+ blockCurr->moveChildrenTo(cloneBlock.get(), currChildNextSibling, 0, true);
// Keep walking up the chain.
currChild = curr;
@@ -589,7 +588,7 @@
}
// Now we are at the columns block level. We need to put the clone into the toBlock.
- toBlock->insertChildInternal(cloneBlock, nullptr, NotifyChildren);
+ toBlock->insertChildInternal(cloneBlock.leakPtr(), nullptr, NotifyChildren);
// Now take all the children after currChild and remove them from the fromBlock
// and put them in the toBlock.
Modified: trunk/Source/WebCore/rendering/RenderBlock.h (161336 => 161337)
--- trunk/Source/WebCore/rendering/RenderBlock.h 2014-01-06 09:49:21 UTC (rev 161336)
+++ trunk/Source/WebCore/rendering/RenderBlock.h 2014-01-06 10:39:36 UTC (rev 161337)
@@ -583,7 +583,7 @@
RenderObject* beforeChild, RenderBoxModelObject* oldCont);
void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
RenderObject* newChild, RenderBoxModelObject* oldCont);
- RenderBlock* clone() const;
+ RenderPtr<RenderBlock> clone() const;
RenderBlock* continuationBefore(RenderObject* beforeChild);
RenderBlock* containingColumnsBlock(bool allowAnonymousColumnBlock = true);
RenderBlock* columnsBlockForSpanningElement(RenderObject* newChild);
Modified: trunk/Source/WebCore/rendering/RenderPtr.h (161336 => 161337)
--- trunk/Source/WebCore/rendering/RenderPtr.h 2014-01-06 09:49:21 UTC (rev 161336)
+++ trunk/Source/WebCore/rendering/RenderPtr.h 2014-01-06 10:39:36 UTC (rev 161337)
@@ -158,6 +158,11 @@
return RenderPtr<T>(new T(std::forward<Args>(args)...));
}
+template<typename T, typename U> inline RenderPtr<T> static_pointer_cast(RenderPtr<U>&& p)
+{
+ return RenderPtr<T>(static_cast<T*>(p.leakPtr()));
+}
+
} // namespace WebCore
namespace WTF {