createMathMLOperator() should return RenderPtr.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Jan 2014 09:47:59 +0000 (09:47 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Jan 2014 09:47:59 +0000 (09:47 +0000)
<https://webkit.org/b/126622>

Reviewed by Antti Koivisto.

* rendering/mathml/RenderMathMLFenced.h:
* rendering/mathml/RenderMathMLFenced.cpp:
(WebCore::RenderMathMLFenced::createMathMLOperator):

    Make this return a RenderPtr<RenderMathMLOperator>.

(WebCore::RenderMathMLFenced::makeFences):
(WebCore::RenderMathMLFenced::addChild):

    Updated for the new createMathMLOperator() signature.

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp
Source/WebCore/rendering/mathml/RenderMathMLFenced.h

index 9954c52d774f8f1f2995717de1775a9a369efa7d..00befe119228ef878f109c0c9c8587270c47df11 100644 (file)
@@ -1,3 +1,21 @@
+2014-01-08  Andreas Kling  <akling@apple.com>
+
+        createMathMLOperator() should return RenderPtr.
+        <https://webkit.org/b/126622>
+
+        Reviewed by Antti Koivisto.
+
+        * rendering/mathml/RenderMathMLFenced.h:
+        * rendering/mathml/RenderMathMLFenced.cpp:
+        (WebCore::RenderMathMLFenced::createMathMLOperator):
+
+            Make this return a RenderPtr<RenderMathMLOperator>.
+
+        (WebCore::RenderMathMLFenced::makeFences):
+        (WebCore::RenderMathMLFenced::addChild):
+
+            Updated for the new createMathMLOperator() signature.
+
 2014-01-07  Antti Koivisto  <antti@apple.com>
 
         REGRESSION (r161195): Acid2 regression tests frequently fail
index 511c641cbd6ed591f2e71239d434c2c425177d94..2e009ae5947f6979c153fef4aec8dc150f0e5d58 100644 (file)
@@ -82,14 +82,14 @@ void RenderMathMLFenced::updateFromElement()
         makeFences();
 }
 
-RenderMathMLOperator* RenderMathMLFenced::createMathMLOperator(UChar uChar, RenderMathMLOperator::OperatorType operatorType)
+RenderPtr<RenderMathMLOperator> RenderMathMLFenced::createMathMLOperator(UChar uChar, RenderMathMLOperator::OperatorType operatorType)
 {
     auto newStyle = RenderStyle::createAnonymousStyleWithDisplay(&style(), FLEX);
     newStyle.get().setFlexDirection(FlowColumn);
     newStyle.get().setMarginEnd(Length((operatorType == RenderMathMLOperator::Fence ? gFenceMarginEms : gSeparatorMarginEndEms) * style().fontSize(), Fixed));
     if (operatorType == RenderMathMLOperator::Fence)
         newStyle.get().setMarginStart(Length(gFenceMarginEms * style().fontSize(), Fixed));
-    RenderMathMLOperator* newOperator = new RenderMathMLOperator(element(), std::move(newStyle), uChar);
+    RenderPtr<RenderMathMLOperator> newOperator = createRenderer<RenderMathMLOperator>(element(), std::move(newStyle), uChar);
     newOperator->setOperatorType(operatorType);
     newOperator->initializeStyle();
     return newOperator;
@@ -97,11 +97,15 @@ RenderMathMLOperator* RenderMathMLFenced::createMathMLOperator(UChar uChar, Rend
 
 void RenderMathMLFenced::makeFences()
 {
-    RenderMathMLOperator* openFence = createMathMLOperator(m_open, RenderMathMLOperator::Fence);
-    RenderMathMLRow::addChild(openFence, firstChild());
-    m_closeFenceRenderer = createMathMLOperator(m_close, RenderMathMLOperator::Fence);
-    RenderMathMLRow::addChild(m_closeFenceRenderer);
-    openFence->updateFromElement();
+    RenderPtr<RenderMathMLOperator> openFence = createMathMLOperator(m_open, RenderMathMLOperator::Fence);
+    RenderMathMLOperator* openFencePtr = openFence.get();
+    RenderMathMLRow::addChild(openFence.leakPtr(), firstChild());
+
+    RenderPtr<RenderMathMLOperator> closeFence = createMathMLOperator(m_close, RenderMathMLOperator::Fence);
+    m_closeFenceRenderer = closeFence.get();
+    RenderMathMLRow::addChild(closeFence.leakPtr());
+
+    openFencePtr->updateFromElement();
     m_closeFenceRenderer->updateFromElement();
 }
 
@@ -114,7 +118,7 @@ void RenderMathMLFenced::addChild(RenderObject* child, RenderObject* beforeChild
     // FIXME: Adding or removing a child should possibly cause all later separators to shift places if they're different,
     // as later child positions change by +1 or -1.
     
-    RenderMathMLOperator* separatorRenderer = nullptr;
+    RenderPtr<RenderMathMLOperator> separatorRenderer;
     if (m_separators.get()) {
         unsigned int count = 0;
         for (Node* position = child->node(); position; position = position->previousSibling()) {
@@ -144,11 +148,11 @@ void RenderMathMLFenced::addChild(RenderObject* child, RenderObject* beforeChild
         // Adding |x| before an existing |y| e.g. in element (y) - first insert our new child |x|, then its separator, to get (x, y).
         RenderMathMLRow::addChild(child, beforeChild);
         if (separatorRenderer)
-            RenderMathMLRow::addChild(separatorRenderer, beforeChild);
+            RenderMathMLRow::addChild(separatorRenderer.leakPtr(), beforeChild);
     } else {
         // Adding |y| at the end of an existing element e.g. (x) - insert the separator first before the closing fence, then |y|, to get (x, y).
         if (separatorRenderer)
-            RenderMathMLRow::addChild(separatorRenderer, m_closeFenceRenderer);
+            RenderMathMLRow::addChild(separatorRenderer.leakPtr(), m_closeFenceRenderer);
         RenderMathMLRow::addChild(child, m_closeFenceRenderer);
     }
 }
index 737ea5eb535d8d9b40c33ceb0f9e32bbb54cc307..e3fc775e44fc8ed61cd84734004afb9a9a434ad4 100644 (file)
@@ -47,7 +47,7 @@ private:
 
     virtual void updateFromElement() OVERRIDE;
 
-    RenderMathMLOperator* createMathMLOperator(UChar, RenderMathMLOperator::OperatorType);
+    RenderPtr<RenderMathMLOperator> createMathMLOperator(UChar, RenderMathMLOperator::OperatorType);
     void makeFences();
 
     UChar m_open;