Title: [222814] trunk/Source/WebCore
Revision
222814
Author
za...@apple.com
Date
2017-10-03 15:39:49 -0700 (Tue, 03 Oct 2017)

Log Message

RenderMenuList should not hold raw pointers
https://bugs.webkit.org/show_bug.cgi?id=177836

Reviewed by Antti Koivisto.

While both m_buttonText and m_innerBlock are child renderers of
the RenderMenuList, so the their lifecycles are supposed to tied
to the parent object, this patch removes some manual raw pointer managing.

Covered by existing tests.

* rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::RenderMenuList):
(WebCore::RenderMenuList::createInnerBlock):
(RenderMenuList::takeChild):
(RenderMenuList::setText):
* rendering/RenderMenuList.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (222813 => 222814)


--- trunk/Source/WebCore/ChangeLog	2017-10-03 22:12:37 UTC (rev 222813)
+++ trunk/Source/WebCore/ChangeLog	2017-10-03 22:39:49 UTC (rev 222814)
@@ -1,3 +1,23 @@
+2017-10-03  Zalan Bujtas  <za...@apple.com>
+
+        RenderMenuList should not hold raw pointers
+        https://bugs.webkit.org/show_bug.cgi?id=177836
+
+        Reviewed by Antti Koivisto.
+
+        While both m_buttonText and m_innerBlock are child renderers of
+        the RenderMenuList, so the their lifecycles are supposed to tied
+        to the parent object, this patch removes some manual raw pointer managing.
+
+        Covered by existing tests.
+
+        * rendering/RenderMenuList.cpp:
+        (WebCore::RenderMenuList::RenderMenuList):
+        (WebCore::RenderMenuList::createInnerBlock):
+        (RenderMenuList::takeChild):
+        (RenderMenuList::setText):
+        * rendering/RenderMenuList.h:
+
 2017-10-03  Timothy Horton  <timothy_hor...@apple.com>
 
         Include a few widespread WTF headers in WebCorePrefix.h

Modified: trunk/Source/WebCore/rendering/RenderMenuList.cpp (222813 => 222814)


--- trunk/Source/WebCore/rendering/RenderMenuList.cpp	2017-10-03 22:12:37 UTC (rev 222813)
+++ trunk/Source/WebCore/rendering/RenderMenuList.cpp	2017-10-03 22:39:49 UTC (rev 222814)
@@ -71,8 +71,6 @@
 
 RenderMenuList::RenderMenuList(HTMLSelectElement& element, RenderStyle&& style)
     : RenderFlexibleBox(element, WTFMove(style))
-    , m_buttonText(nullptr)
-    , m_innerBlock(nullptr)
     , m_needsOptionsWidthUpdate(true)
     , m_optionsWidth(0)
 #if !PLATFORM(IOS)
@@ -108,7 +106,7 @@
     // Create an anonymous block.
     ASSERT(!firstChild());
     auto newInnerBlock = createAnonymousBlock();
-    m_innerBlock = newInnerBlock.get();
+    m_innerBlock = makeWeakPtr(*newInnerBlock.get());
     adjustInnerStyle();
     RenderFlexibleBox::addChild(WTFMove(newInnerBlock));
 }
@@ -185,10 +183,8 @@
 
 RenderPtr<RenderObject> RenderMenuList::takeChild(RenderObject& oldChild)
 {
-    if (&oldChild == m_innerBlock || !m_innerBlock) {
-        m_innerBlock = 0;
+    if (!m_innerBlock || &oldChild == m_innerBlock)
         return RenderFlexibleBox::takeChild(oldChild);
-    }
     return m_innerBlock->takeChild(oldChild);
 }
 
@@ -297,7 +293,7 @@
         m_buttonText->setText(textToUse.impl(), true);
     else {
         auto newButtonText = createRenderer<RenderText>(document(), textToUse);
-        m_buttonText = newButtonText.get();
+        m_buttonText = makeWeakPtr(*newButtonText);
         addChild(WTFMove(newButtonText));
     }
 

Modified: trunk/Source/WebCore/rendering/RenderMenuList.h (222813 => 222814)


--- trunk/Source/WebCore/rendering/RenderMenuList.h	2017-10-03 22:12:37 UTC (rev 222813)
+++ trunk/Source/WebCore/rendering/RenderMenuList.h	2017-10-03 22:39:49 UTC (rev 222814)
@@ -137,8 +137,8 @@
 
     bool isFlexibleBoxImpl() const override { return true; }
 
-    RenderText* m_buttonText;
-    RenderBlock* m_innerBlock;
+    WeakPtr<RenderText> m_buttonText;
+    WeakPtr<RenderBlock> m_innerBlock;
 
     bool m_needsOptionsWidthUpdate;
     int m_optionsWidth;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to