Commit 67e48e85 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

DevTools: notify CSS agent before a DOM node is unbound, not after

CSS agent expects to use DOM node id, so notifying it after the
node has been unbound is too late.

Change-Id: I4dad85d2676ae29998a7a3b05a026768fad97e98
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2328295Reviewed-by: default avatarMathias Bynens <mathias@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#793257}
parent 18833fea
...@@ -2220,13 +2220,12 @@ void InspectorCSSAgent::DidAddDocument(Document* document) { ...@@ -2220,13 +2220,12 @@ void InspectorCSSAgent::DidAddDocument(Document* document) {
void InspectorCSSAgent::DidRemoveDocument(Document* document) {} void InspectorCSSAgent::DidRemoveDocument(Document* document) {}
void InspectorCSSAgent::DidRemoveDOMNode(Node* node) { void InspectorCSSAgent::WillRemoveDOMNode(Node* node) {
if (!node) DCHECK(node);
return;
int node_id = dom_agent_->BoundNodeId(node); int node_id = dom_agent_->BoundNodeId(node);
if (node_id) DCHECK(node_id);
node_id_to_forced_pseudo_state_.erase(node_id); node_id_to_forced_pseudo_state_.erase(node_id);
NodeToInspectorStyleSheet::iterator it = NodeToInspectorStyleSheet::iterator it =
node_to_inspector_style_sheet_.find(node); node_to_inspector_style_sheet_.find(node);
......
...@@ -300,7 +300,7 @@ class CORE_EXPORT InspectorCSSAgent final ...@@ -300,7 +300,7 @@ class CORE_EXPORT InspectorCSSAgent final
// InspectorDOMAgent::DOMListener implementation // InspectorDOMAgent::DOMListener implementation
void DidAddDocument(Document*) override; void DidAddDocument(Document*) override;
void DidRemoveDocument(Document*) override; void DidRemoveDocument(Document*) override;
void DidRemoveDOMNode(Node*) override; void WillRemoveDOMNode(Node*) override;
void DidModifyDOMAttr(Element*) override; void DidModifyDOMAttr(Element*) override;
// InspectorStyleSheet::Listener implementation // InspectorStyleSheet::Listener implementation
......
...@@ -331,9 +331,9 @@ void InspectorDOMAgent::Unbind(Node* node, NodeToIdMap* nodes_map) { ...@@ -331,9 +331,9 @@ void InspectorDOMAgent::Unbind(Node* node, NodeToIdMap* nodes_map) {
} }
} }
nodes_map->erase(node);
if (dom_listener_) if (dom_listener_)
dom_listener_->DidRemoveDOMNode(node); dom_listener_->WillRemoveDOMNode(node);
nodes_map->erase(node);
bool children_requested = children_requested_.Contains(id); bool children_requested = children_requested_.Contains(id);
if (children_requested) { if (children_requested) {
......
...@@ -76,7 +76,7 @@ class CORE_EXPORT InspectorDOMAgent final ...@@ -76,7 +76,7 @@ class CORE_EXPORT InspectorDOMAgent final
virtual ~DOMListener() = default; virtual ~DOMListener() = default;
virtual void DidAddDocument(Document*) = 0; virtual void DidAddDocument(Document*) = 0;
virtual void DidRemoveDocument(Document*) = 0; virtual void DidRemoveDocument(Document*) = 0;
virtual void DidRemoveDOMNode(Node*) = 0; virtual void WillRemoveDOMNode(Node*) = 0;
virtual void DidModifyDOMAttr(Element*) = 0; virtual void DidModifyDOMAttr(Element*) = 0;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment