chrome-devtools-frontend 1.0.1008562 → 1.0.1009019
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.
- package/.vscode/devtools-workspace-launch.json +1 -1
- package/config/gni/devtools_grd_files.gni +0 -1
- package/front_end/core/sdk/Target.ts +2 -2
- package/front_end/legacy_test_runner/elements_test_runner/ElementsTestRunner.js +8 -8
- package/front_end/models/logs/NetworkLog.ts +18 -8
- package/front_end/models/source_map_scopes/NamesResolver.ts +7 -2
- package/front_end/panels/elements/ComputedStyleWidget.ts +190 -221
- package/front_end/panels/elements/ElementsTreeElement.ts +101 -90
- package/front_end/panels/elements/StylePropertyTreeElement.ts +1 -1
- package/front_end/panels/elements/components/ComputedStyleProperty.ts +14 -2
- package/front_end/panels/elements/components/ComputedStyleTrace.ts +4 -1
- package/front_end/panels/elements/components/computedStyleProperty.css +15 -6
- package/front_end/panels/elements/components/computedStyleTrace.css +12 -1
- package/front_end/panels/elements/computedStyleSidebarPane.css +0 -5
- package/front_end/panels/network/NetworkSearchScope.ts +1 -1
- package/front_end/ui/components/docs/computed_style_property/basic.ts +12 -10
- package/front_end/ui/components/docs/computed_style_property/traceable.ts +13 -10
- package/front_end/ui/legacy/components/data_grid/DataGrid.ts +3 -5
- package/package.json +1 -1
- package/front_end/panels/elements/computedStyleWidgetTree.css +0 -66
@@ -209,13 +209,36 @@ const UIStrings = {
|
|
209
209
|
const str_ = i18n.i18n.registerUIStrings('panels/elements/ElementsTreeElement.ts', UIStrings);
|
210
210
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
211
211
|
|
212
|
+
const enum TagType {
|
213
|
+
OPENING = 'OPENING_TAG',
|
214
|
+
CLOSING = 'CLOSING_TAG',
|
215
|
+
}
|
216
|
+
|
217
|
+
type OpeningTagContext = {
|
218
|
+
tagType: TagType.OPENING,
|
219
|
+
readonly adornerContainer: HTMLElement,
|
220
|
+
adorners: Adorners.Adorner.Adorner[],
|
221
|
+
styleAdorners: Adorners.Adorner.Adorner[],
|
222
|
+
readonly adornersThrottler: Common.Throttler.Throttler,
|
223
|
+
slot?: Adorners.Adorner.Adorner,
|
224
|
+
canAddAttributes: boolean,
|
225
|
+
};
|
226
|
+
|
227
|
+
type ClosingTagContext = {
|
228
|
+
tagType: TagType.CLOSING,
|
229
|
+
};
|
230
|
+
|
231
|
+
export type TagTypeContext = OpeningTagContext|ClosingTagContext;
|
232
|
+
|
233
|
+
function isOpeningTag(context: TagTypeContext): context is OpeningTagContext {
|
234
|
+
return context.tagType === TagType.OPENING;
|
235
|
+
}
|
236
|
+
|
212
237
|
export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
213
238
|
nodeInternal: SDK.DOMModel.DOMNode;
|
214
239
|
treeOutline: ElementsTreeOutline|null;
|
215
240
|
private gutterContainer: HTMLElement;
|
216
241
|
private readonly decorationsElement: HTMLElement;
|
217
|
-
private isClosingTagInternal: boolean|undefined;
|
218
|
-
private readonly canAddAttributes: boolean|undefined;
|
219
242
|
private searchQuery: string|null;
|
220
243
|
private expandedChildrenLimitInternal: number;
|
221
244
|
private readonly decorationsThrottler: Common.Throttler.Throttler;
|
@@ -223,24 +246,15 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
223
246
|
private hoveredInternal: boolean;
|
224
247
|
private editing: EditorHandles|null;
|
225
248
|
private highlightResult: UI.UIUtils.HighlightChange[];
|
226
|
-
private
|
227
|
-
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
|
228
|
-
// @ts-expect-error
|
229
|
-
private adorners: Adorners.Adorner.Adorner[];
|
230
|
-
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
|
231
|
-
// @ts-expect-error
|
232
|
-
private styleAdorners: Adorners.Adorner.Adorner[];
|
233
|
-
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
|
234
|
-
// @ts-expect-error
|
235
|
-
private readonly adornersThrottler: Common.Throttler.Throttler;
|
236
|
-
private htmlEditElement!: HTMLElement|undefined;
|
249
|
+
private htmlEditElement?: HTMLElement;
|
237
250
|
expandAllButtonElement: UI.TreeOutline.TreeElement|null;
|
238
251
|
private searchHighlightsVisible?: boolean;
|
239
252
|
selectionElement?: HTMLDivElement;
|
240
253
|
private hintElement?: HTMLElement;
|
241
|
-
#slot?: Adorners.Adorner.Adorner;
|
242
254
|
private contentElement: HTMLElement;
|
243
255
|
|
256
|
+
readonly tagTypeContext: TagTypeContext;
|
257
|
+
|
244
258
|
constructor(node: SDK.DOMModel.DOMNode, isClosingTag?: boolean) {
|
245
259
|
// The title will be updated in onattach.
|
246
260
|
super();
|
@@ -253,11 +267,6 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
253
267
|
this.gutterContainer.append(gutterMenuIcon);
|
254
268
|
this.decorationsElement = this.gutterContainer.createChild('div', 'hidden');
|
255
269
|
|
256
|
-
this.isClosingTagInternal = isClosingTag;
|
257
|
-
|
258
|
-
if (this.nodeInternal.nodeType() === Node.ELEMENT_NODE && !isClosingTag) {
|
259
|
-
this.canAddAttributes = true;
|
260
|
-
}
|
261
270
|
this.searchQuery = null;
|
262
271
|
this.expandedChildrenLimitInternal = InitialChildrenLimit;
|
263
272
|
this.decorationsThrottler = new Common.Throttler.Throttler(100);
|
@@ -269,22 +278,26 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
269
278
|
|
270
279
|
this.highlightResult = [];
|
271
280
|
|
272
|
-
if (
|
273
|
-
this.
|
274
|
-
|
275
|
-
this.
|
276
|
-
|
277
|
-
|
281
|
+
if (isClosingTag) {
|
282
|
+
this.tagTypeContext = {tagType: TagType.CLOSING};
|
283
|
+
} else {
|
284
|
+
this.tagTypeContext = {
|
285
|
+
tagType: TagType.OPENING,
|
286
|
+
adornerContainer: this.contentElement.createChild('div', 'adorner-container hidden'),
|
287
|
+
adorners: [],
|
288
|
+
styleAdorners: [],
|
289
|
+
adornersThrottler: new Common.Throttler.Throttler(100),
|
290
|
+
canAddAttributes: this.nodeInternal.nodeType() === Node.ELEMENT_NODE,
|
291
|
+
};
|
278
292
|
void this.updateStyleAdorners();
|
279
293
|
|
280
294
|
if (node.isAdFrameNode()) {
|
281
295
|
const config = ElementsComponents.AdornerManager.getRegisteredAdorner(
|
282
296
|
ElementsComponents.AdornerManager.RegisteredAdorners.AD);
|
283
|
-
const adorner = this.adorn(config);
|
297
|
+
const adorner = this.adorn(config, this.tagTypeContext);
|
284
298
|
UI.Tooltip.Tooltip.install(adorner, i18nString(UIStrings.thisFrameWasIdentifiedAsAnAd));
|
285
299
|
}
|
286
300
|
}
|
287
|
-
|
288
301
|
this.expandAllButtonElement = null;
|
289
302
|
}
|
290
303
|
|
@@ -341,7 +354,7 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
341
354
|
}
|
342
355
|
|
343
356
|
isClosingTag(): boolean {
|
344
|
-
return
|
357
|
+
return !isOpeningTag(this.tagTypeContext);
|
345
358
|
}
|
346
359
|
|
347
360
|
node(): SDK.DOMModel.DOMNode {
|
@@ -425,17 +438,20 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
425
438
|
}
|
426
439
|
|
427
440
|
createSlotLink(nodeShortcut: SDK.DOMModel.DOMNodeShortcut|null): void {
|
441
|
+
if (!isOpeningTag(this.tagTypeContext)) {
|
442
|
+
return;
|
443
|
+
}
|
428
444
|
if (nodeShortcut) {
|
429
445
|
const config = ElementsComponents.AdornerManager.getRegisteredAdorner(
|
430
446
|
ElementsComponents.AdornerManager.RegisteredAdorners.SLOT);
|
431
|
-
this
|
447
|
+
this.tagTypeContext.slot = this.adornSlot(config, this.tagTypeContext);
|
432
448
|
const deferredNode = nodeShortcut.deferredNode;
|
433
|
-
this
|
449
|
+
this.tagTypeContext.slot.addEventListener('click', () => {
|
434
450
|
deferredNode.resolve(node => {
|
435
451
|
void Common.Revealer.reveal(node);
|
436
452
|
});
|
437
453
|
});
|
438
|
-
this
|
454
|
+
this.tagTypeContext.slot.addEventListener('mousedown', e => e.consume(), false);
|
439
455
|
}
|
440
456
|
}
|
441
457
|
|
@@ -464,7 +480,7 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
464
480
|
}
|
465
481
|
|
466
482
|
onbind(): void {
|
467
|
-
if (this.treeOutline && !this.
|
483
|
+
if (this.treeOutline && !this.isClosingTag()) {
|
468
484
|
this.treeOutline.treeElementByNode.set(this.nodeInternal, this);
|
469
485
|
}
|
470
486
|
}
|
@@ -500,7 +516,7 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
500
516
|
}
|
501
517
|
|
502
518
|
onexpand(): void {
|
503
|
-
if (this.
|
519
|
+
if (this.isClosingTag()) {
|
504
520
|
return;
|
505
521
|
}
|
506
522
|
|
@@ -508,7 +524,7 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
508
524
|
}
|
509
525
|
|
510
526
|
oncollapse(): void {
|
511
|
-
if (this.
|
527
|
+
if (this.isClosingTag()) {
|
512
528
|
return;
|
513
529
|
}
|
514
530
|
|
@@ -574,7 +590,7 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
574
590
|
}
|
575
591
|
|
576
592
|
ondblclick(event: Event): boolean {
|
577
|
-
if (this.editing || this.
|
593
|
+
if (this.editing || this.isClosingTag()) {
|
578
594
|
return false;
|
579
595
|
}
|
580
596
|
if (this.startEditingTarget((event.target as Element))) {
|
@@ -646,7 +662,7 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
646
662
|
populateTagContextMenu(contextMenu: UI.ContextMenu.ContextMenu, event: Event): void {
|
647
663
|
// Add attribute-related actions.
|
648
664
|
const treeElement =
|
649
|
-
this.
|
665
|
+
this.isClosingTag() && this.treeOutline ? this.treeOutline.findTreeElement(this.nodeInternal) : this;
|
650
666
|
if (!treeElement) {
|
651
667
|
return;
|
652
668
|
}
|
@@ -787,7 +803,7 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
787
803
|
|
788
804
|
const listItem = this.listItemElement;
|
789
805
|
|
790
|
-
if (this.canAddAttributes) {
|
806
|
+
if (isOpeningTag(this.tagTypeContext) && this.tagTypeContext.canAddAttributes) {
|
791
807
|
const attribute = listItem.getElementsByClassName('webkit-html-attribute')[0];
|
792
808
|
if (attribute) {
|
793
809
|
return this.startEditingAttribute(
|
@@ -1328,11 +1344,11 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
1328
1344
|
this.title = this.contentElement;
|
1329
1345
|
this.updateDecorations();
|
1330
1346
|
this.contentElement.prepend(this.gutterContainer);
|
1331
|
-
if (
|
1332
|
-
this.contentElement.append(this.adornerContainer);
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1347
|
+
if (isOpeningTag(this.tagTypeContext)) {
|
1348
|
+
this.contentElement.append(this.tagTypeContext.adornerContainer);
|
1349
|
+
if (this.tagTypeContext.slot) {
|
1350
|
+
this.contentElement.append(this.tagTypeContext.slot);
|
1351
|
+
}
|
1336
1352
|
}
|
1337
1353
|
this.highlightResult = [];
|
1338
1354
|
delete this.selectionElement;
|
@@ -1697,7 +1713,7 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
1697
1713
|
}
|
1698
1714
|
|
1699
1715
|
const tagName = node.nodeNameInCorrectCase();
|
1700
|
-
if (this.
|
1716
|
+
if (this.isClosingTag()) {
|
1701
1717
|
this.buildTagDOM(titleDOM, tagName, true, true, updateRecord);
|
1702
1718
|
break;
|
1703
1719
|
}
|
@@ -1942,7 +1958,7 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
1942
1958
|
}
|
1943
1959
|
|
1944
1960
|
// TODO: add unit tests for adorner-related methods after component and TypeScript works are done
|
1945
|
-
adorn({name}: {name: string}): Adorners.Adorner.Adorner {
|
1961
|
+
adorn({name}: {name: string}, context: OpeningTagContext): Adorners.Adorner.Adorner {
|
1946
1962
|
const adornerContent = document.createElement('span');
|
1947
1963
|
adornerContent.textContent = name;
|
1948
1964
|
const adorner = new Adorners.Adorner.Adorner();
|
@@ -1950,13 +1966,13 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
1950
1966
|
name,
|
1951
1967
|
content: adornerContent,
|
1952
1968
|
};
|
1953
|
-
|
1969
|
+
context.adorners.push(adorner);
|
1954
1970
|
ElementsPanel.instance().registerAdorner(adorner);
|
1955
|
-
this.updateAdorners();
|
1971
|
+
this.updateAdorners(context);
|
1956
1972
|
return adorner;
|
1957
1973
|
}
|
1958
1974
|
|
1959
|
-
adornSlot({name}: {name: string}): Adorners.Adorner.Adorner {
|
1975
|
+
adornSlot({name}: {name: string}, context: OpeningTagContext): Adorners.Adorner.Adorner {
|
1960
1976
|
const linkIcon = new IconButton.Icon.Icon();
|
1961
1977
|
linkIcon
|
1962
1978
|
.data = {iconName: 'ic_show_node_16x16', color: 'var(--color-text-disabled)', width: '12px', height: '12px'};
|
@@ -1971,45 +1987,45 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
1971
1987
|
name,
|
1972
1988
|
content: adornerContent,
|
1973
1989
|
};
|
1974
|
-
|
1990
|
+
context.adorners.push(adorner);
|
1975
1991
|
ElementsPanel.instance().registerAdorner(adorner);
|
1976
|
-
this.updateAdorners();
|
1992
|
+
this.updateAdorners(context);
|
1977
1993
|
return adorner;
|
1978
1994
|
}
|
1979
1995
|
|
1980
|
-
removeAdorner(adornerToRemove: Adorners.Adorner.Adorner): void {
|
1981
|
-
const adorners =
|
1996
|
+
removeAdorner(adornerToRemove: Adorners.Adorner.Adorner, context: OpeningTagContext): void {
|
1997
|
+
const adorners = context.adorners;
|
1982
1998
|
ElementsPanel.instance().deregisterAdorner(adornerToRemove);
|
1983
1999
|
adornerToRemove.remove();
|
1984
2000
|
for (let i = 0; i < adorners.length; ++i) {
|
1985
2001
|
if (adorners[i] === adornerToRemove) {
|
1986
2002
|
adorners.splice(i, 1);
|
1987
|
-
this.updateAdorners();
|
2003
|
+
this.updateAdorners(context);
|
1988
2004
|
return;
|
1989
2005
|
}
|
1990
2006
|
}
|
1991
2007
|
}
|
1992
2008
|
|
1993
|
-
removeAllAdorners(): void {
|
1994
|
-
for (const adorner of
|
2009
|
+
removeAllAdorners(context: OpeningTagContext): void {
|
2010
|
+
for (const adorner of context.adorners) {
|
1995
2011
|
ElementsPanel.instance().deregisterAdorner(adorner);
|
1996
2012
|
adorner.remove();
|
1997
2013
|
}
|
1998
2014
|
|
1999
|
-
|
2000
|
-
this.updateAdorners();
|
2015
|
+
context.adorners = [];
|
2016
|
+
this.updateAdorners(context);
|
2001
2017
|
}
|
2002
2018
|
|
2003
|
-
private updateAdorners(): void {
|
2004
|
-
void
|
2019
|
+
private updateAdorners(context: OpeningTagContext): void {
|
2020
|
+
void context.adornersThrottler.schedule(this.updateAdornersInternal.bind(null, context));
|
2005
2021
|
}
|
2006
2022
|
|
2007
|
-
private updateAdornersInternal(): Promise<void> {
|
2008
|
-
const adornerContainer =
|
2023
|
+
private updateAdornersInternal(context: OpeningTagContext): Promise<void> {
|
2024
|
+
const adornerContainer = context.adornerContainer;
|
2009
2025
|
if (!adornerContainer) {
|
2010
2026
|
return Promise.resolve();
|
2011
2027
|
}
|
2012
|
-
const adorners =
|
2028
|
+
const adorners = context.adorners;
|
2013
2029
|
if (adorners.length === 0) {
|
2014
2030
|
adornerContainer.classList.add('hidden');
|
2015
2031
|
return Promise.resolve();
|
@@ -2026,7 +2042,7 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
2026
2042
|
}
|
2027
2043
|
|
2028
2044
|
async updateStyleAdorners(): Promise<void> {
|
2029
|
-
if (this.
|
2045
|
+
if (!isOpeningTag(this.tagTypeContext)) {
|
2030
2046
|
return;
|
2031
2047
|
}
|
2032
2048
|
|
@@ -2038,10 +2054,10 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
2038
2054
|
}
|
2039
2055
|
|
2040
2056
|
const styles = await node.domModel().cssModel().getComputedStyle(nodeId);
|
2041
|
-
for (const styleAdorner of this.styleAdorners) {
|
2042
|
-
this.removeAdorner(styleAdorner);
|
2057
|
+
for (const styleAdorner of this.tagTypeContext.styleAdorners) {
|
2058
|
+
this.removeAdorner(styleAdorner, this.tagTypeContext);
|
2043
2059
|
}
|
2044
|
-
this.styleAdorners = [];
|
2060
|
+
this.tagTypeContext.styleAdorners = [];
|
2045
2061
|
if (!styles) {
|
2046
2062
|
return;
|
2047
2063
|
}
|
@@ -2055,35 +2071,30 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
2055
2071
|
const isContainer =
|
2056
2072
|
SDK.CSSContainerQuery.getQueryAxis(`${containerType} ${contain}`) !== SDK.CSSContainerQuery.QueryAxis.None;
|
2057
2073
|
|
2058
|
-
const appendAdorner = (adorner?: Adorners.Adorner.Adorner|null): void => {
|
2059
|
-
if (adorner) {
|
2060
|
-
this.styleAdorners.push(adorner);
|
2061
|
-
}
|
2062
|
-
};
|
2063
2074
|
if (isGrid) {
|
2064
|
-
|
2075
|
+
this.pushGridAdorner(this.tagTypeContext);
|
2065
2076
|
}
|
2066
2077
|
if (isFlex) {
|
2067
|
-
|
2078
|
+
this.pushFlexAdorner(this.tagTypeContext);
|
2068
2079
|
}
|
2069
2080
|
if (styles.get('scroll-snap-type') && styles.get('scroll-snap-type') !== 'none') {
|
2070
|
-
|
2081
|
+
this.pushScrollSnapAdorner(this.tagTypeContext);
|
2071
2082
|
}
|
2072
2083
|
if (isContainer) {
|
2073
|
-
|
2084
|
+
this.pushContainerAdorner(this.tagTypeContext);
|
2074
2085
|
}
|
2075
2086
|
}
|
2076
2087
|
|
2077
|
-
|
2088
|
+
pushGridAdorner(context: OpeningTagContext): void {
|
2078
2089
|
const node = this.node();
|
2079
2090
|
const nodeId = node.id;
|
2080
2091
|
if (!nodeId) {
|
2081
|
-
return
|
2092
|
+
return;
|
2082
2093
|
}
|
2083
2094
|
|
2084
2095
|
const config = ElementsComponents.AdornerManager.getRegisteredAdorner(
|
2085
2096
|
ElementsComponents.AdornerManager.RegisteredAdorners.GRID);
|
2086
|
-
const adorner = this.adorn(config);
|
2097
|
+
const adorner = this.adorn(config, context);
|
2087
2098
|
adorner.classList.add('grid');
|
2088
2099
|
|
2089
2100
|
const onClick = (((): void => {
|
@@ -2109,18 +2120,18 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
2109
2120
|
adorner.toggle(enabled);
|
2110
2121
|
});
|
2111
2122
|
|
2112
|
-
|
2123
|
+
context.styleAdorners.push(adorner);
|
2113
2124
|
}
|
2114
2125
|
|
2115
|
-
|
2126
|
+
pushScrollSnapAdorner(context: OpeningTagContext): void {
|
2116
2127
|
const node = this.node();
|
2117
2128
|
const nodeId = node.id;
|
2118
2129
|
if (!nodeId) {
|
2119
|
-
return
|
2130
|
+
return;
|
2120
2131
|
}
|
2121
2132
|
const config = ElementsComponents.AdornerManager.getRegisteredAdorner(
|
2122
2133
|
ElementsComponents.AdornerManager.RegisteredAdorners.SCROLL_SNAP);
|
2123
|
-
const adorner = this.adorn(config);
|
2134
|
+
const adorner = this.adorn(config, context);
|
2124
2135
|
adorner.classList.add('scroll-snap');
|
2125
2136
|
|
2126
2137
|
const onClick = (((): void => {
|
@@ -2148,18 +2159,18 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
2148
2159
|
adorner.toggle(enabled);
|
2149
2160
|
});
|
2150
2161
|
|
2151
|
-
|
2162
|
+
context.styleAdorners.push(adorner);
|
2152
2163
|
}
|
2153
2164
|
|
2154
|
-
|
2165
|
+
pushFlexAdorner(context: OpeningTagContext): void {
|
2155
2166
|
const node = this.node();
|
2156
2167
|
const nodeId = node.id;
|
2157
2168
|
if (!nodeId) {
|
2158
|
-
return
|
2169
|
+
return;
|
2159
2170
|
}
|
2160
2171
|
const config = ElementsComponents.AdornerManager.getRegisteredAdorner(
|
2161
2172
|
ElementsComponents.AdornerManager.RegisteredAdorners.FLEX);
|
2162
|
-
const adorner = this.adorn(config);
|
2173
|
+
const adorner = this.adorn(config, context);
|
2163
2174
|
adorner.classList.add('flex');
|
2164
2175
|
|
2165
2176
|
const onClick = (((): void => {
|
@@ -2187,18 +2198,18 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
2187
2198
|
adorner.toggle(enabled);
|
2188
2199
|
});
|
2189
2200
|
|
2190
|
-
|
2201
|
+
context.styleAdorners.push(adorner);
|
2191
2202
|
}
|
2192
2203
|
|
2193
|
-
|
2204
|
+
pushContainerAdorner(context: OpeningTagContext): void {
|
2194
2205
|
const node = this.node();
|
2195
2206
|
const nodeId = node.id;
|
2196
2207
|
if (!nodeId) {
|
2197
|
-
return
|
2208
|
+
return;
|
2198
2209
|
}
|
2199
2210
|
const config = ElementsComponents.AdornerManager.getRegisteredAdorner(
|
2200
2211
|
ElementsComponents.AdornerManager.RegisteredAdorners.CONTAINER);
|
2201
|
-
const adorner = this.adorn(config);
|
2212
|
+
const adorner = this.adorn(config, context);
|
2202
2213
|
adorner.classList.add('container');
|
2203
2214
|
|
2204
2215
|
const onClick = (((): void => {
|
@@ -2226,7 +2237,7 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
2226
2237
|
adorner.toggle(enabled);
|
2227
2238
|
});
|
2228
2239
|
|
2229
|
-
|
2240
|
+
context.styleAdorners.push(adorner);
|
2230
2241
|
}
|
2231
2242
|
}
|
2232
2243
|
|
@@ -918,7 +918,7 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
|
|
918
918
|
propertyNamePattern = '^' + this.property.name + '$';
|
919
919
|
}
|
920
920
|
const regex = new RegExp(propertyNamePattern, 'i');
|
921
|
-
computedStyleWidget.filterComputedStyles(regex);
|
921
|
+
await computedStyleWidget.filterComputedStyles(regex);
|
922
922
|
|
923
923
|
const filterInput = (computedStyleWidget.input as HTMLInputElement);
|
924
924
|
filterInput.value = this.property.name;
|
@@ -9,6 +9,8 @@ import computedStylePropertyStyles from './computedStyleProperty.css.js';
|
|
9
9
|
const {render, html} = LitHtml;
|
10
10
|
|
11
11
|
export interface ComputedStylePropertyData {
|
12
|
+
propertyNameRenderer: () => Element;
|
13
|
+
propertyValueRenderer: () => Element;
|
12
14
|
inherited: boolean;
|
13
15
|
traceable: boolean;
|
14
16
|
onNavigateToSource: (event?: Event) => void;
|
@@ -18,6 +20,8 @@ export class ComputedStyleProperty extends HTMLElement {
|
|
18
20
|
static readonly litTagName = LitHtml.literal`devtools-computed-style-property`;
|
19
21
|
readonly #shadow = this.attachShadow({mode: 'open'});
|
20
22
|
|
23
|
+
#propertyNameRenderer?: () => Element = undefined;
|
24
|
+
#propertyValueRenderer?: () => Element = undefined;
|
21
25
|
#inherited = false;
|
22
26
|
#traceable = false;
|
23
27
|
#onNavigateToSource: ((event?: Event) => void) = () => {};
|
@@ -27,6 +31,8 @@ export class ComputedStyleProperty extends HTMLElement {
|
|
27
31
|
}
|
28
32
|
|
29
33
|
set data(data: ComputedStylePropertyData) {
|
34
|
+
this.#propertyNameRenderer = data.propertyNameRenderer;
|
35
|
+
this.#propertyValueRenderer = data.propertyValueRenderer;
|
30
36
|
this.#inherited = data.inherited;
|
31
37
|
this.#traceable = data.traceable;
|
32
38
|
this.#onNavigateToSource = data.onNavigateToSource;
|
@@ -34,16 +40,22 @@ export class ComputedStyleProperty extends HTMLElement {
|
|
34
40
|
}
|
35
41
|
|
36
42
|
#render(): void {
|
43
|
+
const propertyNameElement = this.#propertyNameRenderer?.();
|
44
|
+
const propertyValueElement = this.#propertyValueRenderer?.();
|
37
45
|
// Disabled until https://crbug.com/1079231 is fixed.
|
38
46
|
// clang-format off
|
39
47
|
render(html`
|
40
48
|
<div class="computed-style-property ${this.#inherited ? 'inherited' : ''}">
|
41
|
-
<
|
49
|
+
<div class="property-name">
|
50
|
+
${propertyNameElement}
|
51
|
+
</div>
|
42
52
|
<span class="hidden" aria-hidden="false">: </span>
|
43
53
|
${this.#traceable ?
|
44
54
|
html`<span class="goto" @click=${this.#onNavigateToSource}></span>` :
|
45
55
|
null}
|
46
|
-
<
|
56
|
+
<div class="property-value">
|
57
|
+
${propertyValueElement}
|
58
|
+
</div>
|
47
59
|
<span class="hidden" aria-hidden="false">;</span>
|
48
60
|
</div>
|
49
61
|
`, this.#shadow, {
|
@@ -12,6 +12,7 @@ export interface ComputedStyleTraceData {
|
|
12
12
|
selector: string;
|
13
13
|
active: boolean;
|
14
14
|
onNavigateToSource: (event?: Event) => void;
|
15
|
+
ruleOriginNode?: Node;
|
15
16
|
}
|
16
17
|
|
17
18
|
export class ComputedStyleTrace extends HTMLElement {
|
@@ -21,6 +22,7 @@ export class ComputedStyleTrace extends HTMLElement {
|
|
21
22
|
#selector = '';
|
22
23
|
#active = false;
|
23
24
|
#onNavigateToSource: ((event?: Event) => void) = () => {};
|
25
|
+
#ruleOriginNode?: Node;
|
24
26
|
|
25
27
|
connectedCallback(): void {
|
26
28
|
this.#shadow.adoptedStyleSheets = [computedStyleTraceStyles];
|
@@ -30,6 +32,7 @@ export class ComputedStyleTrace extends HTMLElement {
|
|
30
32
|
this.#selector = data.selector;
|
31
33
|
this.#active = data.active;
|
32
34
|
this.#onNavigateToSource = data.onNavigateToSource;
|
35
|
+
this.#ruleOriginNode = data.ruleOriginNode;
|
33
36
|
this.#render();
|
34
37
|
}
|
35
38
|
|
@@ -41,7 +44,7 @@ export class ComputedStyleTrace extends HTMLElement {
|
|
41
44
|
<span class="goto" @click=${this.#onNavigateToSource}></span>
|
42
45
|
<slot name="trace-value" @click=${this.#onNavigateToSource}></slot>
|
43
46
|
<span class="trace-selector">${this.#selector}</span>
|
44
|
-
<
|
47
|
+
<span class="trace-link">${this.#ruleOriginNode}</span>
|
45
48
|
</div>
|
46
49
|
`, this.#shadow, {
|
47
50
|
host: this,
|
@@ -14,31 +14,40 @@
|
|
14
14
|
.computed-style-property {
|
15
15
|
--goto-size: 16px;
|
16
16
|
|
17
|
+
font-family: var(--monospace-font-family);
|
18
|
+
font-size: var(--monospace-font-size);
|
17
19
|
min-height: 16px;
|
18
20
|
box-sizing: border-box;
|
19
21
|
padding-top: 2px;
|
20
22
|
white-space: nowrap;
|
21
23
|
}
|
22
24
|
|
25
|
+
.computed-style-property:hover {
|
26
|
+
background-color: var(--legacy-focus-bg-color);
|
27
|
+
cursor: text;
|
28
|
+
}
|
29
|
+
|
23
30
|
.computed-style-property.inherited {
|
24
31
|
opacity: 50%;
|
25
32
|
}
|
26
33
|
|
27
|
-
|
28
|
-
|
34
|
+
.property-name,
|
35
|
+
.property-value {
|
36
|
+
display: contents;
|
29
37
|
overflow: hidden;
|
30
38
|
text-overflow: ellipsis;
|
31
39
|
}
|
32
40
|
|
33
|
-
|
41
|
+
.property-name {
|
34
42
|
width: 16em;
|
35
43
|
max-width: 52%;
|
36
44
|
margin-right: calc(var(--goto-size) / 2);
|
37
45
|
display: inline-block;
|
38
46
|
vertical-align: text-top;
|
47
|
+
color: var(--webkit-css-property-color, var(--color-syntax-1)); /* stylelint-disable-line plugin/use_theme_colors */ /* See: crbug.com/1152736 for color variable migration. */
|
39
48
|
}
|
40
49
|
|
41
|
-
|
50
|
+
.property-value {
|
42
51
|
margin-left: 2em;
|
43
52
|
}
|
44
53
|
|
@@ -66,8 +75,8 @@ slot[name="property-value"] {
|
|
66
75
|
white-space: normal;
|
67
76
|
}
|
68
77
|
|
69
|
-
:host-context(.computed-narrow)
|
70
|
-
:host-context(.computed-narrow)
|
78
|
+
:host-context(.computed-narrow) .property-name,
|
79
|
+
:host-context(.computed-narrow) .property-value {
|
71
80
|
display: inline-block;
|
72
81
|
width: 100%;
|
73
82
|
max-width: 100%;
|
@@ -12,6 +12,8 @@
|
|
12
12
|
|
13
13
|
.computed-style-trace {
|
14
14
|
margin-left: 16px;
|
15
|
+
font-family: var(--monospace-font-family);
|
16
|
+
font-size: var(--monospace-font-size);
|
15
17
|
}
|
16
18
|
|
17
19
|
.computed-style-trace:hover {
|
@@ -38,6 +40,15 @@
|
|
38
40
|
display: inline-block;
|
39
41
|
}
|
40
42
|
|
43
|
+
.devtools-link {
|
44
|
+
--override-text-decoration-color: hsl(0deg 0% 60%);
|
45
|
+
|
46
|
+
color: var(--color-text-primary);
|
47
|
+
text-decoration-color: var(--override-text-decoration-color);
|
48
|
+
text-decoration-line: underline;
|
49
|
+
cursor: pointer;
|
50
|
+
}
|
51
|
+
|
41
52
|
.trace-value {
|
42
53
|
margin-left: 16px;
|
43
54
|
}
|
@@ -53,7 +64,7 @@
|
|
53
64
|
padding-left: 2em;
|
54
65
|
}
|
55
66
|
|
56
|
-
|
67
|
+
.trace-link {
|
57
68
|
user-select: none;
|
58
69
|
float: right;
|
59
70
|
padding-left: 1em;
|
@@ -95,7 +95,7 @@ export class NetworkSearchScope implements Search.SearchConfig.SearchScope {
|
|
95
95
|
let pos = 0;
|
96
96
|
for (const regExp of regExps) {
|
97
97
|
const match = string.substr(pos).match(regExp);
|
98
|
-
if (!match ||
|
98
|
+
if (!match || match.index === undefined) {
|
99
99
|
return false;
|
100
100
|
}
|
101
101
|
pos += match.index + match[0].length;
|