Deploy RenderPtr in RenderMathMLOperator::updateFromElement().
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Jan 2014 15:43:52 +0000 (15:43 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Jan 2014 15:43:52 +0000 (15:43 +0000)
<https://webkit.org/b/126628>

Reviewed by Antti Koivisto.

* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::updateFromElement):

    Use RenderPtr/createRenderer for renderer creation.
    Removed an unnecessary null check (text is always created.)
    Also use RenderStyle::createAnonymousStyleWithDisplay()
    helper to shorten down the code a bit.

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

index 9a947607fa14f6ca3d37647d2520548d4582dcc9..3a22a8b34f4fef7d7d49b5567dcf88ae770e2454 100644 (file)
@@ -1,3 +1,18 @@
+2014-01-08  Andreas Kling  <akling@apple.com>
+
+        Deploy RenderPtr in RenderMathMLOperator::updateFromElement().
+        <https://webkit.org/b/126628>
+
+        Reviewed by Antti Koivisto.
+
+        * rendering/mathml/RenderMathMLOperator.cpp:
+        (WebCore::RenderMathMLOperator::updateFromElement):
+
+            Use RenderPtr/createRenderer for renderer creation.
+            Removed an unnecessary null check (text is always created.)
+            Also use RenderStyle::createAnonymousStyleWithDisplay()
+            helper to shorten down the code a bit.
+
 2014-01-08  Alberto Garcia  <berto@igalia.com>
 
         Fix some compilation warnings
index aadf1842c5664517bc613378c1ba8897f20a0b77..1744f2283c513e68198c70a26928bcf873cd2e9a 100644 (file)
@@ -172,26 +172,20 @@ void RenderMathMLOperator::updateFromElement()
     // Since we share a node with our children, destroying our children may set our node's
     // renderer to 0, so we need to restore it.
     element().setRenderer(savedRenderer);
-    
-    auto newStyle = RenderStyle::create();
-    newStyle.get().inheritFrom(&style());
-    newStyle.get().setDisplay(FLEX);
 
-    RenderMathMLBlock* container = new RenderMathMLBlock(element(), std::move(newStyle));
+    RenderPtr<RenderMathMLBlock> container = createRenderer<RenderMathMLBlock>(element(), RenderStyle::createAnonymousStyleWithDisplay(&style(), FLEX));
     // This container doesn't offer any useful information to accessibility.
     container->setIgnoreInAccessibilityTree(true);
     container->initializeStyle();
 
-    addChild(container);
-    RenderText* text;
+    RenderPtr<RenderText> text;
     if (m_operator)
-        text = new RenderText(document(), String(&m_operator, 1));
+        text = createRenderer<RenderText>(document(), String(&m_operator, 1));
     else
-        text = new RenderText(document(), element().textContent().replace(hyphenMinus, minusSign).impl());
+        text = createRenderer<RenderText>(document(), element().textContent().replace(hyphenMinus, minusSign).impl());
 
-    // If we can't figure out the text, leave it blank.
-    if (text)
-        container->addChild(text);
+    container->addChild(text.leakPtr());
+    addChild(container.leakPtr());
 
     updateStyle();
     setNeedsLayoutAndPrefWidthsRecalc();