Web Inspector: provide a way to view XML/HTML/SVG resource responses as a DOM tree
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / DOMTreeOutline.js
index 85481d7..a932c6d 100644 (file)
@@ -58,6 +58,7 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline
         this._editable = false;
         this._editing = false;
         this._visible = false;
+        this._usingLocalDOMNode = false;
 
         this._hideElementsKeyboardShortcut = new WI.KeyboardShortcut(null, "H", this._hideElements.bind(this), this.element);
         this._hideElementsKeyboardShortcut.implicitlyPreventsDefault = false;
@@ -118,6 +119,12 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline
         return this._isXMLMimeType;
     }
 
+    markAsUsingLocalDOMNode()
+    {
+        this._editable = false;
+        this._usingLocalDOMNode = true;
+    }
+
     selectedDOMNode()
     {
         return this._selectedDOMNode;
@@ -287,6 +294,7 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline
             treeElement.populateDOMNodeContextMenu(contextMenu, subMenus, event, subMenus);
 
         let options = {
+            disallowEditing: !this._editable,
             excludeRevealElement: this._excludeRevealElementContextMenu,
             copySubMenu: subMenus.copy,
         };
@@ -440,6 +448,9 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline
 
     _onmousemove(event)
     {
+        if (this._usingLocalDOMNode)
+            return;
+
         let element = this.treeElementFromEvent(event);
         if (element && this._previousHoveredElement === element)
             return;
@@ -463,6 +474,9 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline
 
     _onmouseout(event)
     {
+        if (this._usingLocalDOMNode)
+            return;
+
         var nodeUnderMouse = document.elementFromPoint(event.pageX, event.pageY);
         if (nodeUnderMouse && this.element.contains(nodeUnderMouse))
             return;
@@ -477,6 +491,9 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline
 
     _ondragstart(event)
     {
+        if (!this._editable)
+            return false;
+
         let treeElement = this.treeElementFromEvent(event);
         if (!treeElement)
             return false;
@@ -500,6 +517,9 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline
 
     _ondragover(event)
     {
+        if (!this._editable)
+            return false;
+
         if (event.dataTransfer.types.includes(WI.GeneralStyleDetailsSidebarPanel.ToggledClassesDragType)) {
             event.preventDefault();
             event.dataTransfer.dropEffect = "copy";
@@ -531,6 +551,9 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline
 
     _ondragleave(event)
     {
+        if (!this._editable)
+            return false;
+
         this._clearDragOverTreeElementMarker();
         event.preventDefault();
         return false;
@@ -553,6 +576,9 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline
 
     _ondrop(event)
     {
+        if (!this._editable)
+            return;
+
         event.preventDefault();
 
         function callback(error, newNodeId)
@@ -592,6 +618,9 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline
 
     _ondragend(event)
     {
+        if (!this._editable)
+            return;
+
         event.preventDefault();
         this._clearDragOverTreeElementMarker();
         delete this._nodeBeingDragged;
@@ -633,6 +662,9 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline
 
     _hideElements(event, keyboardShortcut)
     {
+        if (!this._editable)
+            return;
+
         if (!this.selectedTreeElement || WI.isEditingAnyField())
             return;