I shouldn't be able to capture a screenshot of any random node that I've logged to the console (e.g. `document.createElement("div")`).
<rdar://problem/48916594>
Created attachment 364777 [details] Patch
Comment on attachment 364777 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=364777&action=review > Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js:239 > - if (window.PageAgent) { > + if (window.PageAgent && domNode.ownerDocument) { This feels wrong. Every Node should be associated with a document: document.createElement("div").ownerDocument; // => #document We may want to update our interface, as it doesn't make sense that a detached node doesn't have an ownerDocument... It might be good to have an isAttached() method that resolves this state.
Comment on attachment 364777 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=364777&action=review >> Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js:239 >> + if (window.PageAgent && domNode.ownerDocument) { > > This feels wrong. > > Every Node should be associated with a document: > > document.createElement("div").ownerDocument; // => #document > > We may want to update our interface, as it doesn't make sense that a detached node doesn't have an ownerDocument... > > It might be good to have an isAttached() method that resolves this state. I would agree, but this is the current "reality" of how we're able to determine such things. When we push a detached root to the frontend (e.g. logging a node which you've just created), we don't set a document for it (`WI.DOMManager.prototype._setDetachedRoot`). I'd like to rework this when doing the DOM agent redesign as well.
> > It might be good to have an isAttached() method that resolves this state. > > I would agree, but this is the current "reality" of how we're able to > determine such things. When we push a detached root to the frontend (e.g. > logging a node which you've just created), we don't set a document for it > (`WI.DOMManager.prototype._setDetachedRoot`). I'd like to rework this when > doing the DOM agent redesign as well. There should be another way to check if we are actually attached or not, perhaps by walking up the parentNode hierarchy.
Created attachment 365115 [details] Patch
Comment on attachment 365115 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=365115&action=review r=me > Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js:210 > - if (WI.domDebuggerManager.supported && isElement && !domNode.isPseudoElement() && domNode.ownerDocument) { > + if (WI.domDebuggerManager.supported &&isElement && !domNode.isPseudoElement() && attached) { Style: Oops on the lost space. > Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js:781 > + if (WI.cssManager.canForcePseudoClasses() && this.representedObject.attached) { Might want to extract the attached into a bool hear to avoid people potentially recomputing it later.
Created attachment 365179 [details] Patch
Comment on attachment 365179 [details] Patch Clearing flags on attachment: 365179 Committed r243152: <https://trac.webkit.org/changeset/243152>
All reviewed patches have been landed. Closing bug.