Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/TreeScope.cpp |
| diff --git a/third_party/WebKit/Source/core/dom/TreeScope.cpp b/third_party/WebKit/Source/core/dom/TreeScope.cpp |
| index d536fa338bfc7b3b18026ab5bd713a888c7d33e8..d4547edd6800d8e5488e98c008a1782540e2dee1 100644 |
| --- a/third_party/WebKit/Source/core/dom/TreeScope.cpp |
| +++ b/third_party/WebKit/Source/core/dom/TreeScope.cpp |
| @@ -186,43 +186,11 @@ void TreeScope::addElementById(const AtomicString& elementId, Element* element) |
| } |
| -#if ENABLE(ASSERT) |
| -namespace { |
| - |
| -class RemovingElementIdScope { |
| - STACK_ALLOCATED(); |
| -public: |
| - RemovingElementIdScope(DocumentOrderedMap& elementsById, const AtomicString& id) |
| - : m_elementsById(&elementsById) |
| - { |
| - m_elementsById->willRemoveId(id); |
| - } |
| - ~RemovingElementIdScope() |
| - { |
| - m_elementsById->willRemoveId(nullAtom); |
| - } |
| - |
| -private: |
| - RawPtrWillBeMember<DocumentOrderedMap> m_elementsById; |
| -}; |
| - |
| -} |
| -#endif |
| - |
| void TreeScope::removeElementById(const AtomicString& elementId, Element* element) |
| { |
| if (!m_elementsById) |
| return; |
| m_elementsById->remove(elementId, element); |
| -#if ENABLE(ASSERT) |
| - // Register 'elementId' as being removed. This is done should observers |
| - // attempt to also look it up, something that the underlying DocumentOrderedMap |
| - // is incapable of answering precisely while an element (and its |
| - // children) are being removed from the tree. This is _only_ done to avoid |
| - // an assert in DocumentOrderedMap::get() from falsely triggering for such |
| - // unusual and unexpected lookups. |
| - RemovingElementIdScope removalScope(*m_elementsById, elementId); |
| -#endif |
| m_idTargetObserverRegistry->notifyObservers(elementId); |
| } |
| @@ -612,4 +580,24 @@ DEFINE_TRACE(TreeScope) |
| visitor->trace(m_scopedStyleResolver); |
| } |
| +#if ENABLE(ASSERT) |
| +TreeScope::RemoveScope::RemoveScope(ContainerNode* containerNode) |
| + : m_idMap(containerNode->treeScope().m_elementsById.get()) |
| +{ |
| + // While removing a ContainerNode, lookups in the underlying id map will |
|
esprehn
2016/01/05 07:48:33
this comment should be with the RemoveScope class
sof
2016/01/05 12:37:18
Done, moved to DocumentOrderedMap::RemoveScope dec
|
| + // not be precise should the tree have elements with duplicate IDs |
| + // contained in the node being removed. Rare trees, but ID lookups may legitimately |
| + // fail across such removals; inform the DocumentOrderedMap about the transitory |
| + // state of the underlying tree. |
| + if (m_idMap) |
| + m_idMap->enterTreeRemoveScope(); |
| +} |
| + |
| +TreeScope::RemoveScope::~RemoveScope() |
| +{ |
| + if (m_idMap) |
| + m_idMap->leaveTreeRemoveScope(); |
| +} |
| +#endif |
| + |
| } // namespace blink |