⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243152 in webkit


Ignore:
Timestamp:
Mar 19, 2019, 11:03:33 AM (8 years ago)
Author:
Devin Rousso
Message:

Web Inspector: DOM: "Capture Screenshot" should only be shown if the node is attached
​https://bugs.webkit.org/show_bug.cgi?id=195793
<rdar://problem/48916594>

Reviewed by Joseph Pecoraro.

  • UserInterface/Models/DOMNode.js:

(WI.DOMNode.prototype.get attached): Added.

  • UserInterface/Views/ContextMenuUtilities.js:

(WI.appendContextMenuItemsForDOMNode):

  • UserInterface/Views/DOMTreeElement.js:

(WI.DOMTreeElement.prototype._populateTagContextMenu):

Location:
trunk/Source/WebInspectorUI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r243087 r243152  
     12019-03-19  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: DOM: "Capture Screenshot" should only be shown if the node is attached
     4        https://bugs.webkit.org/show_bug.cgi?id=195793
     5        <rdar://problem/48916594>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * UserInterface/Models/DOMNode.js:
     10        (WI.DOMNode.prototype.get attached): Added.
     11
     12        * UserInterface/Views/ContextMenuUtilities.js:
     13        (WI.appendContextMenuItemsForDOMNode):
     14        * UserInterface/Views/DOMTreeElement.js:
     15        (WI.DOMTreeElement.prototype._populateTagContextMenu):
     16
    1172019-03-18  Joseph Pecoraro  <pecoraro@apple.com>
    218
  • trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js

    r241547 r243152  
    192192            this._frame = WI.networkManager.frameForIdentifier(this.frameIdentifier);
    193193        return this._frame;
     194    }
     195
     196    get attached()
     197    {
     198        for (let node = this; node; node = node.parentNode) {
     199            if (node.ownerDocument === node)
     200                return true;
     201        }
     202        return false;
    194203    }
    195204
  • trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js

    r242992 r243152  
    157157
    158158    let isElement = domNode.nodeType() === Node.ELEMENT_NODE;
    159     if (domNode.ownerDocument && isElement) {
     159    let attached = domNode.attached;
     160
     161    if (isElement && attached) {
    160162        copySubMenu.appendItem(WI.UIString("Selector Path"), () => {
    161163            let cssPath = WI.cssPath(domNode);
    … …  
    164166    }
    165167
    166     if (domNode.ownerDocument && !domNode.isPseudoElement()) {
     168    if (!domNode.isPseudoElement() && attached) {
    167169        copySubMenu.appendItem(WI.UIString("XPath"), () => {
    168170            let xpath = WI.xpath(domNode);
    … …  
    206208    }
    207209
    208     if (WI.domDebuggerManager.supported && isElement && !domNode.isPseudoElement() && domNode.ownerDocument) {
     210    if (WI.domDebuggerManager.supported && isElement && !domNode.isPseudoElement() && attached) {
    209211        contextMenu.appendSeparator();
    210212
    … …  
    225227    }
    226228
    227     if (!options.excludeRevealElement && window.DOMAgent && domNode.ownerDocument) {
     229    if (!options.excludeRevealElement && window.DOMAgent && attached) {
    228230        contextMenu.appendItem(WI.UIString("Reveal in DOM Tree"), () => {
    229231            WI.domManager.inspectElement(domNode.id);
    … …  
    231233    }
    232234
    233     if (!options.excludeRevealLayer && window.LayerTreeAgent && domNode.parentNode) {
     235    if (!options.excludeRevealLayer && window.LayerTreeAgent && attached) {
    234236        contextMenu.appendItem(WI.UIString("Reveal in Layers Tab"), () => {
    235237            WI.showLayersTab({nodeToSelect: domNode});
    … …  
    237239    }
    238240
    239     if (window.PageAgent) {
     241    if (window.PageAgent && attached) {
    240242        contextMenu.appendItem(WI.UIString("Capture Screenshot"), () => {
    241243            PageAgent.snapshotNode(domNode.id, (error, dataURL) => {
    … …  
    260262    }
    261263
    262     if (isElement) {
     264    if (isElement && attached) {
    263265        contextMenu.appendItem(WI.UIString("Scroll Into View"), () => {
    264266            domNode.scrollIntoView();
  • trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js

    r242811 r243152  
    728728        let node = this.representedObject;
    729729        let isNonShadowEditable = !node.isInUserAgentShadowTree() && this.editable;
     730        let attached = node.attached;
    730731
    731732        if (event.target && event.target.tagName === "A") {
    … …  
    761762        }
    762763
    763         let attributeValue = this.representedObject.getAttribute(attributeName);
     764        let attributeValue = node.getAttribute(attributeName);
    764765        subMenus.copy.appendItem(WI.UIString("Attribute"), () => {
    765766            let text = attributeName;
    … …  
    770771
    771772        subMenus.delete.appendItem(WI.UIString("Attribute"), () => {
    772             this.representedObject.removeAttribute(attributeName);
     773            node.removeAttribute(attributeName);
    773774        }, !attribute || !isNonShadowEditable);
    774775
    … …  
    779780        contextMenu.appendSeparator();
    780781
    781         if (WI.cssManager.canForcePseudoClasses()) {
     782        if (WI.cssManager.canForcePseudoClasses() && attached) {
    782783            let pseudoSubMenu = contextMenu.appendSubMenuItem(WI.UIString("Forced Pseudo-Classes"));
    783784
    784             let enabledPseudoClasses = this.representedObject.enabledPseudoClasses;
     785            let enabledPseudoClasses = node.enabledPseudoClasses;
    785786            WI.CSSManager.ForceablePseudoClasses.forEach((pseudoClass) => {
    786787                let enabled = enabledPseudoClasses.includes(pseudoClass);
    787788                pseudoSubMenu.appendCheckboxItem(pseudoClass.capitalize(), () => {
    788                     this.representedObject.setPseudoClassEnabled(pseudoClass, !enabled);
     789                    node.setPseudoClassEnabled(pseudoClass, !enabled);
    789790                }, enabled);
    790791            });
Note: See TracChangeset for help on using the changeset viewer.