Index: third_party/WebKit/Source/core/dom/DocumentOrderedMap.cpp |
diff --git a/third_party/WebKit/Source/core/dom/DocumentOrderedMap.cpp b/third_party/WebKit/Source/core/dom/DocumentOrderedMap.cpp |
index 85495bec18bf499bb57041f8f20c9c76053cd278..1cfba8681409fcf30a5d0d4d967b7d18e26fc905 100644 |
--- a/third_party/WebKit/Source/core/dom/DocumentOrderedMap.cpp |
+++ b/third_party/WebKit/Source/core/dom/DocumentOrderedMap.cpp |
@@ -50,9 +50,20 @@ DocumentOrderedMap::DocumentOrderedMap() |
{ |
} |
-DocumentOrderedMap::~DocumentOrderedMap() |
+DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DocumentOrderedMap); |
+ |
+#if ENABLE(ASSERT) |
+void DocumentOrderedMap::enterTreeRemoveScope() |
esprehn
2016/01/05 07:48:33
no need for the methods, put the class in Document
sof
2016/01/05 07:53:37
That's what ps#1 did, but then I got worried about
|
+{ |
+ m_treeRemovalScopeLevel++; |
+} |
+ |
+void DocumentOrderedMap::leaveTreeRemoveScope() |
{ |
+ ASSERT(m_treeRemovalScopeLevel); |
+ m_treeRemovalScopeLevel--; |
} |
+#endif |
inline bool keyMatchesId(const AtomicString& key, const Element& element) |
{ |
@@ -114,14 +125,6 @@ void DocumentOrderedMap::remove(const AtomicString& key, Element* element) |
} |
} |
-#if ENABLE(ASSERT) |
-void DocumentOrderedMap::willRemoveId(const AtomicString& key) |
-{ |
- ASSERT(m_removingId.isNull() || key.isNull()); |
- m_removingId = key; |
-} |
-#endif |
- |
template<bool keyMatches(const AtomicString&, const Element&)> |
inline Element* DocumentOrderedMap::get(const AtomicString& key, const TreeScope* scope) const |
{ |
@@ -138,20 +141,17 @@ inline Element* DocumentOrderedMap::get(const AtomicString& key, const TreeScope |
// Iterate to find the node that matches. Nothing will match iff an element |
// with children having duplicate IDs is being removed -- the tree traversal |
- // will be over an updated tree not having that element. In all other cases, |
+ // will be over an updated tree not having that subtree. In all other cases, |
// a match is expected. |
- // |
- // Such calls to get()/getElementById() while handling element removals will |
- // legitimately happen when e.g., adjusting form ID associations. Quietly |
- // allow those lookups to (expectedly) fail by having the tree scope removal |
- // register the element ID it is in the process of removing. |
for (Element& element : ElementTraversal::startsAfter(scope->rootNode())) { |
if (!keyMatches(key, element)) |
continue; |
entry->element = &element; |
return &element; |
} |
- ASSERT(key == m_removingId); |
+ // As get()/getElementById() can legitimately be called while handling element |
+ // removals, allow failure iff we're in the scope of node removals. |
+ ASSERT(m_treeRemovalScopeLevel); |
return 0; |
} |