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

Unified Diff: third_party/WebKit/Source/core/dom/DocumentOrderedMap.cpp

Issue 1555653002: Handle some failing DocumentOrderedMap ID lookups across tree removals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: non-assert buildfix Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
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..0d310c491791aec1205d3ef4e9f0c254a67eee17 100644
--- a/third_party/WebKit/Source/core/dom/DocumentOrderedMap.cpp
+++ b/third_party/WebKit/Source/core/dom/DocumentOrderedMap.cpp
@@ -50,9 +50,22 @@ DocumentOrderedMap::DocumentOrderedMap()
{
}
-DocumentOrderedMap::~DocumentOrderedMap()
+DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DocumentOrderedMap);
+
+#if ENABLE(ASSERT)
+static int s_removeScopeLevel = 0;
+
+DocumentOrderedMap::RemoveScope::RemoveScope()
+{
+ s_removeScopeLevel++;
+}
+
+DocumentOrderedMap::RemoveScope::~RemoveScope()
{
+ ASSERT(s_removeScopeLevel);
+ s_removeScopeLevel--;
}
+#endif
inline bool keyMatchesId(const AtomicString& key, const Element& element)
{
@@ -114,14 +127,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 +143,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(s_removeScopeLevel);
return 0;
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/DocumentOrderedMap.h ('k') | third_party/WebKit/Source/core/dom/TreeScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698