chrome-devtools-frontend 1.0.1568190 → 1.0.1569477

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 (46) hide show
  1. package/front_end/Images/src/grid-direction.svg +6 -0
  2. package/front_end/core/common/ParsedURL.ts +3 -0
  3. package/front_end/core/host/AidaClient.ts +1 -0
  4. package/front_end/core/root/Runtime.ts +4 -8
  5. package/front_end/entrypoints/main/MainImpl.ts +17 -20
  6. package/front_end/generated/InspectorBackendCommands.ts +6 -6
  7. package/front_end/generated/SupportedCSSProperties.js +14 -14
  8. package/front_end/generated/protocol.ts +0 -18
  9. package/front_end/models/ai_assistance/agents/PatchAgent.ts +4 -1
  10. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +12 -0
  11. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +12 -2
  12. package/front_end/models/ai_assistance/agents/StylingAgent.ts +4 -1
  13. package/front_end/models/ai_assistance/injected.ts +7 -22
  14. package/front_end/models/javascript_metadata/NativeFunctions.js +12 -0
  15. package/front_end/models/stack_trace/StackTraceImpl.ts +12 -2
  16. package/front_end/models/stack_trace/StackTraceModel.ts +9 -1
  17. package/front_end/models/trace/Styles.ts +11 -8
  18. package/front_end/models/trace/handlers/PageLoadMetricsHandler.ts +3 -2
  19. package/front_end/models/trace/types/TraceEvents.ts +19 -10
  20. package/front_end/panels/application/preloading/PreloadingView.ts +1 -3
  21. package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +13 -28
  22. package/front_end/panels/common/AiCodeCompletionTeaser.ts +58 -15
  23. package/front_end/panels/common/AiCodeGenerationTeaser.ts +1 -1
  24. package/front_end/panels/elements/ElementsPanel.ts +6 -3
  25. package/front_end/panels/elements/ElementsSidebarPane.ts +7 -28
  26. package/front_end/panels/elements/MetricsSidebarPane.ts +208 -216
  27. package/front_end/panels/elements/StylesSidebarPane.ts +6 -6
  28. package/front_end/panels/elements/components/CSSPropertyIconResolver.ts +57 -4
  29. package/front_end/panels/elements/components/StylePropertyEditor.ts +93 -1
  30. package/front_end/panels/elements/metricsSidebarPane.css +3 -11
  31. package/front_end/panels/settings/SettingsScreen.ts +8 -38
  32. package/front_end/panels/settings/settingsScreen.css +0 -4
  33. package/front_end/panels/sources/BreakpointEditDialog.ts +203 -138
  34. package/front_end/panels/sources/DebuggerPlugin.ts +15 -7
  35. package/front_end/panels/timeline/TimelineUIUtils.ts +9 -3
  36. package/front_end/panels/timeline/TimingsTrackAppender.ts +1 -0
  37. package/front_end/panels/timeline/overlays/OverlaysImpl.ts +3 -1
  38. package/front_end/panels/timeline/timelineFlameChartView.css +1 -0
  39. package/front_end/third_party/chromium/README.chromium +1 -1
  40. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +23 -1
  41. package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +16 -4
  42. package/front_end/ui/kit/link/Link.ts +14 -8
  43. package/front_end/ui/kit/link/link.css +1 -1
  44. package/front_end/ui/visual_logging/KnownContextValues.ts +4 -0
  45. package/mcp/mcp.ts +1 -0
  46. package/package.json +1 -1
@@ -1,7 +1,6 @@
1
1
  // Copyright 2021 The Chromium Authors
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
- /* eslint-disable @devtools/no-imperative-dom-api */
5
4
 
6
5
  /*
7
6
  * Copyright (C) 2007 Apple Inc. All rights reserved.
@@ -35,61 +34,210 @@ import * as Common from '../../core/common/common.js';
35
34
  import * as Platform from '../../core/platform/platform.js';
36
35
  import * as SDK from '../../core/sdk/sdk.js';
37
36
  import * as UI from '../../ui/legacy/legacy.js';
37
+ import {Directives, html, type LitTemplate, nothing, render} from '../../ui/lit/lit.js';
38
38
  import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
39
39
 
40
40
  import type {ComputedStyleModel} from './ComputedStyleModel.js';
41
41
  import {ElementsSidebarPane} from './ElementsSidebarPane.js';
42
42
  import metricsSidebarPaneStyles from './metricsSidebarPane.css.js';
43
43
 
44
+ const {live} = Directives;
45
+
46
+ interface ViewInput {
47
+ style: Map<string, string>;
48
+ highlightedMode: string;
49
+ node: SDK.DOMModel.DOMNode|null;
50
+ contentWidth: string;
51
+ contentHeight: string;
52
+ onHighlightNode: (showHighlight: boolean, mode: string) => void;
53
+ onStartEditing: (target: Element, box: string, styleProperty: string, computedStyle: Map<string, string>) => void;
54
+ }
55
+
56
+ type View = (input: ViewInput, output: undefined, target: HTMLElement) => void;
57
+
58
+ const DEFAULT_VIEW: View = (input, output, target) => {
59
+ const {style, highlightedMode, node, contentWidth, contentHeight, onHighlightNode, onStartEditing} = input;
60
+
61
+ function createBoxPartElement(style: Map<string, string>, name: string, side: string, suffix: string): LitTemplate {
62
+ const propertyName = (name !== 'position' ? name + '-' : '') + side + suffix;
63
+ let value = style.get(propertyName);
64
+
65
+ if (value === '' || (name !== 'position' && value === 'unset')) {
66
+ value = '\u2012';
67
+ } else if (name === 'position' && value === 'auto') {
68
+ value = '\u2012';
69
+ }
70
+ value = value?.replace(/px$/, '');
71
+ value = value ? Platform.NumberUtilities.toFixedIfFloating(value) : value;
72
+ // clang-format off
73
+ return html`<div class=${side} jslog=${VisualLogging.value(propertyName).track({
74
+ dblclick: true, keydown: 'Enter|Escape|ArrowUp|ArrowDown|PageUp|PageDown', change: true,
75
+ })}
76
+ @dblclick=${(e: Event) => onStartEditing(e.currentTarget as Element, name, propertyName, style)}
77
+ .innerText=${live(value ?? '')}>
78
+ </div>`;
79
+ // clang-format on
80
+ }
81
+
82
+ // Display types for which margin is ignored.
83
+ const noMarginDisplayType = new Set<string>([
84
+ 'table-cell',
85
+ 'table-column',
86
+ 'table-column-group',
87
+ 'table-footer-group',
88
+ 'table-header-group',
89
+ 'table-row',
90
+ 'table-row-group',
91
+ ]);
92
+
93
+ // Display types for which padding is ignored.
94
+ const noPaddingDisplayType = new Set<string>([
95
+ 'table-column',
96
+ 'table-column-group',
97
+ 'table-footer-group',
98
+ 'table-header-group',
99
+ 'table-row',
100
+ 'table-row-group',
101
+ ]);
102
+
103
+ // Position types for which top, left, bottom and right are ignored.
104
+ const noPositionType = new Set<string>(['static']);
105
+
106
+ const boxes = ['content', 'padding', 'border', 'margin', 'position'];
107
+ const boxColors = [
108
+ Common.Color.PageHighlight.Content,
109
+ Common.Color.PageHighlight.Padding,
110
+ Common.Color.PageHighlight.Border,
111
+ Common.Color.PageHighlight.Margin,
112
+ Common.Color.Legacy.fromRGBA([0, 0, 0, 0]),
113
+ ];
114
+ const boxLabels = ['content', 'padding', 'border', 'margin', 'position'];
115
+ let previousBox: LitTemplate = nothing;
116
+ for (let i = 0; i < boxes.length; ++i) {
117
+ const name = boxes[i];
118
+ const display = style.get('display');
119
+ const position = style.get('position');
120
+ if (!display || !position) {
121
+ continue;
122
+ }
123
+ if (name === 'margin' && noMarginDisplayType.has(display)) {
124
+ continue;
125
+ }
126
+ if (name === 'padding' && noPaddingDisplayType.has(display)) {
127
+ continue;
128
+ }
129
+ if (name === 'position' && noPositionType.has(position)) {
130
+ continue;
131
+ }
132
+
133
+ const shouldHighlight = !node || highlightedMode === 'all' || name === highlightedMode;
134
+ const backgroundColor = boxColors[i].asString(Common.Color.Format.RGBA) || '';
135
+
136
+ const suffix = (name === 'border' ? '-width' : '');
137
+ // clang-format off
138
+ const box: LitTemplate = html`
139
+ <div
140
+ class="${name} ${shouldHighlight ? 'highlighted' : ''}"
141
+ style="background-color: ${shouldHighlight ? backgroundColor : ''}"
142
+ jslog=${VisualLogging.metricsBox().context(name).track({hover: true})}
143
+ @mouseover=${(e: Event) => {e.consume(); onHighlightNode(true, name === 'position' ? 'all' : name);}}>
144
+ ${name === 'content' ? html`
145
+ <span jslog=${VisualLogging.value('width').track({
146
+ dblclick: true,
147
+ keydown: 'Enter|Escape|ArrowUp|ArrowDown|PageUp|PageDown',
148
+ change: true,
149
+ })}
150
+ @dblclick=${(e: Event) => onStartEditing(e.currentTarget as Element, 'width', 'width', style)}
151
+ .innerText=${live(contentWidth)}>
152
+ </span>
153
+ <span> × </span>
154
+ <span jslog=${VisualLogging.value('height').track({
155
+ dblclick: true,
156
+ keydown: 'Enter|Escape|ArrowUp|ArrowDown|PageUp|PageDown',
157
+ change: true,
158
+ })}
159
+ @dblclick=${(e: Event) => onStartEditing(e.currentTarget as Element, 'height', 'height', style)}
160
+ .innerText=${live(contentHeight)}>
161
+ </span>` : html`
162
+ <div class="label">${boxLabels[i]}</div>
163
+ ${createBoxPartElement(style, name, 'top', suffix)}
164
+ <br>
165
+ ${createBoxPartElement(style, name, 'left', suffix)}
166
+ ${previousBox}
167
+ ${createBoxPartElement(style, name, 'right', suffix)}
168
+ <br>
169
+ ${createBoxPartElement(style, name, 'bottom', suffix)}`}
170
+ </div>`;
171
+ // clang-format on
172
+
173
+ previousBox = box;
174
+ }
175
+ // clang-format off
176
+ render(html`
177
+ <div class="metrics ${!node ? 'collapsed' : ''}" @mouseover=${(e: Event) => { e.consume(); onHighlightNode(true, 'all'); }}
178
+ @mouseleave=${(e: Event) => { e.consume(); onHighlightNode(false, 'all'); }}>
179
+ ${previousBox}
180
+ </div>`, target);
181
+ // clang-format on
182
+ };
183
+
44
184
  export class MetricsSidebarPane extends ElementsSidebarPane {
45
185
  originalPropertyData: SDK.CSSProperty.CSSProperty|null;
46
186
  previousPropertyDataCandidate: SDK.CSSProperty.CSSProperty|null;
47
187
  private inlineStyle: SDK.CSSStyleDeclaration.CSSStyleDeclaration|null;
48
188
  private highlightMode: string;
49
- private boxElements: Array<{
50
- element: HTMLElement,
51
- name: string,
52
- backgroundColor: string,
53
- }>;
189
+ private computedStyle: Map<string, string>|null;
54
190
  private isEditingMetrics?: boolean;
191
+ private view: View;
55
192
 
56
- constructor(computedStyleModel: ComputedStyleModel) {
57
- super(computedStyleModel);
193
+ constructor(computedStyleModel: ComputedStyleModel, view = DEFAULT_VIEW) {
194
+ super(computedStyleModel, {jslog: `${VisualLogging.pane('styles-metrics')}`});
58
195
  this.registerRequiredCSS(metricsSidebarPaneStyles);
59
196
 
60
197
  this.originalPropertyData = null;
61
198
  this.previousPropertyDataCandidate = null;
62
199
  this.inlineStyle = null;
63
200
  this.highlightMode = '';
64
- this.boxElements = [];
65
- this.contentElement.setAttribute('jslog', `${VisualLogging.pane('styles-metrics')}`);
201
+ this.computedStyle = null;
202
+ this.view = view;
66
203
  }
67
204
 
68
- override doUpdate(): Promise<void> {
205
+ override async performUpdate(): Promise<void> {
69
206
  // "style" attribute might have changed. Update metrics unless they are being edited
70
207
  // (if a CSS property is added, a StyleSheetChanged event is dispatched).
71
208
  if (this.isEditingMetrics) {
72
- return Promise.resolve();
209
+ return await Promise.resolve();
73
210
  }
74
211
 
75
212
  // FIXME: avoid updates of a collapsed pane.
76
213
  const node = this.node();
77
214
  const cssModel = this.cssModel();
78
215
  if (!node || node.nodeType() !== Node.ELEMENT_NODE || !cssModel) {
79
- this.contentElement.removeChildren();
80
- this.element.classList.add('collapsed');
81
- return Promise.resolve();
216
+ this.view(
217
+ {
218
+ style: new Map(),
219
+ highlightedMode: '',
220
+ node: null,
221
+ contentWidth: '',
222
+ contentHeight: '',
223
+ onHighlightNode: () => {},
224
+ onStartEditing: () => {},
225
+ },
226
+ undefined, this.contentElement);
227
+ return await Promise.resolve();
82
228
  }
83
229
 
84
230
  function callback(this: MetricsSidebarPane, style: Map<string, string>|null): void {
85
231
  if (!style || this.node() !== node) {
232
+ this.computedStyle = null;
86
233
  return;
87
234
  }
235
+ this.computedStyle = style;
88
236
  this.updateMetrics(style);
89
237
  }
90
238
 
91
239
  if (!node.id) {
92
- return Promise.resolve();
240
+ return await Promise.resolve();
93
241
  }
94
242
 
95
243
  const promises = [
@@ -100,21 +248,11 @@ export class MetricsSidebarPane extends ElementsSidebarPane {
100
248
  }
101
249
  }),
102
250
  ];
103
- return Promise.all(promises) as unknown as Promise<void>;
251
+ return await (Promise.all(promises) as unknown as Promise<void>);
104
252
  }
105
253
 
106
254
  override onCSSModelChanged(): void {
107
- this.update();
108
- }
109
-
110
- /**
111
- * Toggle the visibility of the Metrics pane. This toggle allows external
112
- * callers to control the visibility of this pane, but toggling this on does
113
- * not guarantee the pane will always show up, because the pane's visibility
114
- * is also controlled by the internal condition that style cannot be empty.
115
- */
116
- toggleVisibility(isVisible: boolean): void {
117
- this.element.classList.toggle('invisible', !isVisible);
255
+ this.requestUpdate();
118
256
  }
119
257
 
120
258
  private getPropertyValueAsPx(style: Map<string, string>, propertyName: string): number {
@@ -139,8 +277,7 @@ export class MetricsSidebarPane extends ElementsSidebarPane {
139
277
  return {left, top, right, bottom};
140
278
  }
141
279
 
142
- private highlightDOMNode(showHighlight: boolean, mode: string, event: Event): void {
143
- event.consume();
280
+ private highlightDOMNode(showHighlight: boolean, mode: string): void {
144
281
  const node = this.node();
145
282
  if (showHighlight && node) {
146
283
  if (this.highlightMode === mode) {
@@ -153,202 +290,57 @@ export class MetricsSidebarPane extends ElementsSidebarPane {
153
290
  SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight();
154
291
  }
155
292
 
156
- for (const {element, name, backgroundColor} of this.boxElements) {
157
- const shouldHighlight = !node || mode === 'all' || name === mode;
158
- element.style.backgroundColor = shouldHighlight ? backgroundColor : '';
159
- element.classList.toggle('highlighted', shouldHighlight);
293
+ if (this.computedStyle) {
294
+ this.updateMetrics(this.computedStyle, mode);
160
295
  }
161
296
  }
162
297
 
163
- private updateMetrics(style: Map<string, string>): void {
164
- // Updating with computed style.
165
- const metricsElement = document.createElement('div');
166
- metricsElement.className = 'metrics';
167
- const self = this;
168
-
169
- function createBoxPartElement(
170
- this: MetricsSidebarPane, style: Map<string, string>, name: string, side: string,
171
- suffix: string): HTMLDivElement {
172
- const element = document.createElement('div');
173
- element.className = side;
174
-
175
- const propertyName = (name !== 'position' ? name + '-' : '') + side + suffix;
176
- let value = style.get(propertyName);
177
- if (value === undefined) {
178
- return element;
179
- }
180
-
181
- if (value === '' || (name !== 'position' && value === 'unset')) {
182
- value = '\u2012';
183
- } else if (name === 'position' && value === 'auto') {
184
- value = '\u2012';
185
- }
186
- value = value.replace(/px$/, '');
187
- value = Platform.NumberUtilities.toFixedIfFloating(value);
188
-
189
- element.textContent = value;
190
- element.setAttribute('jslog', `${VisualLogging.value(propertyName).track({
191
- dblclick: true,
192
- keydown: 'Enter|Escape|ArrowUp|ArrowDown|PageUp|PageDown',
193
- change: true,
194
- })}`);
195
- element.addEventListener('dblclick', this.startEditing.bind(this, element, name, propertyName, style), false);
196
- return element;
298
+ private getContentAreaWidthPx(style: Map<string, string>): string {
299
+ let width = style.get('width');
300
+ if (!width) {
301
+ return '';
197
302
  }
303
+ width = width.replace(/px$/, '');
304
+ const widthValue = Number(width);
305
+ if (!isNaN(widthValue) && style.get('box-sizing') === 'border-box') {
306
+ const borderBox = this.getBox(style, 'border');
307
+ const paddingBox = this.getBox(style, 'padding');
198
308
 
199
- function getContentAreaWidthPx(style: Map<string, string>): string {
200
- let width = style.get('width');
201
- if (!width) {
202
- return '';
203
- }
204
- width = width.replace(/px$/, '');
205
- const widthValue = Number(width);
206
- if (!isNaN(widthValue) && style.get('box-sizing') === 'border-box') {
207
- const borderBox = self.getBox(style, 'border');
208
- const paddingBox = self.getBox(style, 'padding');
209
-
210
- width = (widthValue - borderBox.left - borderBox.right - paddingBox.left - paddingBox.right).toString();
211
- }
212
-
213
- return Platform.NumberUtilities.toFixedIfFloating(width);
309
+ width = (widthValue - borderBox.left - borderBox.right - paddingBox.left - paddingBox.right).toString();
214
310
  }
215
311
 
216
- function getContentAreaHeightPx(style: Map<string, string>): string {
217
- let height = style.get('height');
218
- if (!height) {
219
- return '';
220
- }
221
- height = height.replace(/px$/, '');
222
- const heightValue = Number(height);
223
- if (!isNaN(heightValue) && style.get('box-sizing') === 'border-box') {
224
- const borderBox = self.getBox(style, 'border');
225
- const paddingBox = self.getBox(style, 'padding');
226
-
227
- height = (heightValue - borderBox.top - borderBox.bottom - paddingBox.top - paddingBox.bottom).toString();
228
- }
312
+ return Platform.NumberUtilities.toFixedIfFloating(width);
313
+ }
229
314
 
230
- return Platform.NumberUtilities.toFixedIfFloating(height);
315
+ private getContentAreaHeightPx(style: Map<string, string>): string {
316
+ let height = style.get('height');
317
+ if (!height) {
318
+ return '';
231
319
  }
320
+ height = height.replace(/px$/, '');
321
+ const heightValue = Number(height);
322
+ if (!isNaN(heightValue) && style.get('box-sizing') === 'border-box') {
323
+ const borderBox = this.getBox(style, 'border');
324
+ const paddingBox = this.getBox(style, 'padding');
232
325
 
233
- // Display types for which margin is ignored.
234
- const noMarginDisplayType = new Set<string>([
235
- 'table-cell',
236
- 'table-column',
237
- 'table-column-group',
238
- 'table-footer-group',
239
- 'table-header-group',
240
- 'table-row',
241
- 'table-row-group',
242
- ]);
243
-
244
- // Display types for which padding is ignored.
245
- const noPaddingDisplayType = new Set<string>([
246
- 'table-column',
247
- 'table-column-group',
248
- 'table-footer-group',
249
- 'table-header-group',
250
- 'table-row',
251
- 'table-row-group',
252
- ]);
253
-
254
- // Position types for which top, left, bottom and right are ignored.
255
- const noPositionType = new Set<string>(['static']);
256
-
257
- const boxes = ['content', 'padding', 'border', 'margin', 'position'];
258
- const boxColors = [
259
- Common.Color.PageHighlight.Content,
260
- Common.Color.PageHighlight.Padding,
261
- Common.Color.PageHighlight.Border,
262
- Common.Color.PageHighlight.Margin,
263
- Common.Color.Legacy.fromRGBA([0, 0, 0, 0]),
264
- ];
265
- const boxLabels = ['content', 'padding', 'border', 'margin', 'position'];
266
- let previousBox: HTMLDivElement|null = null;
267
- this.boxElements = [];
268
- for (let i = 0; i < boxes.length; ++i) {
269
- const name = boxes[i];
270
- const display = style.get('display');
271
- const position = style.get('position');
272
- if (!display || !position) {
273
- continue;
274
- }
275
- if (name === 'margin' && noMarginDisplayType.has(display)) {
276
- continue;
277
- }
278
- if (name === 'padding' && noPaddingDisplayType.has(display)) {
279
- continue;
280
- }
281
- if (name === 'position' && noPositionType.has(position)) {
282
- continue;
283
- }
284
-
285
- const boxElement = document.createElement('div');
286
- boxElement.className = `${name} highlighted`;
287
- const backgroundColor = boxColors[i].asString(Common.Color.Format.RGBA) || '';
288
- boxElement.style.backgroundColor = backgroundColor;
289
- boxElement.setAttribute('jslog', `${VisualLogging.metricsBox().context(name).track({hover: true})}`);
290
- boxElement.addEventListener(
291
- 'mouseover', this.highlightDOMNode.bind(this, true, name === 'position' ? 'all' : name), false);
292
- this.boxElements.push({element: boxElement, name, backgroundColor});
293
-
294
- if (name === 'content') {
295
- const widthElement = document.createElement('span');
296
- widthElement.textContent = getContentAreaWidthPx(style);
297
- widthElement.addEventListener(
298
- 'dblclick', this.startEditing.bind(this, widthElement, 'width', 'width', style), false);
299
- widthElement.setAttribute('jslog', `${VisualLogging.value('width').track({
300
- dblclick: true,
301
- keydown: 'Enter|Escape|ArrowUp|ArrowDown|PageUp|PageDown',
302
- change: true,
303
- })}`);
304
-
305
- const heightElement = document.createElement('span');
306
- heightElement.textContent = getContentAreaHeightPx(style);
307
- heightElement.addEventListener(
308
- 'dblclick', this.startEditing.bind(this, heightElement, 'height', 'height', style), false);
309
- heightElement.setAttribute('jslog', `${VisualLogging.value('height').track({
310
- dblclick: true,
311
- keydown: 'Enter|Escape|ArrowUp|ArrowDown|PageUp|PageDown',
312
- change: true,
313
- })}`);
314
-
315
- const timesElement = document.createElement('span');
316
- timesElement.textContent = ' × ';
317
-
318
- boxElement.appendChild(widthElement);
319
- boxElement.appendChild(timesElement);
320
- boxElement.appendChild(heightElement);
321
- } else {
322
- const suffix = (name === 'border' ? '-width' : '');
323
-
324
- const labelElement = document.createElement('div');
325
- labelElement.className = 'label';
326
- labelElement.textContent = boxLabels[i];
327
- boxElement.appendChild(labelElement);
328
-
329
- boxElement.appendChild(createBoxPartElement.call(this, style, name, 'top', suffix));
330
- boxElement.appendChild(document.createElement('br'));
331
- boxElement.appendChild(createBoxPartElement.call(this, style, name, 'left', suffix));
332
-
333
- if (previousBox) {
334
- boxElement.appendChild(previousBox);
335
- }
326
+ height = (heightValue - borderBox.top - borderBox.bottom - paddingBox.top - paddingBox.bottom).toString();
327
+ }
336
328
 
337
- boxElement.appendChild(createBoxPartElement.call(this, style, name, 'right', suffix));
338
- boxElement.appendChild(document.createElement('br'));
339
- boxElement.appendChild(createBoxPartElement.call(this, style, name, 'bottom', suffix));
340
- }
329
+ return Platform.NumberUtilities.toFixedIfFloating(height);
330
+ }
341
331
 
342
- previousBox = boxElement;
343
- }
344
- if (previousBox) {
345
- metricsElement.appendChild(previousBox);
346
- }
347
- metricsElement.addEventListener('mouseover', this.highlightDOMNode.bind(this, false, 'all'), false);
348
- metricsElement.addEventListener('mouseleave', this.highlightDOMNode.bind(this, false, 'all'), false);
349
- this.contentElement.removeChildren();
350
- this.contentElement.appendChild(metricsElement);
351
- this.element.classList.remove('collapsed');
332
+ private updateMetrics(style: Map<string, string>, highlightedMode = 'all'): void {
333
+ this.view(
334
+ {
335
+ style,
336
+ highlightedMode,
337
+ node: this.node(),
338
+ contentWidth: this.getContentAreaWidthPx(style),
339
+ contentHeight: this.getContentAreaHeightPx(style),
340
+ onHighlightNode: this.highlightDOMNode.bind(this),
341
+ onStartEditing: this.startEditing.bind(this),
342
+ },
343
+ undefined, this.contentElement);
352
344
  }
353
345
 
354
346
  startEditing(targetElement: Element, box: string, styleProperty: string, computedStyle: Map<string, string>): void {
@@ -429,7 +421,7 @@ export class MetricsSidebarPane extends ElementsSidebarPane {
429
421
  }
430
422
  }
431
423
  this.editingEnded(element, context);
432
- this.update();
424
+ this.requestUpdate();
433
425
  }
434
426
 
435
427
  private applyUserInput(
@@ -519,7 +511,7 @@ export class MetricsSidebarPane extends ElementsSidebarPane {
519
511
  }
520
512
 
521
513
  if (commitEditor) {
522
- this.update();
514
+ this.requestUpdate();
523
515
  }
524
516
  }
525
517
  }
@@ -205,10 +205,10 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
205
205
  #updateComputedStylesAbortController?: AbortController;
206
206
 
207
207
  constructor(computedStyleModel: ComputedStyleModel) {
208
- super(computedStyleModel, true /* delegatesFocus */);
208
+ super(computedStyleModel, {delegatesFocus: true});
209
209
  this.setMinimumSize(96, 26);
210
210
  this.registerRequiredCSS(stylesSidebarPaneStyles);
211
- Common.Settings.Settings.instance().moduleSetting('text-editor-indent').addChangeListener(this.update.bind(this));
211
+ Common.Settings.Settings.instance().moduleSetting('text-editor-indent').addChangeListener(this.requestUpdate, this);
212
212
  this.toolbarPaneElement = this.createStylesSidebarToolbar();
213
213
  this.noMatchesElement = this.contentElement.createChild('div', 'gray-info-message hidden');
214
214
  this.noMatchesElement.textContent = i18nString(UIStrings.noMatchingSelectorOrStyle);
@@ -330,7 +330,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
330
330
  revealProperty(cssProperty: SDK.CSSProperty.CSSProperty): void {
331
331
  void this.decorator.highlightProperty(cssProperty);
332
332
  this.lastRevealedProperty = cssProperty;
333
- this.update();
333
+ this.requestUpdate();
334
334
  }
335
335
 
336
336
  jumpToProperty(propertyName: string, sectionName?: string, blockName?: string): boolean {
@@ -366,7 +366,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
366
366
  this.#swatchPopoverHelper.hide();
367
367
  this.#updateAbortController?.abort();
368
368
  this.resetCache();
369
- this.update();
369
+ this.requestUpdate();
370
370
  }
371
371
 
372
372
  private sectionsContainerKeyDown(event: Event): void {
@@ -534,7 +534,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
534
534
  this.nodeStylesUpdatedForTest(node, false);
535
535
  }
536
536
 
537
- override async doUpdate(): Promise<void> {
537
+ override async performUpdate(): Promise<void> {
538
538
  this.#updateAbortController?.abort();
539
539
  this.#updateAbortController = new AbortController();
540
540
  await this.#innerDoUpdate(this.#updateAbortController.signal);
@@ -745,7 +745,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
745
745
  }
746
746
 
747
747
  this.resetCache();
748
- this.update();
748
+ this.requestUpdate();
749
749
  }
750
750
 
751
751
  #scheduleResetUpdateIfNotEditing(): void {
@@ -108,6 +108,41 @@ export function rotateFlexDirectionIcon(direction: PhysicalDirection): IconInfo
108
108
  };
109
109
  }
110
110
 
111
+ /**
112
+ * Rotates the grid direction icon in such way that it indicates
113
+ * the desired `direction` and the arrow in the icon is always at the bottom
114
+ * or at the right.
115
+ *
116
+ * By default, the icon is pointing top-down with the arrow on the right-hand side.
117
+ */
118
+ export function rotateGridDirectionIcon(direction: PhysicalDirection): IconInfo {
119
+ // Default to LTR.
120
+ let flipX = true;
121
+ let flipY = false;
122
+ let rotate = -90;
123
+
124
+ if (direction === PhysicalDirection.RIGHT_TO_LEFT) {
125
+ rotate = 90;
126
+ flipY = false;
127
+ flipX = false;
128
+ } else if (direction === PhysicalDirection.TOP_TO_BOTTOM) {
129
+ rotate = 0;
130
+ flipX = false;
131
+ flipY = false;
132
+ } else if (direction === PhysicalDirection.BOTTOM_TO_TOP) {
133
+ rotate = 0;
134
+ flipX = false;
135
+ flipY = true;
136
+ }
137
+
138
+ return {
139
+ iconName: 'grid-direction',
140
+ rotate,
141
+ scaleX: flipX ? -1 : 1,
142
+ scaleY: flipY ? -1 : 1,
143
+ };
144
+ }
145
+
111
146
  export function rotateAlignContentIcon(iconName: string, direction: PhysicalDirection): IconInfo {
112
147
  return {
113
148
  iconName,
@@ -156,6 +191,14 @@ function flexDirectionIcon(value: string): (styles: ComputedStyles) => IconInfo
156
191
  return getIcon;
157
192
  }
158
193
 
194
+ function gridDirectionIcon(value: string): (styles: ComputedStyles) => IconInfo {
195
+ function getIcon(computedStyles: ComputedStyles): IconInfo {
196
+ const directions = getPhysicalDirections(computedStyles);
197
+ return rotateGridDirectionIcon(directions[value]);
198
+ }
199
+ return getIcon;
200
+ }
201
+
159
202
  function flexAlignContentIcon(iconName: string): (styles: ComputedStyles) => IconInfo {
160
203
  function getIcon(computedStyles: ComputedStyles): IconInfo {
161
204
  const directions = getPhysicalDirections(computedStyles);
@@ -178,7 +221,9 @@ function flexAlignContentIcon(iconName: string): (styles: ComputedStyles) => Ico
178
221
  function gridAlignContentIcon(iconName: string): (styles: ComputedStyles) => IconInfo {
179
222
  function getIcon(computedStyles: ComputedStyles): IconInfo {
180
223
  const directions = getPhysicalDirections(computedStyles);
181
- return rotateAlignContentIcon(iconName, directions.column);
224
+ const gridAutoFlow = computedStyles.get('grid-auto-flow') || 'row';
225
+ const direction = gridAutoFlow.includes('column') ? directions.row : directions.column;
226
+ return rotateAlignContentIcon(iconName, direction);
182
227
  }
183
228
  return getIcon;
184
229
  }
@@ -194,7 +239,9 @@ function flexJustifyContentIcon(iconName: string): (styles: ComputedStyles) => I
194
239
  function gridJustifyContentIcon(iconName: string): (styles: ComputedStyles) => IconInfo {
195
240
  function getIcon(computedStyles: ComputedStyles): IconInfo {
196
241
  const directions = getPhysicalDirections(computedStyles);
197
- return rotateJustifyContentIcon(iconName, directions.row);
242
+ const gridAutoFlow = computedStyles.get('grid-auto-flow') || 'row';
243
+ const direction = gridAutoFlow.includes('column') ? directions.column : directions.row;
244
+ return rotateJustifyContentIcon(iconName, direction);
198
245
  }
199
246
  return getIcon;
200
247
  }
@@ -202,7 +249,9 @@ function gridJustifyContentIcon(iconName: string): (styles: ComputedStyles) => I
202
249
  function gridJustifyItemsIcon(iconName: string): (styles: ComputedStyles) => IconInfo {
203
250
  function getIcon(computedStyles: ComputedStyles): IconInfo {
204
251
  const directions = getPhysicalDirections(computedStyles);
205
- return rotateJustifyItemsIcon(iconName, directions.row);
252
+ const gridAutoFlow = computedStyles.get('grid-auto-flow') || 'row';
253
+ const direction = gridAutoFlow.includes('column') ? directions.column : directions.row;
254
+ return rotateJustifyItemsIcon(iconName, direction);
206
255
  }
207
256
  return getIcon;
208
257
  }
@@ -229,7 +278,9 @@ function flexAlignItemsIcon(iconName: string): (styles: ComputedStyles) => IconI
229
278
  function gridAlignItemsIcon(iconName: string): (styles: ComputedStyles) => IconInfo {
230
279
  function getIcon(computedStyles: ComputedStyles): IconInfo {
231
280
  const directions = getPhysicalDirections(computedStyles);
232
- return rotateAlignItemsIcon(iconName, directions.column);
281
+ const gridAutoFlow = computedStyles.get('grid-auto-flow') || 'row';
282
+ const direction = gridAutoFlow.includes('column') ? directions.row : directions.column;
283
+ return rotateAlignItemsIcon(iconName, direction);
233
284
  }
234
285
  return getIcon;
235
286
  }
@@ -338,6 +389,8 @@ const flexItemIcons = new Map([
338
389
  ]);
339
390
 
340
391
  const gridContainerIcons = new Map([
392
+ ['grid-auto-flow: row', gridDirectionIcon('row')],
393
+ ['grid-auto-flow: column', gridDirectionIcon('column')],
341
394
  ['align-content: center', gridAlignContentIcon('align-content-center')],
342
395
  ['align-content: space-around', gridAlignContentIcon('align-content-space-around')],
343
396
  ['align-content: space-between', gridAlignContentIcon('align-content-space-between')],