WebKit Bugzilla
Attachment 358241 Details for
Bug 193089
: Web Inspector: Elements tab should toggle visibility for all selected nodes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193089-20190102185236.patch (text/plain), 9.16 KB, created by
Matt Baker
on 2019-01-02 18:52:37 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Matt Baker
Created:
2019-01-02 18:52:37 PST
Size:
9.16 KB
patch
obsolete
>Subversion Revision: 239582 >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index d0d8c6c2cb99a6a96941aac00f7af2287933ae7c..b48b1787e985fdec7800767c8c94371995af4fec 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,36 @@ >+2019-01-02 Matt Baker <mattbaker@apple.com> >+ >+ Web Inspector: Elements tab should toggle visibility for all selected nodes >+ https://bugs.webkit.org/show_bug.cgi?id=193089 >+ <rdar://problem/47009256> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Localizations/en.lproj/localizedStrings.js: >+ >+ * UserInterface/Views/DOMTreeElement.js: >+ (WI.DOMTreeElement): >+ Add a property tracking the result of the last call to `toggleElementVisibility`. >+ (WI.DOMTreeElement.prototype.get isElementHidden): >+ (WI.DOMTreeElement.prototype.toggleElementVisibility.inspectedPage_node_injectStyleAndToggleClass): >+ (WI.DOMTreeElement.prototype.toggleElementVisibility): >+ (WI.DOMTreeElement.prototype._populateTagContextMenu): >+ Add an optional flag when toggling element visibility, which forces the >+ hidden style to be added or removed. When showing the DOM node's context >+ menu, check whether the target node belongs to a multiple selection. If >+ it does, display "Show Elements" or "Hide Elements" depending on whether >+ or not all the selected nodes are hidden. >+ >+ * UserInterface/Views/DOMTreeOutline.js: >+ (WI.DOMTreeOutline): >+ (WI.DOMTreeOutline.prototype.toggleSelectedElementsVisibility): >+ (WI.DOMTreeOutline.prototype._hideElements): >+ (WI.DOMTreeOutline.prototype._hideElement): Deleted. >+ Provide a public method for toggling the visibility of selected DOM nodes, >+ for use by "H" KeyboardShortcut and the DOMTreeElement context menu. >+ When the selection contains both visible and hidden DOM nodes, toggling >+ the selection should cause all selected nodes to be hidden. >+ > 2018-12-21 Devin Rousso <drousso@apple.com> > > Web Inspector: Styles Redesign: remove unused CSS style icons >diff --git a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >index aa78eeb05fb3e09d26342f7b42fbebef4a0d536d..f28c20ecdb3c8047bc9dbfcfec6c4b6390c1cceb 100644 >--- a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >+++ b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >@@ -474,6 +474,7 @@ localizedStrings["Heap Snapshot Object (%s)"] = "Heap Snapshot Object (%s)"; > localizedStrings["Height"] = "Height"; > localizedStrings["Hide Console"] = "Hide Console"; > localizedStrings["Hide Console (%s)"] = "Hide Console (%s)"; >+localizedStrings["Hide Elements"] = "Hide Elements"; > localizedStrings["Hide Grid"] = "Hide Grid"; > localizedStrings["Hide Path"] = "Hide Path"; > localizedStrings["Hide Rulers"] = "Hide Rulers"; >@@ -838,6 +839,7 @@ localizedStrings["Show All"] = "Show All"; > localizedStrings["Show All Nodes (%d More)"] = "Show All Nodes (%d More)"; > localizedStrings["Show Console"] = "Show Console"; > localizedStrings["Show Console tab"] = "Show Console tab"; >+localizedStrings["Show Elements"] = "Show Elements"; > localizedStrings["Show Grid"] = "Show Grid"; > localizedStrings["Show Path"] = "Show Path"; > localizedStrings["Show Remaining (%d)"] = "Show Remaining (%d)"; >diff --git a/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js b/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js >index d5d0fafe5e5fcda3ba94eaad3df385049e2c60fe..c27575a17f11a66b27888e3a958461a7e1c9c12e 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js >+++ b/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js >@@ -55,6 +55,7 @@ WI.DOMTreeElement = class DOMTreeElement extends WI.TreeElement > > this._ignoreSingleTextChild = false; > this._forceUpdateTitle = false; >+ this._hidden = false; > } > > // Static >@@ -73,6 +74,8 @@ WI.DOMTreeElement = class DOMTreeElement extends WI.TreeElement > > // Public > >+ get isElementHidden() { return this._hidden; } >+ > get breakpointStatus() > { > return this._breakpointStatus; >@@ -292,7 +295,7 @@ WI.DOMTreeElement = class DOMTreeElement extends WI.TreeElement > return this.children[index]; > } > >- toggleElementVisibility() >+ toggleElementVisibility(forceHidden) > { > let effectiveNode = this.representedObject; > if (effectiveNode.isPseudoElement()) { >@@ -305,7 +308,7 @@ WI.DOMTreeElement = class DOMTreeElement extends WI.TreeElement > if (effectiveNode.nodeType() !== Node.ELEMENT_NODE) > return; > >- function inspectedPage_node_injectStyleAndToggleClass() { >+ function inspectedPage_node_injectStyleAndToggleClass(forceHidden) { > let hideElementStyleSheetIdOrClassName = "__WebInspectorHideElement__"; > let styleElement = document.getElementById(hideElementStyleSheetIdOrClassName); > if (!styleElement) { >@@ -315,11 +318,21 @@ WI.DOMTreeElement = class DOMTreeElement extends WI.TreeElement > document.head.appendChild(styleElement); > } > >- this.classList.toggle(hideElementStyleSheetIdOrClassName); >+ this.classList.toggle(hideElementStyleSheetIdOrClassName, forceHidden); >+ >+ return this.classList.contains(hideElementStyleSheetIdOrClassName); > } > > WI.RemoteObject.resolveNode(effectiveNode).then((object) => { >- object.callFunction(inspectedPage_node_injectStyleAndToggleClass, undefined, false, () => { }); >+ let didInjectStyleAndToggleClass = (error, result, wasThrown) => { >+ if (error || wasThrown || !result || result.type !== "boolean") >+ return; >+ >+ this._hidden = result.value; >+ result.release(); >+ }; >+ >+ object.callFunction(inspectedPage_node_injectStyleAndToggleClass, [forceHidden], false, didInjectStyleAndToggleClass); > object.release(); > }); > } >@@ -725,7 +738,13 @@ WI.DOMTreeElement = class DOMTreeElement extends WI.TreeElement > > this._populateNodeContextMenu(contextMenu, subMenus); > >- contextMenu.appendItem(WI.UIString("Toggle Visibility"), this.toggleElementVisibility.bind(this)); >+ let selectedTreeElements = this.treeOutline.selectedTreeElements; >+ if (this.selected && selectedTreeElements.length > 1) { >+ let allHidden = selectedTreeElements.every((treeElement) => treeElement.isElementHidden); >+ let label = allHidden ? WI.UIString("Show Elements") : WI.UIString("Hide Elements"); >+ contextMenu.appendItem(label, () => { this.treeOutline.toggleSelectedElementsVisibility(); }); >+ } else >+ contextMenu.appendItem(WI.UIString("Toggle Visibility"), this.toggleElementVisibility.bind(this)); > > subMenus.add.appendItem(WI.UIString("Attribute"), this._addNewAttribute.bind(this), !isNonShadowEditable); > >diff --git a/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js b/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js >index 0dc324afb9a9c01d974ae131b5eca602daee9293..2ad1710ff1f9067deb0b0f77c3c8e3e1485422ce 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js >+++ b/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js >@@ -54,8 +54,8 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline > this._editing = false; > this._visible = false; > >- this._hideElementKeyboardShortcut = new WI.KeyboardShortcut(null, "H", this._hideElement.bind(this), this.element); >- this._hideElementKeyboardShortcut.implicitlyPreventsDefault = false; >+ this._hideElementsKeyboardShortcut = new WI.KeyboardShortcut(null, "H", this._hideElements.bind(this), this.element); >+ this._hideElementsKeyboardShortcut.implicitlyPreventsDefault = false; > > WI.settings.showShadowDOM.addEventListener(WI.Setting.Event.Changed, this._showShadowDOMSettingChanged, this); > } >@@ -195,6 +195,19 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline > treeElement.updateSelectionArea(); > } > >+ toggleSelectedElementsVisibility() >+ { >+ let selectedTreeElements = this.selectedTreeElements; >+ if (!selectedTreeElements.length) >+ return; >+ >+ let allHidden = selectedTreeElements.every((treeElement) => treeElement.isElementHidden); >+ const forceHidden = !allHidden; >+ >+ for (let treeElement of selectedTreeElements) >+ treeElement.toggleElementVisibility(forceHidden); >+ } >+ > _selectedNodeChanged() > { > this.dispatchEventToListeners(WI.DOMTreeOutline.Event.SelectedNodeChanged); >@@ -534,14 +547,14 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline > this.selectDOMNode(nodeToSelect); > } > >- _hideElement(event, keyboardShortcut) >+ _hideElements(event, keyboardShortcut) > { > if (!this.selectedTreeElement || WI.isEditingAnyField()) > return; > > event.preventDefault(); > >- this.selectedTreeElement.toggleElementVisibility(); >+ this.toggleSelectedElementsVisibility(); > } > }; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193089
:
358241
|
358246
|
360402
|
360404
|
360426