WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-227192-20210630124059.patch (text/plain), 23.05 KB, created by
Ryosuke Niwa
on 2021-06-30 12:41:00 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Ryosuke Niwa
Created:
2021-06-30 12:41:00 PDT
Size:
23.05 KB
patch
obsolete
>Subversion Revision: 279029 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index c0b1aa8f769492f097f170ab496cb8084ab71ec9..02e7c573c551bf78277a2786e72e5e064ca0a6d4 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,22 @@ >+2021-06-30 Ryosuke Niwa <rniwa@webkit.org> >+ >+ Use WeakHashMap and WeakPtr with Node in more places >+ https://bugs.webkit.org/show_bug.cgi?id=227192 >+ <rdar://problem/79828322> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/WeakHashMap.h: >+ (WTF::WeakHashMap::WeakHashMapIteratorBase::makePeek): Fixed type mismatch errors. >+ (WTF::WeakHashMap::ensure): Made this function return AddResult like HashMap::ensure. >+ (WTF::WeakHashMap::take): Added. >+ (WTF::WeakHashMap::removeIf): Fixed the bug that the callback was called with the iterator >+ of m_impl and not WeakHashMapIterator. >+ * wtf/WeakHashSet.h: >+ (WTF::HashTraits<Ref<WeakPtrImpl<Counter>>>::isReleasedWeakValue): Moved to WeakPtr.h >+ * wtf/WeakPtr.h: >+ (WTF::HashTraits<Ref<WeakPtrImpl<Counter>>>::isReleasedWeakValue): Moved from WeakHashSet.h >+ > 2021-06-17 Mark Lam <mark.lam@apple.com> > > Rename numberOfPACBits to maxNumberOfAllowedPACBits. >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index eeab7b6bb6ddae88ebe5e281c10c85d623b296b2..782ec94b84ee13f30f88f60c45cfff40cbb33627 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,44 @@ >+2021-06-30 Ryosuke Niwa <rniwa@webkit.org> >+ >+ Use WeakHashMap and WeakPtr with Node in more places >+ https://bugs.webkit.org/show_bug.cgi?id=227192 >+ <rdar://problem/79828322> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Deploy WeakHashMap and WeakPtr with Node/Element in more places. >+ >+ * dom/Document.cpp: >+ (WebCore::Document::elementForAccessKey): >+ (WebCore::Document::buildAccessKeyCache): >+ (WebCore::Document::registerForVisibilityStateChangedCallbacks): >+ (WebCore::Document::unregisterForVisibilityStateChangedCallbacks): >+ (WebCore::Document::visibilityStateChanged): >+ * dom/Document.h: >+ * dom/VisibilityChangeClient.h: >+ * html/FormController.cpp: >+ (WebCore::FormKeyGenerator::formKey): >+ (WebCore::FormKeyGenerator::willDeleteForm): >+ * html/HTMLAnchorElement.cpp: >+ (WebCore::rootEditableElementMap): >+ (WebCore::HTMLAnchorElement::rootEditableElementForSelectionOnMouseDown const): >+ (WebCore::HTMLAnchorElement::clearRootEditableElementForSelectionOnMouseDown): >+ (WebCore::HTMLAnchorElement::setRootEditableElementForSelectionOnMouseDown): >+ * inspector/agents/InspectorDOMAgent.cpp: >+ (WebCore::InspectorDOMAgent::bind): >+ (WebCore::InspectorDOMAgent::unbind): >+ (WebCore::InspectorDOMAgent::nodeForId): >+ (WebCore::InspectorDOMAgent::pushNodePathToFrontend): >+ (WebCore::InspectorDOMAgent::boundNodeId): >+ (WebCore::InspectorDOMAgent::willDestroyDOMNode): >+ (WebCore::InspectorDOMAgent::mediaMetricsTimerFired): >+ * inspector/agents/InspectorDOMAgent.h: >+ * inspector/agents/InspectorLayerTreeAgent.cpp: >+ (WebCore::InspectorLayerTreeAgent::bindPseudoElement): >+ (WebCore::InspectorLayerTreeAgent::unbindPseudoElement): >+ * inspector/agents/InspectorLayerTreeAgent.h: >+ * style/StyleSharingResolver.h: >+ > 2021-06-17 Chris Dumez <cdumez@apple.com> > > Add support for IDBCursor.request >diff --git a/Source/WTF/wtf/WeakHashMap.h b/Source/WTF/wtf/WeakHashMap.h >index 16712e57ca63eacd1021c652206e78ec7c834924..714a50d6bdcf7bfb47c359e41afc66fed0c88f66 100644 >--- a/Source/WTF/wtf/WeakHashMap.h >+++ b/Source/WTF/wtf/WeakHashMap.h >@@ -93,14 +93,14 @@ public: > ALWAYS_INLINE IteratorPeekType makePeek() > { > auto* entry = m_position.get(); >- KeyType* key = entry->key->template get<KeyType>(); >+ auto* key = static_cast<KeyType*>(entry->key->template get<KeyType>()); > return IteratorPeekType { *key, entry->value }; > } > > ALWAYS_INLINE IteratorPeekType makePeek() const > { > auto* entry = m_position.get(); >- KeyType* key = entry->key->template get<KeyType>(); >+ auto* key = static_cast<KeyType*>(entry->key->template get<KeyType>()); > return IteratorPeekType { *key, const_cast<ValueType&>(entry->value) }; > } > >@@ -194,7 +194,13 @@ public: > const_iterator begin() const { return WeakHashMapConstIterator(*this, m_map.begin()); } > const_iterator end() const { return WeakHashMapConstIterator(*this, m_map.end()); } > >- template <typename Functor> void ensure(const KeyType& key, Functor&& functor) { return m_map.ensure(key, functor); } >+ template <typename Functor> >+ AddResult ensure(const KeyType& key, Functor&& functor) >+ { >+ amortizedCleanupIfNeeded(); >+ auto result = m_map.ensure(makeKeyImpl(key), functor); >+ return AddResult { WeakHashMapIterator(*this, result.iterator), result.isNewEntry }; >+ } > > template<typename T> > AddResult add(const KeyType& key, T&& value) >@@ -238,6 +244,15 @@ public: > return m_map.contains(*keyImpl); > } > >+ typename ValueTraits::TakeType take(const KeyType& key) >+ { >+ amortizedCleanupIfNeeded(); >+ auto* keyImpl = keyImplIfExists(key); >+ if (!keyImpl) >+ return ValueTraits::take(ValueTraits::emptyValue()); >+ return m_map.take(*keyImpl); >+ } >+ > typename ValueTraits::PeekType get(const KeyType& key) > { > amortizedCleanupIfNeeded(); >@@ -266,11 +281,13 @@ public: > bool removeIf(Functor&& functor) > { > m_operationCountSinceLastCleanup = 0; >- return m_map.removeIf([&](auto& iterator) { >- bool isReleasedWeakKey = !iterator.key.get(); >+ return m_map.removeIf([&](auto& entry) { >+ auto* key = static_cast<KeyType*>(entry.key->template get<KeyType>()); >+ bool isReleasedWeakKey = !key; > if (isReleasedWeakKey) > return true; >- return functor(iterator); >+ PeekType peek { *key, entry.value }; >+ return functor(peek); > }); > } > >diff --git a/Source/WTF/wtf/WeakHashSet.h b/Source/WTF/wtf/WeakHashSet.h >index 2f3d0a35dddb09dae02994267f6936ddd6b30ef0..99bb34bee4a1b084595e9d0237ccd9edeb3f5bca 100644 >--- a/Source/WTF/wtf/WeakHashSet.h >+++ b/Source/WTF/wtf/WeakHashSet.h >@@ -31,14 +31,6 @@ > > namespace WTF { > >-template<typename Counter> struct HashTraits<Ref<WeakPtrImpl<Counter>>> : RefHashTraits<WeakPtrImpl<Counter>> { >- static constexpr bool hasIsReleasedWeakValueFunction = true; >- static bool isReleasedWeakValue(const Ref<WeakPtrImpl<Counter>>& value) >- { >- return !value.isHashTableDeletedValue() && !value.isHashTableEmptyValue() && !value.get(); >- } >-}; >- > template<typename T, typename Counter = EmptyCounter> > class WeakHashSet final { > WTF_MAKE_FAST_ALLOCATED; >diff --git a/Source/WTF/wtf/WeakPtr.h b/Source/WTF/wtf/WeakPtr.h >index 862b85da44ae824707721e3a01cb2063d9070dae..935ed3fe132e339578820431f5fef951c978ef10 100644 >--- a/Source/WTF/wtf/WeakPtr.h >+++ b/Source/WTF/wtf/WeakPtr.h >@@ -26,6 +26,7 @@ > > #pragma once > >+#include <wtf/HashTraits.h> > #include <wtf/Threading.h> > > namespace WTF { >@@ -82,6 +83,14 @@ private: > #endif > }; > >+template<typename Counter> struct HashTraits<Ref<WeakPtrImpl<Counter>>> : RefHashTraits<WeakPtrImpl<Counter>> { >+ static constexpr bool hasIsReleasedWeakValueFunction = true; >+ static bool isReleasedWeakValue(const Ref<WeakPtrImpl<Counter>>& value) >+ { >+ return !value.isHashTableDeletedValue() && !value.isHashTableEmptyValue() && !value.get(); >+ } >+}; >+ > template<typename T, typename Counter> class WeakPtr { > WTF_MAKE_FAST_ALLOCATED; > public: >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index cc261544b9cce0b8a4d1de6dbbcf64064b13700c..4c91877d2c072e85829e9fd23d28da0e15afbbfc 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -880,13 +880,13 @@ Element* Document::elementForAccessKey(const String& key) > return nullptr; > if (!m_accessKeyCache) > buildAccessKeyCache(); >- return m_accessKeyCache->get(key); >+ return m_accessKeyCache->get(key).get(); > } > > void Document::buildAccessKeyCache() > { >- m_accessKeyCache = makeUnique<HashMap<String, Element*, ASCIICaseInsensitiveHash>>([this] { >- HashMap<String, Element*, ASCIICaseInsensitiveHash> map; >+ m_accessKeyCache = makeUnique<HashMap<String, WeakPtr<Element>, ASCIICaseInsensitiveHash>>([this] { >+ HashMap<String, WeakPtr<Element>, ASCIICaseInsensitiveHash> map; > for (auto& node : composedTreeDescendants(*this)) { > if (!is<Element>(node)) > continue; >@@ -894,7 +894,7 @@ void Document::buildAccessKeyCache() > auto& key = element.attributeWithoutSynchronization(accesskeyAttr); > if (key.isEmpty()) > continue; >- map.add(key, &element); >+ map.add(key, makeWeakPtr(element)); > } > return map; > }()); >@@ -1827,20 +1827,20 @@ void Document::titleElementTextChanged(Element& titleElement) > > void Document::registerForVisibilityStateChangedCallbacks(VisibilityChangeClient& client) > { >- m_visibilityStateCallbackClients.add(&client); >+ m_visibilityStateCallbackClients.add(client); > } > > void Document::unregisterForVisibilityStateChangedCallbacks(VisibilityChangeClient& client) > { >- m_visibilityStateCallbackClients.remove(&client); >+ m_visibilityStateCallbackClients.remove(client); > } > > void Document::visibilityStateChanged() > { > // https://w3c.github.io/page-visibility/#reacting-to-visibilitychange-changes > queueTaskToDispatchEvent(TaskSource::UserInteraction, Event::create(eventNames().visibilitychangeEvent, Event::CanBubble::Yes, Event::IsCancelable::No)); >- for (auto* client : m_visibilityStateCallbackClients) >- client->visibilityStateChanged(); >+ for (auto& client : m_visibilityStateCallbackClients) >+ client.visibilityStateChanged(); > > #if ENABLE(MEDIA_STREAM) && PLATFORM(IOS_FAMILY) > if (auto mediaSessionManager = PlatformMediaSessionManager::sharedManagerIfExists()) { >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index ce895dfb1529e5fb7444399fb61216514a5a52be..f099acd5bf49254d3a29050406c24fd9fef08225 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -1874,9 +1874,9 @@ private: > WeakPtr<Element> m_mainArticleElement; > WeakHashSet<Element> m_articleElements; > >- HashSet<VisibilityChangeClient*> m_visibilityStateCallbackClients; >+ WeakHashSet<VisibilityChangeClient> m_visibilityStateCallbackClients; > >- std::unique_ptr<HashMap<String, Element*, ASCIICaseInsensitiveHash>> m_accessKeyCache; >+ std::unique_ptr<HashMap<String, WeakPtr<Element>, ASCIICaseInsensitiveHash>> m_accessKeyCache; > > std::unique_ptr<ConstantPropertyMap> m_constantPropertyMap; > >diff --git a/Source/WebCore/dom/VisibilityChangeClient.h b/Source/WebCore/dom/VisibilityChangeClient.h >index 86868a858ad3c4f3adb7e5edebf4f8b3b7c8d269..62350e429d8539df9a03326b4df8dd39117a0482 100644 >--- a/Source/WebCore/dom/VisibilityChangeClient.h >+++ b/Source/WebCore/dom/VisibilityChangeClient.h >@@ -27,7 +27,7 @@ > > namespace WebCore { > >-class VisibilityChangeClient { >+class VisibilityChangeClient : public CanMakeWeakPtr<VisibilityChangeClient> { > public: > virtual ~VisibilityChangeClient() = default; > >diff --git a/Source/WebCore/html/FormController.cpp b/Source/WebCore/html/FormController.cpp >index 491d057b750e737a1adf645614fe86484950c58e..128c76591d7792a2fff5f573bf6da469c08df03f 100644 >--- a/Source/WebCore/html/FormController.cpp >+++ b/Source/WebCore/html/FormController.cpp >@@ -25,6 +25,7 @@ > #include "HTMLInputElement.h" > #include "ScriptDisallowedScope.h" > #include <wtf/NeverDestroyed.h> >+#include <wtf/WeakHashMap.h> > #include <wtf/text/StringBuilder.h> > #include <wtf/text/StringConcatenateNumbers.h> > #include <wtf/text/StringToIntegerConversion.h> >@@ -272,10 +273,8 @@ public: > void willDeleteForm(HTMLFormElement*); > > private: >- typedef HashMap<HTMLFormElement*, AtomString> FormToKeyMap; >- typedef HashMap<String, unsigned> FormSignatureToNextIndexMap; >- FormToKeyMap m_formToKeyMap; >- FormSignatureToNextIndexMap m_formSignatureToNextIndexMap; >+ WeakHashMap<HTMLFormElement, AtomString> m_formToKeyMap; >+ HashMap<String, unsigned> m_formSignatureToNextIndexMap; > }; > > static inline void recordFormStructure(const HTMLFormElement& form, StringBuilder& builder) >@@ -323,7 +322,7 @@ AtomString FormKeyGenerator::formKey(const HTMLFormControlElementWithState& cont > return formKeyForNoOwner; > } > >- return m_formToKeyMap.ensure(form.get(), [this, &form] { >+ return m_formToKeyMap.ensure(*form, [this, &form] { > auto signature = formSignature(*form); > auto nextIndex = m_formSignatureToNextIndexMap.add(signature, 0).iterator->value++; > // FIXME: Would be nice to have makeAtomString to use to optimize the case where the string already exists. >@@ -333,8 +332,8 @@ AtomString FormKeyGenerator::formKey(const HTMLFormControlElementWithState& cont > > void FormKeyGenerator::willDeleteForm(HTMLFormElement* form) > { >- ASSERT(form); >- m_formToKeyMap.remove(form); >+ RELEASE_ASSERT(form); >+ m_formToKeyMap.remove(*form); > } > > // ---------------------------------------------------------------------------- >diff --git a/Source/WebCore/html/HTMLAnchorElement.cpp b/Source/WebCore/html/HTMLAnchorElement.cpp >index 010707ac36e66561a8e08c6d50c18c88d6627642..01d719ad53a59e517dfb60eaee1dd009d1bf36a9 100644 >--- a/Source/WebCore/html/HTMLAnchorElement.cpp >+++ b/Source/WebCore/html/HTMLAnchorElement.cpp >@@ -55,6 +55,7 @@ > #include "Settings.h" > #include "UserGestureIndicator.h" > #include <wtf/IsoMallocInlines.h> >+#include <wtf/WeakHashMap.h> > #include <wtf/text/StringBuilder.h> > #include <wtf/text/StringConcatenateNumbers.h> > >@@ -589,26 +590,24 @@ bool HTMLAnchorElement::willRespondToMouseClickEvents() > return isLink() || HTMLElement::willRespondToMouseClickEvents(); > } > >-typedef HashMap<const HTMLAnchorElement*, RefPtr<Element>> RootEditableElementMap; >- >-static RootEditableElementMap& rootEditableElementMap() >+static auto& rootEditableElementMap() > { >- static NeverDestroyed<RootEditableElementMap> map; >- return map; >+ static NeverDestroyed<WeakHashMap<HTMLAnchorElement, WeakPtr<Element>>> map; >+ return map.get(); > } > > Element* HTMLAnchorElement::rootEditableElementForSelectionOnMouseDown() const > { > if (!m_hasRootEditableElementForSelectionOnMouseDown) > return 0; >- return rootEditableElementMap().get(this); >+ return rootEditableElementMap().get(*this).get(); > } > > void HTMLAnchorElement::clearRootEditableElementForSelectionOnMouseDown() > { > if (!m_hasRootEditableElementForSelectionOnMouseDown) > return; >- rootEditableElementMap().remove(this); >+ rootEditableElementMap().remove(*this); > m_hasRootEditableElementForSelectionOnMouseDown = false; > } > >@@ -619,7 +618,7 @@ void HTMLAnchorElement::setRootEditableElementForSelectionOnMouseDown(Element* e > return; > } > >- rootEditableElementMap().set(this, element); >+ rootEditableElementMap().set(*this, makeWeakPtr(element)); > m_hasRootEditableElementForSelectionOnMouseDown = true; > } > >diff --git a/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp b/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp >index 6459cedc046c479334d3e983672b04e04dbdad53..dadfa3012201c0eb036a142bafa9eb528efb1c56 100644 >--- a/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp >+++ b/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp >@@ -380,16 +380,16 @@ void InspectorDOMAgent::setDocument(Document* document) > > Protocol::DOM::NodeId InspectorDOMAgent::bind(Node& node) > { >- return m_nodeToId.ensure(&node, [&] { >+ return m_nodeToId.ensure(node, [&] { > auto id = m_lastNodeId++; >- m_idToNode.set(id, &node); >+ m_idToNode.set(id, makeWeakPtr(node)); > return id; > }).iterator->value; > } > > void InspectorDOMAgent::unbind(Node& node) > { >- auto id = m_nodeToId.take(&node); >+ auto id = m_nodeToId.take(node); > if (!id) > return; > >@@ -566,7 +566,7 @@ Node* InspectorDOMAgent::nodeForId(Protocol::DOM::NodeId id) > if (!m_idToNode.isValidKey(id)) > return nullptr; > >- return m_idToNode.get(id); >+ return m_idToNode.get(id).get(); > } > > Protocol::ErrorStringOr<void> InspectorDOMAgent::requestChildNodes(Protocol::DOM::NodeId nodeId, std::optional<int>&& depth) >@@ -646,7 +646,7 @@ Protocol::DOM::NodeId InspectorDOMAgent::pushNodePathToFrontend(Protocol::ErrorS > } > > // FIXME: <https://webkit.org/b/213499> Web Inspector: allow DOM nodes to be instrumented at any point, regardless of whether the main document has also been instrumented >- if (!m_nodeToId.contains(m_document.get())) { >+ if (!m_nodeToId.contains(*m_document)) { > errorString = "Document must have been requested"_s; > return 0; > } >@@ -684,10 +684,10 @@ Protocol::DOM::NodeId InspectorDOMAgent::pushNodePathToFrontend(Protocol::ErrorS > > Protocol::DOM::NodeId InspectorDOMAgent::boundNodeId(const Node* node) > { >- if (!m_nodeToId.isValidKey(node)) >+ if (!node) > return 0; > >- return m_nodeToId.get(node); >+ return m_nodeToId.get(*node); > } > > Protocol::ErrorStringOr<void> InspectorDOMAgent::setAttributeValue(Protocol::DOM::NodeId nodeId, const String& name, const String& value) >@@ -2466,7 +2466,7 @@ void InspectorDOMAgent::willDestroyDOMNode(Node& node) > if (containsOnlyHTMLWhitespace(&node)) > return; > >- auto nodeId = m_nodeToId.take(&node); >+ auto nodeId = m_nodeToId.take(node); > if (!nodeId) > return; > >@@ -2753,9 +2753,9 @@ void InspectorDOMAgent::mediaMetricsTimerFired() > auto videoPlaybackQuality = mediaElement->getVideoPlaybackQuality(); > unsigned displayCompositedVideoFrames = videoPlaybackQuality->displayCompositedVideoFrames(); > >- auto iterator = m_mediaMetrics.find(mediaElement); >+ auto iterator = m_mediaMetrics.find(*mediaElement); > if (iterator == m_mediaMetrics.end()) { >- m_mediaMetrics.set(mediaElement, MediaMetrics(displayCompositedVideoFrames)); >+ m_mediaMetrics.set(*mediaElement, MediaMetrics(displayCompositedVideoFrames)); > continue; > } > >@@ -2773,7 +2773,7 @@ void InspectorDOMAgent::mediaMetricsTimerFired() > } > > m_mediaMetrics.removeIf([&] (auto& entry) { >- return !HTMLMediaElement::allMediaElements().contains(entry.key); >+ return !HTMLMediaElement::allMediaElements().contains(&entry.key); > }); > } > #endif >diff --git a/Source/WebCore/inspector/agents/InspectorDOMAgent.h b/Source/WebCore/inspector/agents/InspectorDOMAgent.h >index 33b8284ea07928818b2bc88bd754df3717076bf6..4eb63b7985721ac6ea6003c884989179c78eda00 100644 >--- a/Source/WebCore/inspector/agents/InspectorDOMAgent.h >+++ b/Source/WebCore/inspector/agents/InspectorDOMAgent.h >@@ -41,6 +41,7 @@ > #include <wtf/JSONValues.h> > #include <wtf/RefPtr.h> > #include <wtf/Vector.h> >+#include <wtf/WeakHashMap.h> > #include <wtf/text/AtomString.h> > > namespace Inspector { >@@ -248,8 +249,8 @@ private: > RefPtr<Inspector::DOMBackendDispatcher> m_backendDispatcher; > Page& m_inspectedPage; > InspectorOverlay* m_overlay { nullptr }; >- HashMap<const Node*, Inspector::Protocol::DOM::NodeId> m_nodeToId; >- HashMap<Inspector::Protocol::DOM::NodeId, Node*> m_idToNode; >+ WeakHashMap<Node, Inspector::Protocol::DOM::NodeId> m_nodeToId; >+ HashMap<Inspector::Protocol::DOM::NodeId, WeakPtr<Node>> m_idToNode; > HashSet<Inspector::Protocol::DOM::NodeId> m_childrenRequested; > Inspector::Protocol::DOM::NodeId m_lastNodeId { 1 }; > RefPtr<Document> m_document; >@@ -282,7 +283,7 @@ private: > }; > > // The pointer key for this map should not be used for anything other than matching. >- HashMap<HTMLMediaElement*, MediaMetrics> m_mediaMetrics; >+ WeakHashMap<HTMLMediaElement, MediaMetrics> m_mediaMetrics; > #endif > > struct InspectorEventListener { >diff --git a/Source/WebCore/inspector/agents/InspectorLayerTreeAgent.cpp b/Source/WebCore/inspector/agents/InspectorLayerTreeAgent.cpp >index e3ce55c3ed5eb254353741635aa7a5cc29ae7a84..3802a34f293e65d66e77eb4438ec41b7c7687cf7 100644 >--- a/Source/WebCore/inspector/agents/InspectorLayerTreeAgent.cpp >+++ b/Source/WebCore/inspector/agents/InspectorLayerTreeAgent.cpp >@@ -351,16 +351,18 @@ String InspectorLayerTreeAgent::bindPseudoElement(PseudoElement* pseudoElement) > { > if (!pseudoElement) > return emptyString(); >- return m_pseudoElementToIdMap.ensure(pseudoElement, [this, pseudoElement] { >+ return m_pseudoElementToIdMap.ensure(*pseudoElement, [this, pseudoElement] { > auto identifier = IdentifiersFactory::createIdentifier(); >- m_idToPseudoElement.set(identifier, pseudoElement); >+ m_idToPseudoElement.set(identifier, makeWeakPtr(pseudoElement)); > return identifier; > }).iterator->value; > } > > void InspectorLayerTreeAgent::unbindPseudoElement(PseudoElement* pseudoElement) > { >- auto identifier = m_pseudoElementToIdMap.take(pseudoElement); >+ if (!pseudoElement) >+ return; >+ auto identifier = m_pseudoElementToIdMap.take(*pseudoElement); > if (identifier.isNull()) > return; > m_idToPseudoElement.remove(identifier); >diff --git a/Source/WebCore/inspector/agents/InspectorLayerTreeAgent.h b/Source/WebCore/inspector/agents/InspectorLayerTreeAgent.h >index 5f11531cc644429f48d1d6d81551dd84b9f94ccc..1c061f16b207492058eae4bcbd11e12f0e994fe2 100644 >--- a/Source/WebCore/inspector/agents/InspectorLayerTreeAgent.h >+++ b/Source/WebCore/inspector/agents/InspectorLayerTreeAgent.h >@@ -32,6 +32,7 @@ > #include <JavaScriptCore/InspectorBackendDispatchers.h> > #include <JavaScriptCore/InspectorFrontendDispatchers.h> > #include <JavaScriptCore/InspectorProtocolObjects.h> >+#include <wtf/WeakHashMap.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -87,8 +88,8 @@ private: > HashMap<const RenderLayer*, Inspector::Protocol::LayerTree::LayerId> m_documentLayerToIdMap; > HashMap<Inspector::Protocol::LayerTree::LayerId, const RenderLayer*> m_idToLayer; > >- HashMap<PseudoElement*, Inspector::Protocol::LayerTree::PseudoElementId> m_pseudoElementToIdMap; >- HashMap<Inspector::Protocol::LayerTree::PseudoElementId, PseudoElement*> m_idToPseudoElement; >+ WeakHashMap<PseudoElement, Inspector::Protocol::LayerTree::PseudoElementId> m_pseudoElementToIdMap; >+ HashMap<Inspector::Protocol::LayerTree::PseudoElementId, WeakPtr<PseudoElement>> m_idToPseudoElement; > > bool m_suppressLayerChangeEvents { false }; > }; >diff --git a/Source/WebCore/style/StyleSharingResolver.h b/Source/WebCore/style/StyleSharingResolver.h >index 9952c665542a34b4fd6dd490d49dba1fe0de2d90..d5ab9447e38f95633536b548d0e33ae665b6bdfc 100644 >--- a/Source/WebCore/style/StyleSharingResolver.h >+++ b/Source/WebCore/style/StyleSharingResolver.h >@@ -64,6 +64,7 @@ private: > const ScopeRuleSets& m_ruleSets; > const SelectorFilter& m_selectorFilter; > >+ // FIXME: Use WeakHashMap or HashMap<CheckedPtr, CheckedPtr>. > HashMap<const Element*, const Element*> m_elementsSharingStyle; > }; >
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 227192
:
431816
|
431823
| 432618