Changeset 279510 in webkit
- Timestamp:
- Jul 2, 2021 12:19:47 PM (13 months ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 6 added
- 11 edited
-
ChangeLog (modified) (1 diff)
-
Localizations/en.lproj/localizedStrings.js (modified) (4 diffs)
-
Scripts/copy-user-interface-resources.pl (modified) (5 diffs)
-
UserInterface/Base/Setting.js (modified) (1 diff)
-
UserInterface/External/ContextualDocumentationDatabase (added)
-
UserInterface/External/ContextualDocumentationDatabase/ContextualDocumentationDatabase.js (added)
-
UserInterface/External/ContextualDocumentationDatabase/LICENSE (added)
-
UserInterface/Images/InfoIcon.svg (added)
-
UserInterface/Main.html (modified) (3 diffs)
-
UserInterface/Views/ComputedStyleDetailsPanel.css (modified) (1 diff)
-
UserInterface/Views/ComputedStyleSection.css (modified) (1 diff)
-
UserInterface/Views/ContextualDocumentationPopover.css (added)
-
UserInterface/Views/ContextualDocumentationPopover.js (added)
-
UserInterface/Views/Main.css (modified) (2 diffs)
-
UserInterface/Views/SettingsTabContentView.js (modified) (1 diff)
-
UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.css (modified) (1 diff)
-
UserInterface/Views/SpreadsheetStyleProperty.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r279502 r279510 1 2021-07-02 Harshil Ratnu <hratnu@apple.com> 2 3 Web Inspector: add contextual documentation for CSS properties 4 https://bugs.webkit.org/show_bug.cgi?id=226883 5 6 Reviewed by Devin Rousso. 7 8 Overview: Add contextual documentation for all supported CSS properties in Styles and Computed panel within Web 9 Inspector. 10 Details: Add an info button which appears next to the property field on Hover. Clicking on the info button shows 11 a popover with the documentation for the property. Tabbing out or clicking anywhere other than the value field 12 dismisses the popover. 13 Architecture: Add a ContextualDocumentationButton in SpreadsheetStyleProperty and append that to the end of the 14 property content. This Button, when clicked, creates an instance of the ContextualDocumentation.js which will 15 search the ContextualDocumentationDB to find the related property and it's relevant details. Embed these details 16 in an instance of Popover.js and present next to the associated propertyName. 17 18 * Localizations/en.lproj/localizedStrings.js: 19 * Scripts/copy-user-interface-resources.pl: 20 Add details for the ContextualDocumentationDatabase from External Folder to build properly. 21 22 * UserInterface/Base/Setting.js: 23 Add setting to show syntax in documentation popover and define default state as false. 24 25 * UserInterface/External/ContextualDocumentationDatabase/ContextualDocumentationDatabase.js: Added. 26 * UserInterface/External/ContextualDocumentationDatabase/LICENSE: Added. 27 * UserInterface/Images/InfoIcon.svg: Added. 28 * UserInterface/Main.html: 29 Add and link new files. 30 31 * UserInterface/Views/ComputedStyleDetailsPanel.css: 32 (.sidebar > .panel.details.css-style > .content > .computed > .details-section.computed-style-variables .property .go-to-arrow): 33 (.sidebar > .panel.details.css-style > .content > .computed > .details-section.computed-style-variables .property:not(:hover) .go-to-arrow): 34 Remove absolute positioning from go-to-arrow button to align it with rest of the text in line and style it 35 similar to contextual-documentation-button. 36 (.sidebar > .panel.details.css-style > .content > .computed .property .go-to-arrow): Deleted. 37 (.sidebar > .panel.details.css-style > .content > .computed .property:not(:hover) .go-to-arrow): Deleted. 38 Change hover area to include white space on the side of computed variables. 39 40 * UserInterface/Views/ComputedStyleSection.css: 41 (.sidebar > .panel.details.css-style > .content > .computed .computed-property-item > .property .go-to-arrow): 42 (.sidebar > .panel.details.css-style > .content > .computed .computed-property-item:not(:hover) > .property .go-to-arrow): 43 (.sidebar > .panel.details.css-style > .content > .computed .computed-property-item > .property > .content > .contextual-documentation-button): 44 (.sidebar > .panel.details.css-style > .content > .computed .computed-property-item:not(:hover) > .property > .content > .contextual-documentation-button): 45 Add unifrom styling for go-to-arrow button and contextual-documentation-button for computed properties. 46 47 * UserInterface/Views/ContextualDocumentationPopover.css: Added. 48 (.popover .documentation-popover-content): 49 (.popover .documentation-popover-content > p): 50 (.popover .documentation-popover-content > .name-header): 51 (.popover .documentation-popover-content > .syntax): 52 (.popover .documentation-popover-content > .syntax > .syntax-title): 53 (.popover .documentation-popover-content > .reference-link): 54 * UserInterface/Views/ContextualDocumentationPopover.js: Added. 55 (WI.ContextualDocumentationPopover): 56 (WI.ContextualDocumentationPopover.prototype.show): 57 (WI.ContextualDocumentationPopover.prototype._presentOverTargetElement): 58 (WI.ContextualDocumentationPopover.prototype._getDocumentationDetails): 59 (WI.ContextualDocumentationPopover.prototype._createDocumentationElement): 60 Add new class that extends Popover.js and handles fetching the values from VS Code documentation, puts relevant 61 information in the popover and presents the popover when the documentation-button is clicked. 62 63 * UserInterface/Views/Main.css: 64 (.contextual-documentation-button): 65 (.contextual-documentation-button:active): 66 (@media (prefers-color-scheme: dark) .contextual-documentation-button): 67 Add general styling for contextualDocumentationButton. 68 69 * UserInterface/Views/SettingsTabContentView.js: 70 (WI.SettingsTabContentView.prototype._createElementsSettingsView): 71 Add a new setting in Elements Tab to show syntax. 72 73 * UserInterface/Views/SpreadsheetStyleProperty.js: 74 (WI.SpreadsheetStyleProperty.prototype.willDismissPopover): 75 Add a method - willDismissPopover to handle changes when the documentation popover is about to dismiss. 76 (WI.SpreadsheetStyleProperty.prototype.update): 77 (WI.SpreadsheetStyleProperty.prototype.spreadsheetTextFieldDidCommit): 78 (WI.SpreadsheetStyleProperty.prototype.spreadsheetTextFieldDidBlur): 79 (WI.SpreadsheetStyleProperty.prototype._addContextualDocumentationButton): 80 Add a method which gets called for all property fields and also gets called when property name is changed and 81 updated by clicking out of the property name field or tabbing into the next value field and is responsible for 82 adding the info button add the end of the property. 83 (WI.SpreadsheetStyleProperty.prototype._handleContextualDocumentationButtonClicked): 84 (WI.SpreadsheetStyleProperty.prototype._presentContextualDocumentation): 85 Add a method which creates an instance of the ContextualDocumentationPopover.js class and shows it. 86 1 87 2021-07-02 Razvan Caliman <rcaliman@apple.com> 2 88 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r278607 r279510 254 254 localizedStrings["CSS Animations"] = "CSS Animations"; 255 255 localizedStrings["CSS Canvas"] = "CSS Canvas"; 256 localizedStrings["CSS Changes:"] = "CSS Changes:";257 256 localizedStrings["CSS Transition"] = "CSS Transition"; 258 257 localizedStrings["CSS Transitions"] = "CSS Transitions"; 259 258 localizedStrings["CSS canvas \u201C%s\u201D"] = "CSS canvas \u201C%s\u201D"; 259 localizedStrings["CSS:"] = "CSS:"; 260 260 localizedStrings["Cached"] = "Cached"; 261 261 localizedStrings["Call Frames Truncated"] = "Call Frames Truncated"; … … 324 324 localizedStrings["Click to show %d warning in the Console"] = "Click to show %d warning in the Console"; 325 325 localizedStrings["Click to show %d warnings in the Console"] = "Click to show %d warnings in the Console"; 326 /* Tooltip to show purpose of the contextual documentation button */ 327 localizedStrings["Click to show documentation @ Contextual Documentation Button"] = "Click to show documentation"; 326 328 localizedStrings["Click to view variable value\nShift-click to replace variable with value"] = "Click to view variable value\nShift-click to replace variable with value"; 327 329 localizedStrings["Clickable"] = "Clickable"; … … 1337 1339 localizedStrings["Show all actions"] = "Show all actions"; 1338 1340 localizedStrings["Show all resources"] = "Show all resources"; 1341 localizedStrings["Show changes only for selected node"] = "Show changes only for selected node"; 1339 1342 localizedStrings["Show compositing borders"] = "Show compositing borders"; 1340 1343 /* Label for option to toggle the extended lines setting for CSS grid overlays */ … … 1346 1349 localizedStrings["Show jump to effective property button"] = "Show jump to effective property button"; 1347 1350 localizedStrings["Show jump to variable declaration button"] = "Show jump to variable declaration button"; 1348 localizedStrings["Show only for selected node"] = "Show only for selected node";1349 1351 localizedStrings["Show page rulers and node border lines"] = "Show page rulers and node border lines"; 1352 localizedStrings["Show property syntax in documentation popover"] = "Show property syntax in documentation popover"; 1350 1353 localizedStrings["Show rulers"] = "Show rulers"; 1351 1354 localizedStrings["Show the details sidebar (%s)"] = "Show the details sidebar (%s)"; -
trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl
r276680 r279510 168 168 my $esprimaPath = File::Spec->catdir($uiRoot, 'External', 'Esprima'); 169 169 my $threejsPath = File::Spec->catdir($uiRoot, 'External', 'three.js'); 170 my $contextualDocumentationDatabasePath = File::Spec->catdir($uiRoot, 'External', 'ContextualDocumentationDatabase'); 170 171 171 172 $webInspectorUIAdditionsDir = &webInspectorUIAdditionsDir(); … … 174 175 my $esprimaLicense = readLicenseFile(File::Spec->catfile($esprimaPath, 'LICENSE')); 175 176 my $threejsLicense = readLicenseFile(File::Spec->catfile($threejsPath, 'LICENSE')); 177 my $contextualDocumentationDatabaseLicense = readLicenseFile(File::Spec->catfile($contextualDocumentationDatabasePath, 'LICENSE')); 176 178 make_path($protocolDir, $targetResourcePath); 177 179 … … 328 330 '--output-script-name', 'CodeMirror.js', 329 331 '--output-style-name', 'CodeMirror.css'); 332 333 # Combine the ContextualDocumentationDatabase JavaScript files in Production builds into a single file (ContextualDocumentationDatabase.js). 334 system($perl, $combineResourcesCmd, 335 '--input-dir', 'External/ContextualDocumentationDatabase', 336 '--input-html', $derivedSourcesMainHTML, 337 '--input-html-dir', $uiRoot, 338 '--derived-sources-dir', $derivedSourcesDir, 339 '--output-dir', $derivedSourcesDir, 340 '--output-script-name', 'ContextualDocumentationDatabase.js'); 330 341 331 342 # Combine the Esprima JavaScript files in Production builds into a single file (Esprima.js). … … 396 407 seedFile($targetCodeMirrorCSS, $codeMirrorLicense); 397 408 409 # Export the license into ContextualDocumentationDatabase.js. 410 my $targetContextualDocumentationDatabaseJS = File::Spec->catfile($targetResourcePath, 'ContextualDocumentationDatabase.js'); 411 seedFile($targetContextualDocumentationDatabaseJS, $contextualDocumentationDatabaseLicense); 412 398 413 # Export the license into Esprima.js. 399 414 my $targetEsprimaJS = File::Spec->catfile($targetResourcePath, 'Esprima.js'); … … 415 430 system(qq("$python" "$jsMinScript" < "$derivedSourcesCodeMirrorJS" >> "$targetCodeMirrorJS")) and die "Failed to minify $derivedSourcesCodeMirrorJS: $!"; 416 431 system(qq("$python" "$cssMinScript" < "$derivedSourcesCodeMirrorCSS" >> "$targetCodeMirrorCSS")) and die "Failed to minify $derivedSourcesCodeMirrorCSS: $!"; 432 433 # Minify the ContextualDocumentationDatabase.js file, appending to the license that was exported above. 434 my $derivedSourcesContextualDocumentationDatabaseJS = File::Spec->catfile($derivedSourcesDir, 'ContextualDocumentationDatabase.js'); 435 system(qq("$python" "$jsMinScript" < "$derivedSourcesContextualDocumentationDatabaseJS" >> "$targetContextualDocumentationDatabaseJS")) and die "Failed to minify $derivedSourcesContextualDocumentationDatabaseJS: $!"; 417 436 418 437 # Minify the Esprima.js file, appending to the license that was exported above. -
trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js
r275982 r279510 212 212 selectedNetworkDetailContentViewIdentifier: new WI.Setting("network-detail-content-view-identifier", "preview"), 213 213 sourceMapsEnabled: new WI.Setting("source-maps-enabled", true), 214 showCSSPropertySyntaxInDocumentationPopover: new WI.Setting("show-css-property-syntax-in-documentation-popover", false), 214 215 showCanvasPath: new WI.Setting("show-canvas-path", false), 215 216 showImageGrid: new WI.Setting("show-image-grid", true), -
trunk/Source/WebInspectorUI/UserInterface/Main.html
r277284 r279510 87 87 <link rel="stylesheet" href="Views/ContentView.css"> 88 88 <link rel="stylesheet" href="Views/ContentViewContainer.css"> 89 <link rel="stylesheet" href="Views/ContextualDocumentationPopover.css"> 89 90 <link rel="stylesheet" href="Views/CookiePopover.css"> 90 91 <link rel="stylesheet" href="Views/CookieStorageContentView.css"> … … 297 298 <script src="External/CodeMirror/xml.js"></script> 298 299 300 <script src="External/ContextualDocumentationDatabase/ContextualDocumentationDatabase.js"></script> 301 299 302 <script src="External/Esprima/esprima.js"></script> 300 303 … … 673 676 <script src="Views/ContextMenu.js"></script> 674 677 <script src="Views/ContextMenuUtilities.js"></script> 678 <script src="Views/ContextualDocumentationPopover.js"></script> 675 679 <script src="Views/CookiePopover.js"></script> 676 680 <script src="Views/CookieStorageContentView.js"></script> -
trunk/Source/WebInspectorUI/UserInterface/Views/ComputedStyleDetailsPanel.css
r270637 r279510 51 51 } 52 52 53 .sidebar > .panel.details.css-style > .content > .computed .property .go-to-arrow { 54 position: absolute; 55 bottom: 0; 56 width: var(--disclosure-button-size); 57 height: var(--disclosure-button-size); 53 .sidebar > .panel.details.css-style > .content > .computed > .details-section.computed-style-variables .property .go-to-arrow { 54 vertical-align: -2px; 55 width: 1em; 56 height: 1em; 58 57 } 59 58 60 .sidebar > .panel.details.css-style > .content > .computed .property:not(:hover) .go-to-arrow {59 .sidebar > .panel.details.css-style > .content > .computed > .details-section.computed-style-variables .property:not(:hover) .go-to-arrow { 61 60 display: none; 62 61 } -
trunk/Source/WebInspectorUI/UserInterface/Views/ComputedStyleSection.css
r269166 r279510 159 159 display: block; 160 160 } 161 162 .sidebar > .panel.details.css-style > .content > .computed .computed-property-item > .property .go-to-arrow { 163 vertical-align: bottom; 164 width: var(--disclosure-button-size); 165 height: var(--disclosure-button-size); 166 } 167 168 .sidebar > .panel.details.css-style > .content > .computed .computed-property-item:not(:hover) > .property .go-to-arrow { 169 display: none; 170 } 171 172 .sidebar > .panel.details.css-style > .content > .computed .computed-property-item > .property > .content > .contextual-documentation-button { 173 vertical-align: bottom; 174 width: var(--disclosure-button-size); 175 height: var(--disclosure-button-size); 176 margin-left: 1px; 177 } 178 179 .sidebar > .panel.details.css-style > .content > .computed .computed-property-item:not(:hover) > .property > .content > .contextual-documentation-button { 180 display: none; 181 } -
trunk/Source/WebInspectorUI/UserInterface/Views/Main.css
r269166 r279510 336 336 } 337 337 338 .contextual-documentation-button { 339 -webkit-appearance: none; 340 padding: 0; 341 margin: 0; 342 border: none; 343 background: none; 344 background-image: url(../Images/InfoIcon.svg#normal); 345 background-position: center; 346 background-size: 10px 10px; 347 background-repeat: no-repeat; 348 width: 1em; 349 height: 1em; 350 vertical-align: -2px; 351 } 352 353 .contextual-documentation-button:active { 354 background-image: url(../Images/InfoIcon.svg#active); 355 } 356 338 357 .search-settings { 339 358 display: inline-block; … … 597 616 } 598 617 618 .contextual-documentation-button { 619 filter: invert(); 620 } 621 599 622 .expand-list-button { 600 623 color: inherit; -
trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js
r278513 r279510 289 289 elementsSettingsView.addSeparator(); 290 290 291 elementsSettingsView.addSetting(WI.UIString("CSS Changes:"), WI.settings.cssChangesPerNode, WI.UIString("Show only for selected node")); 291 let cssGroup = elementsSettingsView.addGroup(WI.UIString("CSS:")); 292 cssGroup.addSetting(WI.settings.cssChangesPerNode, WI.UIString("Show changes only for selected node")); 293 cssGroup.addSetting(WI.settings.showCSSPropertySyntaxInDocumentationPopover, WI.UIString("Show property syntax in documentation popover")); 292 294 293 295 this._createReferenceLink(elementsSettingsView); -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.css
r278607 r279510 91 91 } 92 92 93 .spreadsheet-style-declaration-editor > .property:not(:hover) > .content > .contextual-documentation-button, 94 .spreadsheet-style-declaration-editor > .property > .content > .name.editing ~ .contextual-documentation-button { 95 display: none; 96 } 97 93 98 .spreadsheet-style-declaration-editor .property-toggle { 94 99 visibility: hidden; -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js
r279502 r279510 43 43 this._nameElement = null; 44 44 this._valueElement = null; 45 this._contextualDocumentationButton = null; 45 46 this._jumpToEffectivePropertyButton = null; 46 47 … … 50 51 this._selected = false; 51 52 this._hasInvalidVariableValue = false; 53 this._contextualDocumentationPopover = null; 52 54 53 55 this.update(); … … 215 217 this._contentElement.append(" */"); 216 218 219 this._addContextualDocumentationButton(); 220 217 221 if (!this._property.implicit && this._property.ownerStyle.type === WI.CSSStyleDeclaration.Type.Computed && !this._property.isShorthand) { 218 222 let effectiveProperty = this._property.ownerStyle.nodeStyles.effectivePropertyForName(this._property.name); … … 385 389 this._renderValue(this._property.rawValue); 386 390 391 this._contextualDocumentationPopover?.dismiss(); 392 387 393 if (direction === "forward") { 388 394 if (isEditingName && !willRemoveProperty) { … … 410 416 spreadsheetTextFieldDidBlur(textField, event, changed) 411 417 { 418 this._addContextualDocumentationButton(); 419 412 420 let focusedOutsideThisProperty = event.relatedTarget !== this._nameElement && event.relatedTarget !== this._valueElement; 413 421 if (focusedOutsideThisProperty && (!this._nameTextField.value.trim() || !this._valueTextField.value.trim())) { … … 444 452 else if (this._delegate.spreadsheetStylePropertyDidPressEsc) 445 453 this._delegate.spreadsheetStylePropertyDidPressEsc(this); 454 } 455 456 // Popover delegate 457 458 willDismissPopover() 459 { 460 this._valueElement.classList.remove(WI.Popover.IgnoreAutoDismissClassName); 461 this._contextualDocumentationPopover = null; 446 462 } 447 463 … … 508 524 this._valueElement.removeChildren(); 509 525 this._valueElement.append(...tokens); 526 } 527 528 _addContextualDocumentationButton() 529 { 530 if (this._contextualDocumentationButton) { 531 this._contextualDocumentationButton.remove(); 532 this._contextualDocumentationButton = null; 533 } 534 535 if (this.property.isVariable) 536 return; 537 538 if (!WI.CSSCompletions.cssNameCompletions.isValidPropertyName(this._property.name)) 539 return; 540 541 if (!ContextualDocumentationDatabase.hasOwnProperty(this._property.name) && !ContextualDocumentationDatabase.hasOwnProperty(this._property.canonicalName)) 542 return; 543 544 this._contextualDocumentationButton = this._contentElement.appendChild(document.createElement("button")); 545 this._contextualDocumentationButton.className = "contextual-documentation-button"; 546 this._contextualDocumentationButton.title = WI.UIString("Click to show documentation", "Click to show documentation @ Contextual Documentation Button", "Tooltip to show purpose of the contextual documentation button"); 547 this._contextualDocumentationButton.addEventListener("mousedown", this._handleContextualDocumentationButtonClicked.bind(this)); 548 } 549 550 _handleContextualDocumentationButtonClicked(event) 551 { 552 if (event.button !== 0) 553 return; 554 555 if (this._valueTextField?.editing) { 556 event.stopPropagation(); 557 event.preventDefault(); 558 this._valueTextField.discardCompletion(); 559 } 560 561 this._presentContextualDocumentation(); 562 } 563 564 _presentContextualDocumentation() 565 { 566 this._contextualDocumentationPopover ??= new WI.ContextualDocumentationPopover(this._property, this); 567 this._contextualDocumentationPopover.show(this._nameElement); 568 if (this._isEditable()) 569 this._valueElement.classList.add(WI.Popover.IgnoreAutoDismissClassName); 510 570 } 511 571
Note: See TracChangeset
for help on using the changeset viewer.