Changeset 144449 in webkit
- Timestamp:
- Mar 1, 2013 6:12:38 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r144447 r144449 1 2013-03-01 Alexander Pavlov <apavlov@chromium.org> 2 3 Web Inspector: [Styles] Implement navigation to UI locations of property names/values in the source code 4 https://bugs.webkit.org/show_bug.cgi?id=105285 5 6 Reviewed by Vsevolod Vlasov. 7 8 Users can now Ctrl/Cmd-click CSS property names/values whose UI locations are found in 9 an external stylesheet/sass/other file. Inline stylesheets are not navigable, 10 since their start position is not detectable inside the surrounding HTML as of yet. 11 12 No new tests, a UI change. 13 14 * inspector/front-end/CSSStyleModel.js: 15 (WebInspector.CSSRule.prototype.isSourceNavigable): Whether the rule contains reliable source code information. 16 (WebInspector.CSSProperty.prototype.uiLocation): Returns a UILocation for the property name of value. 17 * inspector/front-end/StylesSidebarPane.js: Add navigation code. 18 (WebInspector.StylesSidebarPane.prototype._innerRebuildUpdate): 19 (WebInspector.StylePropertiesSection): 20 1 21 2013-03-01 Sheriff Bot <webkit.review.bot@gmail.com> 2 22 -
trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js
r144434 r144449 883 883 { 884 884 return this.origin === "regular"; 885 }, 886 887 /** 888 * @return {boolean} 889 */ 890 isSourceNavigable: function() 891 { 892 if (!this.sourceURL) 893 return false; 894 var resource = WebInspector.resourceTreeModel.resourceForURL(this.sourceURL); 895 return !!resource && resource.contentType() === WebInspector.resourceTypes.Stylesheet; 885 896 } 886 897 } … … 1071 1082 WebInspector.cssModel._pendingCommandsMajorState.push(false); 1072 1083 CSSAgent.toggleProperty(this.ownerStyle.id, this.index, disabled, callback.bind(this)); 1084 }, 1085 1086 /** 1087 * @param {boolean} forName 1088 * @return {WebInspector.UILocation} 1089 */ 1090 uiLocation: function(forName) 1091 { 1092 if (!this.range || !this.ownerStyle || !this.ownerStyle.parentRule || !this.ownerStyle.parentRule.sourceURL) 1093 return null; 1094 1095 var range = this.range; 1096 var line = forName ? range.startLine : range.endLine; 1097 // End of range is exclusive, so subtract 1 from the end offset. 1098 var column = forName ? range.startColumn : range.endColumn - 1; 1099 var rawLocation = new WebInspector.CSSLocation(this.ownerStyle.parentRule.sourceURL, line, column); 1100 return WebInspector.cssModel.rawLocationToUILocation(rawLocation); 1073 1101 } 1074 1102 } -
trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js
r143333 r144449 377 377 var anchorElement = this.sections[0].inheritedPropertiesSeparatorElement; 378 378 379 if (styles.computedStyle) 379 if (styles.computedStyle) 380 380 this.sections[0][0].rebuildComputedTrace(this.sections[0]); 381 381 … … 895 895 if (this.rule.isUserAgent || this.rule.isUser) 896 896 this.editable = false; 897 else 898 this.navigable = this.rule.isSourceNavigable(); 897 899 this.titleElement.addStyleClass("styles-selector"); 898 900 } … … 909 911 if (isInherited) 910 912 this.element.addStyleClass("show-inherited"); // This one is related to inherited rules, not computed style. 913 914 if (this.navigable) 915 this.element.addStyleClass("navigable"); 911 916 912 917 if (!this.editable) … … 2046 2051 return; 2047 2052 2053 newStyle.parentRule = this.style.parentRule; 2048 2054 this.style = newStyle; 2049 2055 this._styleRule.style = newStyle; … … 2159 2165 } 2160 2166 2167 if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && this.section().navigable) { 2168 this._navigateToSource(event.target); 2169 return; 2170 } 2171 2161 2172 this.startEditing(event.target); 2173 }, 2174 2175 /** 2176 * @param {Element} element 2177 */ 2178 _navigateToSource: function(element) 2179 { 2180 console.assert(this.section().navigable); 2181 var propertyNameClicked = element === this.nameElement; 2182 var uiLocation = this.property.uiLocation(propertyNameClicked); 2183 if (!uiLocation) 2184 return; 2185 WebInspector.showPanel("scripts").showUISourceCode(uiLocation.uiSourceCode, uiLocation.lineNumber); 2162 2186 }, 2163 2187 … … 2581 2605 if (this._newProperty) 2582 2606 this._newPropertyInStyle = true; 2607 newStyle.parentRule = this.style.parentRule; 2583 2608 this.style = newStyle; 2584 2609 this.property = newStyle.propertyAt(this.property.index); … … 2674 2699 this._sidebarPane.applyStyleText(this._sidebarPane.nameElement.textContent + ": " + this._sidebarPane.valueElement.textContent, false, false, false); 2675 2700 } 2676 2701 2677 2702 // Handle numeric value increment/decrement only at this point. 2678 2703 if (!this._isEditingName && WebInspector.handleElementValueModifications(event, this._sidebarPane.valueElement, finishHandler.bind(this), this._isValueSuggestion.bind(this)))
Note: See TracChangeset
for help on using the changeset viewer.