Title: [164425] trunk/Source/WebCore
Revision
164425
Author
[email protected]
Date
2014-02-20 04:29:53 -0800 (Thu, 20 Feb 2014)

Log Message

Move to using std::unique_ptr for VisitedLinkState, CheckedRadioButtons
https://bugs.webkit.org/show_bug.cgi?id=128967

Reviewed by Andreas Kling.

Replace uses of OwnPtr and PassOwnPtr in the VisitedLinkState and
CheckedRadioButtons classes with std::unique_ptr.

* dom/CheckedRadioButtons.cpp:
(WebCore::RadioButtonGroup::RadioButtonGroup):
(WebCore::RadioButtonGroup::remove):
(WebCore::CheckedRadioButtons::addButton):
(WebCore::CheckedRadioButtons::removeButton):
* dom/CheckedRadioButtons.h:
* dom/Document.cpp:
(WebCore::Document::Document):
* dom/Document.h:
* dom/VisitedLinkState.cpp:
* dom/VisitedLinkState.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (164424 => 164425)


--- trunk/Source/WebCore/ChangeLog	2014-02-20 11:33:09 UTC (rev 164424)
+++ trunk/Source/WebCore/ChangeLog	2014-02-20 12:29:53 UTC (rev 164425)
@@ -1,3 +1,25 @@
+2014-02-20  Zan Dobersek  <[email protected]>
+
+        Move to using std::unique_ptr for VisitedLinkState, CheckedRadioButtons
+        https://bugs.webkit.org/show_bug.cgi?id=128967
+
+        Reviewed by Andreas Kling.
+
+        Replace uses of OwnPtr and PassOwnPtr in the VisitedLinkState and
+        CheckedRadioButtons classes with std::unique_ptr.
+
+        * dom/CheckedRadioButtons.cpp:
+        (WebCore::RadioButtonGroup::RadioButtonGroup):
+        (WebCore::RadioButtonGroup::remove):
+        (WebCore::CheckedRadioButtons::addButton):
+        (WebCore::CheckedRadioButtons::removeButton):
+        * dom/CheckedRadioButtons.h:
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        * dom/Document.h:
+        * dom/VisitedLinkState.cpp:
+        * dom/VisitedLinkState.h:
+
 2014-02-20  Artur Moryc  <[email protected]>
 
         AX: Children Nodes for Canvas objects are not equal to Render Objects.

Modified: trunk/Source/WebCore/dom/CheckedRadioButtons.cpp (164424 => 164425)


--- trunk/Source/WebCore/dom/CheckedRadioButtons.cpp	2014-02-20 11:33:09 UTC (rev 164424)
+++ trunk/Source/WebCore/dom/CheckedRadioButtons.cpp	2014-02-20 12:29:53 UTC (rev 164425)
@@ -29,7 +29,7 @@
 class RadioButtonGroup {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static PassOwnPtr<RadioButtonGroup> create();
+    RadioButtonGroup();
     bool isEmpty() const { return m_members.isEmpty(); }
     bool isRequired() const { return m_requiredCount; }
     HTMLInputElement* checkedButton() const { return m_checkedButton; }
@@ -40,7 +40,6 @@
     bool contains(HTMLInputElement*) const;
 
 private:
-    RadioButtonGroup();
     void setNeedsValidityCheckForAllButtons();
     bool isValid() const;
     void setCheckedButton(HTMLInputElement*);
@@ -51,16 +50,11 @@
 };
 
 RadioButtonGroup::RadioButtonGroup()
-    : m_checkedButton(0)
+    : m_checkedButton(nullptr)
     , m_requiredCount(0)
 {
 }
 
-PassOwnPtr<RadioButtonGroup> RadioButtonGroup::create()
-{
-    return adoptPtr(new RadioButtonGroup);
-}
-
 inline bool RadioButtonGroup::isValid() const
 {
     return !isRequired() || m_checkedButton;
@@ -140,7 +134,7 @@
         --m_requiredCount;
     }
     if (m_checkedButton == button)
-        m_checkedButton = 0;
+        m_checkedButton = nullptr;
 
     if (m_members.isEmpty()) {
         ASSERT(!m_requiredCount);
@@ -190,11 +184,11 @@
         return;
 
     if (!m_nameToGroupMap)
-        m_nameToGroupMap = adoptPtr(new NameToGroupMap);
+        m_nameToGroupMap = std::make_unique<NameToGroupMap>();
 
-    OwnPtr<RadioButtonGroup>& group = m_nameToGroupMap->add(element->name().impl(), PassOwnPtr<RadioButtonGroup>()).iterator->value;
+    auto& group = m_nameToGroupMap->add(element->name().impl(), nullptr).iterator->value;
     if (!group)
-        group = RadioButtonGroup::create();
+        group = std::make_unique<RadioButtonGroup>();
     group->add(element);
 }
 
@@ -263,7 +257,7 @@
         // of m_nameToGroupMap from AtomicStringImpl* to RefPtr<AtomicStringImpl>.
         m_nameToGroupMap->remove(it);
         if (m_nameToGroupMap->isEmpty())
-            m_nameToGroupMap.clear();
+            m_nameToGroupMap = nullptr;
     }
 }
 

Modified: trunk/Source/WebCore/dom/CheckedRadioButtons.h (164424 => 164425)


--- trunk/Source/WebCore/dom/CheckedRadioButtons.h	2014-02-20 11:33:09 UTC (rev 164424)
+++ trunk/Source/WebCore/dom/CheckedRadioButtons.h	2014-02-20 12:29:53 UTC (rev 164425)
@@ -21,9 +21,9 @@
 #ifndef CheckedRadioButtons_h
 #define CheckedRadioButtons_h
 
+#include <memory>
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
-#include <wtf/OwnPtr.h>
 
 namespace WebCore {
 
@@ -44,8 +44,8 @@
     bool isInRequiredGroup(HTMLInputElement*) const;
 
 private:
-    typedef HashMap<AtomicStringImpl*, OwnPtr<RadioButtonGroup>> NameToGroupMap;
-    OwnPtr<NameToGroupMap> m_nameToGroupMap;
+    typedef HashMap<AtomicStringImpl*, std::unique_ptr<RadioButtonGroup>> NameToGroupMap;
+    std::unique_ptr<NameToGroupMap> m_nameToGroupMap;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/Document.cpp (164424 => 164425)


--- trunk/Source/WebCore/dom/Document.cpp	2014-02-20 11:33:09 UTC (rev 164424)
+++ trunk/Source/WebCore/dom/Document.cpp	2014-02-20 12:29:53 UTC (rev 164425)
@@ -420,7 +420,7 @@
     , m_listenerTypes(0)
     , m_mutationObserverTypes(0)
     , m_styleSheetCollection(*this)
-    , m_visitedLinkState(VisitedLinkState::create(*this))
+    , m_visitedLinkState(std::make_unique<VisitedLinkState>(*this))
     , m_visuallyOrdered(false)
     , m_readyState(Complete)
     , m_bParsing(false)

Modified: trunk/Source/WebCore/dom/Document.h (164424 => 164425)


--- trunk/Source/WebCore/dom/Document.h	2014-02-20 11:33:09 UTC (rev 164424)
+++ trunk/Source/WebCore/dom/Document.h	2014-02-20 12:29:53 UTC (rev 164425)
@@ -52,6 +52,7 @@
 #include "UserActionElementSet.h"
 #include "ViewportArguments.h"
 #include <chrono>
+#include <memory>
 #include <wtf/Deque.h>
 #include <wtf/HashSet.h>
 #include <wtf/OwnPtr.h>
@@ -1424,7 +1425,7 @@
     Color m_linkColor;
     Color m_visitedLinkColor;
     Color m_activeLinkColor;
-    const OwnPtr<VisitedLinkState> m_visitedLinkState;
+    const std::unique_ptr<VisitedLinkState> m_visitedLinkState;
 
     bool m_visuallyOrdered;
     ReadyState m_readyState;

Modified: trunk/Source/WebCore/dom/VisitedLinkState.cpp (164424 => 164425)


--- trunk/Source/WebCore/dom/VisitedLinkState.cpp	2014-02-20 11:33:09 UTC (rev 164424)
+++ trunk/Source/WebCore/dom/VisitedLinkState.cpp	2014-02-20 12:29:53 UTC (rev 164425)
@@ -53,11 +53,6 @@
     return 0;
 }
 
-PassOwnPtr<VisitedLinkState> VisitedLinkState::create(Document& document)
-{
-    return adoptPtr(new VisitedLinkState(document));
-}
-
 VisitedLinkState::VisitedLinkState(Document& document)
     : m_document(document)
 {

Modified: trunk/Source/WebCore/dom/VisitedLinkState.h (164424 => 164425)


--- trunk/Source/WebCore/dom/VisitedLinkState.h	2014-02-20 11:33:09 UTC (rev 164424)
+++ trunk/Source/WebCore/dom/VisitedLinkState.h	2014-02-20 12:29:53 UTC (rev 164425)
@@ -33,7 +33,6 @@
 #include "LinkHash.h"
 #include "RenderStyleConstants.h"
 #include <wtf/HashSet.h>
-#include <wtf/OwnPtr.h>
 
 namespace WebCore {
 
@@ -42,15 +41,13 @@
 class VisitedLinkState {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static PassOwnPtr<VisitedLinkState> create(Document&);
+    explicit VisitedLinkState(Document&);
 
     void invalidateStyleForAllLinks();
     void invalidateStyleForLink(LinkHash);
     EInsideLink determineLinkState(Element*);
 
 private:
-    explicit VisitedLinkState(Document&);
-
     EInsideLink determineLinkStateSlowCase(Element&);
 
     Document& m_document;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to