Skip to content

Commit e003c58

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
RPP: make the perf panel UI inert when consent dialog shows
This CL makes the UI inert (it will not respond to user events) when the dialog is showing, so you cannot tab around elements in the background. We might want to expand this to a higher component so all of RPP is covered, but this is enough for now. Fixed: 406541486 Change-Id: Ie95ff549ba2392f6bdafeeff69c66e9ccd18ff7b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6403235 Auto-Submit: Jack Franklin <[email protected]> Commit-Queue: Alina Varkki <[email protected]> Reviewed-by: Alina Varkki <[email protected]>
1 parent 1096554 commit e003c58

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

front_end/panels/timeline/TimelineFlameChartView.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,18 @@ export class TimelineFlameChartView extends Common.ObjectWrapper.eventMixin<Even
286286
},
287287
});
288288

289+
this.#overlays.addEventListener(Overlays.Overlays.ConsentDialogVisibilityChange.eventName, e => {
290+
const event = e as Overlays.Overlays.ConsentDialogVisibilityChange;
291+
if (event.isVisible) {
292+
// If the dialog is visible, we do not want anything in the performance
293+
// panel capturing tab focus.
294+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inert
295+
this.element.setAttribute('inert', 'inert');
296+
} else {
297+
this.element.removeAttribute('inert');
298+
}
299+
});
300+
289301
this.#overlays.addEventListener(Overlays.Overlays.EntryLabelMouseClick.eventName, event => {
290302
const {overlay} = (event as Overlays.Overlays.EntryLabelMouseClick);
291303
this.dispatchEventToListeners(

front_end/panels/timeline/overlays/OverlaysImpl.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,12 @@ export class AnnotationOverlayActionEvent extends Event {
402402
super(AnnotationOverlayActionEvent.eventName);
403403
}
404404
}
405+
export class ConsentDialogVisibilityChange extends Event {
406+
static readonly eventName = 'consentdialogvisibilitychange';
407+
constructor(public isVisible: boolean) {
408+
super(ConsentDialogVisibilityChange.eventName, {bubbles: true, composed: true});
409+
}
410+
}
405411

406412
export class TimeRangeMouseOverEvent extends Event {
407413
static readonly eventName = 'timerangemouseoverevent';
@@ -1534,6 +1540,11 @@ export class Overlays extends EventTarget {
15341540
const callTree = parsedTrace ? Utils.AICallTree.AICallTree.fromEvent(overlay.entry, parsedTrace) : null;
15351541
component.callTree = callTree;
15361542

1543+
component.addEventListener(
1544+
Components.EntryLabelOverlay.LabelAnnotationsConsentDialogVisiblityChange.eventName, e => {
1545+
const event = e as Components.EntryLabelOverlay.LabelAnnotationsConsentDialogVisiblityChange;
1546+
this.dispatchEvent(new ConsentDialogVisibilityChange(event.isVisible));
1547+
});
15371548
component.addEventListener(Components.EntryLabelOverlay.EmptyEntryLabelRemoveEvent.eventName, () => {
15381549
this.dispatchEvent(new AnnotationOverlayActionEvent(overlay, 'Remove'));
15391550
});

front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ export class EntryLabelChangeEvent extends Event {
140140
}
141141
}
142142

143+
export class LabelAnnotationsConsentDialogVisiblityChange extends Event {
144+
static readonly eventName = 'labelannotationsconsentdialogvisiblitychange';
145+
constructor(public isVisible: boolean) {
146+
super(LabelAnnotationsConsentDialogVisiblityChange.eventName, {bubbles: true, composed: true});
147+
}
148+
}
149+
143150
export class EntryLabelOverlay extends HTMLElement {
144151
// The label is angled on the left from the centre of the entry it belongs to.
145152
// `LABEL_AND_CONNECTOR_SHIFT_LENGTH` specifies how many pixels to the left it is shifted.
@@ -548,6 +555,7 @@ export class EntryLabelOverlay extends HTMLElement {
548555
* @returns `true` if the user has now consented, and `false` otherwise.
549556
*/
550557
async #showUserAiFirstRunDialog(): Promise<boolean> {
558+
this.dispatchEvent(new LabelAnnotationsConsentDialogVisiblityChange(true));
551559
const userConsented = await PanelCommon.FreDialog.show({
552560
ariaLabel: i18nString(UIStrings.freDialog),
553561
header: {iconName: 'pen-spark', text: lockedString(UIStringsNotTranslate.freDisclaimerHeader)},
@@ -584,6 +592,7 @@ export class EntryLabelOverlay extends HTMLElement {
584592
},
585593
learnMoreButtonTitle: UIStringsNotTranslate.learnMoreButton,
586594
});
595+
this.dispatchEvent(new LabelAnnotationsConsentDialogVisiblityChange(false));
587596

588597
if (userConsented) {
589598
this.#aiAnnotationsEnabledSetting.set(true);

0 commit comments

Comments
 (0)