RESOLVED FIXED 179283
Web Inspector: support undo/redo of insertAdjacentHTML
https://bugs.webkit.org/show_bug.cgi?id=179283
Summary Web Inspector: support undo/redo of insertAdjacentHTML
Devin Rousso
Reported 2017-11-04 00:24:58 PDT
.
Attachments
Patch (20.16 KB, patch)
2017-11-05 02:45 PST, Devin Rousso
no flags
Patch (27.03 KB, patch)
2017-11-09 03:59 PST, Devin Rousso
no flags
Patch (22.10 KB, patch)
2017-11-09 14:10 PST, Devin Rousso
no flags
Patch (27.05 KB, patch)
2017-11-09 14:13 PST, Devin Rousso
no flags
Devin Rousso
Comment 1 2017-11-05 02:45:34 PST
Joseph Pecoraro
Comment 2 2017-11-08 18:47:52 PST
Comment on attachment 326060 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=326060&action=review Nice test! This looks good to me, but I will want to see a version that shares the Element algorithm. We should never duplicate core algorithms (even if this seems relative simple). > Source/JavaScriptCore/inspector/protocol/DOM.json:225 > + "name": "insertAdjacentHTML", I think this would go better down by "setOuterHTML". > Source/WebCore/dom/Element.cpp:3669 > +ExceptionOr<NodeVector> Element::nodesForInsertedAdjacentHTML(const String& position, const String& html) I feel like the algorithm should really be one place. That could be done with something like: ExceptionOr<void> Element::insertAdjacentHTML(const String& where, const String& markup, std::optional<NodeVector>& nodes) { ... /* this will only collect nodes if (nodes) */ } ExceptionOr<void> Element::insertAdjacentHTML(const String& where, const String& markup) { return insertAdjacentHTML(where, markup, std::nullopt); } > Source/WebCore/inspector/DOMEditor.cpp:280 > + : Action("InsertAdjacentHTML") Is the name actually used for anything? I wonder if we should just remove it. Or we can move to ASCIILiteral("...") to save a copy. > Source/WebCore/inspector/DOMEditor.h:75 > class ReplaceWholeTextAction; > + class InsertAdjacentHTMLAction; Nit: `sort` these > Source/WebCore/inspector/agents/InspectorDOMAgent.h:125 > + void insertAdjacentHTML(ErrorString&, int nodeId, const String& position, const String& html) override; Nit: The order of these should match the JSON, so preferably after setOuterHTML. > Source/WebInspectorUI/UserInterface/Models/DOMNode.js:508 > + // COMPATIBILITY (iOS 11.1): DOM.insertAdjacentHTML did not exist. Nit: Just say "COMPATIBILITY (iOS 11.0)", since `11.0` is the last versioned protocol that was different. > LayoutTests/inspector/dom/insertAdjacentHTML-expected.txt:1 > +Test for DOM.setOuterHTML on a page without a documentElement. Fix this title.
Devin Rousso
Comment 3 2017-11-09 03:59:17 PST
Created attachment 326439 [details] Patch It took way too long to figure out that I needed to put & after NodeVector in order to not copy a Ref...
Joseph Pecoraro
Comment 4 2017-11-09 11:23:18 PST
Comment on attachment 326439 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=326439&action=review r=me > Source/WebCore/dom/Element.h:315 > + ExceptionOr<void> insertAdjacentHTML(const String& where, const String& html, std::optional<NodeVector&> nodes); I think the name `nodes` could be `addedNodes` and it would be clearer.
Devin Rousso
Comment 5 2017-11-09 14:10:19 PST
Devin Rousso
Comment 6 2017-11-09 14:13:35 PST
Created attachment 326486 [details] Patch Whoops. Forgot tests.
WebKit Commit Bot
Comment 7 2017-11-09 15:12:05 PST
Comment on attachment 326486 [details] Patch Clearing flags on attachment: 326486 Committed r224648: <https://trac.webkit.org/changeset/224648>
WebKit Commit Bot
Comment 8 2017-11-09 15:12:07 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 9 2017-11-15 09:42:34 PST
Note You need to log in before you can comment on or make changes to this bug.