RenderInline::clone() should return RenderPtr.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jan 2014 09:47:01 +0000 (09:47 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jan 2014 09:47:01 +0000 (09:47 +0000)
<https://webkit.org/b/126514>

Patch by Gurpreet Kaur <k.gurpreet@samsung.com> on 2014-01-06
Reviewed by Antti Koivisto.

* rendering/RenderInline.h:
* rendering/RenderInline.cpp:
(WebCore::RenderInline::clone):

    Tweaked to return RenderPtr<RenderInline>.

(WebCore::RenderInline::splitInlines):

    Store cloned RenderInlines in RenderPtrs. Use leakPtr() to sink
    them into ownership-taking APIs that still use raw pointers.

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderInline.h

index e32530474d1cd26f58880b6b47458381aed4fbb9..2d5bb46e325a964c838b7e18f4ffa9a81ffb6b14 100644 (file)
@@ -1,5 +1,23 @@
 2014-01-06  Gurpreet Kaur  <k.gurpreet@samsung.com>
 
+        RenderInline::clone() should return RenderPtr.
+        <https://webkit.org/b/126514>
+
+        Reviewed by Antti Koivisto.
+
+        * rendering/RenderInline.h:
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::clone):
+
+            Tweaked to return RenderPtr<RenderInline>.
+
+        (WebCore::RenderInline::splitInlines):
+
+            Store cloned RenderInlines in RenderPtrs. Use leakPtr() to sink
+            them into ownership-taking APIs that still use raw pointers.
+
+2014-01-06  Andreas Kling  <akling@apple.com>
+
         <hr> appears gray instead of green because of color attribute is defined followed by noshade attribute
         https://bugs.webkit.org/show_bug.cgi?id=17674
 
index 6800ca515ff935a329791f2ec11ae8ce1d23b175..db4ba6eab2b2ab5a92d6a6db042634718cea99dd 100644 (file)
@@ -330,9 +330,9 @@ void RenderInline::addChildIgnoringContinuation(RenderObject* newChild, RenderOb
     newChild->setNeedsLayoutAndPrefWidthsRecalc();
 }
 
-RenderInline* RenderInline::clone() const
+RenderPtr<RenderInline> RenderInline::clone() const
 {
-    RenderInline* cloneInline = new RenderInline(*element(), style());
+    RenderPtr<RenderInline> cloneInline = createRenderer<RenderInline>(*element(), style());
     cloneInline->initializeStyle();
     cloneInline->setFlowThreadState(flowThreadState());
     return cloneInline;
@@ -343,7 +343,7 @@ void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock,
                                 RenderObject* beforeChild, RenderBoxModelObject* oldCont)
 {
     // Create a clone of this inline.
-    RenderInline* cloneInline = clone();
+    RenderPtr<RenderInline> cloneInline = clone();
     cloneInline->setContinuation(oldCont);
 
 #if ENABLE(FULLSCREEN_API)
@@ -369,7 +369,7 @@ void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock,
     }
 
     // Hook |clone| up as the continuation of the middle block.
-    middleBlock->setContinuation(cloneInline);
+    middleBlock->setContinuation(cloneInline.get());
 
     // We have been reparented and are now under the fromBlock.  We need
     // to walk up our inline parent chain until we hit the containing block.
@@ -387,16 +387,16 @@ void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock,
         ASSERT(curr->isRenderInline());
         if (splitDepth < cMaxSplitDepth) {
             // Create a new clone.
-            RenderInline* cloneChild = cloneInline;
+            RenderPtr<RenderInline> cloneChild = std::move(cloneInline);
             cloneInline = toRenderInline(curr)->clone();
 
             // Insert our child clone as the first child.
-            cloneInline->addChildIgnoringContinuation(cloneChild, 0);
+            cloneInline->addChildIgnoringContinuation(cloneChild.leakPtr(), 0);
 
             // Hook the clone up as a continuation of |curr|.
             RenderInline* inlineCurr = toRenderInline(curr);
             oldCont = inlineCurr->continuation();
-            inlineCurr->setContinuation(cloneInline);
+            inlineCurr->setContinuation(cloneInline.get());
             cloneInline->setContinuation(oldCont);
 
             // Now we need to take all of the children starting from the first child
@@ -418,7 +418,7 @@ void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock,
     }
 
     // Now we are at the block level. We need to put the clone into the toBlock.
-    toBlock->insertChildInternal(cloneInline, nullptr, NotifyChildren);
+    toBlock->insertChildInternal(cloneInline.leakPtr(), nullptr, NotifyChildren);
 
     // Now take all the children after currChild and remove them from the fromBlock
     // and put them in the toBlock.
index 63d1cedd8a0e3c1a86edec31a63609a90b6ea338..26fbdb2bc9c16b28f159f1bc1890568433d83bb1 100644 (file)
@@ -169,7 +169,7 @@ private:
     
     virtual void updateFromStyle() OVERRIDE FINAL;
     
-    RenderInline* clone() const;
+    RenderPtr<RenderInline> clone() const;
 
     void paintOutlineForLine(GraphicsContext*, const LayoutPoint&, const LayoutRect& prevLine, const LayoutRect& thisLine,
                              const LayoutRect& nextLine, const Color);