Web Inspector: support undo/redo of insertAdjacentHTML
[WebKit-https.git] / Source / WebCore / inspector / agents / InspectorDOMAgent.cpp
index f9d7dbf..167fda4 100644 (file)
@@ -808,6 +808,20 @@ void InspectorDOMAgent::setOuterHTML(ErrorString& errorString, int nodeId, const
         pushChildNodesToFrontend(newId);
 }
 
+void InspectorDOMAgent::insertAdjacentHTML(ErrorString& errorString, int nodeId, const String& position, const String& html)
+{
+    Node* node = assertEditableNode(errorString, nodeId);
+    if (!node)
+        return;
+
+    if (!is<Element>(node)) {
+        errorString = ASCIILiteral("Can only call insertAdjacentHTML on Elements.");
+        return;
+    }
+
+    m_domEditor->insertAdjacentHTML(downcast<Element>(*node), position, html, errorString);
+}
+
 void InspectorDOMAgent::setNodeValue(ErrorString& errorString, int nodeId, const String& value)
 {
     Node* node = assertEditableNode(errorString, nodeId);