Changeset 225569 in webkit
- Timestamp:
- Dec 5, 2017 11:54:42 PM (6 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r225568 r225569 1 2017-12-05 Devin Rousso <webkit@devinrousso.com> 2 3 Web Inspector: [PARITY] Styles Redesign: Make filtering work 4 https://bugs.webkit.org/show_bug.cgi?id=178331 5 <rdar://problem/35001015> 6 7 Reviewed by Timothy Hatcher. 8 9 Since both the sections and editors (per-section) use View semantics, we cannot simply 10 search for instances of the filtered text since not all of the subviews may have called 11 layout() yet. Instead, we have to rely on event listeners to relay information as to whether 12 the filtered text was matched up the chain, applying the correct style classes along the way. 13 14 * UserInterface/Views/SpreadsheetRulesStyleDetailsPanel.js: 15 (WI.SpreadsheetRulesStyleDetailsPanel): 16 (WI.SpreadsheetRulesStyleDetailsPanel.prototype.refresh): 17 (WI.SpreadsheetRulesStyleDetailsPanel.prototype.applyFilter): 18 (WI.SpreadsheetRulesStyleDetailsPanel.prototype.filterDidChange): 19 (WI.SpreadsheetRulesStyleDetailsPanel.prototype._handleSectionFilterApplied): 20 Save the "Inherited From" elements so that they can be hidden if no styles inherited from 21 that node match the filter. 22 23 * UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js: 24 (WI.SpreadsheetCSSStyleDeclarationSection): 25 (WI.SpreadsheetCSSStyleDeclarationSection.prototype.initialLayout): 26 (WI.SpreadsheetCSSStyleDeclarationSection.prototype.layout): 27 (WI.SpreadsheetCSSStyleDeclarationSection.prototype.applyFilter): 28 (WI.SpreadsheetCSSStyleDeclarationSection.prototype._renderSelector): 29 (WI.SpreadsheetCSSStyleDeclarationSection.prototype._createMediaHeader): 30 (WI.SpreadsheetCSSStyleDeclarationSection.prototype._handleEditorFilterApplied): 31 Save the media header elements so that they can also be filtered. 32 33 * UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js: 34 (WI.SpreadsheetCSSStyleDeclarationEditor): 35 (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.layout): 36 (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.applyFilter): 37 38 * UserInterface/Views/SpreadsheetStyleProperty.js: 39 (WI.SpreadsheetStyleProperty): 40 (WI.SpreadsheetStyleProperty.prototype.applyFilter): 41 (WI.SpreadsheetStyleProperty.prototype._update): 42 Move the name and value elements to a new container so that filter highlight won't also 43 apply to the checkbox or warning element. 44 1 45 2017-12-05 Nikita Vasilyev <nvasilyev@apple.com> 2 46 -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js
r224523 r225569 36 36 this._propertyViews = []; 37 37 this._propertyPendingStartEditing = null; 38 this._filterText = null; 38 39 } 39 40 … … 67 68 this._propertyPendingStartEditing = null; 68 69 } 70 71 if (this._filterText) 72 this.applyFilter(this._filterText); 69 73 } 70 74 … … 223 227 } 224 228 229 applyFilter(filterText) 230 { 231 this._filterText = filterText; 232 233 if (!this.didInitialLayout) 234 return; 235 236 let matches = false; 237 for (let propertyView of this._propertyViews) { 238 if (propertyView.applyFilter(this._filterText)) 239 matches = true; 240 } 241 242 this.dispatchEventToListeners(WI.SpreadsheetCSSStyleDeclarationEditor.Event.FilterApplied, {matches}); 243 } 244 225 245 // Private 226 246 … … 243 263 }; 244 264 265 WI.SpreadsheetCSSStyleDeclarationEditor.Event = { 266 FilterApplied: "spreadsheet-css-style-declaration-editor-filter-applied", 267 }; 268 245 269 WI.SpreadsheetCSSStyleDeclarationEditor.StyleClassName = "spreadsheet-style-declaration-editor"; -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js
r224768 r225569 38 38 this._propertiesEditor = null; 39 39 this._selectorElements = []; 40 this._mediaElements = []; 41 this._filterText = null; 40 42 this._wasFocused = false; 41 43 } … … 83 85 this._propertiesEditor = new WI.SpreadsheetCSSStyleDeclarationEditor(this, this._style); 84 86 this._propertiesEditor.element.classList.add("properties"); 87 this._propertiesEditor.addEventListener(WI.SpreadsheetCSSStyleDeclarationEditor.Event.FilterApplied, this._handleEditorFilterApplied, this); 85 88 86 89 this._closeBrace = document.createElement("span"); … … 175 178 else if (!toPreviousRule && typeof this._delegate.cssStyleDeclarationSectionStartEditingNextRule === "function") 176 179 this._delegate.cssStyleDeclarationSectionStartEditingNextRule(this); 180 } 181 182 applyFilter(filterText) 183 { 184 this._filterText = filterText; 185 186 if (!this.didInitialLayout) 187 return; 188 189 this._element.classList.remove(WI.CSSStyleDetailsSidebarPanel.NoFilterMatchInSectionClassName); 190 191 this._propertiesEditor.applyFilter(this._filterText); 177 192 } 178 193 … … 258 273 break; 259 274 } 275 276 if (this._filterText) 277 this.applyFilter(this._filterText); 260 278 } 261 279 … … 327 345 _createMediaHeader() 328 346 { 329 if (!this._style.ownerRule) 330 return ""; 331 332 console.assert(Array.isArray(this._style.ownerRule.mediaList)); 333 334 let mediaList = this._style.ownerRule.mediaList; 335 let mediaText = mediaList.map((media) => media.text).join(", "); 336 if (!mediaText || mediaText === "all" || mediaText === "screen") 347 let mediaList = this._style.mediaList; 348 if (!mediaList.length || (mediaList.length === 1 && (mediaList[0].text === "all" || mediaList[0].text === "screen"))) 337 349 return ""; 338 350 … … 342 354 let mediaLabel = mediaElement.appendChild(document.createElement("div")); 343 355 mediaLabel.className = "media-label"; 344 mediaLabel.append("@media ", mediaText); 345 mediaElement.append(mediaLabel); 356 mediaLabel.append("@media "); 357 358 this._mediaElements = mediaList.map((media, i) => { 359 if (i) 360 mediaLabel.append(", "); 361 362 let span = mediaLabel.appendChild(document.createElement("span")); 363 span.textContent = media.text; 364 return span; 365 }); 346 366 347 367 return mediaElement; … … 392 412 WI.domTreeManager.hideDOMNodeHighlight(); 393 413 } 414 415 _handleEditorFilterApplied(event) 416 { 417 let matchesMedia = false; 418 for (let mediaElement of this._mediaElements) { 419 mediaElement.classList.remove(WI.CSSStyleDetailsSidebarPanel.FilterMatchSectionClassName); 420 421 if (mediaElement.textContent.includes(this._filterText)) { 422 mediaElement.classList.add(WI.CSSStyleDetailsSidebarPanel.FilterMatchSectionClassName); 423 matchesMedia = true; 424 } 425 } 426 427 let matchesSelector = false; 428 for (let selectorElement of this._selectorElements) { 429 selectorElement.classList.remove(WI.CSSStyleDetailsSidebarPanel.FilterMatchSectionClassName); 430 431 if (selectorElement.textContent.includes(this._filterText)) { 432 selectorElement.classList.add(WI.CSSStyleDetailsSidebarPanel.FilterMatchSectionClassName); 433 matchesSelector = true; 434 } 435 } 436 437 let matches = event.data.matches || matchesMedia || matchesSelector; 438 if (!matches) 439 this._element.classList.add(WI.CSSStyleDetailsSidebarPanel.NoFilterMatchInSectionClassName); 440 441 this.dispatchEventToListeners(WI.SpreadsheetCSSStyleDeclarationSection.Event.FilterApplied, {matches}); 442 } 394 443 }; 395 444 445 WI.SpreadsheetCSSStyleDeclarationSection.Event = { 446 FilterApplied: "spreadsheet-css-style-declaration-section-filter-applied", 447 }; 448 396 449 WI.SpreadsheetCSSStyleDeclarationSection.MatchedSelectorElementStyleClassName = "matched"; -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetRulesStyleDetailsPanel.js
r225487 r225569 35 35 this.element.classList.add("spreadsheet-style-panel"); 36 36 37 this._inheritedHeaderMap = new Map; 37 38 this._sections = []; 38 39 this._inspectorSection = null; … … 40 41 this._ruleMediaAndInherticanceList = []; 41 42 this._propertyToSelectAndHighlight = null; 43 this._filterText = null; 42 44 43 45 this._emptyFilterResultsElement = WI.createMessageTextView(WI.UIString("No Results Found")); … … 87 89 })); 88 90 91 this._inheritedHeaderMap.set(style.node, inheritedHeader); 92 89 93 return inheritedHeader; 90 94 }; … … 95 99 let previousStyle = null; 96 100 101 this._inheritedHeaderMap.clear(); 97 102 this._sections = []; 98 103 … … 110 115 } 111 116 117 section.addEventListener(WI.SpreadsheetCSSStyleDeclarationSection.Event.FilterApplied, this._handleSectionFilterApplied, this); 118 112 119 if (this._isInspectorSectionPendingFocus && style.isInspectorRule()) 113 120 this._inspectorSection = section; … … 121 128 122 129 this.element.append(this._emptyFilterResultsElement); 130 131 if (this._filterText) 132 this.applyFilter(this._filterText); 123 133 124 134 super.refresh(significantChange); … … 172 182 } 173 183 } 184 185 applyFilter(filterText) 186 { 187 this._filterText = filterText; 188 189 if (!this.didInitialLayout) 190 return; 191 192 if (this._filterText) 193 this.element.classList.add("filter-non-matching"); 194 195 for (let inheritedHeader of this._inheritedHeaderMap.values()) 196 inheritedHeader.classList.remove(WI.CSSStyleDetailsSidebarPanel.NoFilterMatchInSectionClassName); 197 198 for (let section of this._sections) 199 section.applyFilter(this._filterText); 200 } 201 202 // Protected 203 204 filterDidChange(filterBar) 205 { 206 super.filterDidChange(filterBar); 207 208 this.applyFilter(filterBar.filters.text); 209 } 210 211 // Private 212 213 _handleSectionFilterApplied(event) 214 { 215 if (event.data.matches) 216 this.element.classList.remove("filter-non-matching"); 217 else if (event.target.style.inherited) { 218 let inheritedHeader = this._inheritedHeaderMap.get(event.target.style.node); 219 if (inheritedHeader) 220 inheritedHeader.classList.add(WI.CSSStyleDetailsSidebarPanel.NoFilterMatchInSectionClassName); 221 } 222 } 174 223 }; 175 224 -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js
r224906 r225569 37 37 this._element.dataset.propertyIndex = index; 38 38 39 this._contentElement = null; 39 40 this._nameElement = null; 40 41 this._valueElement = null; … … 127 128 this._element.className = classNames.join(" "); 128 129 this._element.title = elementTitle; 130 } 131 132 applyFilter(filterText) 133 { 134 let matchesName = this._nameElement.textContent.includes(filterText); 135 let matchesValue = this._valueElement.textContent.includes(filterText); 136 let matches = matchesName || matchesValue; 137 this._contentElement.classList.toggle(WI.CSSStyleDetailsSidebarPanel.FilterMatchSectionClassName, matches); 138 this._contentElement.classList.toggle(WI.CSSStyleDetailsSidebarPanel.NoFilterMatchInPropertyClassName, !matches); 139 return matches; 129 140 } 130 141 … … 159 170 } 160 171 172 this._contentElement = this.element.appendChild(document.createElement("span")); 173 161 174 if (!this._property.enabled) 162 this. element.append("/* ");163 164 this._nameElement = this. element.appendChild(document.createElement("span"));175 this._contentElement.append("/* "); 176 177 this._nameElement = this._contentElement.appendChild(document.createElement("span")); 165 178 this._nameElement.classList.add("name"); 166 179 this._nameElement.textContent = this._property.name; 167 180 168 this. element.append(": ");169 170 this._valueElement = this. element.appendChild(document.createElement("span"));181 this._contentElement.append(": "); 182 183 this._valueElement = this._contentElement.appendChild(document.createElement("span")); 171 184 this._valueElement.classList.add("value"); 172 185 this._renderValue(this._property.rawValue); … … 187 200 } 188 201 189 this. element.append(";");202 this._contentElement.append(";"); 190 203 191 204 if (this._property.enabled) { … … 193 206 this._warningElement.className = "warning"; 194 207 } else 195 this. element.append(" */");208 this._contentElement.append(" */"); 196 209 197 210 this.updateStatus();
Note: See TracChangeset
for help on using the changeset viewer.