Web Inspector: provide a way to view XML/HTML/SVG resource responses as a DOM tree
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / DOMTreeElement.js
index dababa4..40200cc 100644 (file)
@@ -824,7 +824,7 @@ WI.DOMTreeElement = class DOMTreeElement extends WI.TreeElement
             });
         }
 
-        if (attributeName && isNonShadowEditable) {
+        if (attributeName) {
             subMenus.copy.appendItem(WI.UIString("Attribute"), () => {
                 let text = attributeName;
                 let attributeValue = this.representedObject.getAttribute(attributeName);
@@ -855,16 +855,18 @@ WI.DOMTreeElement = class DOMTreeElement extends WI.TreeElement
         for (let subMenu of Object.values(subMenus))
             contextMenu.pushItem(subMenu);
 
-        if (this.selected && this.treeOutline && this.treeOutline.selectedTreeElements.length > 1) {
-            let forceHidden = !this.treeOutline.selectedTreeElements.every((treeElement) => treeElement.isNodeHidden);
-            let label = forceHidden ? WI.UIString("Hide Elements") : WI.UIString("Show Elements");
-            contextMenu.appendItem(label, () => {
-                this.treeOutline.toggleSelectedElementsVisibility(forceHidden);
-            });
-        } else {
-            contextMenu.appendItem(WI.UIString("Toggle Visibility"), () => {
-                this.toggleElementVisibility();
-            });
+        if (this.treeOutline.editable) {
+            if (this.selected && this.treeOutline && this.treeOutline.selectedTreeElements.length > 1) {
+                let forceHidden = !this.treeOutline.selectedTreeElements.every((treeElement) => treeElement.isNodeHidden);
+                let label = forceHidden ? WI.UIString("Hide Elements") : WI.UIString("Show Elements");
+                contextMenu.appendItem(label, () => {
+                    this.treeOutline.toggleSelectedElementsVisibility(forceHidden);
+                });
+            } else if (isEditableNode) {
+                contextMenu.appendItem(WI.UIString("Toggle Visibility"), () => {
+                    this.toggleElementVisibility();
+                });
+            }
         }
     }