Changeset 259929 in webkit
- Timestamp:
- Apr 11, 2020 8:14:34 AM (4 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r259842 r259929 1 2020-04-11 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: CSS: variables should have a go-to arrow to quickly jump to the definition 4 https://bugs.webkit.org/show_bug.cgi?id=195775 5 <rdar://problem/48905785> 6 7 Reviewed by Timothy Hatcher. 8 9 Often when debugging/editing styles that use CSS variables, the desired workflow is to 10 modify the variable itself, not that specific usage. This is especially helpful when editing 11 colors saved in CSS variables. 12 13 Add an always visible go-to arrow immediately after the variable (e.g. `--XYZ (->)`) that 14 will jump to the declaration of the variable elsewhere in the style cascade. 15 16 * UserInterface/Views/SpreadsheetStyleProperty.js: 17 (WI.SpreadsheetStyleProperty.prototype._addVariableTokens): 18 * UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.css: 19 (.spreadsheet-style-declaration-editor .property .select-variable-property): Added. 20 21 * UserInterface/Base/Setting.js: 22 * UserInterface/Views/SettingsTabContentView.js: 23 (WI.SettingsTabContentView.prototype._createExperimentalSettingsView): 24 25 * Localizations/en.lproj/localizedStrings.js: 26 1 27 2020-04-09 Devin Rousso <drousso@apple.com> 2 28 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r259748 r259929 619 619 localizedStrings["Global Search From Selection @ Settings"] = "%s from selection"; 620 620 localizedStrings["Global Variables"] = "Global Variables"; 621 localizedStrings["Go to variable"] = "Go to variable"; 621 622 localizedStrings["Grammar"] = "Grammar"; 622 623 /* Name of Graphics Tab */ … … 1123 1124 localizedStrings["Show Console tab"] = "Show Console tab"; 1124 1125 localizedStrings["Show Elements"] = "Show Elements"; 1125 localizedStrings["Show Jump to Effective Property Button"] = "Show Jump to Effective Property Button";1126 1126 localizedStrings["Show Path"] = "Show Path"; 1127 1127 localizedStrings["Show Remaining (%d)"] = "Show Remaining (%d)"; … … 1132 1132 localizedStrings["Show full certificate"] = "Show full certificate"; 1133 1133 localizedStrings["Show hidden tabs"] = "Show hidden tabs"; 1134 localizedStrings["Show jump to effective property button"] = "Show jump to effective property button"; 1135 localizedStrings["Show jump to variable declaration button"] = "Show jump to variable declaration button"; 1134 1136 localizedStrings["Show only for selected node"] = "Show only for selected node"; 1135 1137 localizedStrings["Show page rulers and node border lines"] = "Show page rulers and node border lines"; -
trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js
r259748 r259929 221 221 experimentalEnablePreviewFeatures: new WI.Setting("experimental-enable-preview-features", true), 222 222 experimentalEnableStylesJumpToEffective: new WI.Setting("experimental-styles-jump-to-effective", false), 223 experimentalEnableStyelsJumpToVariableDeclaration: new WI.Setting("experimental-styles-jump-to-variable-declaration", false), 223 224 224 225 // Protocol -
trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js
r259748 r259929 370 370 _createExperimentalSettingsView() 371 371 { 372 let canShowPreviewFeatures = WI.canShowPreviewFeatures(); 373 let hasCSSDomain = InspectorBackend.hasDomain("CSS"); 374 if (!canShowPreviewFeatures && !hasCSSDomain) 375 return; 376 372 377 let experimentalSettingsView = new WI.SettingsView("experimental", WI.UIString("Experimental")); 373 378 374 379 let initialValues = new Map; 375 380 376 if ( WI.canShowPreviewFeatures()) {381 if (canShowPreviewFeatures) { 377 382 experimentalSettingsView.addSetting(WI.UIString("Staging:"), WI.settings.experimentalEnablePreviewFeatures, WI.UIString("Enable Preview Features")); 378 383 experimentalSettingsView.addSeparator(); 379 384 } 380 385 381 if ( InspectorBackend.hasDomain("CSS")) {386 if (hasCSSDomain) { 382 387 let stylesGroup = experimentalSettingsView.addGroup(WI.UIString("Styles:")); 383 stylesGroup.addSetting(WI.settings.experimentalEnableStylesJumpToEffective, WI.UIString("Show Jump to Effective Property Button")); 388 stylesGroup.addSetting(WI.settings.experimentalEnableStylesJumpToEffective, WI.UIString("Show jump to effective property button")); 389 stylesGroup.addSetting(WI.settings.experimentalEnableStyelsJumpToVariableDeclaration, WI.UIString("Show jump to variable declaration button")); 390 384 391 experimentalSettingsView.addSeparator(); 385 392 } … … 403 410 listenForChange(WI.settings.experimentalEnablePreviewFeatures); 404 411 405 if ( InspectorBackend.hasDomain("CSS"))412 if (hasCSSDomain) { 406 413 listenForChange(WI.settings.experimentalEnableStylesJumpToEffective); 414 listenForChange(WI.settings.experimentalEnableStyelsJumpToVariableDeclaration); 415 } 407 416 408 417 this._createReferenceLink(experimentalSettingsView); -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.css
r253405 r259929 195 195 } 196 196 197 .spreadsheet-style-declaration-editor .property .select-variable-property { 198 display: inline-block; 199 width: 10px; 200 height: 10px; 201 -webkit-margin-start: 2px; 202 vertical-align: -1px; 203 cursor: pointer; 204 } 205 197 206 .spreadsheet-style-declaration-editor .property .select-effective-property { 198 207 display: none; -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js
r259170 r259929 784 784 let variableNameIndex = rawTokens.findIndex((token) => token.value.startsWith("--") && /\bvariable-2\b/.test(token.type)); 785 785 if (variableNameIndex !== -1) { 786 let contents = []; 786 let contents = rawTokens.slice(0, variableNameIndex + 1); 787 788 if (WI.settings.experimentalEnableStyelsJumpToVariableDeclaration.value && this._property.ownerStyle.type !== WI.CSSStyleDeclaration.Type.Computed && this._delegate && this._delegate.spreadsheetStylePropertySelectByProperty) { 789 const dontCreateIfMissing = true; 790 let effectiveVariableProperty = this._property.ownerStyle.nodeStyles.effectivePropertyForName(rawTokens[variableNameIndex].value, dontCreateIfMissing); 791 if (effectiveVariableProperty) { 792 let arrowElement = WI.createGoToArrowButton(); 793 arrowElement.classList.add("select-variable-property"); 794 arrowElement.title = WI.UIString("Go to variable"); 795 arrowElement.addEventListener("click", (event) => { 796 event.stop(); 797 this._delegate.spreadsheetStylePropertySelectByProperty(effectiveVariableProperty); 798 }); 799 contents.push(arrowElement); 800 } 801 } 802 787 803 let fallbackStartIndex = rawTokens.findIndex((value, i) => i > variableNameIndex + 1 && /\bm-css\b/.test(value.type)); 788 804 if (fallbackStartIndex !== -1) { 789 contents.pushAll(rawTokens.slice( 0, fallbackStartIndex));805 contents.pushAll(rawTokens.slice(variableNameIndex + 1, fallbackStartIndex)); 790 806 contents.pushAll(this._replaceSpecialTokens(rawTokens.slice(fallbackStartIndex, i))); 791 807 } else 792 contents.pushAll(rawTokens.slice( 0, i));808 contents.pushAll(rawTokens.slice(variableNameIndex + 1, i)); 793 809 contents.push(token); 794 810
Note: See TracChangeset
for help on using the changeset viewer.