chrome-devtools-frontend 1.0.1679704 → 1.0.1681091

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 (54) 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 +102 -0
  6. package/front_end/core/sdk/EmulationModel.ts +4 -2
  7. package/front_end/core/sdk/NetworkManager.ts +7 -6
  8. package/front_end/core/sdk/PageResourceLoader.ts +4 -3
  9. package/front_end/core/sdk/RuntimeModel.ts +5 -3
  10. package/front_end/core/sdk/SDKSettings.ts +47 -0
  11. package/front_end/core/sdk/sdk-meta.ts +0 -138
  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/generated/InspectorBackendCommands.ts +3 -1
  16. package/front_end/generated/SupportedCSSProperties.ts +20 -0
  17. package/front_end/generated/protocol-mapping.d.ts +7 -0
  18. package/front_end/generated/protocol-proxy-api.d.ts +5 -0
  19. package/front_end/generated/protocol.ts +15 -3
  20. package/front_end/panels/console/ConsoleView.ts +2 -1
  21. package/front_end/panels/console/console-meta.ts +10 -5
  22. package/front_end/panels/elements/DOMTreeContextMenu.ts +541 -0
  23. package/front_end/panels/elements/ElementsTreeElement.ts +27 -494
  24. package/front_end/panels/elements/ElementsTreeOutline.ts +173 -287
  25. package/front_end/panels/elements/StylesSidebarPane.ts +2 -1
  26. package/front_end/panels/elements/elements.ts +3 -0
  27. package/front_end/panels/issues/CorsIssueDetailsView.ts +13 -9
  28. package/front_end/panels/mobile_throttling/NetworkPanelIndicator.ts +3 -1
  29. package/front_end/panels/network/NetworkConfigView.ts +2 -1
  30. package/front_end/panels/network/NetworkPanel.ts +1 -1
  31. package/front_end/panels/network/network-meta.ts +60 -0
  32. package/front_end/panels/profiler/HeapDetachedElementsDataGrid.ts +2 -1
  33. package/front_end/panels/profiler/ProfileLauncherView.ts +19 -16
  34. package/front_end/panels/profiler/ProfileSidebarTreeElement.ts +1 -1
  35. package/front_end/panels/security/security.ts +6 -0
  36. package/front_end/panels/sources/SourcesView.ts +8 -107
  37. package/front_end/panels/sources/TabbedEditorContainer.ts +110 -7
  38. package/front_end/panels/sources/sources-meta.ts +16 -0
  39. package/front_end/panels/timeline/TimelineLoader.ts +1 -1
  40. package/front_end/panels/timeline/TimelineUIUtils.ts +6 -0
  41. package/front_end/panels/timeline/components/LayoutShiftDetails.ts +4 -3
  42. package/front_end/panels/timeline/components/LiveMetricsView.ts +1 -1
  43. package/front_end/panels/timeline/components/MetricCard.ts +4 -3
  44. package/front_end/panels/timeline/components/NetworkRequestDetails.ts +5 -2
  45. package/front_end/panels/timeline/components/TimelineRangeSummaryView.ts +1 -1
  46. package/front_end/panels/timeline/components/TimelineSummary.ts +8 -5
  47. package/front_end/third_party/chromium/README.chromium +1 -1
  48. package/front_end/ui/legacy/TabbedPane.ts +34 -2
  49. package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +5 -5
  50. package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +7 -7
  51. package/front_end/ui/legacy/components/quick_open/QuickOpen.ts +1 -1
  52. package/front_end/ui/legacy/components/quick_open/quick_open-meta.ts +2 -2
  53. package/front_end/ui/visual_logging/KnownContextValues.ts +29 -0
  54. package/package.json +1 -1
@@ -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';
@@ -107,37 +106,10 @@ const UIStrings = {
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
109
+ * @description Context menu item in the Edit as HTML editor that selects the editor's entire
110
+ * contents. "Select all" should be used as a verb.
139
111
  */
140
- editData: 'Edit data',
112
+ selectAll: 'Select all',
141
113
  /**
142
114
  * @description Text to cut an element, cut should be used as a verb
143
115
  */
@@ -150,67 +122,6 @@ const UIStrings = {
150
122
  * @description Text to paste an element, paste should be used as a verb
151
123
  */
152
124
  paste: 'Paste',
153
- /**
154
- * @description Context menu item in the Edit as HTML editor that selects the editor's entire
155
- * contents. "Select all" should be used as a verb.
156
- */
157
- selectAll: 'Select all',
158
- /**
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
125
  /**
215
126
  * @description Text in Elements Tree Element of the Elements panel
216
127
  */
@@ -227,9 +138,6 @@ const UIStrings = {
227
138
  * @description ARIA label for Elements Tree adorners
228
139
  */
229
140
  disableGridMode: 'Disable grid mode',
230
- /**
231
- * @description ARIA label for Elements Tree adorners
232
- */
233
141
  /**
234
142
  * @description ARIA label for Elements Tree adorners
235
143
  */
@@ -313,10 +221,6 @@ const UIStrings = {
313
221
  * @description Text of the tooltip for 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
  */
@@ -326,74 +230,6 @@ const UIStrings = {
326
230
  * the definition of the custom element in the Sources panel.
327
231
  */
328
232
  showCustomElementDefinition: 'Show custom element definition',
329
- /**
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.
363
- */
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
233
  /**
398
234
  * @description Link text content in Elements Tree Outline of the Elements panel. When clicked, it "reveals" the true location of an element.
399
235
  */
@@ -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();