| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/dom/MutationObserverRegistration.h" | 31 #include "core/dom/MutationObserverRegistration.h" |
| 32 | 32 |
| 33 #include "core/dom/Node.h" | 33 #include "core/dom/Node.h" |
| 34 #include "core/dom/QualifiedName.h" | 34 #include "core/dom/QualifiedName.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 PassOwnPtrWillBeRawPtr<MutationObserverRegistration> MutationObserverRegistratio
n::create(MutationObserver& observer, Node* registrationNode, MutationObserverOp
tions options, const HashSet<AtomicString>& attributeFilter) | 38 RawPtr<MutationObserverRegistration> MutationObserverRegistration::create(Mutati
onObserver& observer, Node* registrationNode, MutationObserverOptions options, c
onst HashSet<AtomicString>& attributeFilter) |
| 39 { | 39 { |
| 40 return adoptPtrWillBeNoop(new MutationObserverRegistration(observer, registr
ationNode, options, attributeFilter)); | 40 return new MutationObserverRegistration(observer, registrationNode, options,
attributeFilter); |
| 41 } | 41 } |
| 42 | 42 |
| 43 MutationObserverRegistration::MutationObserverRegistration(MutationObserver& obs
erver, Node* registrationNode, MutationObserverOptions options, const HashSet<At
omicString>& attributeFilter) | 43 MutationObserverRegistration::MutationObserverRegistration(MutationObserver& obs
erver, Node* registrationNode, MutationObserverOptions options, const HashSet<At
omicString>& attributeFilter) |
| 44 : m_observer(observer) | 44 : m_observer(observer) |
| 45 , m_registrationNode(registrationNode) | 45 , m_registrationNode(registrationNode) |
| 46 , m_options(options) | 46 , m_options(options) |
| 47 , m_attributeFilter(attributeFilter) | 47 , m_attributeFilter(attributeFilter) |
| 48 { | 48 { |
| 49 m_observer->observationStarted(this); | 49 m_observer->observationStarted(this); |
| 50 } | 50 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 76 return; | 76 return; |
| 77 | 77 |
| 78 node.registerTransientMutationObserver(this); | 78 node.registerTransientMutationObserver(this); |
| 79 m_observer->setHasTransientRegistration(); | 79 m_observer->setHasTransientRegistration(); |
| 80 | 80 |
| 81 if (!m_transientRegistrationNodes) { | 81 if (!m_transientRegistrationNodes) { |
| 82 m_transientRegistrationNodes = adoptPtrWillBeNoop(new NodeHashSet); | 82 m_transientRegistrationNodes = adoptPtrWillBeNoop(new NodeHashSet); |
| 83 | 83 |
| 84 ASSERT(m_registrationNode); | 84 ASSERT(m_registrationNode); |
| 85 ASSERT(!m_registrationNodeKeepAlive); | 85 ASSERT(!m_registrationNodeKeepAlive); |
| 86 m_registrationNodeKeepAlive = PassRefPtrWillBeRawPtr<Node>(m_registratio
nNode.get()); // Balanced in clearTransientRegistrations. | 86 m_registrationNodeKeepAlive = RawPtr<Node>(m_registrationNode.get()); //
Balanced in clearTransientRegistrations. |
| 87 } | 87 } |
| 88 m_transientRegistrationNodes->add(&node); | 88 m_transientRegistrationNodes->add(&node); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void MutationObserverRegistration::clearTransientRegistrations() | 91 void MutationObserverRegistration::clearTransientRegistrations() |
| 92 { | 92 { |
| 93 if (!m_transientRegistrationNodes) { | 93 if (!m_transientRegistrationNodes) { |
| 94 ASSERT(!m_registrationNodeKeepAlive); | 94 ASSERT(!m_registrationNodeKeepAlive); |
| 95 return; | 95 return; |
| 96 } | 96 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 122 | 122 |
| 123 if (type != MutationObserver::Attributes || !(m_options & MutationObserver::
AttributeFilter)) | 123 if (type != MutationObserver::Attributes || !(m_options & MutationObserver::
AttributeFilter)) |
| 124 return true; | 124 return true; |
| 125 | 125 |
| 126 if (!attributeName->namespaceURI().isNull()) | 126 if (!attributeName->namespaceURI().isNull()) |
| 127 return false; | 127 return false; |
| 128 | 128 |
| 129 return m_attributeFilter.contains(attributeName->localName()); | 129 return m_attributeFilter.contains(attributeName->localName()); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void MutationObserverRegistration::addRegistrationNodesToSet(WillBeHeapHashSet<R
awPtrWillBeMember<Node>>& nodes) const | 132 void MutationObserverRegistration::addRegistrationNodesToSet(HeapHashSet<Member<
Node>>& nodes) const |
| 133 { | 133 { |
| 134 ASSERT(m_registrationNode); | 134 ASSERT(m_registrationNode); |
| 135 nodes.add(m_registrationNode.get()); | 135 nodes.add(m_registrationNode.get()); |
| 136 if (!m_transientRegistrationNodes) | 136 if (!m_transientRegistrationNodes) |
| 137 return; | 137 return; |
| 138 for (NodeHashSet::const_iterator iter = m_transientRegistrationNodes->begin(
); iter != m_transientRegistrationNodes->end(); ++iter) | 138 for (NodeHashSet::const_iterator iter = m_transientRegistrationNodes->begin(
); iter != m_transientRegistrationNodes->end(); ++iter) |
| 139 nodes.add(iter->get()); | 139 nodes.add(iter->get()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 DEFINE_TRACE(MutationObserverRegistration) | 142 DEFINE_TRACE(MutationObserverRegistration) |
| 143 { | 143 { |
| 144 visitor->trace(m_observer); | 144 visitor->trace(m_observer); |
| 145 visitor->trace(m_registrationNode); | 145 visitor->trace(m_registrationNode); |
| 146 visitor->trace(m_registrationNodeKeepAlive); | 146 visitor->trace(m_registrationNodeKeepAlive); |
| 147 #if ENABLE(OILPAN) | 147 #if ENABLE(OILPAN) |
| 148 visitor->trace(m_transientRegistrationNodes); | 148 visitor->trace(m_transientRegistrationNodes); |
| 149 #endif | 149 #endif |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace blink | 152 } // namespace blink |
| OLD | NEW |