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 // The observer is heap allocated, and cannot be accessed. | |
| 58 // | |
| 59 // So should an observer still have this object in its | |
| 60 // list of registrations, and that observer lives beyond | |
| 61 // the current sweep, this dead registration object might | |
| 62 // be attempted accessed. Hence, insist that all | |
| 63 // MutationObserverRegistration objects are explicitly | |
| 64 // dispose()d before being let go of. | |
| 65 ASSERT(!m_observer); | |
| 66 #endif | |
| 67 dispose(); | |
| 68 } | |
| 69 | |
| 70 void MutationObserverRegistration::dispose() | |
| 71 { | |
| 56 clearTransientRegistrations(); | 72 clearTransientRegistrations(); |
| 57 m_observer->observationEnded(this); | 73 if (m_observer) { |
| 74 m_observer->observationEnded(this); | |
|
haraken
2014/04/15 02:33:25
If you make MutationObserver::m_registration a has
| |
| 75 m_observer.clear(); | |
| 76 } | |
| 58 } | 77 } |
| 59 | 78 |
| 60 void MutationObserverRegistration::resetObservation(MutationObserverOptions opti ons, const HashSet<AtomicString>& attributeFilter) | 79 void MutationObserverRegistration::resetObservation(MutationObserverOptions opti ons, const HashSet<AtomicString>& attributeFilter) |
| 61 { | 80 { |
| 62 clearTransientRegistrations(); | 81 clearTransientRegistrations(); |
| 63 m_options = options; | 82 m_options = options; |
| 64 m_attributeFilter = attributeFilter; | 83 m_attributeFilter = attributeFilter; |
| 65 } | 84 } |
| 66 | 85 |
| 67 void MutationObserverRegistration::observedSubtreeNodeWillDetach(Node& node) | 86 void MutationObserverRegistration::observedSubtreeNodeWillDetach(Node& node) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 | 142 |
| 124 void MutationObserverRegistration::addRegistrationNodesToSet(HashSet<Node*>& nod es) const | 143 void MutationObserverRegistration::addRegistrationNodesToSet(HashSet<Node*>& nod es) const |
| 125 { | 144 { |
| 126 nodes.add(&m_registrationNode); | 145 nodes.add(&m_registrationNode); |
| 127 if (!m_transientRegistrationNodes) | 146 if (!m_transientRegistrationNodes) |
| 128 return; | 147 return; |
| 129 for (NodeHashSet::const_iterator iter = m_transientRegistrationNodes->begin( ); iter != m_transientRegistrationNodes->end(); ++iter) | 148 for (NodeHashSet::const_iterator iter = m_transientRegistrationNodes->begin( ); iter != m_transientRegistrationNodes->end(); ++iter) |
| 130 nodes.add(iter->get()); | 149 nodes.add(iter->get()); |
| 131 } | 150 } |
| 132 | 151 |
| 152 void MutationObserverRegistration::trace(Visitor* visitor) | |
| 153 { | |
| 154 visitor->trace(m_observer); | |
| 155 } | |
| 156 | |
| 133 } // namespace WebCore | 157 } // namespace WebCore |
| OLD | NEW |