Skip to content

Commit c71b0b4

Browse files
danilsomsikovDevtools-frontend LUCI CQ
authored andcommitted
Record non-DOM loggable sizes
Bug: 406819817 Change-Id: I59d14c9ac8ac9ad072e14b238f80298cd0ed7d82 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6406317 Reviewed-by: Changhao Han <[email protected]> Commit-Queue: Danil Somsikov <[email protected]>
1 parent c5bdffc commit c71b0b4

File tree

12 files changed

+42
-26
lines changed

12 files changed

+42
-26
lines changed

front_end/panels/accessibility/AXBreadcrumbsPane.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,8 @@ export class AXBreadcrumb {
496496
if (!this.axNodeInternal.ignored() && this.axNodeInternal.hasOnlyUnloadedChildren()) {
497497
this.nodeElementInternal.classList.add('children-unloaded');
498498
UI.ARIAUtils.setExpanded(this.nodeElementInternal, false);
499-
VisualLogging.registerLoggable(this.expandLoggable, `${VisualLogging.expand()}`, this.elementInternal);
499+
VisualLogging.registerLoggable(
500+
this.expandLoggable, `${VisualLogging.expand()}`, this.elementInternal, new DOMRect(0, 0, 16, 16));
500501
}
501502

502503
if (!this.axNodeInternal.isDOMNode()) {
@@ -518,7 +519,8 @@ export class AXBreadcrumb {
518519
this.nodeElementInternal.classList.add('parent');
519520
UI.ARIAUtils.setExpanded(this.nodeElementInternal, true);
520521
this.childrenGroupElement.appendChild(breadcrumb.element());
521-
VisualLogging.registerLoggable(this.expandLoggable, `${VisualLogging.expand()}`, this.elementInternal);
522+
VisualLogging.registerLoggable(
523+
this.expandLoggable, `${VisualLogging.expand()}`, this.elementInternal, new DOMRect(0, 0, 16, 16));
522524
}
523525

524526
hasExpandedChildren(): number {

front_end/panels/sources/SourcesPanel.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,13 +506,14 @@ export class SourcesPanel extends UI.Panel.Panel implements
506506
if (withOverlay && !this.overlayLoggables) {
507507
this.overlayLoggables = {debuggerPausedMessage: {}, resumeButton: {}, stepOverButton: {}};
508508
VisualLogging.registerLoggable(
509-
this.overlayLoggables.debuggerPausedMessage, `${VisualLogging.dialog('debugger-paused')}`, null);
509+
this.overlayLoggables.debuggerPausedMessage, `${VisualLogging.dialog('debugger-paused')}`, null,
510+
new DOMRect(0, 0, 200, 20));
510511
VisualLogging.registerLoggable(
511512
this.overlayLoggables.resumeButton, `${VisualLogging.action('debugger.toggle-pause')}`,
512-
this.overlayLoggables.debuggerPausedMessage);
513+
this.overlayLoggables.debuggerPausedMessage, new DOMRect(0, 0, 20, 20));
513514
VisualLogging.registerLoggable(
514515
this.overlayLoggables.stepOverButton, `${VisualLogging.action('debugger.step-over')}`,
515-
this.overlayLoggables.debuggerPausedMessage);
516+
this.overlayLoggables.debuggerPausedMessage, new DOMRect(0, 0, 20, 20));
516517
}
517518
this.#lastPausedTarget = new WeakRef(details.debuggerModel.target());
518519
}

front_end/panels/timeline/TimelineFlameChartView.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,8 @@ export class TimelineFlameChartView extends Common.ObjectWrapper.eventMixin<Even
12851285
// This is the first time this group has been created, so register its loggable.
12861286
this.#loggableForGroupByLogContext.set(group.jslogContext, loggable);
12871287
VisualLogging.registerLoggable(
1288-
loggable, `${VisualLogging.section().context(`timeline.${group.jslogContext}`)}`, this.delegate.element);
1288+
loggable, `${VisualLogging.section().context(`timeline.${group.jslogContext}`)}`, this.delegate.element,
1289+
new DOMRect(0, 0, 200, 100));
12891290
}
12901291
}
12911292
}

front_end/ui/legacy/ContextMenu.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ describeWithEnvironment('ContextMenu', () => {
120120
const menuId = impressions.find(i => !i.parent)?.id;
121121
assert.exists(menuId);
122122
assert.sameDeepMembers(impressions.map(i => ({...i, id: 0})), [
123-
{id: 0, type: 67, height: 0, width: 0},
124-
{id: 0, type: 29, parent: menuId, context: 42, height: 0, width: 0},
125-
{id: 0, type: 29, parent: menuId, context: 44, height: 0, width: 0},
123+
{id: 0, type: 67, height: 40, width: 200},
124+
{id: 0, type: 29, parent: menuId, context: 42, height: 20, width: 200},
125+
{id: 0, type: 29, parent: menuId, context: 44, height: 20, width: 200},
126126
]);
127127

128128
Host.InspectorFrontendHost.InspectorFrontendHostInstance.events.dispatchEventToListeners(

front_end/ui/legacy/ContextMenu.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,9 @@ export interface ContextMenuOptions {
426426
y?: number;
427427
}
428428

429+
const MENU_ITEM_HEIGHT_FOR_LOGGING = 20;
430+
const MENU_ITEM_WIDTH_FOR_LOGGING = 200;
431+
429432
export class ContextMenu extends SubMenu {
430433
protected override contextMenu: this;
431434
private pendingTargets: unknown[];
@@ -545,14 +548,15 @@ export class ContextMenu extends SubMenu {
545548
if (descriptor.type === 'checkbox') {
546549
VisualLogging.registerLoggable(
547550
descriptor, `${VisualLogging.toggle().track({click: true}).context(descriptor.jslogContext)}`,
548-
parent || descriptors);
551+
parent || descriptors, new DOMRect(0, 0, MENU_ITEM_WIDTH_FOR_LOGGING, MENU_ITEM_HEIGHT_FOR_LOGGING));
549552
} else if (descriptor.type === 'item') {
550553
VisualLogging.registerLoggable(
551554
descriptor, `${VisualLogging.action().track({click: true}).context(descriptor.jslogContext)}`,
552-
parent || descriptors);
555+
parent || descriptors, new DOMRect(0, 0, MENU_ITEM_WIDTH_FOR_LOGGING, MENU_ITEM_HEIGHT_FOR_LOGGING));
553556
} else if (descriptor.type === 'subMenu') {
554557
VisualLogging.registerLoggable(
555-
descriptor, `${VisualLogging.item().context(descriptor.jslogContext)}`, parent || descriptors);
558+
descriptor, `${VisualLogging.item().context(descriptor.jslogContext)}`, parent || descriptors,
559+
new DOMRect(0, 0, MENU_ITEM_WIDTH_FOR_LOGGING, MENU_ITEM_HEIGHT_FOR_LOGGING));
556560
}
557561
if (descriptor.subItems) {
558562
this.registerLoggablesWithin(descriptor.subItems, descriptor);
@@ -592,7 +596,9 @@ export class ContextMenu extends SubMenu {
592596
Host.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(
593597
Host.InspectorFrontendHostAPI.Events.ContextMenuItemSelected, this.onItemSelected, this);
594598
}
595-
VisualLogging.registerLoggable(menuObject, `${VisualLogging.menu()}`, this.loggableParent);
599+
VisualLogging.registerLoggable(
600+
menuObject, `${VisualLogging.menu()}`, this.loggableParent,
601+
new DOMRect(0, 0, MENU_ITEM_WIDTH_FOR_LOGGING, MENU_ITEM_HEIGHT_FOR_LOGGING * menuObject.length));
596602
this.registerLoggablesWithin(menuObject);
597603
this.openHostedMenu = menuObject;
598604
// showContextMenuAtPoint call above synchronously issues a clear event for previous context menu (if any),

front_end/ui/legacy/Treeoutline.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,8 @@ export class TreeElement {
843843
this.collapse();
844844
ARIAUtils.unsetExpandable(this.listItemNode);
845845
} else {
846-
VisualLogging.registerLoggable(this.expandLoggable, `${VisualLogging.expand()}`, this.listItemNode);
846+
VisualLogging.registerLoggable(
847+
this.expandLoggable, `${VisualLogging.expand()}`, this.listItemNode, new DOMRect(0, 0, 16, 16));
847848
ARIAUtils.setExpanded(this.listItemNode, false);
848849
}
849850
}

front_end/ui/visual_logging/LoggingDriver.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,6 @@ describe('LoggingDriver', () => {
10341034
]);
10351035
assert.deepInclude(
10361036
VisualLoggingTesting.NonDomState.getNonDomLoggables(parent),
1037-
{loggable, config: {ve: 1, context: '123'}, parent});
1037+
{loggable, config: {ve: 1, context: '123'}, parent, size: undefined});
10381038
});
10391039
});

front_end/ui/visual_logging/LoggingDriver.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,11 @@ async function process(): Promise<void> {
263263
}
264264
for (let i = 0; i < nonDomRoots.length; ++i) {
265265
const root = nonDomRoots[i];
266-
for (const {loggable, config, parent} of getNonDomLoggables(root)) {
266+
for (const {loggable, config, parent, size} of getNonDomLoggables(root)) {
267267
const loggingState = getOrCreateLoggingState(loggable, config, parent);
268+
if (size) {
269+
loggingState.size = size;
270+
}
268271
processForDebugging(loggable);
269272
visibleLoggables.push(loggable);
270273
loggingState.impressionLogged = true;

front_end/ui/visual_logging/NonDomState.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@ describe('NonDomState', () => {
88
it('registers, unregisters and returns loggables', () => {
99
const parent = {};
1010
const child = {};
11+
const size = new DOMRect(0, 0, 100, 100);
1112
VisualLogging.NonDomState.registerLoggable(parent, {ve: 1, context: '1'});
12-
VisualLogging.NonDomState.registerLoggable(child, {ve: 1, context: '2'}, parent);
13+
VisualLogging.NonDomState.registerLoggable(child, {ve: 1, context: '2'}, parent, size);
1314

1415
assert.sameDeepMembers(VisualLogging.NonDomState.getNonDomLoggables(), [
15-
{loggable: parent, config: {ve: 1, context: '1'}, parent: undefined},
16+
{loggable: parent, config: {ve: 1, context: '1'}, parent: undefined, size: undefined},
1617
]);
1718
assert.sameDeepMembers(VisualLogging.NonDomState.getNonDomLoggables(parent), [
18-
{loggable: child, config: {ve: 1, context: '2'}, parent},
19+
{loggable: child, config: {ve: 1, context: '2'}, parent, size},
1920
]);
2021

2122
VisualLogging.NonDomState.unregisterLoggables(parent);
2223

2324
assert.sameDeepMembers(VisualLogging.NonDomState.getNonDomLoggables(parent), []);
2425
assert.sameDeepMembers(VisualLogging.NonDomState.getNonDomLoggables(), [
25-
{loggable: parent, config: {ve: 1, context: '1'}, parent: undefined},
26+
{loggable: parent, config: {ve: 1, context: '1'}, parent: undefined, size: undefined},
2627
]);
2728
VisualLogging.NonDomState.unregisterLoggables();
2829
assert.sameDeepMembers(VisualLogging.NonDomState.getNonDomLoggables(), []);
@@ -36,7 +37,7 @@ describe('NonDomState', () => {
3637
loggables.pop();
3738

3839
assert.sameDeepMembers(VisualLogging.NonDomState.getNonDomLoggables(), [
39-
{loggable, config: {ve: 1, context: '1'}, parent: undefined},
40+
{loggable, config: {ve: 1, context: '1'}, parent: undefined, size: undefined},
4041
]);
4142
VisualLogging.NonDomState.unregisterLoggables();
4243
});

front_end/ui/visual_logging/NonDomState.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ interface LoggableRegistration {
88
loggable: Loggable;
99
config: LoggingConfig;
1010
parent?: Loggable;
11+
size?: DOMRect;
1112
}
1213

1314
let registry = new WeakMap<Loggable, LoggableRegistration[]>();
@@ -16,9 +17,9 @@ function getLoggables(parent?: Loggable): LoggableRegistration[] {
1617
return registry.get(parent || nullParent) || [];
1718
}
1819

19-
export function registerLoggable(loggable: Loggable, config: LoggingConfig, parent?: Loggable): void {
20+
export function registerLoggable(loggable: Loggable, config: LoggingConfig, parent?: Loggable, size?: DOMRect): void {
2021
const values = getLoggables(parent);
21-
values.push({loggable, config, parent});
22+
values.push({loggable, config, parent, size});
2223
registry.set(parent || nullParent, values);
2324
}
2425

0 commit comments

Comments
 (0)