This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Web Inspector: preserve DOM.NodeId if a node is removed and re-added
https://bugs.webkit.org/show_bug.cgi?id=189687 Reviewed by Devin Rousso. Source/WebCore: Instead of unbinding and rebinding nodes upon removal/reinsertion to the DOM tree, we should only perform the unbinding actions on a `Node` that is being destroyed. This resolves an issue where console messages with DOM nodes would behave unexpectedly because the node for a visible console message could have its children removed in `DOMManager.prototype._unbind`, even though the node would still have its children when it is removed from the DOM tree (unless it is being destroyed, which is handled by `DOMManager.prototype.willDestroyDOMNode`). While not a cause of an issue here, it is worth noting (due to confusion it caused me while investigating) that even after we stopped keeping `RefPtr<Node>` for nodes in r278785 the nodes themselves continued to be kept alive as part of the `RemoteObject` mechanism because the inspector injected script holds on to nodes until the `RemoteObject` is released. * inspector/agents/InspectorCSSAgent.cpp: (WebCore::InspectorCSSAgent::nodeLayoutContextTypeChanged): * inspector/agents/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::reset): (WebCore::InspectorDOMAgent::bind): (WebCore::InspectorDOMAgent::didCommitLoad): (WebCore::InspectorDOMAgent::didInsertDOMNode): (WebCore::InspectorDOMAgent::didRemoveDOMNode): (WebCore::InspectorDOMAgent::pseudoElementDestroyed): (WebCore::InspectorDOMAgent::unbind): Deleted. - We should no longer be unbinding and rebinding nodes on insertion/removal, since nodes should keep the same ID for their lifetime, and we will clean up the binding upon the Node's destruction. (WebCore::InspectorDOMAgent::willDestroyDOMNode): (WebCore::InspectorDOMAgent::destroyedNodesTimerFired): - A Node in middle of being destroyed will no longer have a parent. * inspector/agents/InspectorDOMAgent.h: Source/WebInspectorUI: Instead of unbinding and rebinding nodes upon removal/reinsertion to the DOM tree, we should only perform the unbinding actions on a `Node` that is being destroyed. * UserInterface/Controllers/DOMDebuggerManager.js: * UserInterface/Controllers/DOMManager.js: (WI.DOMManager.prototype._pseudoElementAdded): (WI.DOMManager.prototype.willDestroyDOMNode): (WI.DOMManager.prototype._unbind): - To match the backend, we should only unbind nodes when they are destroyed, not removed. * UserInterface/Models/DOMNode.js: (WI.DOMNode.prototype.newOrExistingFromPayload): - Reuse an existing orphaned DOMNode if it already exists. In the future, we want to stop sending entire node payloads to the frontend in those situations. (WI.DOMNode.prototype._insertChild): (WI.DOMNode.prototype._setChildrenPayload): LayoutTests: Update test to reflect that DOM breakpoints are now able to be reattached to their original node upon insertion following removal. * inspector/dom-debugger/dom-breakpoint-node-removed-ancestor.html: * inspector/dom-debugger/dom-breakpoint-node-removed-ancestor-expected.txt: * inspector/dom-debugger/dom-breakpoint-node-removed-direct-expected.txt: * inspector/dom-debugger/resources/dom-breakpoint-utilities.js: (TestPage.registerInitializer.InspectorTest.DOMBreakpoint.createBreakpoint): - Add an event handler to log the setting of the domNode for breakpoints. In order to prevent spurious output when removing breakpoints, instrument the removal of breakpoints to remove the testing event handler before the node is changed. Canonical link: https://commits.webkit.org/249538@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292754 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing 13 changed files with 228 additions and 85 deletions.