Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "core/dom/MutationObserverRegistration.h" | 33 #include "core/dom/MutationObserverRegistration.h" |
| 34 | 34 |
| 35 #include "core/dom/Node.h" | 35 #include "core/dom/Node.h" |
| 36 #include "core/dom/QualifiedName.h" | 36 #include "core/dom/QualifiedName.h" |
| 37 | 37 |
| 38 namespace WebCore { | 38 namespace WebCore { |
| 39 | 39 |
| 40 PassOwnPtr<MutationObserverRegistration> MutationObserverRegistration::create(Mu tationObserver& observer, Node& registrationNode, MutationObserverOptions option s, const HashSet<AtomicString>& attributeFilter) | 40 PassOwnPtrWillBeRawPtr<MutationObserverRegistration> MutationObserverRegistratio n::create(MutationObserver& observer, Node& registrationNode, MutationObserverOp tions options, const HashSet<AtomicString>& attributeFilter) |
| 41 { | 41 { |
| 42 return adoptPtr(new MutationObserverRegistration(observer, registrationNode, options, attributeFilter)); | 42 return adoptPtrWillBeNoop(new MutationObserverRegistration(observer, registr ationNode, options, attributeFilter)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 MutationObserverRegistration::MutationObserverRegistration(MutationObserver& obs erver, Node& registrationNode, MutationObserverOptions options, const HashSet<At omicString>& attributeFilter) | 45 MutationObserverRegistration::MutationObserverRegistration(MutationObserver& obs erver, Node& registrationNode, MutationObserverOptions options, const HashSet<At omicString>& attributeFilter) |
| 46 : m_observer(observer) | 46 : m_observer(observer) |
| 47 , m_registrationNode(registrationNode) | 47 , m_registrationNode(registrationNode) |
| 48 , m_options(options) | 48 , m_options(options) |
| 49 , m_attributeFilter(attributeFilter) | 49 , m_attributeFilter(attributeFilter) |
| 50 { | 50 { |
| 51 m_observer->observationStarted(this); | 51 m_observer->observationStarted(this); |
| 52 } | 52 } |
| 53 | 53 |
| 54 MutationObserverRegistration::~MutationObserverRegistration() | 54 MutationObserverRegistration::~MutationObserverRegistration() |
| 55 { | 55 { |
| 56 #if ENABLE(OILPAN) | |
| 57 // dispose() will not have been called if this assert | |
| 58 // triggers. | |
| 59 ASSERT(!m_observer); | |
| 60 #else | |
| 61 dispose(); | |
| 62 #endif | |
|
haraken
2014/04/21 06:00:34
As I commented previously, would it be possible to
sof
2014/04/21 07:34:05
I can remove it, but why is the assert harmful to
haraken
2014/04/21 07:41:31
I'm not concerned about having the assert. My poin
sof
2014/04/21 12:45:16
ok, I've switched to explicit dispose()s for the n
| |
| 63 } | |
| 64 | |
| 65 void MutationObserverRegistration::dispose() | |
| 66 { | |
| 56 clearTransientRegistrations(); | 67 clearTransientRegistrations(); |
| 57 m_observer->observationEnded(this); | 68 m_observer->observationEnded(this); |
| 69 m_observer.clear(); | |
|
haraken
2014/04/21 06:00:34
Shall we also clear m_registrationNode in dispose(
sof
2014/04/21 12:45:16
m_registrationNode was left as a reference, as tha
| |
| 58 } | 70 } |
| 59 | 71 |
| 60 void MutationObserverRegistration::resetObservation(MutationObserverOptions opti ons, const HashSet<AtomicString>& attributeFilter) | 72 void MutationObserverRegistration::resetObservation(MutationObserverOptions opti ons, const HashSet<AtomicString>& attributeFilter) |
| 61 { | 73 { |
| 62 clearTransientRegistrations(); | 74 clearTransientRegistrations(); |
| 63 m_options = options; | 75 m_options = options; |
| 64 m_attributeFilter = attributeFilter; | 76 m_attributeFilter = attributeFilter; |
| 65 } | 77 } |
| 66 | 78 |
| 67 void MutationObserverRegistration::observedSubtreeNodeWillDetach(Node& node) | 79 void MutationObserverRegistration::observedSubtreeNodeWillDetach(Node& node) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 | 135 |
| 124 void MutationObserverRegistration::addRegistrationNodesToSet(HashSet<Node*>& nod es) const | 136 void MutationObserverRegistration::addRegistrationNodesToSet(HashSet<Node*>& nod es) const |
| 125 { | 137 { |
| 126 nodes.add(&m_registrationNode); | 138 nodes.add(&m_registrationNode); |
| 127 if (!m_transientRegistrationNodes) | 139 if (!m_transientRegistrationNodes) |
| 128 return; | 140 return; |
| 129 for (NodeHashSet::const_iterator iter = m_transientRegistrationNodes->begin( ); iter != m_transientRegistrationNodes->end(); ++iter) | 141 for (NodeHashSet::const_iterator iter = m_transientRegistrationNodes->begin( ); iter != m_transientRegistrationNodes->end(); ++iter) |
| 130 nodes.add(iter->get()); | 142 nodes.add(iter->get()); |
| 131 } | 143 } |
| 132 | 144 |
| 145 void MutationObserverRegistration::trace(Visitor* visitor) | |
| 146 { | |
| 147 visitor->trace(m_observer); | |
| 148 } | |
| 149 | |
| 133 } // namespace WebCore | 150 } // namespace WebCore |
| OLD | NEW |