Title: [243152] trunk/Source/WebInspectorUI
- Revision
- 243152
- Author
- [email protected]
- Date
- 2019-03-19 11:03:33 -0700 (Tue, 19 Mar 2019)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (243151 => 243152)
--- trunk/Source/WebInspectorUI/ChangeLog 2019-03-19 17:59:24 UTC (rev 243151)
+++ trunk/Source/WebInspectorUI/ChangeLog 2019-03-19 18:03:33 UTC (rev 243152)
@@ -1,3 +1,19 @@
+2019-03-19 Devin Rousso <[email protected]>
+
+ 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):
+
2019-03-18 Joseph Pecoraro <[email protected]>
Web Inspector: HAR Extension for `serverIPAddress` port number
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js (243151 => 243152)
--- trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js 2019-03-19 17:59:24 UTC (rev 243151)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js 2019-03-19 18:03:33 UTC (rev 243152)
@@ -193,6 +193,15 @@
return this._frame;
}
+ get attached()
+ {
+ for (let node = this; node; node = node.parentNode) {
+ if (node.ownerDocument === node)
+ return true;
+ }
+ return false;
+ }
+
get children()
{
if (!this._children)
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js (243151 => 243152)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js 2019-03-19 17:59:24 UTC (rev 243151)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js 2019-03-19 18:03:33 UTC (rev 243152)
@@ -156,7 +156,9 @@
let copySubMenu = options.copySubMenu || contextMenu.appendSubMenuItem(WI.UIString("Copy"));
let isElement = domNode.nodeType() === Node.ELEMENT_NODE;
- if (domNode.ownerDocument && isElement) {
+ let attached = domNode.attached;
+
+ if (isElement && attached) {
copySubMenu.appendItem(WI.UIString("Selector Path"), () => {
let cssPath = WI.cssPath(domNode);
InspectorFrontendHost.copyText(cssPath);
@@ -163,7 +165,7 @@
});
}
- if (domNode.ownerDocument && !domNode.isPseudoElement()) {
+ if (!domNode.isPseudoElement() && attached) {
copySubMenu.appendItem(WI.UIString("XPath"), () => {
let xpath = WI.xpath(domNode);
InspectorFrontendHost.copyText(xpath);
@@ -205,7 +207,7 @@
contextMenu.appendSeparator();
}
- if (WI.domDebuggerManager.supported && isElement && !domNode.isPseudoElement() && domNode.ownerDocument) {
+ if (WI.domDebuggerManager.supported && isElement && !domNode.isPseudoElement() && attached) {
contextMenu.appendSeparator();
WI.appendContextMenuItemsForDOMNodeBreakpoints(contextMenu, domNode);
@@ -224,19 +226,19 @@
});
}
- if (!options.excludeRevealElement && window.DOMAgent && domNode.ownerDocument) {
+ if (!options.excludeRevealElement && window.DOMAgent && attached) {
contextMenu.appendItem(WI.UIString("Reveal in DOM Tree"), () => {
WI.domManager.inspectElement(domNode.id);
});
}
- if (!options.excludeRevealLayer && window.LayerTreeAgent && domNode.parentNode) {
+ if (!options.excludeRevealLayer && window.LayerTreeAgent && attached) {
contextMenu.appendItem(WI.UIString("Reveal in Layers Tab"), () => {
WI.showLayersTab({nodeToSelect: domNode});
});
}
- if (window.PageAgent) {
+ if (window.PageAgent && attached) {
contextMenu.appendItem(WI.UIString("Capture Screenshot"), () => {
PageAgent.snapshotNode(domNode.id, (error, dataURL) => {
if (error) {
@@ -259,7 +261,7 @@
});
}
- if (isElement) {
+ if (isElement && attached) {
contextMenu.appendItem(WI.UIString("Scroll Into View"), () => {
domNode.scrollIntoView();
});
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js (243151 => 243152)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js 2019-03-19 17:59:24 UTC (rev 243151)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js 2019-03-19 18:03:33 UTC (rev 243152)
@@ -727,6 +727,7 @@
{
let node = this.representedObject;
let isNonShadowEditable = !node.isInUserAgentShadowTree() && this.editable;
+ let attached = node.attached;
if (event.target && event.target.tagName === "A") {
let url = ""
@@ -760,7 +761,7 @@
attributeName = attributeNameElement.textContent.trim();
}
- let attributeValue = this.representedObject.getAttribute(attributeName);
+ let attributeValue = node.getAttribute(attributeName);
subMenus.copy.appendItem(WI.UIString("Attribute"), () => {
let text = attributeName;
if (attributeValue)
@@ -769,7 +770,7 @@
}, !attribute || !isNonShadowEditable);
subMenus.delete.appendItem(WI.UIString("Attribute"), () => {
- this.representedObject.removeAttribute(attributeName);
+ node.removeAttribute(attributeName);
}, !attribute || !isNonShadowEditable);
subMenus.edit.appendItem(WI.UIString("Tag"), () => {
@@ -778,14 +779,14 @@
contextMenu.appendSeparator();
- if (WI.cssManager.canForcePseudoClasses()) {
+ if (WI.cssManager.canForcePseudoClasses() && attached) {
let pseudoSubMenu = contextMenu.appendSubMenuItem(WI.UIString("Forced Pseudo-Classes"));
- let enabledPseudoClasses = this.representedObject.enabledPseudoClasses;
+ let enabledPseudoClasses = node.enabledPseudoClasses;
WI.CSSManager.ForceablePseudoClasses.forEach((pseudoClass) => {
let enabled = enabledPseudoClasses.includes(pseudoClass);
pseudoSubMenu.appendCheckboxItem(pseudoClass.capitalize(), () => {
- this.representedObject.setPseudoClassEnabled(pseudoClass, !enabled);
+ node.setPseudoClassEnabled(pseudoClass, !enabled);
}, enabled);
});
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes