Changeset 184977 in webkit
- Timestamp:
- May 28, 2015, 9:47:39 PM (10 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r184974 r184977 1 2015-05-28 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Jump from a computed style to the rule it came from 4 https://bugs.webkit.org/show_bug.cgi?id=120640 5 6 Reviewed by Timothy Hatcher. 7 8 * UserInterface/Views/CSSStyleDeclarationTextEditor.js: 9 (WebInspector.CSSStyleDeclarationTextEditor.prototype._createTextMarkerForPropertyIfNeeded): 10 If the delegate of CSSStyleDeclarationTextEditor has cssStyleDeclarationTextEditorShouldAddPropertyGoToArrows set to true, add a goToArrow to all CSS property entries. 11 (WebInspector.CSSStyleDeclarationTextEditor.prototype.highlightProperty.propertiesMatch): 12 (WebInspector.CSSStyleDeclarationTextEditor.prototype.highlightProperty.hasMatchingLonghandProperty): 13 (WebInspector.CSSStyleDeclarationTextEditor.prototype.highlightProperty): 14 Determines if a given CSS property is in the CSS style section and if so, select that CSS property, focus on the section containing that CSS property, and return true. 15 * UserInterface/Views/CSSStyleDeclarationSection.js: 16 (WebInspector.CSSStyleDeclarationSection.prototype.highlightProperty): 17 Searches through the properties of the section for a given property and scrolls to it if found. 18 * UserInterface/Views/CSSStyleDetailsSidebarPanel.js: 19 (WebInspector.CSSStyleDetailsSidebarPanel.prototype.computedStyleDetailsPanelShowProperty): 20 Switches to the rulesStyleDetailsPanel and scrolls to and hightlights a given property in that panel. 21 (WebInspector.CSSStyleDetailsSidebarPanel.prototype._navigationItemSelected): 22 (WebInspector.CSSStyleDetailsSidebarPanel.prototype._switchPanels): 23 Moved this function out of _navigationItemSelected for better reusablity. 24 * UserInterface/Views/ComputedStyleDetailsPanel.js: 25 (WebInspector.ComputedStyleDetailsPanel.prototype.cssStyleDeclarationTextEditorShowProperty): 26 Function that calls the delegate (which should be CSSStyleDetailsSidebarPanel) function computedStyleDetailsPanelShowProperty. 27 * UserInterface/Views/RulesStyleDetailsPanel.js: 28 (WebInspector.RulesStyleDetailsPanel): 29 (WebInspector.RulesStyleDetailsPanel.prototype.refresh): 30 (WebInspector.RulesStyleDetailsPanel.prototype.scrollToSectionAndHighlightProperty): 31 Searches through all the sections of the RulesStyleDetailsPanel for a given CSS property. 32 (WebInspector.RulesStyleDetailsPanel.prototype.shown): 33 (WebInspector.RulesStyleDetailsPanel.prototype.hidden): 34 (WebInspector.RulesStyleDetailsPanel.prototype.nodeStylesRefreshed): 35 Added a flag to this function that will highlight and scroll to a given property (_propertyToSelectAndHighlight) if set on load. 36 * UserInterface/Views/StyleDetailsPanel.js: 37 (WebInspector.StyleDetailsPanel.prototype.markAsNeedsRefresh): 38 (WebInspector.StyleDetailsPanel.prototype.nodeStylesRefreshed): 39 Made into protected function to allow it to be overridden. 40 (WebInspector.StyleDetailsPanel.prototype._nodeStylesRefreshed): Deleted. 41 1 42 2015-05-28 Joseph Pecoraro <pecoraro@apple.com> 2 43 -
trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js
r184819 r184977 261 261 }, 262 262 263 highlightProperty: function(property) 264 { 265 if (this._propertiesTextEditor.highlightProperty(property)) { 266 this._element.scrollIntoView(); 267 return true; 268 } 269 270 return false; 271 }, 272 263 273 updateLayout: function() 264 274 { -
trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js
r184000 r184977 182 182 } 183 183 184 highlightProperty(property) 185 { 186 function propertiesMatch(cssProperty) 187 { 188 if (cssProperty.enabled && !cssProperty.overridden) { 189 if (cssProperty.canonicalName === property.canonicalName || hasMatchingLonghandProperty(cssProperty)) 190 return true; 191 } 192 193 return false; 194 } 195 196 function hasMatchingLonghandProperty(cssProperty) 197 { 198 var cssProperties = cssProperty.relatedLonghandProperties; 199 200 if (!cssProperties.length) 201 return false; 202 203 for (var property of cssProperties) { 204 if (propertiesMatch(property)) 205 return true; 206 } 207 208 return false; 209 } 210 211 for (var cssProperty of this.style.properties) { 212 if (propertiesMatch(cssProperty)) { 213 var selection = cssProperty.__propertyTextMarker.find(); 214 this._codeMirror.setSelection(selection.from, selection.to); 215 this.focus(); 216 217 return true; 218 } 219 } 220 221 return false; 222 } 223 184 224 // Protected 185 225 … … 438 478 var checkboxMarker = this._codeMirror.setUniqueBookmark(from, checkboxElement); 439 479 checkboxMarker.__propertyCheckbox = true; 480 } else if (this._delegate.cssStyleDeclarationTextEditorShouldAddPropertyGoToArrows 481 && !property.implicit && typeof this._delegate.cssStyleDeclarationTextEditorShowProperty === "function") { 482 483 var arrowElement = WebInspector.createGoToArrowButton(); 484 485 var delegate = this._delegate; 486 arrowElement.addEventListener("click", function() { 487 delegate.cssStyleDeclarationTextEditorShowProperty(property); 488 }); 489 490 this._codeMirror.setUniqueBookmark(to, arrowElement); 440 491 } 441 492 -
trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDetailsSidebarPanel.js
r184819 r184977 71 71 } 72 72 73 this._computedStyleDetailsPanel = new WebInspector.ComputedStyleDetailsPanel ;73 this._computedStyleDetailsPanel = new WebInspector.ComputedStyleDetailsPanel(this); 74 74 this._rulesStyleDetailsPanel = new WebInspector.RulesStyleDetailsPanel; 75 75 this._metricsStyleDetailsPanel = new WebInspector.MetricsStyleDetailsPanel; … … 136 136 if (this._selectedPanel) 137 137 this._selectedPanel.widthDidChange(); 138 } 139 140 computedStyleDetailsPanelShowProperty(property) 141 { 142 this._rulesStyleDetailsPanel.scrollToSectionAndHighlightProperty(property); 143 this._switchPanels(this._rulesStyleDetailsPanel); 144 145 this._navigationBar.selectedNavigationItem = this._lastSelectedSectionSetting.value; 138 146 } 139 147 … … 181 189 } 182 190 191 this._switchPanels(selectedPanel); 192 } 193 194 _switchPanels(selectedPanel) 195 { 183 196 console.assert(selectedPanel); 184 197 … … 202 215 } 203 216 204 this._lastSelectedSectionSetting.value = selected NavigationItem.identifier;217 this._lastSelectedSectionSetting.value = selectedPanel.navigationItem.identifier; 205 218 } 206 219 -
trunk/Source/WebInspectorUI/UserInterface/Views/ComputedStyleDetailsPanel.css
r164543 r184977 36 36 vertical-align: top; 37 37 } 38 39 .details-section > .content > .group > .row .CodeMirror-code pre .go-to-arrow { 40 display: none; 41 position: absolute; 42 width: 12px; 43 height: 10px; 44 vertical-align: text-bottom; 45 } 46 47 .details-section > .content > .group > .row .CodeMirror-code pre:hover .go-to-arrow { 48 display: initial; 49 } -
trunk/Source/WebInspectorUI/UserInterface/Views/ComputedStyleDetailsPanel.js
r183331 r184977 26 26 WebInspector.ComputedStyleDetailsPanel = class ComputedStyleDetailsPanel extends WebInspector.StyleDetailsPanel 27 27 { 28 constructor( )28 constructor(delegate) 29 29 { 30 30 super(WebInspector.ComputedStyleDetailsPanel.StyleClassName, "computed", WebInspector.UIString("Computed")); 31 32 this._delegate = delegate || null; 31 33 32 34 this._computedStyleShowAllSetting = new WebInspector.Setting("computed-style-show-all", false); … … 89 91 90 92 this._resetFlowDetails(); 93 94 this.cssStyleDeclarationTextEditorShouldAddPropertyGoToArrows = true; 91 95 } 92 96 … … 138 142 139 143 this._containerRegionsFlowSection.element.classList.remove("hidden"); 144 } 145 146 cssStyleDeclarationTextEditorShowProperty(property) 147 { 148 if (typeof this._delegate.computedStyleDetailsPanelShowProperty === "function") 149 this._delegate.computedStyleDetailsPanelShowProperty(property); 140 150 } 141 151 -
trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js
r182055 r184977 31 31 32 32 this._sections = []; 33 this._propertyToSelectAndHighlight = null; 33 34 } 34 35 … … 242 243 } 243 244 245 scrollToSectionAndHighlightProperty(property) 246 { 247 if (!this._visible) { 248 this._propertyToSelectAndHighlight = property; 249 return false; 250 } 251 252 for (var section of this._sections) { 253 if (section.highlightProperty(property)) 254 return true; 255 } 256 257 return false; 258 } 259 244 260 // Protected 245 261 246 262 shown() 247 263 { 248 WebInspector.StyleDetailsPanel.prototype.shown.call(this);264 super.shown(); 249 265 250 266 // Associate the style and section objects so they can be reused. … … 259 275 hidden() 260 276 { 261 WebInspector.StyleDetailsPanel.prototype.hidden.call(this);277 super.hidden(); 262 278 263 279 // Disconnect the style and section objects so they have a chance … … 273 289 } 274 290 291 nodeStylesRefreshed(event) 292 { 293 super.nodeStylesRefreshed(event); 294 295 if (this._propertyToSelectAndHighlight) { 296 this.scrollToSectionAndHighlightProperty(this._propertyToSelectAndHighlight); 297 this._propertyToSelectAndHighlight = null; 298 } 299 } 300 275 301 // Private 276 302 -
trunk/Source/WebInspectorUI/UserInterface/Views/StyleDetailsPanel.js
r182055 r184977 87 87 if (!this._nodeStyles || this._nodeStyles.node !== domNode) { 88 88 if (this._nodeStyles) { 89 this._nodeStyles.removeEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, this. _nodeStylesRefreshed, this);89 this._nodeStyles.removeEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, this.nodeStylesRefreshed, this); 90 90 this._nodeStyles.removeEventListener(WebInspector.DOMNodeStyles.Event.NeedsRefresh, this._nodeStylesNeedsRefreshed, this); 91 91 } … … 97 97 return; 98 98 99 this._nodeStyles.addEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, this. _nodeStylesRefreshed, this);99 this._nodeStyles.addEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, this.nodeStylesRefreshed, this); 100 100 this._nodeStyles.addEventListener(WebInspector.DOMNodeStyles.Event.NeedsRefresh, this._nodeStylesNeedsRefreshed, this); 101 101 … … 110 110 { 111 111 // Implemented by subclasses. 112 } 113 114 // Protected 115 116 nodeStylesRefreshed(event) 117 { 118 if (this._visible) 119 this._refreshPreservingScrollPosition(event.data.significantChange); 112 120 } 113 121 … … 147 155 } 148 156 149 _nodeStylesRefreshed(event)150 {151 if (this._visible)152 this._refreshPreservingScrollPosition(event.data.significantChange);153 }154 155 157 _nodeStylesNeedsRefreshed(event) 156 158 {
Note:
See TracChangeset
for help on using the changeset viewer.