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

Side by Side Diff: third_party/WebKit/Source/core/dom/MutationObserverRegistration.cpp

Issue 1854423002: ASSERT -> {DCHECK|DCHECK_XX}, ENABLE(ASSERT) -> DCHECK_IS_ON() in dom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark svg/as-image/svg-nested.html crash on win Created 4 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 { 74 {
75 if (!isSubtree()) 75 if (!isSubtree())
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 = new NodeHashSet; 82 m_transientRegistrationNodes = new NodeHashSet;
83 83
84 ASSERT(m_registrationNode); 84 DCHECK(m_registrationNode);
85 ASSERT(!m_registrationNodeKeepAlive); 85 DCHECK(!m_registrationNodeKeepAlive);
86 m_registrationNodeKeepAlive = RawPtr<Node>(m_registrationNode.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 DCHECK(!m_registrationNodeKeepAlive);
95 return; 95 return;
96 } 96 }
97 97
98 for (auto& node : *m_transientRegistrationNodes) 98 for (auto& node : *m_transientRegistrationNodes)
99 node->unregisterTransientMutationObserver(this); 99 node->unregisterTransientMutationObserver(this);
100 100
101 m_transientRegistrationNodes.clear(); 101 m_transientRegistrationNodes.clear();
102 102
103 ASSERT(m_registrationNodeKeepAlive); 103 DCHECK(m_registrationNodeKeepAlive);
104 m_registrationNodeKeepAlive = nullptr; // Balanced in observeSubtreeNodeWill Detach. 104 m_registrationNodeKeepAlive = nullptr; // Balanced in observeSubtreeNodeWill Detach.
105 } 105 }
106 106
107 void MutationObserverRegistration::unregister() 107 void MutationObserverRegistration::unregister()
108 { 108 {
109 ASSERT(m_registrationNode); 109 DCHECK(m_registrationNode);
110 m_registrationNode->unregisterMutationObserver(this); 110 m_registrationNode->unregisterMutationObserver(this);
111 // The above line will cause this object to be deleted, so don't do any more in this function. 111 // The above line will cause this object to be deleted, so don't do any more in this function.
112 } 112 }
113 113
114 bool MutationObserverRegistration::shouldReceiveMutationFrom(Node& node, Mutatio nObserver::MutationType type, const QualifiedName* attributeName) const 114 bool MutationObserverRegistration::shouldReceiveMutationFrom(Node& node, Mutatio nObserver::MutationType type, const QualifiedName* attributeName) const
115 { 115 {
116 ASSERT((type == MutationObserver::Attributes && attributeName) || !attribute Name); 116 DCHECK((type == MutationObserver::Attributes && attributeName) || !attribute Name);
117 if (!(m_options & type)) 117 if (!(m_options & type))
118 return false; 118 return false;
119 119
120 if (m_registrationNode != &node && !isSubtree()) 120 if (m_registrationNode != &node && !isSubtree())
121 return false; 121 return false;
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(HeapHashSet<Member< Node>>& nodes) const 132 void MutationObserverRegistration::addRegistrationNodesToSet(HeapHashSet<Member< Node>>& nodes) const
133 { 133 {
134 ASSERT(m_registrationNode); 134 DCHECK(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 visitor->trace(m_transientRegistrationNodes); 147 visitor->trace(m_transientRegistrationNodes);
148 } 148 }
149 149
150 } // namespace blink 150 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698