Web Inspector: support undo/redo of insertAdjacentHTML
authorwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Nov 2017 23:12:01 +0000 (23:12 +0000)
committerwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Nov 2017 23:12:01 +0000 (23:12 +0000)
commit2fc542d8b7a4f8bf55433a75a4b3208a0867ce45
tree9ebbaadb40f1122022a4b63c2a2ee186c472a0cb
parent98bf0097db55f803172b2ce78538b524e2f9b468
Web Inspector: support undo/redo of insertAdjacentHTML
https://bugs.webkit.org/show_bug.cgi?id=179283

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

* inspector/protocol/DOM.json:
Add `insertAdjacentHTML` command that executes an undoable version of `insertAdjacentHTML`
on the given node.

Source/WebCore:

Test: inspector/dom/insertAdjacentHTML.html

Create another version of Element::insertAdjacentHTML that keeps track of the nodes that are
added. This is necessary because the children of a DocumentFragment are removed when it is
added to a ContainerNode. In this way, it is possible to remove those nodes during an undo.

* dom/Element.h:
* dom/Element.cpp:
(WebCore::Element::insertAdjacentHTML):

* inspector/DOMEditor.h:
* inspector/DOMEditor.cpp:
(WebCore::DOMEditor::insertAdjacentHTML):
Drive-by fix: sort functions and class declarations.

* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::insertAdjacentHTML):

Source/WebInspectorUI:

* UserInterface/Models/DOMNode.js:
(WI.DOMNode.prototype.insertAdjacentHTML):

* UserInterface/Views/DOMTreeElement.js:
(WI.DOMTreeElement.prototype._startEditingAsHTML):
Drive-by: only attempt to update the cursor if an initialValue is supplied.
LayoutTests:

* inspector/dom/insertAdjacentHTML-expected.txt: Added.
* inspector/dom/insertAdjacentHTML.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224648 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/dom/insertAdjacentHTML-expected.txt [new file with mode: 0644]
LayoutTests/inspector/dom/insertAdjacentHTML.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/DOM.json
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/inspector/DOMEditor.cpp
Source/WebCore/inspector/DOMEditor.h
Source/WebCore/inspector/InspectorHistory.cpp
Source/WebCore/inspector/InspectorHistory.h
Source/WebCore/inspector/agents/InspectorCSSAgent.cpp
Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
Source/WebCore/inspector/agents/InspectorDOMAgent.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/DOMNode.js
Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js