Changeset 246658 in webkit


Ignore:
Timestamp:
Jun 20, 2019 3:45:17 PM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Edit -> Tag doesn't do anything for html, head, and body elements
https://bugs.webkit.org/show_bug.cgi?id=199052
<rdar://problem/51923906>

Reviewed by Matt Baker.

  • UserInterface/Views/DOMTreeElement.js:

(WI.DOMTreeElement.prototype.populateDOMNodeContextMenu):

  • Don't show an "Edit > Tag" for <html>, <head>, and <body> nodes
  • Disable any "Edit" submenu item if it's target is already being edited
  • Prevent "Add" submenu items from being shown for text nodes
Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r246624 r246658  
     12019-06-20  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Edit -> Tag doesn't do anything for html, head, and body elements
     4        https://bugs.webkit.org/show_bug.cgi?id=199052
     5        <rdar://problem/51923906>
     6
     7        Reviewed by Matt Baker.
     8
     9        * UserInterface/Views/DOMTreeElement.js:
     10        (WI.DOMTreeElement.prototype.populateDOMNodeContextMenu):
     11         - Don't show an "Edit > Tag" for <html>, <head>, and <body> nodes
     12         - Disable any "Edit" submenu item if it's target is already being edited
     13         - Prevent "Add" submenu items from being shown for text nodes
     14
    1152019-06-19  Devin Rousso  <drousso@apple.com>
    216
  • trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js

    r245827 r246658  
    744744    populateDOMNodeContextMenu(contextMenu, subMenus, event)
    745745    {
    746         let attribute = event.target.closest(".html-attribute");
     746        let attributeNode = event.target.closest(".html-attribute");
    747747        let textNode = event.target.closest(".html-text-node");
    748748
    749749        let attributeName = null;
    750         if (attribute) {
    751             let attributeNameElement = attribute.getElementsByClassName("html-attribute-name")[0];
     750        if (attributeNode) {
     751            let attributeNameElement = attributeNode.getElementsByClassName("html-attribute-name")[0];
    752752            if (attributeNameElement)
    753753                attributeName = attributeNameElement.textContent.trim();
     
    760760
    761761        let isEditableNode = this.representedObject.nodeType() === Node.ELEMENT_NODE && this.editable;
    762         let isNonShadowEditable = !this.representedObject.isInUserAgentShadowTree() && this.editable;
    763         let forbiddenClosingTag = WI.DOMTreeElement.ForbiddenClosingTagElements.has(this.representedObject.nodeNameInCorrectCase());
     762        let isNonShadowEditable = !this.representedObject.isInUserAgentShadowTree() && isEditableNode;
     763        let alreadyEditingHTML = this._htmlEditElement && WI.isBeingEdited(this._htmlEditElement);
    764764
    765765        if (isEditableNode) {
    766             if (!forbiddenClosingTag) {
     766            if (!DOMTreeElement.ForbiddenClosingTagElements.has(this.representedObject.nodeNameInCorrectCase())) {
    767767                subMenus.add.appendItem(WI.UIString("Child", "A submenu item of 'Add' to append DOM nodes to the selected DOM node"), () => {
    768768                    this._addHTML();
    769                 });
     769                }, alreadyEditingHTML);
    770770            }
    771771
    772772            subMenus.add.appendItem(WI.UIString("Previous Sibling", "A submenu item of 'Add' to add DOM nodes before the selected DOM node"), () => {
    773773                this._addPreviousSibling();
    774             });
     774            }, alreadyEditingHTML);
    775775
    776776            subMenus.add.appendItem(WI.UIString("Next Sibling", "A submenu item of 'Add' to add DOM nodes after the selected DOM node"), () => {
    777777                this._addNextSibling();
    778             });
     778            }, alreadyEditingHTML);
    779779        }
    780780
     
    788788            subMenus.edit.appendItem(WI.UIString("HTML"), () => {
    789789                this._editAsHTML();
    790             });
     790            }, alreadyEditingHTML);
    791791        }
    792792
     
    794794            if (attributeName) {
    795795                subMenus.edit.appendItem(WI.UIString("Attribute"), () => {
    796                     this._startEditingAttribute(attribute, event.target);
    797                 });
    798             }
    799 
    800             subMenus.edit.appendItem(WI.UIString("Tag", "A submenu item of 'Edit' to change DOM element's tag name"), () => {
    801                 this._startEditingTagName();
    802             });
     796                    this._startEditingAttribute(attributeNode, event.target);
     797                }, WI.isBeingEdited(attributeNode));
     798            }
     799
     800            if (!DOMTreeElement.EditTagBlacklist.has(this.representedObject.nodeNameInCorrectCase())) {
     801                let tagNameNode = event.target.closest(".html-tag-name");
     802
     803                subMenus.edit.appendItem(WI.UIString("Tag", "A submenu item of 'Edit' to change DOM element's tag name"), () => {
     804                    this._startEditingTagName(tagNameNode);
     805                }, WI.isBeingEdited(tagNameNode));
     806            }
    803807        }
    804808
     
    806810            subMenus.edit.appendItem(WI.UIString("Text"), () => {
    807811                this._startEditingTextNode(textNode);
    808             });
     812            }, WI.isBeingEdited(textNode));
    809813        }
    810814
Note: See TracChangeset for help on using the changeset viewer.