Title: [102267] trunk/Source
Revision
102267
Author
ad...@chromium.org
Date
2011-12-07 13:01:59 -0800 (Wed, 07 Dec 2011)

Log Message

Use HashMap<Node*, OwnPtr<...>> in ChildListMutationScope
https://bugs.webkit.org/show_bug.cgi?id=73964

Reviewed by Ryosuke Niwa.

Source/_javascript_Core:

* wtf/HashTraits.h: Add passOut(std::nullptr_t) to allow callers to use HashMap::take on an entry whose value is null.

Source/WebCore:

No new tests, refactoring only.

* dom/ChildListMutationScope.cpp:
(WebCore::ChildListMutationAccumulator::MutationAccumulationRouter::childAdded):
(WebCore::ChildListMutationAccumulator::MutationAccumulationRouter::willRemoveChild):
(WebCore::ChildListMutationAccumulator::MutationAccumulationRouter::incrementScopingLevel):
(WebCore::ChildListMutationAccumulator::MutationAccumulationRouter::decrementScopingLevel):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (102266 => 102267)


--- trunk/Source/_javascript_Core/ChangeLog	2011-12-07 20:59:35 UTC (rev 102266)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-12-07 21:01:59 UTC (rev 102267)
@@ -1,3 +1,12 @@
+2011-12-07  Adam Klein  <ad...@chromium.org>
+
+        Use HashMap<Node*, OwnPtr<...>> in ChildListMutationScope
+        https://bugs.webkit.org/show_bug.cgi?id=73964
+
+        Reviewed by Ryosuke Niwa.
+
+        * wtf/HashTraits.h: Add passOut(std::nullptr_t) to allow callers to use HashMap::take on an entry whose value is null.
+
 2011-12-07  Filip Pizlo  <fpi...@apple.com>
 
         Non-Mac devices should benefit from a larger heap

Modified: trunk/Source/_javascript_Core/wtf/HashTraits.h (102266 => 102267)


--- trunk/Source/_javascript_Core/wtf/HashTraits.h	2011-12-07 20:59:35 UTC (rev 102266)
+++ trunk/Source/_javascript_Core/wtf/HashTraits.h	2011-12-07 21:01:59 UTC (rev 102267)
@@ -117,6 +117,7 @@
 
         typedef PassOwnPtr<P> PassOutType;
         static PassOwnPtr<P> passOut(OwnPtr<P>& value) { return value.release(); }
+        static PassOwnPtr<P> passOut(std::nullptr_t) { return nullptr; }
 
         typedef typename OwnPtr<P>::PtrType PeekType;
         static PeekType peek(const OwnPtr<P>& value) { return value.get(); }

Modified: trunk/Source/WebCore/ChangeLog (102266 => 102267)


--- trunk/Source/WebCore/ChangeLog	2011-12-07 20:59:35 UTC (rev 102266)
+++ trunk/Source/WebCore/ChangeLog	2011-12-07 21:01:59 UTC (rev 102267)
@@ -1,3 +1,18 @@
+2011-12-07  Adam Klein  <ad...@chromium.org>
+
+        Use HashMap<Node*, OwnPtr<...>> in ChildListMutationScope
+        https://bugs.webkit.org/show_bug.cgi?id=73964
+
+        Reviewed by Ryosuke Niwa.
+
+        No new tests, refactoring only.
+
+        * dom/ChildListMutationScope.cpp:
+        (WebCore::ChildListMutationAccumulator::MutationAccumulationRouter::childAdded):
+        (WebCore::ChildListMutationAccumulator::MutationAccumulationRouter::willRemoveChild):
+        (WebCore::ChildListMutationAccumulator::MutationAccumulationRouter::incrementScopingLevel):
+        (WebCore::ChildListMutationAccumulator::MutationAccumulationRouter::decrementScopingLevel):
+
 2011-12-07  Andreas Kling  <kl...@webkit.org>
 
         RenderLayer::updateZOrderLists(): Inline early-return condition.

Modified: trunk/Source/WebCore/dom/ChildListMutationScope.cpp (102266 => 102267)


--- trunk/Source/WebCore/dom/ChildListMutationScope.cpp	2011-12-07 20:59:35 UTC (rev 102266)
+++ trunk/Source/WebCore/dom/ChildListMutationScope.cpp	2011-12-07 21:01:59 UTC (rev 102267)
@@ -40,7 +40,7 @@
 #include "Node.h"
 #include "StaticNodeList.h"
 #include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
+#include <wtf/OwnPtr.h>
 
 namespace WebCore {
 
@@ -50,7 +50,7 @@
 // and precede any additions. If this is violated (i.e. because of code changes elsewhere
 // in WebCore) it will likely result in both (a) ASSERTions failing, and (b) mutation records
 // being enqueued for delivery before the outer-most scope closes.
-class ChildListMutationAccumulator : public RefCounted<ChildListMutationAccumulator> {
+class ChildListMutationAccumulator {
     WTF_MAKE_NONCOPYABLE(ChildListMutationAccumulator);
 public:
     ChildListMutationAccumulator(PassRefPtr<Node>, PassOwnPtr<MutationObserverInterestGroup> observers);
@@ -95,7 +95,7 @@
 
     typedef HashMap<Node*, unsigned> ScopingLevelMap;
     ScopingLevelMap m_scopingLevels;
-    HashMap<Node*, RefPtr<ChildListMutationAccumulator> > m_accumulations;
+    HashMap<Node*, OwnPtr<ChildListMutationAccumulator> > m_accumulations;
 
     static MutationAccumulationRouter* s_instance;
 };
@@ -216,7 +216,7 @@
 
 void MutationAccumulationRouter::childAdded(Node* target, Node* child)
 {
-    HashMap<Node*, RefPtr<ChildListMutationAccumulator> >::iterator iter = m_accumulations.find(target);
+    HashMap<Node*, OwnPtr<ChildListMutationAccumulator> >::iterator iter = m_accumulations.find(target);
     ASSERT(iter != m_accumulations.end());
 
     if (iter->second)
@@ -225,7 +225,7 @@
 
 void MutationAccumulationRouter::willRemoveChild(Node* target, Node* child)
 {
-    HashMap<Node*, RefPtr<ChildListMutationAccumulator> >::iterator iter = m_accumulations.find(target);
+    HashMap<Node*, OwnPtr<ChildListMutationAccumulator> >::iterator iter = m_accumulations.find(target);
     ASSERT(iter != m_accumulations.end());
 
     if (iter->second)
@@ -242,9 +242,9 @@
 
     OwnPtr<MutationObserverInterestGroup> observers = MutationObserverInterestGroup::createForChildListMutation(target);
     if (observers->isEmpty())
-        m_accumulations.set(target, 0);
+        m_accumulations.set(target, nullptr);
     else
-        m_accumulations.set(target, adoptRef(new ChildListMutationAccumulator(target, observers.release())));
+        m_accumulations.set(target, adoptPtr(new ChildListMutationAccumulator(target, observers.release())));
 }
 
 void MutationAccumulationRouter::decrementScopingLevel(Node* target)
@@ -258,7 +258,7 @@
 
     m_scopingLevels.remove(iter);
 
-    RefPtr<ChildListMutationAccumulator> record = m_accumulations.take(target);
+    OwnPtr<ChildListMutationAccumulator> record = m_accumulations.take(target);
     if (record)
         record->enqueueMutationRecord();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to