chrome-devtools-frontend 1.0.1679704 → 1.0.1681498

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/AUTHORS +1 -0
  2. package/front_end/core/platform/TypescriptUtilities.ts +0 -9
  3. package/front_end/core/platform/platform.ts +1 -1
  4. package/front_end/core/sdk/ConsoleModel.ts +6 -3
  5. package/front_end/core/sdk/DOMModel.ts +110 -0
  6. package/front_end/core/sdk/EmulationModel.ts +4 -2
  7. package/front_end/core/sdk/NetworkManager.ts +15 -9
  8. package/front_end/core/sdk/OverlayModel.ts +3 -2
  9. package/front_end/core/sdk/PageResourceLoader.ts +4 -3
  10. package/front_end/core/sdk/RuntimeModel.ts +5 -3
  11. package/front_end/core/sdk/SDKSettings.ts +66 -0
  12. package/front_end/entrypoints/inspector_main/RenderingOptions.ts +4 -2
  13. package/front_end/entrypoints/inspector_main/inspector_main-meta.ts +32 -0
  14. package/front_end/entrypoints/main/MainImpl.ts +1 -1
  15. package/front_end/entrypoints/main/main-meta.ts +82 -0
  16. package/front_end/entrypoints/shell/shell.ts +0 -3
  17. package/front_end/entrypoints/trace_app/trace_app.ts +0 -3
  18. package/front_end/generated/InspectorBackendCommands.ts +3 -1
  19. package/front_end/generated/SupportedCSSProperties.ts +20 -0
  20. package/front_end/generated/protocol-mapping.d.ts +7 -0
  21. package/front_end/generated/protocol-proxy-api.d.ts +5 -0
  22. package/front_end/generated/protocol.ts +15 -3
  23. package/front_end/models/ai_code_completion/debug.ts +6 -3
  24. package/front_end/models/ai_code_generation/debug.ts +6 -3
  25. package/front_end/models/badges/UserBadges.ts +9 -2
  26. package/front_end/models/emulation/DeviceModeModel.ts +16 -27
  27. package/front_end/models/emulation/EmulatedDevices.ts +30 -125
  28. package/front_end/models/extensions/ExtensionAPI.ts +34 -23
  29. package/front_end/models/logs/NetworkLog.ts +3 -3
  30. package/front_end/models/logs/logs-meta.ts +0 -60
  31. package/front_end/models/persistence/NetworkPersistenceManager.ts +7 -1
  32. package/front_end/panels/application/ServiceWorkersView.ts +1 -1
  33. package/front_end/panels/application/StorageView.ts +2 -0
  34. package/front_end/panels/common/BadgeNotification.ts +1 -1
  35. package/front_end/panels/common/ExtensionPanel.ts +12 -7
  36. package/front_end/panels/common/ExtensionServer.ts +76 -16
  37. package/front_end/panels/common/GdpSignUpDialog.ts +1 -1
  38. package/front_end/panels/console/ConsoleView.ts +4 -2
  39. package/front_end/panels/console/ConsoleViewMessage.ts +3 -2
  40. package/front_end/panels/console/console-meta.ts +19 -5
  41. package/front_end/panels/elements/CSSRuleValidator.ts +12 -12
  42. package/front_end/panels/elements/CSSSpecificityBreakdown.ts +1 -1
  43. package/front_end/panels/elements/ClassesPaneWidget.ts +6 -6
  44. package/front_end/panels/elements/ColorSwatchPopoverIcon.ts +1 -1
  45. package/front_end/panels/elements/ComputedStyleWidget.ts +4 -5
  46. package/front_end/panels/elements/DOMTreeContextMenu.ts +538 -0
  47. package/front_end/panels/elements/ElementIssueUtils.ts +20 -20
  48. package/front_end/panels/elements/ElementStatePaneWidget.ts +6 -6
  49. package/front_end/panels/elements/ElementsPanel.ts +10 -10
  50. package/front_end/panels/elements/ElementsTreeElement.ts +47 -514
  51. package/front_end/panels/elements/ElementsTreeOutline.ts +168 -297
  52. package/front_end/panels/elements/EventListenersWidget.ts +8 -8
  53. package/front_end/panels/elements/LayersWidget.ts +4 -4
  54. package/front_end/panels/elements/LayoutPane.ts +11 -11
  55. package/front_end/panels/elements/MarkerDecorator.ts +3 -3
  56. package/front_end/panels/elements/PlatformFontsWidget.ts +8 -8
  57. package/front_end/panels/elements/PropertiesWidget.ts +4 -4
  58. package/front_end/panels/elements/PropertyRenderer.ts +2 -2
  59. package/front_end/panels/elements/ShortcutTreeElement.ts +1 -1
  60. package/front_end/panels/elements/StylePropertiesSection.ts +14 -14
  61. package/front_end/panels/elements/StylePropertyTreeElement.ts +21 -21
  62. package/front_end/panels/elements/StylesSidebarPane.ts +14 -14
  63. package/front_end/panels/elements/components/AccessibilityTreeNode.ts +1 -1
  64. package/front_end/panels/elements/components/CSSHintDetailsView.ts +1 -1
  65. package/front_end/panels/elements/components/CSSVariableValueView.ts +3 -3
  66. package/front_end/panels/elements/components/ElementsBreadcrumbsUtils.ts +2 -2
  67. package/front_end/panels/elements/components/ElementsTreeExpandButton.ts +1 -1
  68. package/front_end/panels/elements/elements-meta.ts +13 -13
  69. package/front_end/panels/elements/elements.ts +3 -0
  70. package/front_end/panels/issues/AffectedCookiesView.ts +2 -0
  71. package/front_end/panels/issues/AffectedElementsView.ts +5 -0
  72. package/front_end/panels/issues/CorsIssueDetailsView.ts +13 -9
  73. package/front_end/panels/issues/IssueView.ts +7 -2
  74. package/front_end/panels/layer_viewer/LayerDetailsView.ts +11 -7
  75. package/front_end/panels/layer_viewer/LayerTreeOutline.ts +2 -0
  76. package/front_end/panels/mobile_throttling/NetworkPanelIndicator.ts +3 -1
  77. package/front_end/panels/network/NetworkConfigView.ts +2 -1
  78. package/front_end/panels/network/NetworkLogView.ts +5 -2
  79. package/front_end/panels/network/NetworkOverview.ts +11 -5
  80. package/front_end/panels/network/NetworkPanel.ts +3 -2
  81. package/front_end/panels/network/NetworkWaterfallColumn.ts +16 -3
  82. package/front_end/panels/network/RequestHeadersView.ts +4 -4
  83. package/front_end/panels/network/components/ResponseHeaderSection.ts +6 -2
  84. package/front_end/panels/network/network-meta.ts +117 -0
  85. package/front_end/panels/profiler/HeapDetachedElementsDataGrid.ts +2 -1
  86. package/front_end/panels/profiler/ProfileLauncherView.ts +19 -16
  87. package/front_end/panels/profiler/ProfileSidebarTreeElement.ts +1 -1
  88. package/front_end/panels/security/security.ts +6 -0
  89. package/front_end/panels/settings/components/SyncSection.ts +1 -1
  90. package/front_end/panels/settings/emulation/DevicesSettingsTab.ts +0 -3
  91. package/front_end/panels/sources/NavigatorView.ts +6 -2
  92. package/front_end/panels/sources/SourcesNavigator.ts +8 -4
  93. package/front_end/panels/sources/SourcesPanel.ts +4 -2
  94. package/front_end/panels/sources/SourcesSearchScope.ts +3 -1
  95. package/front_end/panels/sources/SourcesView.ts +8 -107
  96. package/front_end/panels/sources/TabbedEditorContainer.ts +110 -7
  97. package/front_end/panels/sources/UISourceCodeFrame.ts +2 -2
  98. package/front_end/panels/sources/sources-meta.ts +16 -0
  99. package/front_end/panels/timeline/TimelineLoader.ts +1 -1
  100. package/front_end/panels/timeline/TimelineUIUtils.ts +6 -0
  101. package/front_end/panels/timeline/components/LayoutShiftDetails.ts +4 -3
  102. package/front_end/panels/timeline/components/LiveMetricsView.ts +1 -1
  103. package/front_end/panels/timeline/components/MetricCard.ts +4 -3
  104. package/front_end/panels/timeline/components/NetworkRequestDetails.ts +5 -2
  105. package/front_end/panels/timeline/components/TimelineRangeSummaryView.ts +1 -1
  106. package/front_end/panels/timeline/components/TimelineSummary.ts +8 -5
  107. package/front_end/panels/web_audio/WebAudioView.ts +8 -0
  108. package/front_end/third_party/chromium/README.chromium +1 -1
  109. package/front_end/third_party/web-vitals/rebuild.sh +1 -1
  110. package/front_end/ui/legacy/TabbedPane.ts +34 -2
  111. package/front_end/ui/legacy/components/color_picker/ContrastDetails.ts +11 -11
  112. package/front_end/ui/legacy/components/color_picker/FormatPickerContextMenu.ts +1 -1
  113. package/front_end/ui/legacy/components/color_picker/Spectrum.ts +19 -20
  114. package/front_end/ui/legacy/components/object_ui/ObjectPopoverHelper.ts +2 -2
  115. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +164 -325
  116. package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +5 -5
  117. package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +7 -7
  118. package/front_end/ui/legacy/components/quick_open/QuickOpen.ts +1 -1
  119. package/front_end/ui/legacy/components/quick_open/quick_open-meta.ts +2 -2
  120. package/front_end/ui/visual_logging/KnownContextValues.ts +40 -0
  121. package/mcp/mcp.ts +0 -3
  122. package/package.json +1 -1
  123. package/front_end/core/sdk/sdk-meta.ts +0 -178
  124. package/front_end/models/badges/badges-meta.ts +0 -27
  125. package/front_end/models/persistence/persistence-meta.ts +0 -69
@@ -62,11 +62,10 @@ import * as Lit from '../../ui/lit/lit.js';
62
62
  import type {DirectiveResult} from '../../ui/lit/lit.js';
63
63
  import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
64
64
  import * as PanelsCommon from '../common/common.js';
65
- import * as Emulation from '../emulation/emulation.js';
66
65
  import * as Media from '../media/media.js';
67
66
 
68
67
  import * as ElementsComponents from './components/components.js';
69
- import {canGetJSPath, cssPath, jsPath, xPath} from './DOMPath.js';
68
+ import {cssPath, jsPath, xPath} from './DOMPath.js';
70
69
  import {getElementIssueDetails} from './ElementIssueUtils.js';
71
70
  import {ElementsPanel} from './ElementsPanel.js';
72
71
  import {type ElementsTreeOutline, MappedCharToEntity} from './ElementsTreeOutline.js';
@@ -102,52 +101,20 @@ const UIStrings = {
102
101
  */
103
102
  forceState: 'Force state',
104
103
  /**
105
- * @description Hint element title in Elements Tree Element of the Elements panel
104
+ * @description Hint element title in the DOM tree of the Elements panel.
106
105
  * @example {0} PH1
107
106
  */
108
107
  useSInTheConsoleToReferToThis: 'Use {PH1} in the console to refer to this element.',
109
108
  /**
110
- * @description A context menu item in the Elements Tree Element of the Elements panel
111
- */
112
- addAttribute: 'Add attribute',
113
- /**
114
- * @description Text to modify the attribute of an item
115
- */
116
- editAttribute: 'Edit attribute',
117
- /**
118
- * @description Text to focus on something
119
- */
120
- focus: 'Focus',
121
- /**
122
- * @description Text to scroll the displayed content into view
123
- */
124
- scrollIntoView: 'Scroll into view',
125
- /**
126
- * @description A context menu item in the Elements panel to switch to Accessibility tree
127
- */
128
- switchToAccessibilityTree: 'Switch to accessibility tree',
129
- /**
130
- * @description A context menu item in the Elements Tree Element of the Elements panel
131
- */
132
- editText: 'Edit text',
133
- /**
134
- * @description A context menu item in the Elements Tree Element of the Elements panel
135
- */
136
- editAsHtml: 'Edit as HTML',
137
- /**
138
- * @description A context menu item in the Elements Tree Element of the Elements panel
139
- */
140
- editData: 'Edit data',
141
- /**
142
- * @description Text to cut an element, cut should be used as a verb
109
+ * @description Text to cut an element, cut should be used as a verb.
143
110
  */
144
111
  cut: 'Cut',
145
112
  /**
146
- * @description Text for copying, copy should be used as a verb
113
+ * @description Text for copying, copy should be used as a verb.
147
114
  */
148
115
  copy: 'Copy',
149
116
  /**
150
- * @description Text to paste an element, paste should be used as a verb
117
+ * @description Text to paste an element, paste should be used as a verb.
151
118
  */
152
119
  paste: 'Paste',
153
120
  /**
@@ -156,110 +123,51 @@ const UIStrings = {
156
123
  */
157
124
  selectAll: 'Select all',
158
125
  /**
159
- * @description Text in Elements Tree Element of the Elements panel, copy should be used as a verb
160
- */
161
- copyOuterhtml: 'Copy outerHTML',
162
- /**
163
- * @description Text in Elements Tree Element of the Elements panel, copy should be used as a verb
164
- */
165
- copySelector: 'Copy `selector`',
166
- /**
167
- * @description Text in Elements Tree Element of the Elements panel
168
- */
169
- copyJsPath: 'Copy JS path',
170
- /**
171
- * @description Text in Elements Tree Element of the Elements panel, copy should be used as a verb
172
- */
173
- copyStyles: 'Copy styles',
174
- /**
175
- * @description Text in Elements Tree Element of the Elements panel, copy should be used as a verb
176
- */
177
- copyXpath: 'Copy XPath',
178
- /**
179
- * @description Text in Elements Tree Element of the Elements panel, copy should be used as a verb
180
- */
181
- copyFullXpath: 'Copy full XPath',
182
- /**
183
- * @description Text in Elements Tree Element of the Elements panel, copy should be used as a verb
184
- */
185
- copyElement: 'Copy element',
186
- /**
187
- * @description A context menu item in the Elements Tree Element of the Elements panel
188
- */
189
- duplicateElement: 'Duplicate element',
190
- /**
191
- * @description Text to hide an element
192
- */
193
- hideElement: 'Hide element',
194
- /**
195
- * @description A context menu item in the Elements Tree Element of the Elements panel
196
- */
197
- deleteElement: 'Delete element',
198
- /**
199
- * @description Text to expand something recursively
200
- */
201
- expandRecursively: 'Expand recursively',
202
- /**
203
- * @description Text to collapse children of a parent group
204
- */
205
- collapseChildren: 'Collapse children',
206
- /**
207
- * @description Title of an action in the emulation tool to capture node screenshot
208
- */
209
- captureNodeScreenshot: 'Capture node screenshot',
210
- /**
211
- * @description Title of a context menu item. When clicked DevTools goes to the Application panel and shows this specific iframe's details
212
- */
213
- showFrameDetails: 'Show `iframe` details',
214
- /**
215
- * @description Text in Elements Tree Element of the Elements panel
126
+ * @description Text in the DOM tree of the Elements panel.
216
127
  */
217
128
  valueIsTooLargeToEdit: '<value is too large to edit>',
218
129
  /**
219
- * @description Element text content in Elements Tree Element of the Elements panel
130
+ * @description Element text content in the DOM tree of the Elements panel.
220
131
  */
221
132
  children: 'Children:',
222
133
  /**
223
- * @description ARIA label for Elements Tree adorners
134
+ * @description ARIA label for Elements Tree adorners.
224
135
  */
225
136
  enableGridMode: 'Enable grid mode',
226
137
  /**
227
- * @description ARIA label for Elements Tree adorners
138
+ * @description ARIA label for Elements Tree adorners.
228
139
  */
229
140
  disableGridMode: 'Disable grid mode',
230
141
  /**
231
- * @description ARIA label for Elements Tree adorners
232
- */
233
- /**
234
- * @description ARIA label for Elements Tree adorners
142
+ * @description ARIA label for Elements Tree adorners.
235
143
  */
236
144
  enableGridLanesMode: 'Enable grid-lanes mode',
237
145
  /**
238
- * @description ARIA label for Elements Tree adorners
146
+ * @description ARIA label for Elements Tree adorners.
239
147
  */
240
148
  disableGridLanesMode: 'Disable grid-lanes mode',
241
149
  /**
242
- * @description ARIA label for an elements tree adorner
150
+ * @description ARIA label for an elements tree adorner.
243
151
  */
244
152
  forceOpenPopover: 'Keep this popover open',
245
153
  /**
246
- * @description ARIA label for an elements tree adorner
154
+ * @description ARIA label for an elements tree adorner.
247
155
  */
248
156
  stopForceOpenPopover: 'Stop keeping this popover open',
249
157
  /**
250
- * @description ARIA label for an elements tree adorner
158
+ * @description ARIA label for an elements tree adorner.
251
159
  */
252
160
  forceShowInterest: 'Trigger interest on this element',
253
161
  /**
254
- * @description ARIA label for an elements tree adorner
162
+ * @description ARIA label for an elements tree adorner.
255
163
  */
256
164
  stopForceShowInterest: 'Cancel interest on this element',
257
165
  /**
258
- * @description Label of the adorner for flex elements in the Elements panel
166
+ * @description Label of the adorner for flex elements in the Elements panel.
259
167
  */
260
168
  enableFlexMode: 'Enable flex mode',
261
169
  /**
262
- * @description Label of the adorner for flex elements in the Elements panel
170
+ * @description Label of the adorner for flex elements in the Elements panel.
263
171
  */
264
172
  disableFlexMode: 'Disable flex mode',
265
173
  /**
@@ -294,29 +202,25 @@ const UIStrings = {
294
202
  disableStartingStyle: 'Disable @starting-style mode',
295
203
  /**
296
204
  * @description Label of an adorner in the Elements panel. When clicked, it redirects
297
- * to the Media Panel.
205
+ * to the Media panel.
298
206
  */
299
207
  openMediaPanel: 'Jump to Media panel',
300
208
  /**
301
- * @description Text of a tooltip to redirect to another element in the Elements panel
209
+ * @description Text of a tooltip to redirect to another element in the Elements panel.
302
210
  */
303
211
  showPopoverTarget: 'Show element associated with the `popovertarget` attribute',
304
212
  /**
305
- * @description Text of a tooltip to redirect to another element in the Elements panel, associated with the `interesttarget` attribute
213
+ * @description Text of a tooltip to redirect to another element in the Elements panel, associated with the `interesttarget` attribute.
306
214
  */
307
215
  showInterestTarget: 'Show element associated with the `interesttarget` attribute',
308
216
  /**
309
- * @description Text of a tooltip to redirect to another element in the Elements panel, associated with the `commandfor` attribute
217
+ * @description Text of a tooltip to redirect to another element in the Elements panel, associated with the `commandfor` attribute.
310
218
  */
311
219
  showCommandForTarget: 'Show element associated with the `commandfor` attribute',
312
220
  /**
313
- * @description Text of the tooltip for scroll adorner.
221
+ * @description Text of the tooltip for the scroll adorner.
314
222
  */
315
223
  elementHasScrollableOverflow: 'This element has a scrollable overflow',
316
- /**
317
- * @description Text of a context menu item to redirect to the AI assistance panel and to start a chat.
318
- */
319
- startAChat: 'Start a chat',
320
224
  /**
321
225
  * @description Label of an adorner next to the html node in the Elements panel.
322
226
  */
@@ -327,77 +231,9 @@ const UIStrings = {
327
231
  */
328
232
  showCustomElementDefinition: 'Show custom element definition',
329
233
  /**
330
- * @description Context menu item in Elements panel to assess visibility of an element via AI.
331
- */
332
- assessVisibility: 'Assess visibility',
333
- /**
334
- * @description Context menu item in Elements panel to center an element via AI.
335
- */
336
- centerElement: 'Center element',
337
- /**
338
- * @description Context menu item in Elements panel to wrap flex items via AI.
339
- */
340
- wrapTheseItems: 'Wrap these items',
341
- /**
342
- * @description Context menu item in Elements panel to distribute flex items evenly via AI.
343
- */
344
- distributeItemsEvenly: 'Distribute items evenly',
345
- /**
346
- * @description Context menu item in Elements panel to explain flexbox via AI.
347
- */
348
- explainFlexbox: 'Explain flexbox',
349
- /**
350
- * @description Context menu item in Elements panel to align grid items via AI.
351
- */
352
- alignItems: 'Align items',
353
- /**
354
- * @description Context menu item in Elements panel to add padding/gap to grid via AI.
355
- */
356
- addPadding: 'Add padding',
357
- /**
358
- * @description Context menu item in Elements panel to explain grid layout via AI.
359
- */
360
- explainGridLayout: 'Explain grid layout',
361
- /**
362
- * @description Context menu item in Elements panel to find grid definition for a subgrid item via AI.
234
+ * @description ARIA label for the top-layer adorner in the DOM tree of the Elements panel. When clicked, it reveals the true location of an element.
363
235
  */
364
- findGridDefinition: 'Find grid definition',
365
- /**
366
- * @description Context menu item in Elements panel to change parent grid properties for a subgrid item via AI.
367
- */
368
- changeParentProperties: 'Change parent properties',
369
- /**
370
- * @description Context menu item in Elements panel to explain subgrids via AI.
371
- */
372
- explainSubgrids: 'Explain subgrids',
373
- /**
374
- * @description Context menu item in Elements panel to remove scrollbars via AI.
375
- */
376
- removeScrollbars: 'Remove scrollbars',
377
- /**
378
- * @description Context menu item in Elements panel to style scrollbars via AI.
379
- */
380
- styleScrollbars: 'Style scrollbars',
381
- /**
382
- * @description Context menu item in Elements panel to explain scrollbars via AI.
383
- */
384
- explainScrollbars: 'Explain scrollbars',
385
- /**
386
- * @description Context menu item in Elements panel to explain container queries via AI.
387
- */
388
- explainContainerQueries: 'Explain container queries',
389
- /**
390
- * @description Context menu item in Elements panel to explain container types via AI.
391
- */
392
- explainContainerTypes: 'Explain container types',
393
- /**
394
- * @description Context menu item in Elements panel to explain container context via AI.
395
- */
396
- explainContainerContext: 'Explain container context',
397
- /**
398
- * @description Link text content in Elements Tree Outline of the Elements panel. When clicked, it "reveals" the true location of an element.
399
- */
400
- reveal: 'reveal',
236
+ reveal: 'Reveal',
401
237
  } as const;
402
238
  const str_ = i18n.i18n.registerUIStrings('panels/elements/ElementsTreeElement.ts', UIStrings);
403
239
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -2134,319 +1970,10 @@ export class ElementsTreeWidget extends UI.Widget.Widget {
2134
1970
  }
2135
1971
  }
2136
1972
 
2137
- async populateTagContextMenu(contextMenu: UI.ContextMenu.ContextMenu, event: Event): Promise<void> {
2138
- const targetWidget = this.isClosingTag ? this.findStartTagWidget?.() : this;
2139
- if (!targetWidget) {
2140
- return;
2141
- }
2142
- contextMenu.editSection().appendItem(i18nString(UIStrings.addAttribute),
2143
- targetWidget.addNewAttribute.bind(targetWidget),
2144
- {jslogContext: 'add-attribute'});
2145
-
2146
- const target = (event.composedPath()[0] || event.target) as Element;
2147
- const attribute = target.enclosingNodeOrSelfWithClass('webkit-html-attribute');
2148
- const newAttribute = target.enclosingNodeOrSelfWithClass('add-attribute');
2149
- if (attribute && !newAttribute) {
2150
- contextMenu.editSection().appendItem(
2151
- i18nString(UIStrings.editAttribute), this.startEditingAttribute.bind(this, attribute, target),
2152
- {jslogContext: 'edit-attribute'});
2153
- }
2154
- await this.populateNodeContextMenu(contextMenu);
2155
- ElementsTreeWidget.populateForcedPseudoStateItems(contextMenu, this.node);
2156
- this.populateScrollIntoView(contextMenu);
2157
- contextMenu.viewSection().appendItem(i18nString(UIStrings.focus), async () => {
2158
- await this.node.focus();
2159
- }, {jslogContext: 'focus'});
2160
- }
2161
-
2162
- populatePseudoElementContextMenu(contextMenu: UI.ContextMenu.ContextMenu): void {
2163
- if ((this.childCount?.() ?? 0) !== 0) {
2164
- this.populateExpandRecursively(contextMenu);
2165
- }
2166
-
2167
- this.populateScrollIntoView(contextMenu);
2168
- }
2169
-
2170
- private populateExpandRecursively(contextMenu: UI.ContextMenu.ContextMenu): void {
2171
- if (this.expandRecursively) {
2172
- contextMenu.viewSection().appendItem(i18nString(UIStrings.expandRecursively),
2173
- () => void this.expandRecursively?.(), {jslogContext: 'expand-recursively'});
2174
- }
2175
- }
2176
-
2177
- private populateScrollIntoView(contextMenu: UI.ContextMenu.ContextMenu): void {
2178
- contextMenu.viewSection().appendItem(i18nString(UIStrings.scrollIntoView), () => this.node.scrollIntoView(),
2179
- {jslogContext: 'scroll-into-view'});
2180
- }
2181
-
2182
1973
  private isAiButtonEnabled(): boolean {
2183
1974
  return UI.ActionRegistry.ActionRegistry.instance().hasAction('freestyler.elements-floating-button');
2184
1975
  }
2185
1976
 
2186
- async populateTextContextMenu(contextMenu: UI.ContextMenu.ContextMenu, textNode: Node): Promise<void> {
2187
- if (!this.editing) {
2188
- contextMenu.editSection().appendItem(i18nString(UIStrings.editText),
2189
- this.startEditingTextNode.bind(this, textNode as Element),
2190
- {jslogContext: 'edit-text'});
2191
- }
2192
- return await this.populateNodeContextMenu(contextMenu);
2193
- }
2194
-
2195
- async populateNodeContextMenu(contextMenu: UI.ContextMenu.ContextMenu): Promise<void> {
2196
- // Add free-form node-related actions.
2197
- const isEditable = this.hasEditableNode();
2198
- // clang-format off
2199
- if (isEditable && !this.editing) {
2200
- contextMenu.editSection().appendItem(i18nString(UIStrings.editAsHtml), this.editAsHTML.bind(this), { jslogContext: 'elements.edit-as-html' });
2201
- }
2202
- // clang-format on
2203
- const isShadowRoot = this.node.isShadowRoot();
2204
-
2205
- const createShortcut = UI.KeyboardShortcut.KeyboardShortcut.shortcutToString.bind(null);
2206
- const modifier = UI.KeyboardShortcut.Modifiers.CtrlOrMeta.value;
2207
- let menuItem;
2208
-
2209
- const openAiAssistanceId = 'freestyler.element-panel-context';
2210
- if (UI.ActionRegistry.ActionRegistry.instance().hasAction(openAiAssistanceId)) {
2211
- function appendSubmenuPromptAction(
2212
- submenu: UI.ContextMenu.SubMenu, action: UI.ActionRegistration.Action, label: Common.UIString.LocalizedString,
2213
- prompt: string, jslogContext: string): void {
2214
- submenu.defaultSection().appendItem(label, () => {
2215
- void action.execute({prompt});
2216
- UI.UIUtils.PromotionManager.instance().recordFeatureInteraction(openAiAssistanceId);
2217
- }, {disabled: !action.enabled(), jslogContext});
2218
- }
2219
- UI.Context.Context.instance().setFlavor(SDK.DOMModel.DOMNode, this.node);
2220
- const action = UI.ActionRegistry.ActionRegistry.instance().getAction(openAiAssistanceId);
2221
- const submenu = contextMenu.footerSection().appendSubMenuItem(action.title(), false, openAiAssistanceId);
2222
- submenu.defaultSection().appendAction(openAiAssistanceId, i18nString(UIStrings.startAChat));
2223
-
2224
- const submenuConfigs = [
2225
- {
2226
- condition: (props: SDK.CSSModel.LayoutProperties|null): boolean => Boolean(props?.isFlex),
2227
- items: [
2228
- {
2229
- label: i18nString(UIStrings.wrapTheseItems),
2230
- prompt: 'How can I make flex items wrap?',
2231
- jslogContextSuffix: '.flex-wrap',
2232
- },
2233
- {
2234
- label: i18nString(UIStrings.distributeItemsEvenly),
2235
- prompt: 'How do I distribute flex items evenly?',
2236
- jslogContextSuffix: '.flex-distribute',
2237
- },
2238
- {
2239
- label: i18nString(UIStrings.explainFlexbox),
2240
- prompt: 'What is flexbox?',
2241
- jslogContextSuffix: '.flex-what',
2242
- },
2243
- ],
2244
- },
2245
- {
2246
- condition: (props: SDK.CSSModel.LayoutProperties|null): boolean =>
2247
- Boolean(props?.isGrid && !props?.isSubgrid),
2248
- items: [
2249
- {
2250
- label: i18nString(UIStrings.alignItems),
2251
- prompt: 'How do I align items in a grid?',
2252
- jslogContextSuffix: '.grid-align',
2253
- },
2254
- {
2255
- label: i18nString(UIStrings.addPadding),
2256
- prompt: 'How to add spacing between grid items?',
2257
- jslogContextSuffix: '.grid-gap',
2258
- },
2259
- {
2260
- label: i18nString(UIStrings.explainGridLayout),
2261
- prompt: 'How does grid layout work?',
2262
- jslogContextSuffix: '.grid-how',
2263
- },
2264
- ],
2265
- },
2266
- {
2267
- condition: (props: SDK.CSSModel.LayoutProperties|null): boolean => Boolean(props?.isSubgrid),
2268
- items: [
2269
- {
2270
- label: i18nString(UIStrings.findGridDefinition),
2271
- prompt: 'Where is this grid defined?',
2272
- jslogContextSuffix: '.subgrid-where',
2273
- },
2274
- {
2275
- label: i18nString(UIStrings.changeParentProperties),
2276
- prompt: 'How to overwrite parent grid properties?',
2277
- jslogContextSuffix: '.subgrid-override',
2278
- },
2279
- {
2280
- label: i18nString(UIStrings.explainSubgrids),
2281
- prompt: 'How do subgrids work?',
2282
- jslogContextSuffix: '.subgrid-how',
2283
- },
2284
- ],
2285
- },
2286
- {
2287
- condition: (props: SDK.CSSModel.LayoutProperties|null): boolean => Boolean(props?.hasScroll),
2288
- items: [
2289
- {
2290
- label: i18nString(UIStrings.removeScrollbars),
2291
- prompt: 'How do I remove scrollbars for this element?',
2292
- jslogContextSuffix: '.scroll-remove',
2293
- },
2294
- {
2295
- label: i18nString(UIStrings.styleScrollbars),
2296
- prompt: 'How can I style a scrollbar?',
2297
- jslogContextSuffix: '.scroll-style',
2298
- },
2299
- {
2300
- label: i18nString(UIStrings.explainScrollbars),
2301
- prompt: 'Why does this element scroll?',
2302
- jslogContextSuffix: '.scroll-why',
2303
- },
2304
- ],
2305
- },
2306
- {
2307
- condition: (props: SDK.CSSModel.LayoutProperties|null): boolean => Boolean(props?.containerType),
2308
- items: [
2309
- {
2310
- label: i18nString(UIStrings.explainContainerQueries),
2311
- prompt: 'What are container queries?',
2312
- jslogContextSuffix: '.container-what',
2313
- },
2314
- {
2315
- label: i18nString(UIStrings.explainContainerTypes),
2316
- prompt: 'How do I use container-type?',
2317
- jslogContextSuffix: '.container-how',
2318
- },
2319
- {
2320
- label: i18nString(UIStrings.explainContainerContext),
2321
- prompt: 'What\'s the container context for this element?',
2322
- jslogContextSuffix: '.container-context',
2323
- },
2324
- ],
2325
- },
2326
- {
2327
- // Default items
2328
- condition: (): boolean => true,
2329
- items: [
2330
- {
2331
- label: i18nString(UIStrings.assessVisibility),
2332
- prompt: 'Why isn’t this element visible?',
2333
- jslogContextSuffix: '.visibility',
2334
- },
2335
- {
2336
- label: i18nString(UIStrings.centerElement),
2337
- prompt: 'How do I center this element?',
2338
- jslogContextSuffix: '.center',
2339
- },
2340
- ],
2341
- },
2342
- ];
2343
-
2344
- const layoutProps = await this.node.domModel().cssModel().getLayoutPropertiesFromComputedStyle(this.node.id);
2345
- const config = submenuConfigs.find(c => c.condition(layoutProps));
2346
- if (config) {
2347
- for (const item of config.items) {
2348
- appendSubmenuPromptAction(
2349
- submenu, action, item.label, item.prompt, openAiAssistanceId + item.jslogContextSuffix);
2350
- }
2351
- }
2352
- }
2353
-
2354
- menuItem = contextMenu.clipboardSection().appendItem(i18nString(UIStrings.cut),
2355
- () => this.performCopyOrCut?.(true, this.node),
2356
- {disabled: !this.hasEditableNode(), jslogContext: 'cut'});
2357
- menuItem.setShortcut(createShortcut('X', modifier));
2358
-
2359
- // Place it here so that all "Copy"-ing items stick together.
2360
- const copyMenu = contextMenu.clipboardSection().appendSubMenuItem(i18nString(UIStrings.copy), false, 'copy');
2361
- const section = copyMenu.section();
2362
- if (!isShadowRoot) {
2363
- menuItem = section.appendItem(i18nString(UIStrings.copyOuterhtml),
2364
- () => this.performCopyOrCut?.(false, this.node), {jslogContext: 'copy-outer-html'});
2365
- menuItem.setShortcut(createShortcut('V', modifier));
2366
- }
2367
- if (this.node.nodeType() === Node.ELEMENT_NODE) {
2368
- section.appendItem(
2369
- i18nString(UIStrings.copySelector), this.copyCSSPath.bind(this), {jslogContext: 'copy-selector'});
2370
- section.appendItem(i18nString(UIStrings.copyJsPath), this.copyJSPath.bind(this),
2371
- {disabled: !canGetJSPath(this.node), jslogContext: 'copy-js-path'});
2372
- section.appendItem(
2373
- i18nString(UIStrings.copyStyles), this.copyStyles.bind(this), {jslogContext: 'elements.copy-styles'});
2374
- }
2375
- if (!isShadowRoot) {
2376
- section.appendItem(i18nString(UIStrings.copyXpath), this.copyXPath.bind(this), {jslogContext: 'copy-xpath'});
2377
- section.appendItem(
2378
- i18nString(UIStrings.copyFullXpath), this.copyFullXPath.bind(this), {jslogContext: 'copy-full-xpath'});
2379
- }
2380
-
2381
- menuItem = copyMenu.clipboardSection().appendItem(i18nString(UIStrings.copyElement),
2382
- () => this.performCopyOrCut?.(false, this.node, true),
2383
- {jslogContext: 'copy-element'});
2384
- menuItem.setShortcut(createShortcut('C', modifier));
2385
-
2386
- if (!isShadowRoot) {
2387
- // Duplicate element, disabled on root element and ShadowDOM.
2388
- const isRootElement = !this.node.parentNode || this.node.parentNode.nodeName() === '#document';
2389
- menuItem = contextMenu.editSection().appendItem(i18nString(UIStrings.duplicateElement),
2390
- () => this.duplicateNode?.(this.node), {
2391
- disabled: (this.node.isInShadowTree() || isRootElement),
2392
- jslogContext: 'elements.duplicate-element',
2393
- });
2394
- }
2395
-
2396
- menuItem =
2397
- contextMenu.clipboardSection().appendItem(i18nString(UIStrings.paste), () => this.pasteNode?.(this.node),
2398
- {disabled: !this.canPaste?.(this.node), jslogContext: 'paste'});
2399
- menuItem.setShortcut(createShortcut('V', modifier));
2400
-
2401
- menuItem = contextMenu.debugSection().appendCheckboxItem(i18nString(UIStrings.hideElement),
2402
- () => this.toggleHideElement?.(this.node), {
2403
- checked: Boolean(this.isToggledToHidden?.(this.node)),
2404
- jslogContext: 'elements.hide-element',
2405
- });
2406
- menuItem.setShortcut(
2407
- UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction('elements.hide-element') || '');
2408
-
2409
- if (isEditable) {
2410
- contextMenu.editSection().appendItem(
2411
- i18nString(UIStrings.deleteElement), this.remove.bind(this), {jslogContext: 'delete-element'});
2412
- }
2413
-
2414
- this.populateExpandRecursively(contextMenu);
2415
- contextMenu.viewSection().appendItem(i18nString(UIStrings.collapseChildren), () => this.collapseChildren?.(),
2416
- {jslogContext: 'collapse-children'});
2417
- contextMenu.viewSection().appendItem(i18nString(UIStrings.switchToAccessibilityTree),
2418
- () => ElementsPanel.instance().toggleAccessibilityTree(),
2419
- {jslogContext: 'switch-to-accessibility-tree'});
2420
- const deviceModeWrapperAction = new Emulation.DeviceModeView.ActionDelegate();
2421
- contextMenu.viewSection().appendItem(
2422
- i18nString(UIStrings.captureNodeScreenshot),
2423
- deviceModeWrapperAction.handleAction.bind(
2424
- null, UI.Context.Context.instance(), 'emulation.capture-node-screenshot'),
2425
- {jslogContext: 'emulation.capture-node-screenshot'});
2426
- if (this.node.frameOwnerFrameId()) {
2427
- contextMenu.viewSection().appendItem(i18nString(UIStrings.showFrameDetails), () => {
2428
- const frameOwnerFrameId = this.node.frameOwnerFrameId();
2429
- if (frameOwnerFrameId) {
2430
- const frame = SDK.FrameManager.FrameManager.instance().getFrame(frameOwnerFrameId);
2431
- void Common.Revealer.reveal(frame);
2432
- }
2433
- }, {jslogContext: 'show-frame-details'});
2434
- }
2435
- }
2436
-
2437
- async populateProcessingElementContextMenu(contextMenu: UI.ContextMenu.ContextMenu): Promise<void> {
2438
- contextMenu.editSection().appendItem(
2439
- i18nString(UIStrings.editData), this.startEditingProcessingInstructionValue.bind(this),
2440
- {jslogContext: 'elements.edit-data'});
2441
- contextMenu.editSection().appendItem(i18nString(UIStrings.duplicateElement), () => this.duplicateNode?.(this.node),
2442
- {
2443
- disabled: (this.node.isInShadowTree()),
2444
- jslogContext: 'elements.duplicate-element',
2445
- });
2446
- contextMenu.editSection().appendItem(
2447
- i18nString(UIStrings.deleteElement), this.remove.bind(this), {jslogContext: 'delete-element'});
2448
- }
2449
-
2450
1977
  private startEditing(): boolean|undefined {
2451
1978
  if (!this.isDOMNodeSelected) {
2452
1979
  return;
@@ -2522,7 +2049,7 @@ export class ElementsTreeWidget extends UI.Widget.Widget {
2522
2049
  return;
2523
2050
  }
2524
2051
 
2525
- private startEditingAttribute(attribute: Element, elementForSelection: Element): boolean {
2052
+ startEditingAttribute(attribute: Element, elementForSelection: Element): boolean {
2526
2053
  console.assert(this.element.isAncestor(attribute));
2527
2054
 
2528
2055
  if (UI.UIUtils.isBeingEdited(attribute)) {
@@ -2598,7 +2125,7 @@ export class ElementsTreeWidget extends UI.Widget.Widget {
2598
2125
  return true;
2599
2126
  }
2600
2127
 
2601
- private startEditingTextNode(textNodeElement: Element): boolean {
2128
+ startEditingTextNode(textNodeElement: Element): boolean {
2602
2129
  if (UI.UIUtils.isBeingEdited(textNodeElement)) {
2603
2130
  return true;
2604
2131
  }
@@ -3162,19 +2689,19 @@ export class ElementsTreeWidget extends UI.Widget.Widget {
3162
2689
  void node.getOuterHTML().then(this.startEditingAsHTML.bind(this, commitChange, disposeCallback));
3163
2690
  }
3164
2691
 
3165
- private copyCSSPath(): void {
2692
+ copyCSSPath(): void {
3166
2693
  Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(cssPath(this.node, true));
3167
2694
  }
3168
2695
 
3169
- private copyJSPath(): void {
2696
+ copyJSPath(): void {
3170
2697
  Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(jsPath(this.node, true));
3171
2698
  }
3172
2699
 
3173
- private copyXPath(): void {
2700
+ copyXPath(): void {
3174
2701
  Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(xPath(this.node, true));
3175
2702
  }
3176
2703
 
3177
- private copyFullXPath(): void {
2704
+ copyFullXPath(): void {
3178
2705
  Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(xPath(this.node, false));
3179
2706
  }
3180
2707
 
@@ -3235,7 +2762,7 @@ export class ElementsTreeWidget extends UI.Widget.Widget {
3235
2762
  this.contentElement, matchRanges);
3236
2763
  }
3237
2764
 
3238
- private editAsHTML(): void {
2765
+ editAsHTML(): void {
3239
2766
  const promise = Common.Revealer.reveal(this.node);
3240
2767
  void promise.then(() => {
3241
2768
  const action = UI.ActionRegistry.ActionRegistry.instance().getAction('elements.edit-as-html');
@@ -3439,20 +2966,26 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
3439
2966
  highlightAttribute(name: string): void {
3440
2967
  this.widget.highlightAttribute(name);
3441
2968
  }
3442
- populateTextContextMenu(contextMenu: UI.ContextMenu.ContextMenu, textNode: Node): Promise<void> {
3443
- return this.widget.populateTextContextMenu(contextMenu, textNode);
2969
+ startEditingAttribute(attribute: Element, elementForSelection: Element): boolean {
2970
+ return this.widget.startEditingAttribute(attribute, elementForSelection);
2971
+ }
2972
+ startEditingTextNode(textNodeElement: Element): boolean {
2973
+ return this.widget.startEditingTextNode(textNodeElement);
2974
+ }
2975
+ editAsHTML(): void {
2976
+ this.widget.editAsHTML();
3444
2977
  }
3445
- populateTagContextMenu(contextMenu: UI.ContextMenu.ContextMenu, event: Event): Promise<void> {
3446
- return this.widget.populateTagContextMenu(contextMenu, event);
2978
+ copyCSSPath(): void {
2979
+ this.widget.copyCSSPath();
3447
2980
  }
3448
- populateNodeContextMenu(contextMenu: UI.ContextMenu.ContextMenu): Promise<void> {
3449
- return this.widget.populateNodeContextMenu(contextMenu);
2981
+ copyJSPath(): void {
2982
+ this.widget.copyJSPath();
3450
2983
  }
3451
- populatePseudoElementContextMenu(contextMenu: UI.ContextMenu.ContextMenu): void {
3452
- this.widget.populatePseudoElementContextMenu(contextMenu);
2984
+ copyXPath(): void {
2985
+ this.widget.copyXPath();
3453
2986
  }
3454
- populateProcessingElementContextMenu(contextMenu: UI.ContextMenu.ContextMenu): Promise<void> {
3455
- return this.widget.populateProcessingElementContextMenu(contextMenu);
2987
+ copyFullXPath(): void {
2988
+ this.widget.copyFullXPath();
3456
2989
  }
3457
2990
  hasEditableNode(): boolean {
3458
2991
  return this.widget.hasEditableNode();