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

Side by Side Diff: Source/core/dom/MutationObserverInterestGroup.cpp

Issue 236653002: Oilpan: move mutation observers to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased + explicitly dispose() mutation observer registrations always (non-Oilpan also.) Created 6 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 32
33 #include "core/dom/MutationObserverInterestGroup.h" 33 #include "core/dom/MutationObserverInterestGroup.h"
34 34
35 #include "core/dom/MutationRecord.h" 35 #include "core/dom/MutationRecord.h"
36 36
37 namespace WebCore { 37 namespace WebCore {
38 38
39 PassOwnPtr<MutationObserverInterestGroup> MutationObserverInterestGroup::createI fNeeded(Node& target, MutationObserver::MutationType type, MutationRecordDeliver yOptions oldValueFlag, const QualifiedName* attributeName) 39 PassOwnPtrWillBeRawPtr<MutationObserverInterestGroup> MutationObserverInterestGr oup::createIfNeeded(Node& target, MutationObserver::MutationType type, MutationR ecordDeliveryOptions oldValueFlag, const QualifiedName* attributeName)
40 { 40 {
41 ASSERT((type == MutationObserver::Attributes && attributeName) || !attribute Name); 41 ASSERT((type == MutationObserver::Attributes && attributeName) || !attribute Name);
42 HashMap<MutationObserver*, MutationRecordDeliveryOptions> observers; 42 WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, MutationRecordDelive ryOptions> observers;
43 target.getRegisteredMutationObserversOfType(observers, type, attributeName); 43 target.getRegisteredMutationObserversOfType(observers, type, attributeName);
44 if (observers.isEmpty()) 44 if (observers.isEmpty())
45 return nullptr; 45 return nullptr;
46 46
47 return adoptPtr(new MutationObserverInterestGroup(observers, oldValueFlag)); 47 return adoptPtrWillBeNoop(new MutationObserverInterestGroup(observers, oldVa lueFlag));
48 } 48 }
49 49
50 MutationObserverInterestGroup::MutationObserverInterestGroup(HashMap<MutationObs erver*, MutationRecordDeliveryOptions>& observers, MutationRecordDeliveryOptions oldValueFlag) 50 MutationObserverInterestGroup::MutationObserverInterestGroup(WillBeHeapHashMap<R awPtrWillBeMember<MutationObserver>, MutationRecordDeliveryOptions>& observers, MutationRecordDeliveryOptions oldValueFlag)
51 : m_oldValueFlag(oldValueFlag) 51 : m_oldValueFlag(oldValueFlag)
52 { 52 {
53 ASSERT(!observers.isEmpty()); 53 ASSERT(!observers.isEmpty());
54 m_observers.swap(observers); 54 m_observers.swap(observers);
55 } 55 }
56 56
57 bool MutationObserverInterestGroup::isOldValueRequested() 57 bool MutationObserverInterestGroup::isOldValueRequested()
58 { 58 {
59 for (HashMap<MutationObserver*, MutationRecordDeliveryOptions>::iterator ite r = m_observers.begin(); iter != m_observers.end(); ++iter) { 59 for (WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, MutationRecordD eliveryOptions>::iterator iter = m_observers.begin(); iter != m_observers.end(); ++iter) {
60 if (hasOldValue(iter->value)) 60 if (hasOldValue(iter->value))
61 return true; 61 return true;
62 } 62 }
63 return false; 63 return false;
64 } 64 }
65 65
66 void MutationObserverInterestGroup::enqueueMutationRecord(PassRefPtr<MutationRec ord> prpMutation) 66 void MutationObserverInterestGroup::enqueueMutationRecord(PassRefPtrWillBeRawPtr <MutationRecord> prpMutation)
67 { 67 {
68 RefPtr<MutationRecord> mutation = prpMutation; 68 RefPtrWillBeRawPtr<MutationRecord> mutation = prpMutation;
69 RefPtr<MutationRecord> mutationWithNullOldValue; 69 RefPtrWillBeRawPtr<MutationRecord> mutationWithNullOldValue = nullptr;
70 for (HashMap<MutationObserver*, MutationRecordDeliveryOptions>::iterator ite r = m_observers.begin(); iter != m_observers.end(); ++iter) { 70 for (WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, MutationRecordD eliveryOptions>::iterator iter = m_observers.begin(); iter != m_observers.end(); ++iter) {
71 MutationObserver* observer = iter->key; 71 MutationObserver* observer = iter->key;
72 if (hasOldValue(iter->value)) { 72 if (hasOldValue(iter->value)) {
73 observer->enqueueMutationRecord(mutation); 73 observer->enqueueMutationRecord(mutation);
74 continue; 74 continue;
75 } 75 }
76 if (!mutationWithNullOldValue) { 76 if (!mutationWithNullOldValue) {
77 if (mutation->oldValue().isNull()) 77 if (mutation->oldValue().isNull())
78 mutationWithNullOldValue = mutation; 78 mutationWithNullOldValue = mutation;
79 else 79 else
80 mutationWithNullOldValue = MutationRecord::createWithNullOldValu e(mutation).get(); 80 mutationWithNullOldValue = MutationRecord::createWithNullOldValu e(mutation).get();
81 } 81 }
82 observer->enqueueMutationRecord(mutationWithNullOldValue); 82 observer->enqueueMutationRecord(mutationWithNullOldValue);
83 } 83 }
84 } 84 }
85 85
86 void MutationObserverInterestGroup::trace(Visitor* visitor)
87 {
88 visitor->trace(m_observers);
89 }
90
86 } // namespace WebCore 91 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698