Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: Source/core/dom/Node.cpp

Issue 178473026: Have MutationObserverRegistration deal with references instead of pointers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Node.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Node.cpp
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index c68b65a70962d84fb059d981da4f58dcb101cb33..bcd4ca3091f1dfe831cbe81c8a757c06a2f115c7 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -2076,7 +2076,7 @@ HashSet<MutationObserverRegistration*>* Node::transientMutationObserverRegistry(
}
template<typename Registry>
-static inline void collectMatchingObserversForMutation(HashMap<MutationObserver*, MutationRecordDeliveryOptions>& observers, Registry* registry, Node* target, MutationObserver::MutationType type, const QualifiedName* attributeName)
+static inline void collectMatchingObserversForMutation(HashMap<MutationObserver*, MutationRecordDeliveryOptions>& observers, Registry* registry, Node& target, MutationObserver::MutationType type, const QualifiedName* attributeName)
{
if (!registry)
return;
@@ -2084,7 +2084,7 @@ static inline void collectMatchingObserversForMutation(HashMap<MutationObserver*
const MutationObserverRegistration& registration = **iter;
if (registration.shouldReceiveMutationFrom(target, type, attributeName)) {
MutationRecordDeliveryOptions deliveryOptions = registration.deliveryOptions();
- HashMap<MutationObserver*, MutationRecordDeliveryOptions>::AddResult result = observers.add(registration.observer(), deliveryOptions);
+ HashMap<MutationObserver*, MutationRecordDeliveryOptions>::AddResult result = observers.add(&registration.observer(), deliveryOptions);
if (!result.isNewEntry)
result.storedValue->value |= deliveryOptions;
}
@@ -2094,27 +2094,27 @@ static inline void collectMatchingObserversForMutation(HashMap<MutationObserver*
void Node::getRegisteredMutationObserversOfType(HashMap<MutationObserver*, MutationRecordDeliveryOptions>& observers, MutationObserver::MutationType type, const QualifiedName* attributeName)
{
ASSERT((type == MutationObserver::Attributes && attributeName) || !attributeName);
- collectMatchingObserversForMutation(observers, mutationObserverRegistry(), this, type, attributeName);
- collectMatchingObserversForMutation(observers, transientMutationObserverRegistry(), this, type, attributeName);
+ collectMatchingObserversForMutation(observers, mutationObserverRegistry(), *this, type, attributeName);
+ collectMatchingObserversForMutation(observers, transientMutationObserverRegistry(), *this, type, attributeName);
for (Node* node = parentNode(); node; node = node->parentNode()) {
- collectMatchingObserversForMutation(observers, node->mutationObserverRegistry(), this, type, attributeName);
- collectMatchingObserversForMutation(observers, node->transientMutationObserverRegistry(), this, type, attributeName);
+ collectMatchingObserversForMutation(observers, node->mutationObserverRegistry(), *this, type, attributeName);
+ collectMatchingObserversForMutation(observers, node->transientMutationObserverRegistry(), *this, type, attributeName);
}
}
-void Node::registerMutationObserver(MutationObserver* observer, MutationObserverOptions options, const HashSet<AtomicString>& attributeFilter)
+void Node::registerMutationObserver(MutationObserver& observer, MutationObserverOptions options, const HashSet<AtomicString>& attributeFilter)
{
MutationObserverRegistration* registration = 0;
Vector<OwnPtr<MutationObserverRegistration> >& registry = ensureRareData().ensureMutationObserverData().registry;
for (size_t i = 0; i < registry.size(); ++i) {
- if (registry[i]->observer() == observer) {
+ if (&registry[i]->observer() == &observer) {
registration = registry[i].get();
registration->resetObservation(options, attributeFilter);
}
}
if (!registration) {
- registry.append(MutationObserverRegistration::create(observer, this, options, attributeFilter));
+ registry.append(MutationObserverRegistration::create(observer, *this, options, attributeFilter));
registration = registry.last().get();
}
@@ -2165,12 +2165,12 @@ void Node::notifyMutationObserversNodeWillDetach()
if (Vector<OwnPtr<MutationObserverRegistration> >* registry = node->mutationObserverRegistry()) {
const size_t size = registry->size();
for (size_t i = 0; i < size; ++i)
- registry->at(i)->observedSubtreeNodeWillDetach(this);
+ registry->at(i)->observedSubtreeNodeWillDetach(*this);
}
if (HashSet<MutationObserverRegistration*>* transientRegistry = node->transientMutationObserverRegistry()) {
for (HashSet<MutationObserverRegistration*>::iterator iter = transientRegistry->begin(); iter != transientRegistry->end(); ++iter)
- (*iter)->observedSubtreeNodeWillDetach(this);
+ (*iter)->observedSubtreeNodeWillDetach(*this);
}
}
}
« no previous file with comments | « Source/core/dom/Node.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698