Changeset 289757 in webkit
- Timestamp:
- Feb 14, 2022 1:05:45 PM (5 months ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 1 added
- 5 edited
- 1 copied
- 2 moved
-
ChangeLog (modified) (1 diff)
-
Localizations/en.lproj/localizedStrings.js (modified) (3 diffs)
-
UserInterface/Main.html (modified) (4 diffs)
-
UserInterface/Views/CSSFlexNodeOverlayListSection.js (copied) (copied from trunk/Source/WebInspectorUI/UserInterface/Views/LayoutDetailsSidebarPanel.css) (2 diffs)
-
UserInterface/Views/CSSGridNodeOverlayListSection.js (added)
-
UserInterface/Views/LayoutDetailsSidebarPanel.css (modified) (1 diff)
-
UserInterface/Views/LayoutDetailsSidebarPanel.js (modified) (6 diffs)
-
UserInterface/Views/NodeOverlayListSection.css (moved) (moved from trunk/Source/WebInspectorUI/UserInterface/Views/CSSGridSection.css) (5 diffs)
-
UserInterface/Views/NodeOverlayListSection.js (moved) (moved from trunk/Source/WebInspectorUI/UserInterface/Views/CSSGridSection.js) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r289670 r289757 1 2022-02-14 Razvan Caliman <rcaliman@apple.com> 2 3 Web Inspector: [Flexbox] List flex containers in Layout sidebar 4 https://bugs.webkit.org/show_bug.cgi?id=235647 5 <rdar://87886241> 6 7 Reviewed by Patrick Angle. 8 9 The representation in the Layout details sidebar of the list of flex containers on the page is very similar to the one for grid containers: 10 a list of nodes identified by selector, with adjacent checkboxes that synchronize state with the visibility of a page overlay, interactive 11 color swatches to decorate the corresponding overlay, and a button to jump to the node in the DOM Tree view. 12 13 Therefore, it makes sense to generalize the code for CSS Grid and reuse it for Flexbox. 14 15 This patch extracts a generic `WI.NodeOverlayListSection` from `WI.CSSGridNodeOverlayListSection`. 16 This is subclassed by `WI.CSSGridNodeOverlayListSection` and `WI.CSSFlexboxSection`. 17 The two rely on the abstract implementations to show/hide overlays, get/set overlay colors, interrogate overlay visibility, and listen to generic overlay show events. 18 19 Which particular type of overlay is the target of each panel is determined in `WI.OverlayManager` 20 by the value of `WI.DomNode.layoutContextType`, either "flex" or "grid". A node cannot have more than one layout context type. 21 22 Where the subclasses differ: 23 - each section has its own label (obviously). 24 - the layout for `WI.CSSGridNodeOverlayListSection` includes a section with settings for the CSS Grid overlay. 25 26 * Localizations/en.lproj/localizedStrings.js: 27 We've received feedback that the latter is more common in web developers' vocabulary when 28 refering to CSS grids. Adopted the same for the flexbox section empty message. 29 30 * UserInterface/Main.html: 31 32 * UserInterface/Views/CSSFlexNodeOverlayListSection.js: Added. 33 (WI.CSSFlexNodeOverlayListSection.prototype.get sectionLabel): 34 (WI.CSSFlexNodeOverlayListSection): 35 36 * UserInterface/Views/CSSGridNodeOverlayListSection.js: Renamed from Source/WebInspectorUI/UserInterface/Views/CSSGridSection.js. 37 (WI.CSSGridNodeOverlayListSection.prototype.get sectionLabel): 38 (WI.CSSGridNodeOverlayListSection.prototype.initialLayout): 39 (WI.CSSGridNodeOverlayListSection): 40 The layout of `WI.CSSFlexNodeOverlayListSection` includes a set of options to configure the CSS Grid overlay. 41 42 * UserInterface/Views/LayoutDetailsSidebarPanel.css: 43 (.details-section:is(.layout-css-flexbox, .layout-css-grid):not(.collapsed) > .content,): 44 (.details-section.layout-css-grid > .content > .group > .row > .css-grid-section): Deleted. 45 (.details-section.layout-css-grid:not(.collapsed) > .content,): Deleted. 46 47 * UserInterface/Views/LayoutDetailsSidebarPanel.js: 48 (WI.LayoutDetailsSidebarPanel): 49 (WI.LayoutDetailsSidebarPanel.prototype.attached): 50 (WI.LayoutDetailsSidebarPanel.prototype.initialLayout): 51 (WI.LayoutDetailsSidebarPanel.prototype.layout): 52 (WI.LayoutDetailsSidebarPanel.prototype._handleLayoutContextTypeChanged): 53 (WI.LayoutDetailsSidebarPanel.prototype._refreshNodeSets): 54 (WI.LayoutDetailsSidebarPanel.prototype._refreshGridNodeSet): Deleted. 55 Added Flexbox section to Layout details sidebar. 56 57 * UserInterface/Views/NodeOverlayListSection.css: Renamed from Source/WebInspectorUI/UserInterface/Views/CSSGridSection.css. 58 (.node-overlay-list-section): 59 (.node-overlay-list-section > .node-overlay-list): 60 (.node-overlay-list-section > .node-overlay-list > li > .node-overlay-list-item-container): 61 (.node-overlay-list-section > .node-overlay-list > li > .node-overlay-list-item-container > label): 62 (.node-overlay-list-section > .node-overlay-list > li > .node-overlay-list-item-container > label > .node-display-name): 63 (.node-overlay-list-section > .node-overlay-list > li > .node-overlay-list-item-container > :is(.go-to-arrow, .inline-swatch)): 64 (.node-overlay-list-section > .node-overlay-list > li > .node-overlay-list-item-container:not(:hover) > .go-to-arrow): 65 (.node-overlay-list-section > .heading,): 66 (.node-overlay-list-section > .heading > label > .toggle-all): 67 (.node-overlay-list-section :is(.setting-editor, .node-overlay-list-item-container, .heading) input[type="checkbox"]): 68 A full-on replacement of `.css-grid-section` with `.node-overlay-list-section` since the two sections share the same styles. 69 70 * UserInterface/Views/NodeOverlayListSection.js: Copied from Source/WebInspectorUI/UserInterface/Views/CSSGridSection.js. 71 (WI.NodeOverlayListSection): 72 (WI.NodeOverlayListSection.prototype.set nodeSet): 73 (WI.NodeOverlayListSection.prototype.get sectionLabel): 74 (WI.NodeOverlayListSection.prototype.attached): 75 (WI.NodeOverlayListSection.prototype.detached): 76 (WI.NodeOverlayListSection.prototype.initialLayout): 77 (WI.NodeOverlayListSection.prototype.layout): 78 (WI.NodeOverlayListSection.prototype._handleOverlayStateChanged): 79 (WI.NodeOverlayListSection.prototype._handleToggleAllCheckboxChanged): 80 (WI.NodeOverlayListSection.prototype._updateToggleAllCheckbox): 81 Removed all the specific implementations for CSS Grid after generalizing them into `WI.NodeOverlayListSection`. 82 1 83 2022-02-11 Devin Rousso <drousso@apple.com> 2 84 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r288702 r289757 675 675 localizedStrings["Find Next (%s)"] = "Find Next (%s)"; 676 676 localizedStrings["Find Previous (%s)"] = "Find Previous (%s)"; 677 /* Flexbox layout section name */ 678 localizedStrings["Flexbox @ Elements details sidebar"] = "Flexbox"; 677 679 localizedStrings["Flows"] = "Flows"; 678 680 localizedStrings["Focus on Subtree"] = "Focus on Subtree"; … … 969 971 localizedStrings["No Box Model Information"] = "No Box Model Information"; 970 972 localizedStrings["No CSS Changes"] = "No CSS Changes"; 971 /* Message shown when there are no CSS Grid contexts on the inspected page. */ 972 localizedStrings["No CSS Grid Contexts @ Layout Details Sidebar Panel"] = "No CSS Grid Contexts"; 973 /* Message shown when there are no CSS Flex containers on the inspected page. */ 974 localizedStrings["No CSS Flex Containers @ Layout Details Sidebar Panel"] = "No CSS Flex Containers"; 975 /* Message shown when there are no CSS Grid containers on the inspected page. */ 976 localizedStrings["No CSS Grid Containers @ Layout Details Sidebar Panel"] = "No CSS Grid Containers"; 973 977 localizedStrings["No Canvas Contexts"] = "No Canvas Contexts"; 974 978 localizedStrings["No Canvas Selected"] = "No Canvas Selected"; … … 1076 1080 /* Heading for list of grid nodes */ 1077 1081 localizedStrings["Page Overlays @ Layout Sidebar Section Header"] = "Grid Overlays"; 1082 /* Heading for list of flex container nodes */ 1083 localizedStrings["Page Overlays for Flex containers @ Layout Sidebar Section Header"] = "Flexbox Overlays"; 1078 1084 localizedStrings["Page navigated at %s"] = "Page navigated at %s"; 1079 1085 localizedStrings["Page reloaded at %s"] = "Page reloaded at %s"; -
trunk/Source/WebInspectorUI/UserInterface/Main.html
r288623 r289757 93 93 <link rel="stylesheet" href="Views/CookieStorageContentView.css"> 94 94 <link rel="stylesheet" href="Views/CreateAuditPopover.css"> 95 <link rel="stylesheet" href="Views/CSSGridSection.css">96 95 <link rel="stylesheet" href="Views/DOMBreakpointTreeElement.css"> 97 96 <link rel="stylesheet" href="Views/DOMEventsBreakdownView.css"> … … 172 171 <link rel="stylesheet" href="Views/NetworkTimelineOverviewGraph.css"> 173 172 <link rel="stylesheet" href="Views/NetworkTimelineView.css"> 173 <link rel="stylesheet" href="Views/NodeOverlayListSection.css"> 174 174 <link rel="stylesheet" href="Views/ObjectPreviewView.css"> 175 175 <link rel="stylesheet" href="Views/ObjectTreeArrayIndexTreeElement.css"> … … 615 615 <script src="Views/DetailsSectionTextRow.js"></script> 616 616 617 <script src="Views/NodeOverlayListSection.js"></script> 618 617 619 <script src="Views/SettingEditor.js"></script> 618 620 <script src="Views/SettingsGroup.js"></script> … … 652 654 <script src="Views/CPUUsageCombinedView.js"></script> 653 655 <script src="Views/CPUUsageView.js"></script> 656 <script src="Views/CSSFlexNodeOverlayListSection.js"></script> 657 <script src="Views/CSSGridNodeOverlayListSection.js"></script> 654 658 <script src="Views/CSSStyleSheetTreeElement.js"></script> 655 <script src="Views/CSSGridSection.js"></script>656 659 <script src="Views/CallFrameTreeElement.js"></script> 657 660 <script src="Views/CallFrameView.js"></script> -
trunk/Source/WebInspectorUI/UserInterface/Views/CSSFlexNodeOverlayListSection.js
r289756 r289757 1 1 /* 2 * Copyright (C) 202 1Apple Inc. All rights reserved.2 * Copyright (C) 2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 .details-section.layout-css-grid > .content > .group > .row > .css-grid-section { 27 margin-inline: 6px; 28 margin-bottom: 4px; 29 } 26 WI.CSSFlexNodeOverlayListSection = class CSSFlexNodeOverlayListSection extends WI.NodeOverlayListSection 27 { 28 // Protected 30 29 31 .details-section.layout-css-grid:not(.collapsed) > .content, 32 .details-section.layout-css-grid > .content > .group { 33 display: block; 34 } 30 get sectionLabel() 31 { 32 return WI.UIString("Flexbox Overlays", "Page Overlays for Flex containers @ Layout Sidebar Section Header", "Heading for list of flex container nodes"); 33 } 34 }; -
trunk/Source/WebInspectorUI/UserInterface/Views/LayoutDetailsSidebarPanel.css
r273847 r289757 24 24 */ 25 25 26 .details-section.layout-css-grid > .content > .group > .row > .css-grid-section { 27 margin-inline: 6px; 28 margin-bottom: 4px; 29 } 30 31 .details-section.layout-css-grid:not(.collapsed) > .content, 32 .details-section.layout-css-grid > .content > .group { 26 .details-section:is(.layout-css-flexbox, .layout-css-grid):not(.collapsed) > .content, 27 .details-section:is(.layout-css-flexbox, .layout-css-grid) > .content > .group { 33 28 display: block; 34 29 } -
trunk/Source/WebInspectorUI/UserInterface/Views/LayoutDetailsSidebarPanel.js
r275545 r289757 30 30 super("layout-details", WI.UIString("Layout", "Layout @ Styles Sidebar", "Title of the CSS style panel.")); 31 31 32 this._flexNodeSet = new Set; 32 33 this._gridNodeSet = new Set; 33 34 this._nodeStyles = null; … … 83 84 WI.cssManager.layoutContextTypeChangedMode = WI.CSSManager.LayoutContextTypeChangedMode.All; 84 85 85 this._refresh GridNodeSet();86 this._refreshNodeSets(); 86 87 } 87 88 … … 98 99 initialLayout() 99 100 { 100 this._gridDetailsSectionRow = new WI.DetailsSectionRow(WI.UIString("No CSS Grid Cont exts", "No CSS Grid Contexts @ Layout Details Sidebar Panel", "Message shown when there are no CSS Grid contexts on the inspected page."));101 this._gridDetailsSectionRow = new WI.DetailsSectionRow(WI.UIString("No CSS Grid Containers", "No CSS Grid Containers @ Layout Details Sidebar Panel", "Message shown when there are no CSS Grid containers on the inspected page.")); 101 102 let gridGroup = new WI.DetailsSectionGroup([this._gridDetailsSectionRow]); 102 103 let gridDetailsSection = new WI.DetailsSection("layout-css-grid", WI.UIString("Grid", "Grid @ Elements details sidebar", "CSS Grid layout section name"), [gridGroup]); 103 104 this.contentView.element.appendChild(gridDetailsSection.element); 104 105 105 this._gridSection = new WI.CSSGridSection; 106 this._gridSection = new WI.CSSGridNodeOverlayListSection; 107 108 // FIXME: <https://webkit.org/b/235820> Enable Flexbox Inspector feature 109 if (!WI.settings.engineeringEnableFlexboxInspector.value) 110 return; 111 112 this._flexDetailsSectionRow = new WI.DetailsSectionRow(WI.UIString("No CSS Flex Containers", "No CSS Flex Containers @ Layout Details Sidebar Panel", "Message shown when there are no CSS Flex containers on the inspected page.")); 113 let flexDetailsSection = new WI.DetailsSection("layout-css-flexbox", WI.UIString("Flexbox", "Flexbox @ Elements details sidebar", "Flexbox layout section name"), [new WI.DetailsSectionGroup([this._flexDetailsSectionRow])]); 114 this.contentView.element.appendChild(flexDetailsSection.element); 115 116 this._flexSection = new WI.CSSFlexNodeOverlayListSection; 106 117 } 107 118 … … 110 121 super.layout(); 111 122 112 if (!this._gridNodeSet.size) { 123 if (this._gridNodeSet.size) { 124 this._gridDetailsSectionRow.hideEmptyMessage(); 125 this._gridDetailsSectionRow.element.appendChild(this._gridSection.element); 126 127 if (!this._gridSection.isAttached) 128 this.addSubview(this._gridSection); 129 130 this._gridSection.nodeSet = this._gridNodeSet; 131 } else { 113 132 this._gridDetailsSectionRow.showEmptyMessage(); 114 133 115 134 if (this._gridSection.isAttached) 116 135 this.removeSubview(this._gridSection); 117 136 } 137 138 // FIXME: <https://webkit.org/b/235820> Enable Flexbox Inspector feature 139 if (!WI.settings.engineeringEnableFlexboxInspector.value) 140 return; 141 142 if (this._flexNodeSet.size) { 143 this._flexDetailsSectionRow.hideEmptyMessage(); 144 this._flexDetailsSectionRow.element.appendChild(this._flexSection.element); 145 146 if (!this._flexSection.isAttached) 147 this.addSubview(this._flexSection); 148 149 this._flexSection.nodeSet = this._flexNodeSet; 118 150 } else { 119 this._gridDetailsSectionRow.hideEmptyMessage(); 120 this._gridDetailsSectionRow.element.appendChild(this._gridSection.element); 121 122 if (!this._gridSection.isAttached) 123 this.addSubview(this._gridSection); 124 125 this._gridSection.gridNodeSet = this._gridNodeSet; 151 this._flexDetailsSectionRow.showEmptyMessage(); 152 153 if (this._flexSection.isAttached) 154 this.removeSubview(this._flexSection); 126 155 } 127 156 } … … 132 161 { 133 162 let domNode = event.target; 134 if (domNode.layoutContextType === WI.DOMNode.LayoutContextType.Grid) 163 164 // A node may switch layout context type between grid and flex. 165 // Remove it from both node sets in case it was previously added. 166 // It is also the default case when the layout context type switches to something unknown. 167 this._flexNodeSet.delete(domNode); 168 this._gridNodeSet.delete(domNode); 169 170 switch (domNode.layoutContextType) { 171 case WI.DOMNode.LayoutContextType.Grid: 135 172 this._gridNodeSet.add(domNode); 136 else 137 this._gridNodeSet.delete(domNode); 173 break; 174 175 case WI.DOMNode.LayoutContextType.Flex: 176 this._flexNodeSet.add(domNode); 177 break; 178 } 138 179 139 180 this.needsLayout(); … … 160 201 } 161 202 162 _refresh GridNodeSet()203 _refreshNodeSets() 163 204 { 164 205 this._gridNodeSet = new Set(WI.domManager.nodesWithLayoutContextType(WI.DOMNode.LayoutContextType.Grid)); 206 207 // FIXME: <https://webkit.org/b/235820> Enable Flexbox Inspector feature 208 if (WI.settings.engineeringEnableFlexboxInspector.value) 209 this._flexNodeSet = new Set(WI.domManager.nodesWithLayoutContextType(WI.DOMNode.LayoutContextType.Flex)); 165 210 } 166 211 }; -
trunk/Source/WebInspectorUI/UserInterface/Views/NodeOverlayListSection.css
r289756 r289757 1 1 /* 2 * Copyright (C) 202 1Apple Inc. All rights reserved.2 * Copyright (C) 2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 .css-grid-section .node-display-name { 27 margin-inline: 5px 4px; 26 .node-overlay-list-section { 27 margin-inline: 6px; 28 margin-bottom: 4px; 29 padding-inline-start: 6px; 28 30 } 29 31 30 . css-grid-section.node-overlay-list {32 .node-overlay-list-section > .node-overlay-list { 31 33 list-style: none; 32 34 margin: 0; … … 34 36 } 35 37 36 . css-grid-section.node-overlay-list-item-container {38 .node-overlay-list-section > .node-overlay-list > li > .node-overlay-list-item-container { 37 39 display: flex; 38 40 align-items: center; 39 41 } 40 42 41 . css-grid-section .node-overlay-list-item-containerlabel {43 .node-overlay-list-section > .node-overlay-list > li > .node-overlay-list-item-container > label { 42 44 flex-shrink: 1; 43 45 min-width: 0; … … 47 49 } 48 50 49 .css-grid-section .node-overlay-list-item-container :is(.go-to-arrow, .inline-swatch) { 51 .node-overlay-list-section > .node-overlay-list > li > .node-overlay-list-item-container > label > .node-display-name { 52 margin-inline: 5px 4px; 53 } 54 55 .node-overlay-list-section > .node-overlay-list > li > .node-overlay-list-item-container > :is(.go-to-arrow, .inline-swatch) { 50 56 flex-shrink: 0; 51 57 } 52 58 53 . css-grid-section .node-overlay-list-item-container:not(:hover).go-to-arrow {59 .node-overlay-list-section > .node-overlay-list > li > .node-overlay-list-item-container:not(:hover) > .go-to-arrow { 54 60 opacity: 0; 55 61 } 56 62 57 .css-grid-section :is(.heading, .title) { 63 .node-overlay-list-section > .heading, 64 .node-overlay-list-section > .container > .title { 58 65 font-size: 11px; 59 margin-top: 10px;66 margin-top: 5px; 60 67 margin-bottom: 5px; 61 68 font-weight: 500; … … 63 70 } 64 71 65 . css-grid-section.toggle-all {72 .node-overlay-list-section > .heading > label > .toggle-all { 66 73 padding-inline-start: 4px; 67 74 } 68 75 69 . css-grid-section :is(.setting-editor, .node-overlay-list-item-container, .heading) input[type="checkbox"] {76 .node-overlay-list-section :is(.setting-editor, .node-overlay-list-item-container, .heading) input[type="checkbox"] { 70 77 margin-inline-end: 0; 71 78 } 72 73 .css-grid-section .setting-editor > input[type="checkbox"] {74 font-size: revert;75 } -
trunk/Source/WebInspectorUI/UserInterface/Views/NodeOverlayListSection.js
r289756 r289757 1 1 /* 2 * Copyright (C) 202 1Apple Inc. All rights reserved.2 * Copyright (C) 2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 // FIXME: <https://webkit.org/b/152269> convert `WI.CSSGridSection` to be a subclass of `WI.DetailsSectionRow` 27 28 WI.CSSGridSection = class CSSGridSection extends WI.View 26 WI.NodeOverlayListSection = class NodeOverlayListSection extends WI.View 29 27 { 30 28 constructor() … … 32 30 super(); 33 31 34 this.element.classList.add(" css-grid-section");35 36 this._ gridNodeSet = new Set;32 this.element.classList.add("node-overlay-list-section"); 33 34 this._nodeSet = new Set; 37 35 this._checkboxElementByNodeMap = new WeakMap; 38 36 this._toggleAllCheckboxElement = null; … … 42 40 // Public 43 41 44 set gridNodeSet(value)45 { 46 this._ gridNodeSet = value;42 set nodeSet(value) 43 { 44 this._nodeSet = value; 47 45 this.needsLayout(); 48 46 } … … 50 48 // Protected 51 49 50 get sectionLabel() 51 { 52 throw WI.NotImplementedError.subclassMustOverride(); 53 } 54 52 55 attached() 53 56 { 54 57 super.attached(); 55 58 56 WI.overlayManager.addEventListener(WI.OverlayManager.Event.OverlayShown, this._handle GridOverlayStateChanged, this);57 WI.overlayManager.addEventListener(WI.OverlayManager.Event.OverlayHidden, this._handle GridOverlayStateChanged, this);59 WI.overlayManager.addEventListener(WI.OverlayManager.Event.OverlayShown, this._handleOverlayStateChanged, this); 60 WI.overlayManager.addEventListener(WI.OverlayManager.Event.OverlayHidden, this._handleOverlayStateChanged, this); 58 61 } 59 62 60 63 detached() 61 64 { 62 WI.overlayManager.removeEventListener(WI.OverlayManager.Event.OverlayShown, this._handle GridOverlayStateChanged, this);63 WI.overlayManager.removeEventListener(WI.OverlayManager.Event.OverlayHidden, this._handle GridOverlayStateChanged, this);65 WI.overlayManager.removeEventListener(WI.OverlayManager.Event.OverlayShown, this._handleOverlayStateChanged, this); 66 WI.overlayManager.removeEventListener(WI.OverlayManager.Event.OverlayHidden, this._handleOverlayStateChanged, this); 64 67 65 68 super.detached(); … … 69 72 { 70 73 super.initialLayout(); 71 72 let settingsGroup = new WI.SettingsGroup(WI.UIString("Page Overlay Options", "Page Overlay Options @ Layout Panel Section Header", "Heading for list of grid overlay options"));73 this.element.append(settingsGroup.element);74 75 settingsGroup.addSetting(WI.settings.gridOverlayShowTrackSizes, WI.UIString("Track Sizes", "Track sizes @ Layout Panel Overlay Options", "Label for option to toggle the track sizes setting for CSS grid overlays"));76 settingsGroup.addSetting(WI.settings.gridOverlayShowLineNumbers, WI.UIString("Line Numbers", "Line numbers @ Layout Panel Overlay Options", "Label for option to toggle the line numbers setting for CSS grid overlays"));77 settingsGroup.addSetting(WI.settings.gridOverlayShowLineNames, WI.UIString("Line Names", "Line names @ Layout Panel Overlay Options", "Label for option to toggle the line names setting for CSS grid overlays"));78 settingsGroup.addSetting(WI.settings.gridOverlayShowAreaNames, WI.UIString("Area Names", "Area names @ Layout Panel Overlay Options", "Label for option to toggle the area names setting for CSS grid overlays"));79 settingsGroup.addSetting(WI.settings.gridOverlayShowExtendedGridLines, WI.UIString("Extended Grid Lines", "Show extended lines @ Layout Panel Overlay Options", "Label for option to toggle the extended lines setting for CSS grid overlays"));80 74 81 75 let listHeading = this.element.appendChild(document.createElement("h2")); … … 88 82 89 83 let labelInner = label.createChild("span", "toggle-all"); 90 labelInner.textContent = WI.UIString("Grid Overlays", "Page Overlays @ Layout Sidebar Section Header", "Heading for list of grid nodes");84 labelInner.textContent = this.sectionLabel; 91 85 92 86 this._listElement = this.element.appendChild(document.createElement("ul")); … … 94 88 } 95 89 96 _handleToggleAllCheckboxChanged(event)97 {98 let isChecked = event.target.checked;99 this._suppressUpdateToggleAllCheckbox = true;100 for (let domNode of this._gridNodeSet) {101 if (isChecked)102 WI.overlayManager.showOverlay(domNode, {initiator: WI.GridOverlayDiagnosticEventRecorder.Initiator.Panel});103 else104 WI.overlayManager.hideOverlay(domNode);105 }106 this._suppressUpdateToggleAllCheckbox = false;107 }108 90 109 91 layout() … … 113 95 this._listElement.removeChildren(); 114 96 115 for (let domNode of this._ gridNodeSet) {97 for (let domNode of this._nodeSet) { 116 98 let itemElement = this._listElement.appendChild(document.createElement("li")); 117 99 let itemContainerElement = itemElement.appendChild(document.createElement("span")); … … 119 101 120 102 let labelElement = itemContainerElement.appendChild(document.createElement("label")); 103 let nodeDisplayName = labelElement.appendChild(document.createElement("span")); 104 nodeDisplayName.classList.add("node-display-name"); 105 nodeDisplayName.textContent = domNode.displayName; 106 121 107 let checkboxElement = labelElement.appendChild(document.createElement("input")); 108 labelElement.insertBefore(checkboxElement, nodeDisplayName); 122 109 checkboxElement.type = "checkbox"; 123 110 checkboxElement.checked = WI.overlayManager.hasVisibleOverlay(domNode); 124 111 125 const nodeDisplayName = labelElement.appendChild(document.createElement("span"));126 nodeDisplayName.classList.add("node-display-name");127 nodeDisplayName.textContent = domNode.displayName;128 129 112 this._checkboxElementByNodeMap.set(domNode, checkboxElement); 113 114 let initiator; 115 if (domNode.layoutContextType === WI.DOMNode.LayoutContextType.Grid) 116 initiator = WI.GridOverlayDiagnosticEventRecorder.Initiator.Panel; 130 117 131 118 checkboxElement.addEventListener("change", (event) => { 132 119 if (checkboxElement.checked) 133 WI.overlayManager.showOverlay(domNode, {color: swatch .value, initiator: WI.GridOverlayDiagnosticEventRecorder.Initiator.Panel});120 WI.overlayManager.showOverlay(domNode, {color: swatch?.value, initiator}); 134 121 else 135 122 WI.overlayManager.hideOverlay(domNode); 136 123 }); 137 124 138 let gridColor = WI.overlayManager.getColorForNode(domNode);139 let swatch = new WI.InlineSwatch(WI.InlineSwatch.Type.Color, gridColor);125 let color = WI.overlayManager.getColorForNode(domNode); 126 let swatch = new WI.InlineSwatch(WI.InlineSwatch.Type.Color, color); 140 127 swatch.shiftClickColorEnabled = false; 141 128 itemContainerElement.append(swatch.element); 142 129 143 130 swatch.addEventListener(WI.InlineSwatch.Event.ValueChanged, (event) => { 144 if (checkboxElement.checked) 145 // While changing the overlay color, WI.OverlayManager.Event.GridOverlayShown is dispatched with high frequency. 146 // An initiator is not provided so as not to skew usage count of overlay options when logging diagnostics in WI.GridOverlayDiagnosticEventRecorder. 131 if (checkboxElement?.checked) 147 132 WI.overlayManager.showOverlay(domNode, {color: event.data.value}); 148 133 }, swatch); 149 134 150 135 swatch.addEventListener(WI.InlineSwatch.Event.Deactivated, (event) => { 151 if (event.target.value === gridColor)136 if (event.target.value === color) 152 137 return; 153 138 154 gridColor = event.target.value;155 WI.overlayManager.setColorForNode(domNode, gridColor);139 color = event.target.value; 140 WI.overlayManager.setColorForNode(domNode, color); 156 141 }, swatch); 157 142 … … 166 151 // Private 167 152 168 _handleGridOverlayStateChanged(event) 169 { 170 if (event.data.domNode.layoutContextType !== WI.DOMNode.LayoutContextType.Grid) 171 return; 172 153 _handleOverlayStateChanged(event) 154 { 173 155 let checkboxElement = this._checkboxElementByNodeMap.get(event.data.domNode); 174 156 if (!checkboxElement) … … 179 161 } 180 162 163 _handleToggleAllCheckboxChanged(event) 164 { 165 let isChecked = event.target.checked; 166 this._suppressUpdateToggleAllCheckbox = true; 167 168 for (let domNode of this._nodeSet) { 169 if (isChecked) 170 WI.overlayManager.showOverlay(domNode); 171 else 172 WI.overlayManager.hideOverlay(domNode); 173 } 174 175 this._suppressUpdateToggleAllCheckbox = false; 176 } 177 181 178 _updateToggleAllCheckbox() 182 179 { … … 186 183 let hasVisible = false; 187 184 let hasHidden = false; 188 for (let domNode of this._ gridNodeSet) {185 for (let domNode of this._nodeSet) { 189 186 let isVisible = WI.overlayManager.hasVisibleOverlay(domNode); 190 187 if (isVisible)
Note: See TracChangeset
for help on using the changeset viewer.