WebKit Bugzilla
Attachment 339595 Details for
Bug 185290
: Rename DocumentOrderedMap to TreeScopeOrderedMap
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-185290-20180504142540.patch (text/plain), 45.49 KB, created by
Ryosuke Niwa
on 2018-05-04 14:25:41 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Ryosuke Niwa
Created:
2018-05-04 14:25:41 PDT
Size:
45.49 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 231378) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,26 @@ >+2018-05-04 Ryosuke Niwa <rniwa@webkit.org> >+ >+ Rename DocumentOrderedMap to TreeScopeOrderedMap >+ https://bugs.webkit.org/show_bug.cgi?id=185290 >+ >+ Reviewed by Zalan Bujtas. >+ >+ Renamed the class since it's almost always a mistake to use this class as a member variable of Document. >+ >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * dom/MouseRelatedEvent.cpp: Include the forgotten DOMWindow.h. Unified build files bit us here. >+ * dom/TreeScope.cpp: >+ (WebCore::TreeScope::addElementById): >+ (WebCore::TreeScope::addElementByName): >+ (WebCore::TreeScope::addImageMap): >+ (WebCore::TreeScope::addImageElementByUsemap): >+ (WebCore::TreeScope::labelElementForId): >+ * dom/TreeScope.h: >+ * dom/TreeScopeOrderedMap.cpp: Renamed from DocumentOrderedMap.cpp >+ * dom/TreeScopeOrderedMap.h: Renamed from DocumentOrderedMap.h >+ * html/HTMLDocument.h: >+ > 2018-05-04 Tim Horton <timothy_horton@apple.com> > > Don't use GSFont* in minimal simulator mode >Index: Source/WebCore/Sources.txt >=================================================================== >--- Source/WebCore/Sources.txt (revision 231378) >+++ Source/WebCore/Sources.txt (working copy) >@@ -729,7 +729,6 @@ dom/Document.cpp > dom/DocumentEventQueue.cpp > dom/DocumentFragment.cpp > dom/DocumentMarkerController.cpp >-dom/DocumentOrderedMap.cpp > dom/DocumentParser.cpp > dom/DocumentSharedObjectPool.cpp > dom/DocumentTouch.cpp @no-unify >@@ -826,6 +825,7 @@ dom/TransformSourceLibxslt.cpp > dom/TransitionEvent.cpp > dom/Traversal.cpp > dom/TreeScope.cpp >+dom/TreeScopeOrderedMap.cpp > dom/TreeWalker.cpp > dom/UIEvent.cpp > dom/UIEventWithKeyState.cpp >Index: Source/WebCore/WebCore.xcodeproj/project.pbxproj >=================================================================== >--- Source/WebCore/WebCore.xcodeproj/project.pbxproj (revision 231378) >+++ Source/WebCore/WebCore.xcodeproj/project.pbxproj (working copy) >@@ -432,7 +432,7 @@ > 1479FAF0109AE37500DED655 /* RenderRubyBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 1479FAE8109AE37500DED655 /* RenderRubyBase.h */; }; > 1479FAF2109AE37500DED655 /* RenderRubyRun.h in Headers */ = {isa = PBXBuildFile; fileRef = 1479FAEA109AE37500DED655 /* RenderRubyRun.h */; }; > 1479FAF4109AE37500DED655 /* RenderRubyText.h in Headers */ = {isa = PBXBuildFile; fileRef = 1479FAEC109AE37500DED655 /* RenderRubyText.h */; }; >- 14947FFE12F80CD200A0F631 /* DocumentOrderedMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 14947FFC12F80CD200A0F631 /* DocumentOrderedMap.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 14947FFE12F80CD200A0F631 /* TreeScopeOrderedMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 14947FFC12F80CD200A0F631 /* TreeScopeOrderedMap.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 14993BE60B2F2B1C0050497F /* FocusController.h in Headers */ = {isa = PBXBuildFile; fileRef = 14993BE40B2F2B1C0050497F /* FocusController.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 14CF7B3409F6ECD700EB3665 /* JSCSSRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 14CF7B3209F6ECD700EB3665 /* JSCSSRule.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 14D64B5D134A5B6B00E58FDA /* TreeScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D64B5B134A5B6B00E58FDA /* TreeScope.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -5822,8 +5822,8 @@ > 14813BF309EDF88E00F757E1 /* IDLParser.pm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; name = IDLParser.pm; path = scripts/IDLParser.pm; sourceTree = "<group>"; }; > 148B4FFF1B6904C500C954E4 /* CountQueuingStrategy.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CountQueuingStrategy.idl; sourceTree = "<group>"; }; > 148B4FFF1B6904C500C954E5 /* ByteLengthQueuingStrategy.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ByteLengthQueuingStrategy.idl; sourceTree = "<group>"; }; >- 14947FFB12F80CD200A0F631 /* DocumentOrderedMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentOrderedMap.cpp; sourceTree = "<group>"; }; >- 14947FFC12F80CD200A0F631 /* DocumentOrderedMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentOrderedMap.h; sourceTree = "<group>"; }; >+ 14947FFB12F80CD200A0F631 /* TreeScopeOrderedMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TreeScopeOrderedMap.cpp; sourceTree = "<group>"; }; >+ 14947FFC12F80CD200A0F631 /* TreeScopeOrderedMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeScopeOrderedMap.h; sourceTree = "<group>"; }; > 14993BE30B2F2B1C0050497F /* FocusController.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FocusController.cpp; sourceTree = "<group>"; }; > 14993BE40B2F2B1C0050497F /* FocusController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FocusController.h; sourceTree = "<group>"; }; > 14A98E05136386A200C9FED2 /* Blob.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Blob.idl; sourceTree = "<group>"; }; >@@ -26076,8 +26076,6 @@ > ED2BA83B09A24B91006C0AC4 /* DocumentMarker.h */, > CE057FA31220731100A476D5 /* DocumentMarkerController.cpp */, > CE057FA41220731100A476D5 /* DocumentMarkerController.h */, >- 14947FFB12F80CD200A0F631 /* DocumentOrderedMap.cpp */, >- 14947FFC12F80CD200A0F631 /* DocumentOrderedMap.h */, > 9B0FE8731D9E02DF004A8ACB /* DocumentOrShadowRoot.idl */, > A8C2280D11D4A59700D5A7D3 /* DocumentParser.cpp */, > BCCFBAE70B5152ED0001F1D7 /* DocumentParser.h */, >@@ -26401,6 +26399,8 @@ > 37FD4297118368460093C029 /* TreeDepthLimit.h */, > 14D64B5A134A5B6B00E58FDA /* TreeScope.cpp */, > 14D64B5B134A5B6B00E58FDA /* TreeScope.h */, >+ 14947FFB12F80CD200A0F631 /* TreeScopeOrderedMap.cpp */, >+ 14947FFC12F80CD200A0F631 /* TreeScopeOrderedMap.h */, > 854FE72E0A2297BE0058D7AD /* TreeWalker.cpp */, > 854FE72F0A2297BE0058D7AD /* TreeWalker.h */, > 1A750D3C0A90DE35000FF215 /* TreeWalker.idl */, >@@ -27603,7 +27603,6 @@ > 656D37360ADBA5DE00A4554D /* DocumentLoader.h in Headers */, > ED2BA83C09A24B91006C0AC4 /* DocumentMarker.h in Headers */, > CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */, >- 14947FFE12F80CD200A0F631 /* DocumentOrderedMap.h in Headers */, > BCCFBAE80B5152ED0001F1D7 /* DocumentParser.h in Headers */, > 4A4F48AA16B0DFC000EDBB29 /* DocumentRuleSets.h in Headers */, > AD6E71AD1668899D00320C13 /* DocumentSharedObjectPool.h in Headers */, >@@ -30580,6 +30579,7 @@ > 854FE7370A2297BE0058D7AD /* Traversal.h in Headers */, > 37FD4298118368460093C029 /* TreeDepthLimit.h in Headers */, > 14D64B5D134A5B6B00E58FDA /* TreeScope.h in Headers */, >+ 14947FFE12F80CD200A0F631 /* TreeScopeOrderedMap.h in Headers */, > 854FE7390A2297BE0058D7AD /* TreeWalker.h in Headers */, > C375D7FE16639519006184AB /* TypeAhead.h in Headers */, > E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */, >Index: Source/WebCore/dom/DocumentOrderedMap.cpp >=================================================================== >--- Source/WebCore/dom/DocumentOrderedMap.cpp (revision 231378) >+++ Source/WebCore/dom/DocumentOrderedMap.cpp (nonexistent) >@@ -1,223 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions are >- * met: >- * >- * * Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * * Redistributions in binary form must reproduce the above >- * copyright notice, this list of conditions and the following disclaimer >- * in the documentation and/or other materials provided with the >- * distribution. >- * * Neither the name of Google Inc. nor the names of its >- * contributors may be used to endorse or promote products derived from >- * this software without specific prior written permission. >- * >- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include "DocumentOrderedMap.h" >- >-#include "ContainerNodeAlgorithms.h" >-#include "ElementIterator.h" >-#include "HTMLImageElement.h" >-#include "HTMLLabelElement.h" >-#include "HTMLMapElement.h" >-#include "HTMLNameCollection.h" >- >-namespace WebCore { >- >-using namespace HTMLNames; >- >-void DocumentOrderedMap::clear() >-{ >- m_map.clear(); >-} >- >-void DocumentOrderedMap::add(const AtomicStringImpl& key, Element& element, const TreeScope& treeScope) >-{ >- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(&element.treeScope() == &treeScope); >- ASSERT_WITH_SECURITY_IMPLICATION(treeScope.rootNode().containsIncludingShadowDOM(&element)); >- >- if (!element.isInTreeScope()) >- return; >- Map::AddResult addResult = m_map.ensure(&key, [&element] { >- return MapEntry(&element); >- }); >- MapEntry& entry = addResult.iterator->value; >- >-#if !ASSERT_DISABLED || ENABLE(SECURITY_ASSERTIONS) >- ASSERT_WITH_SECURITY_IMPLICATION(!entry.registeredElements.contains(&element)); >- entry.registeredElements.add(&element); >-#endif >- >- if (addResult.isNewEntry) >- return; >- >- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.count); >- entry.element = nullptr; >- entry.count++; >- entry.orderedList.clear(); >-} >- >-void DocumentOrderedMap::remove(const AtomicStringImpl& key, Element& element) >-{ >- m_map.checkConsistency(); >- auto it = m_map.find(&key); >- >- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(it != m_map.end()); >- >- MapEntry& entry = it->value; >- ASSERT_WITH_SECURITY_IMPLICATION(entry.registeredElements.remove(&element)); >- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.count); >- if (entry.count == 1) { >- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!entry.element || entry.element == &element); >- m_map.remove(it); >- } else { >- if (entry.element == &element) >- entry.element = nullptr; >- entry.count--; >- entry.orderedList.clear(); // FIXME: Remove the element instead if there are only few items left. >- } >-} >- >-template <typename KeyMatchingFunction> >-inline Element* DocumentOrderedMap::get(const AtomicStringImpl& key, const TreeScope& scope, const KeyMatchingFunction& keyMatches) const >-{ >- m_map.checkConsistency(); >- >- auto it = m_map.find(&key); >- if (it == m_map.end()) >- return nullptr; >- >- MapEntry& entry = it->value; >- ASSERT(entry.count); >- if (entry.element) { >- auto& element = *entry.element; >- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(&element.treeScope() == &scope); >- ASSERT_WITH_SECURITY_IMPLICATION(entry.registeredElements.contains(&element)); >- return &element; >- } >- >- // We know there's at least one node that matches; iterate to find the first one. >- for (auto& element : descendantsOfType<Element>(scope.rootNode())) { >- if (!keyMatches(key, element)) >- continue; >- entry.element = &element; >- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(&element.treeScope() == &scope); >- ASSERT_WITH_SECURITY_IMPLICATION(entry.registeredElements.contains(entry.element)); >- return &element; >- } >- >-#if !ASSERT_DISABLED >- // FormAssociatedElement may call getElementById to find its owner form in the middle of a tree removal. >- if (auto* currentScope = ContainerChildRemovalScope::currentScope()) { >- ASSERT(&scope.rootNode() == ¤tScope->parentOfRemovedTree().rootNode()); >- Node& removedTree = currentScope->removedChild(); >- ASSERT(is<ContainerNode>(removedTree)); >- for (auto& element : descendantsOfType<Element>(downcast<ContainerNode>(removedTree))) { >- if (!keyMatches(key, element)) >- continue; >- bool removedFromAncestorHasNotBeenCalledYet = element.isConnected(); >- ASSERT(removedFromAncestorHasNotBeenCalledYet); >- return nullptr; >- } >- } >- ASSERT_NOT_REACHED(); >-#endif >- >- return nullptr; >-} >- >-Element* DocumentOrderedMap::getElementById(const AtomicStringImpl& key, const TreeScope& scope) const >-{ >- return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >- return element.getIdAttribute().impl() == &key; >- }); >-} >- >-Element* DocumentOrderedMap::getElementByName(const AtomicStringImpl& key, const TreeScope& scope) const >-{ >- return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >- return element.getNameAttribute().impl() == &key; >- }); >-} >- >-HTMLMapElement* DocumentOrderedMap::getElementByMapName(const AtomicStringImpl& key, const TreeScope& scope) const >-{ >- return downcast<HTMLMapElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >- return is<HTMLMapElement>(element) && downcast<HTMLMapElement>(element).getName().impl() == &key; >- })); >-} >- >-HTMLImageElement* DocumentOrderedMap::getElementByUsemap(const AtomicStringImpl& key, const TreeScope& scope) const >-{ >- return downcast<HTMLImageElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >- // FIXME: HTML5 specification says we should match both image and object elements. >- return is<HTMLImageElement>(element) && downcast<HTMLImageElement>(element).matchesUsemap(key); >- })); >-} >- >-HTMLLabelElement* DocumentOrderedMap::getElementByLabelForAttribute(const AtomicStringImpl& key, const TreeScope& scope) const >-{ >- return downcast<HTMLLabelElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >- return is<HTMLLabelElement>(element) && element.attributeWithoutSynchronization(forAttr).impl() == &key; >- })); >-} >- >-Element* DocumentOrderedMap::getElementByWindowNamedItem(const AtomicStringImpl& key, const TreeScope& scope) const >-{ >- return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >- return WindowNameCollection::elementMatches(element, &key); >- }); >-} >- >-Element* DocumentOrderedMap::getElementByDocumentNamedItem(const AtomicStringImpl& key, const TreeScope& scope) const >-{ >- return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >- return DocumentNameCollection::elementMatches(element, &key); >- }); >-} >- >-const Vector<Element*>* DocumentOrderedMap::getAllElementsById(const AtomicStringImpl& key, const TreeScope& scope) const >-{ >- m_map.checkConsistency(); >- >- auto it = m_map.find(&key); >- if (it == m_map.end()) >- return nullptr; >- >- MapEntry& entry = it->value; >- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.count); >- >- if (entry.orderedList.isEmpty()) { >- entry.orderedList.reserveCapacity(entry.count); >- auto elementDescandents = descendantsOfType<Element>(scope.rootNode()); >- auto it = entry.element ? elementDescandents.beginAt(*entry.element) : elementDescandents.begin(); >- auto end = elementDescandents.end(); >- for (; it != end; ++it) { >- auto& element = *it; >- if (element.getIdAttribute().impl() != &key) >- continue; >- entry.orderedList.append(&element); >- } >- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.orderedList.size() == entry.count); >- } >- >- return &entry.orderedList; >-} >- >-} // namespace WebCore > >Property changes on: Source/WebCore/dom/DocumentOrderedMap.cpp >___________________________________________________________________ >Deleted: svn:eol-style >## -1 +0,0 ## >-native >\ No newline at end of property >Index: Source/WebCore/dom/DocumentOrderedMap.h >=================================================================== >--- Source/WebCore/dom/DocumentOrderedMap.h (revision 231378) >+++ Source/WebCore/dom/DocumentOrderedMap.h (nonexistent) >@@ -1,109 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions are >- * met: >- * >- * * Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * * Redistributions in binary form must reproduce the above >- * copyright notice, this list of conditions and the following disclaimer >- * in the documentation and/or other materials provided with the >- * distribution. >- * * Neither the name of Google Inc. nor the names of its >- * contributors may be used to endorse or promote products derived from >- * this software without specific prior written permission. >- * >- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#pragma once >- >-#include <wtf/HashMap.h> >-#include <wtf/HashSet.h> >-#include <wtf/Vector.h> >-#include <wtf/text/AtomicStringImpl.h> >- >-namespace WebCore { >- >-class Element; >-class HTMLImageElement; >-class HTMLLabelElement; >-class HTMLMapElement; >-class TreeScope; >- >-class DocumentOrderedMap { >- WTF_MAKE_FAST_ALLOCATED; >-public: >- void add(const AtomicStringImpl&, Element&, const TreeScope&); >- void remove(const AtomicStringImpl&, Element&); >- void clear(); >- >- bool contains(const AtomicStringImpl&) const; >- bool containsSingle(const AtomicStringImpl&) const; >- bool containsMultiple(const AtomicStringImpl&) const; >- >- // concrete instantiations of the get<>() method template >- Element* getElementById(const AtomicStringImpl&, const TreeScope&) const; >- Element* getElementByName(const AtomicStringImpl&, const TreeScope&) const; >- HTMLMapElement* getElementByMapName(const AtomicStringImpl&, const TreeScope&) const; >- HTMLImageElement* getElementByUsemap(const AtomicStringImpl&, const TreeScope&) const; >- HTMLLabelElement* getElementByLabelForAttribute(const AtomicStringImpl&, const TreeScope&) const; >- Element* getElementByWindowNamedItem(const AtomicStringImpl&, const TreeScope&) const; >- Element* getElementByDocumentNamedItem(const AtomicStringImpl&, const TreeScope&) const; >- >- const Vector<Element*>* getAllElementsById(const AtomicStringImpl&, const TreeScope&) const; >- >-private: >- template <typename KeyMatchingFunction> >- Element* get(const AtomicStringImpl&, const TreeScope&, const KeyMatchingFunction&) const; >- >- struct MapEntry { >- MapEntry() { } >- explicit MapEntry(Element* firstElement) >- : element(firstElement) >- , count(1) >- { } >- >- Element* element { nullptr }; >- unsigned count { 0 }; >- Vector<Element*> orderedList; >-#if !ASSERT_DISABLED || ENABLE(SECURITY_ASSERTIONS) >- HashSet<Element*> registeredElements; >-#endif >- }; >- >- typedef HashMap<const AtomicStringImpl*, MapEntry> Map; >- >- mutable Map m_map; >-}; >- >-inline bool DocumentOrderedMap::containsSingle(const AtomicStringImpl& id) const >-{ >- auto it = m_map.find(&id); >- return it != m_map.end() && it->value.count == 1; >-} >- >-inline bool DocumentOrderedMap::contains(const AtomicStringImpl& id) const >-{ >- return m_map.contains(&id); >-} >- >-inline bool DocumentOrderedMap::containsMultiple(const AtomicStringImpl& id) const >-{ >- auto it = m_map.find(&id); >- return it != m_map.end() && it->value.count > 1; >-} >- >-} // namespace WebCore > >Property changes on: Source/WebCore/dom/DocumentOrderedMap.h >___________________________________________________________________ >Deleted: svn:eol-style >## -1 +0,0 ## >-native >\ No newline at end of property >Index: Source/WebCore/dom/MouseRelatedEvent.cpp >=================================================================== >--- Source/WebCore/dom/MouseRelatedEvent.cpp (revision 231378) >+++ Source/WebCore/dom/MouseRelatedEvent.cpp (working copy) >@@ -23,6 +23,7 @@ > #include "config.h" > #include "MouseRelatedEvent.h" > >+#include "DOMWindow.h" > #include "Document.h" > #include "Frame.h" > #include "FrameView.h" >Index: Source/WebCore/dom/TreeScope.cpp >=================================================================== >--- Source/WebCore/dom/TreeScope.cpp (revision 231378) >+++ Source/WebCore/dom/TreeScope.cpp (working copy) >@@ -141,7 +141,7 @@ const Vector<Element*>* TreeScope::getAl > void TreeScope::addElementById(const AtomicStringImpl& elementId, Element& element, bool notifyObservers) > { > if (!m_elementsById) >- m_elementsById = std::make_unique<DocumentOrderedMap>(); >+ m_elementsById = std::make_unique<TreeScopeOrderedMap>(); > m_elementsById->add(elementId, element, *this); > if (notifyObservers) > m_idTargetObserverRegistry->notifyObservers(elementId); >@@ -168,7 +168,7 @@ Element* TreeScope::getElementByName(con > void TreeScope::addElementByName(const AtomicStringImpl& name, Element& element) > { > if (!m_elementsByName) >- m_elementsByName = std::make_unique<DocumentOrderedMap>(); >+ m_elementsByName = std::make_unique<TreeScopeOrderedMap>(); > m_elementsByName->add(name, element, *this); > } > >@@ -239,7 +239,7 @@ void TreeScope::addImageMap(HTMLMapEleme > if (!name) > return; > if (!m_imageMapsByName) >- m_imageMapsByName = std::make_unique<DocumentOrderedMap>(); >+ m_imageMapsByName = std::make_unique<TreeScopeOrderedMap>(); > m_imageMapsByName->add(*name, imageMap, *this); > } > >@@ -263,7 +263,7 @@ HTMLMapElement* TreeScope::getImageMap(c > void TreeScope::addImageElementByUsemap(const AtomicStringImpl& name, HTMLImageElement& element) > { > if (!m_imagesByUsemap) >- m_imagesByUsemap = std::make_unique<DocumentOrderedMap>(); >+ m_imagesByUsemap = std::make_unique<TreeScopeOrderedMap>(); > return m_imagesByUsemap->add(name, element, *this); > } > >@@ -300,7 +300,7 @@ HTMLLabelElement* TreeScope::labelElemen > > if (!m_labelsByForAttribute) { > // Populate the map on first access. >- m_labelsByForAttribute = std::make_unique<DocumentOrderedMap>(); >+ m_labelsByForAttribute = std::make_unique<TreeScopeOrderedMap>(); > > for (auto& label : descendantsOfType<HTMLLabelElement>(m_rootNode)) { > const AtomicString& forValue = label.attributeWithoutSynchronization(forAttr); >Index: Source/WebCore/dom/TreeScope.h >=================================================================== >--- Source/WebCore/dom/TreeScope.h (revision 231378) >+++ Source/WebCore/dom/TreeScope.h (working copy) >@@ -26,7 +26,7 @@ > > #pragma once > >-#include "DocumentOrderedMap.h" >+#include "TreeScopeOrderedMap.h" > #include <memory> > #include <wtf/Forward.h> > #include <wtf/Vector.h> >@@ -126,11 +126,11 @@ private: > std::reference_wrapper<Document> m_documentScope; > TreeScope* m_parentTreeScope; > >- std::unique_ptr<DocumentOrderedMap> m_elementsById; >- std::unique_ptr<DocumentOrderedMap> m_elementsByName; >- std::unique_ptr<DocumentOrderedMap> m_imageMapsByName; >- std::unique_ptr<DocumentOrderedMap> m_imagesByUsemap; >- std::unique_ptr<DocumentOrderedMap> m_labelsByForAttribute; >+ std::unique_ptr<TreeScopeOrderedMap> m_elementsById; >+ std::unique_ptr<TreeScopeOrderedMap> m_elementsByName; >+ std::unique_ptr<TreeScopeOrderedMap> m_imageMapsByName; >+ std::unique_ptr<TreeScopeOrderedMap> m_imagesByUsemap; >+ std::unique_ptr<TreeScopeOrderedMap> m_labelsByForAttribute; > > std::unique_ptr<IdTargetObserverRegistry> m_idTargetObserverRegistry; > }; >Index: Source/WebCore/dom/TreeScopeOrderedMap.cpp >=================================================================== >--- Source/WebCore/dom/TreeScopeOrderedMap.cpp (revision 231378) (from Source/WebCore/dom/DocumentOrderedMap.cpp:231378) >+++ Source/WebCore/dom/TreeScopeOrderedMap.cpp (working copy) >@@ -0,0 +1,223 @@ >+/* >+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "DocumentOrderedMap.h" >+ >+#include "ContainerNodeAlgorithms.h" >+#include "ElementIterator.h" >+#include "HTMLImageElement.h" >+#include "HTMLLabelElement.h" >+#include "HTMLMapElement.h" >+#include "HTMLNameCollection.h" >+ >+namespace WebCore { >+ >+using namespace HTMLNames; >+ >+void DocumentOrderedMap::clear() >+{ >+ m_map.clear(); >+} >+ >+void DocumentOrderedMap::add(const AtomicStringImpl& key, Element& element, const TreeScope& treeScope) >+{ >+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(&element.treeScope() == &treeScope); >+ ASSERT_WITH_SECURITY_IMPLICATION(treeScope.rootNode().containsIncludingShadowDOM(&element)); >+ >+ if (!element.isInTreeScope()) >+ return; >+ Map::AddResult addResult = m_map.ensure(&key, [&element] { >+ return MapEntry(&element); >+ }); >+ MapEntry& entry = addResult.iterator->value; >+ >+#if !ASSERT_DISABLED || ENABLE(SECURITY_ASSERTIONS) >+ ASSERT_WITH_SECURITY_IMPLICATION(!entry.registeredElements.contains(&element)); >+ entry.registeredElements.add(&element); >+#endif >+ >+ if (addResult.isNewEntry) >+ return; >+ >+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.count); >+ entry.element = nullptr; >+ entry.count++; >+ entry.orderedList.clear(); >+} >+ >+void DocumentOrderedMap::remove(const AtomicStringImpl& key, Element& element) >+{ >+ m_map.checkConsistency(); >+ auto it = m_map.find(&key); >+ >+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(it != m_map.end()); >+ >+ MapEntry& entry = it->value; >+ ASSERT_WITH_SECURITY_IMPLICATION(entry.registeredElements.remove(&element)); >+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.count); >+ if (entry.count == 1) { >+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!entry.element || entry.element == &element); >+ m_map.remove(it); >+ } else { >+ if (entry.element == &element) >+ entry.element = nullptr; >+ entry.count--; >+ entry.orderedList.clear(); // FIXME: Remove the element instead if there are only few items left. >+ } >+} >+ >+template <typename KeyMatchingFunction> >+inline Element* DocumentOrderedMap::get(const AtomicStringImpl& key, const TreeScope& scope, const KeyMatchingFunction& keyMatches) const >+{ >+ m_map.checkConsistency(); >+ >+ auto it = m_map.find(&key); >+ if (it == m_map.end()) >+ return nullptr; >+ >+ MapEntry& entry = it->value; >+ ASSERT(entry.count); >+ if (entry.element) { >+ auto& element = *entry.element; >+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(&element.treeScope() == &scope); >+ ASSERT_WITH_SECURITY_IMPLICATION(entry.registeredElements.contains(&element)); >+ return &element; >+ } >+ >+ // We know there's at least one node that matches; iterate to find the first one. >+ for (auto& element : descendantsOfType<Element>(scope.rootNode())) { >+ if (!keyMatches(key, element)) >+ continue; >+ entry.element = &element; >+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(&element.treeScope() == &scope); >+ ASSERT_WITH_SECURITY_IMPLICATION(entry.registeredElements.contains(entry.element)); >+ return &element; >+ } >+ >+#if !ASSERT_DISABLED >+ // FormAssociatedElement may call getElementById to find its owner form in the middle of a tree removal. >+ if (auto* currentScope = ContainerChildRemovalScope::currentScope()) { >+ ASSERT(&scope.rootNode() == ¤tScope->parentOfRemovedTree().rootNode()); >+ Node& removedTree = currentScope->removedChild(); >+ ASSERT(is<ContainerNode>(removedTree)); >+ for (auto& element : descendantsOfType<Element>(downcast<ContainerNode>(removedTree))) { >+ if (!keyMatches(key, element)) >+ continue; >+ bool removedFromAncestorHasNotBeenCalledYet = element.isConnected(); >+ ASSERT(removedFromAncestorHasNotBeenCalledYet); >+ return nullptr; >+ } >+ } >+ ASSERT_NOT_REACHED(); >+#endif >+ >+ return nullptr; >+} >+ >+Element* DocumentOrderedMap::getElementById(const AtomicStringImpl& key, const TreeScope& scope) const >+{ >+ return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >+ return element.getIdAttribute().impl() == &key; >+ }); >+} >+ >+Element* DocumentOrderedMap::getElementByName(const AtomicStringImpl& key, const TreeScope& scope) const >+{ >+ return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >+ return element.getNameAttribute().impl() == &key; >+ }); >+} >+ >+HTMLMapElement* DocumentOrderedMap::getElementByMapName(const AtomicStringImpl& key, const TreeScope& scope) const >+{ >+ return downcast<HTMLMapElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >+ return is<HTMLMapElement>(element) && downcast<HTMLMapElement>(element).getName().impl() == &key; >+ })); >+} >+ >+HTMLImageElement* DocumentOrderedMap::getElementByUsemap(const AtomicStringImpl& key, const TreeScope& scope) const >+{ >+ return downcast<HTMLImageElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >+ // FIXME: HTML5 specification says we should match both image and object elements. >+ return is<HTMLImageElement>(element) && downcast<HTMLImageElement>(element).matchesUsemap(key); >+ })); >+} >+ >+HTMLLabelElement* DocumentOrderedMap::getElementByLabelForAttribute(const AtomicStringImpl& key, const TreeScope& scope) const >+{ >+ return downcast<HTMLLabelElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >+ return is<HTMLLabelElement>(element) && element.attributeWithoutSynchronization(forAttr).impl() == &key; >+ })); >+} >+ >+Element* DocumentOrderedMap::getElementByWindowNamedItem(const AtomicStringImpl& key, const TreeScope& scope) const >+{ >+ return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >+ return WindowNameCollection::elementMatches(element, &key); >+ }); >+} >+ >+Element* DocumentOrderedMap::getElementByDocumentNamedItem(const AtomicStringImpl& key, const TreeScope& scope) const >+{ >+ return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { >+ return DocumentNameCollection::elementMatches(element, &key); >+ }); >+} >+ >+const Vector<Element*>* DocumentOrderedMap::getAllElementsById(const AtomicStringImpl& key, const TreeScope& scope) const >+{ >+ m_map.checkConsistency(); >+ >+ auto it = m_map.find(&key); >+ if (it == m_map.end()) >+ return nullptr; >+ >+ MapEntry& entry = it->value; >+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.count); >+ >+ if (entry.orderedList.isEmpty()) { >+ entry.orderedList.reserveCapacity(entry.count); >+ auto elementDescandents = descendantsOfType<Element>(scope.rootNode()); >+ auto it = entry.element ? elementDescandents.beginAt(*entry.element) : elementDescandents.begin(); >+ auto end = elementDescandents.end(); >+ for (; it != end; ++it) { >+ auto& element = *it; >+ if (element.getIdAttribute().impl() != &key) >+ continue; >+ entry.orderedList.append(&element); >+ } >+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.orderedList.size() == entry.count); >+ } >+ >+ return &entry.orderedList; >+} >+ >+} // namespace WebCore > >Property changes on: Source/WebCore/dom/DocumentOrderedMap.cpp >___________________________________________________________________ >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Index: Source/WebCore/dom/TreeScopeOrderedMap.cpp >=================================================================== >--- Source/WebCore/dom/TreeScopeOrderedMap.cpp (revision 231378) >+++ Source/WebCore/dom/TreeScopeOrderedMap.cpp (working copy) >@@ -29,7 +29,7 @@ > */ > > #include "config.h" >-#include "DocumentOrderedMap.h" >+#include "TreeScopeOrderedMap.h" > > #include "ContainerNodeAlgorithms.h" > #include "ElementIterator.h" >@@ -42,12 +42,12 @@ namespace WebCore { > > using namespace HTMLNames; > >-void DocumentOrderedMap::clear() >+void TreeScopeOrderedMap::clear() > { > m_map.clear(); > } > >-void DocumentOrderedMap::add(const AtomicStringImpl& key, Element& element, const TreeScope& treeScope) >+void TreeScopeOrderedMap::add(const AtomicStringImpl& key, Element& element, const TreeScope& treeScope) > { > RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(&element.treeScope() == &treeScope); > ASSERT_WITH_SECURITY_IMPLICATION(treeScope.rootNode().containsIncludingShadowDOM(&element)); >@@ -73,7 +73,7 @@ void DocumentOrderedMap::add(const Atomi > entry.orderedList.clear(); > } > >-void DocumentOrderedMap::remove(const AtomicStringImpl& key, Element& element) >+void TreeScopeOrderedMap::remove(const AtomicStringImpl& key, Element& element) > { > m_map.checkConsistency(); > auto it = m_map.find(&key); >@@ -95,7 +95,7 @@ void DocumentOrderedMap::remove(const At > } > > template <typename KeyMatchingFunction> >-inline Element* DocumentOrderedMap::get(const AtomicStringImpl& key, const TreeScope& scope, const KeyMatchingFunction& keyMatches) const >+inline Element* TreeScopeOrderedMap::get(const AtomicStringImpl& key, const TreeScope& scope, const KeyMatchingFunction& keyMatches) const > { > m_map.checkConsistency(); > >@@ -142,28 +142,28 @@ inline Element* DocumentOrderedMap::get( > return nullptr; > } > >-Element* DocumentOrderedMap::getElementById(const AtomicStringImpl& key, const TreeScope& scope) const >+Element* TreeScopeOrderedMap::getElementById(const AtomicStringImpl& key, const TreeScope& scope) const > { > return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { > return element.getIdAttribute().impl() == &key; > }); > } > >-Element* DocumentOrderedMap::getElementByName(const AtomicStringImpl& key, const TreeScope& scope) const >+Element* TreeScopeOrderedMap::getElementByName(const AtomicStringImpl& key, const TreeScope& scope) const > { > return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { > return element.getNameAttribute().impl() == &key; > }); > } > >-HTMLMapElement* DocumentOrderedMap::getElementByMapName(const AtomicStringImpl& key, const TreeScope& scope) const >+HTMLMapElement* TreeScopeOrderedMap::getElementByMapName(const AtomicStringImpl& key, const TreeScope& scope) const > { > return downcast<HTMLMapElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { > return is<HTMLMapElement>(element) && downcast<HTMLMapElement>(element).getName().impl() == &key; > })); > } > >-HTMLImageElement* DocumentOrderedMap::getElementByUsemap(const AtomicStringImpl& key, const TreeScope& scope) const >+HTMLImageElement* TreeScopeOrderedMap::getElementByUsemap(const AtomicStringImpl& key, const TreeScope& scope) const > { > return downcast<HTMLImageElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { > // FIXME: HTML5 specification says we should match both image and object elements. >@@ -171,28 +171,28 @@ HTMLImageElement* DocumentOrderedMap::ge > })); > } > >-HTMLLabelElement* DocumentOrderedMap::getElementByLabelForAttribute(const AtomicStringImpl& key, const TreeScope& scope) const >+HTMLLabelElement* TreeScopeOrderedMap::getElementByLabelForAttribute(const AtomicStringImpl& key, const TreeScope& scope) const > { > return downcast<HTMLLabelElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { > return is<HTMLLabelElement>(element) && element.attributeWithoutSynchronization(forAttr).impl() == &key; > })); > } > >-Element* DocumentOrderedMap::getElementByWindowNamedItem(const AtomicStringImpl& key, const TreeScope& scope) const >+Element* TreeScopeOrderedMap::getElementByWindowNamedItem(const AtomicStringImpl& key, const TreeScope& scope) const > { > return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { > return WindowNameCollection::elementMatches(element, &key); > }); > } > >-Element* DocumentOrderedMap::getElementByDocumentNamedItem(const AtomicStringImpl& key, const TreeScope& scope) const >+Element* TreeScopeOrderedMap::getElementByDocumentNamedItem(const AtomicStringImpl& key, const TreeScope& scope) const > { > return get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { > return DocumentNameCollection::elementMatches(element, &key); > }); > } > >-const Vector<Element*>* DocumentOrderedMap::getAllElementsById(const AtomicStringImpl& key, const TreeScope& scope) const >+const Vector<Element*>* TreeScopeOrderedMap::getAllElementsById(const AtomicStringImpl& key, const TreeScope& scope) const > { > m_map.checkConsistency(); > >Index: Source/WebCore/dom/TreeScopeOrderedMap.h >=================================================================== >--- Source/WebCore/dom/TreeScopeOrderedMap.h (revision 231378) (from Source/WebCore/dom/DocumentOrderedMap.h:231378) >+++ Source/WebCore/dom/TreeScopeOrderedMap.h (working copy) >@@ -0,0 +1,109 @@ >+/* >+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/HashMap.h> >+#include <wtf/HashSet.h> >+#include <wtf/Vector.h> >+#include <wtf/text/AtomicStringImpl.h> >+ >+namespace WebCore { >+ >+class Element; >+class HTMLImageElement; >+class HTMLLabelElement; >+class HTMLMapElement; >+class TreeScope; >+ >+class DocumentOrderedMap { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ void add(const AtomicStringImpl&, Element&, const TreeScope&); >+ void remove(const AtomicStringImpl&, Element&); >+ void clear(); >+ >+ bool contains(const AtomicStringImpl&) const; >+ bool containsSingle(const AtomicStringImpl&) const; >+ bool containsMultiple(const AtomicStringImpl&) const; >+ >+ // concrete instantiations of the get<>() method template >+ Element* getElementById(const AtomicStringImpl&, const TreeScope&) const; >+ Element* getElementByName(const AtomicStringImpl&, const TreeScope&) const; >+ HTMLMapElement* getElementByMapName(const AtomicStringImpl&, const TreeScope&) const; >+ HTMLImageElement* getElementByUsemap(const AtomicStringImpl&, const TreeScope&) const; >+ HTMLLabelElement* getElementByLabelForAttribute(const AtomicStringImpl&, const TreeScope&) const; >+ Element* getElementByWindowNamedItem(const AtomicStringImpl&, const TreeScope&) const; >+ Element* getElementByDocumentNamedItem(const AtomicStringImpl&, const TreeScope&) const; >+ >+ const Vector<Element*>* getAllElementsById(const AtomicStringImpl&, const TreeScope&) const; >+ >+private: >+ template <typename KeyMatchingFunction> >+ Element* get(const AtomicStringImpl&, const TreeScope&, const KeyMatchingFunction&) const; >+ >+ struct MapEntry { >+ MapEntry() { } >+ explicit MapEntry(Element* firstElement) >+ : element(firstElement) >+ , count(1) >+ { } >+ >+ Element* element { nullptr }; >+ unsigned count { 0 }; >+ Vector<Element*> orderedList; >+#if !ASSERT_DISABLED || ENABLE(SECURITY_ASSERTIONS) >+ HashSet<Element*> registeredElements; >+#endif >+ }; >+ >+ typedef HashMap<const AtomicStringImpl*, MapEntry> Map; >+ >+ mutable Map m_map; >+}; >+ >+inline bool DocumentOrderedMap::containsSingle(const AtomicStringImpl& id) const >+{ >+ auto it = m_map.find(&id); >+ return it != m_map.end() && it->value.count == 1; >+} >+ >+inline bool DocumentOrderedMap::contains(const AtomicStringImpl& id) const >+{ >+ return m_map.contains(&id); >+} >+ >+inline bool DocumentOrderedMap::containsMultiple(const AtomicStringImpl& id) const >+{ >+ auto it = m_map.find(&id); >+ return it != m_map.end() && it->value.count > 1; >+} >+ >+} // namespace WebCore > >Property changes on: Source/WebCore/dom/DocumentOrderedMap.h >___________________________________________________________________ >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Index: Source/WebCore/dom/TreeScopeOrderedMap.h >=================================================================== >--- Source/WebCore/dom/TreeScopeOrderedMap.h (revision 231378) >+++ Source/WebCore/dom/TreeScopeOrderedMap.h (working copy) >@@ -43,7 +43,7 @@ class HTMLLabelElement; > class HTMLMapElement; > class TreeScope; > >-class DocumentOrderedMap { >+class TreeScopeOrderedMap { > WTF_MAKE_FAST_ALLOCATED; > public: > void add(const AtomicStringImpl&, Element&, const TreeScope&); >@@ -89,18 +89,18 @@ private: > mutable Map m_map; > }; > >-inline bool DocumentOrderedMap::containsSingle(const AtomicStringImpl& id) const >+inline bool TreeScopeOrderedMap::containsSingle(const AtomicStringImpl& id) const > { > auto it = m_map.find(&id); > return it != m_map.end() && it->value.count == 1; > } > >-inline bool DocumentOrderedMap::contains(const AtomicStringImpl& id) const >+inline bool TreeScopeOrderedMap::contains(const AtomicStringImpl& id) const > { > return m_map.contains(&id); > } > >-inline bool DocumentOrderedMap::containsMultiple(const AtomicStringImpl& id) const >+inline bool TreeScopeOrderedMap::containsMultiple(const AtomicStringImpl& id) const > { > auto it = m_map.find(&id); > return it != m_map.end() && it->value.count > 1; >Index: Source/WebCore/html/HTMLDocument.h >=================================================================== >--- Source/WebCore/html/HTMLDocument.h (revision 231378) >+++ Source/WebCore/html/HTMLDocument.h (working copy) >@@ -69,8 +69,8 @@ private: > Ref<DocumentParser> createParser() override; > Ref<Document> cloneDocumentWithoutChildren() const final; > >- DocumentOrderedMap m_documentNamedItem; >- DocumentOrderedMap m_windowNamedItem; >+ TreeScopeOrderedMap m_documentNamedItem; >+ TreeScopeOrderedMap m_windowNamedItem; > }; > > } // namespace WebCore
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185290
:
339517
| 339595