mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-02 23:11:40 +01:00
[PM-5189] Working through subFrameRecalculation approach
This commit is contained in:
parent
a850f0127b
commit
cd1f9fb7c9
@ -776,7 +776,7 @@ export default class NotificationBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const messageResponse = handler({ message, sender });
|
const messageResponse = handler({ message, sender });
|
||||||
if (!messageResponse) {
|
if (typeof messageResponse === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,9 +392,9 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
if (subFrameOffsetsForTab) {
|
if (subFrameOffsetsForTab) {
|
||||||
const tabFrameIds = Array.from(subFrameOffsetsForTab.keys());
|
const tabFrameIds = Array.from(subFrameOffsetsForTab.keys());
|
||||||
for (const frameId of tabFrameIds) {
|
for (const frameId of tabFrameIds) {
|
||||||
if (frameId === sender.frameId) {
|
// if (frameId === sender.frameId) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
|
||||||
subFrameOffsetsForTab.delete(frameId);
|
subFrameOffsetsForTab.delete(frameId);
|
||||||
await this.buildSubFrameOffsets(sender.tab, frameId, sender.url);
|
await this.buildSubFrameOffsets(sender.tab, frameId, sender.url);
|
||||||
|
@ -182,7 +182,7 @@ class AutofillInit implements AutofillInitInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const messageResponse = handler({ message, sender });
|
const messageResponse = handler({ message, sender });
|
||||||
if (!messageResponse) {
|
if (typeof messageResponse === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ export class Fido2Background implements Fido2BackgroundInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const messageResponse = handler({ message, sender });
|
const messageResponse = handler({ message, sender });
|
||||||
if (!messageResponse) {
|
if (typeof messageResponse === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -798,21 +798,16 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
|
|
||||||
if ("PerformanceObserver" in window && "LayoutShift" in window) {
|
if ("PerformanceObserver" in window && "LayoutShift" in window) {
|
||||||
this.reflowPerformanceObserver = new PerformanceObserver(
|
this.reflowPerformanceObserver = new PerformanceObserver(
|
||||||
throttle(this.updateSubFrameOffsetsFromLayoutShiftEvent.bind(this), 10),
|
throttle(this.updateSubFrameOffsetsFromLayoutShiftEvent.bind(this), 100),
|
||||||
);
|
);
|
||||||
this.reflowPerformanceObserver.observe({ type: "layout-shift", buffered: true });
|
this.reflowPerformanceObserver.observe({ type: "layout-shift", buffered: true });
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.reflowMutationObserver = new MutationObserver(
|
if (globalThis.window.top !== globalThis.window && this.formFieldElements.size > 0) {
|
||||||
throttle(this.updateSubFrameForReflow.bind(this), 10),
|
this.setupRebuildSubFrameOffsetsEventListeners();
|
||||||
);
|
}
|
||||||
this.reflowMutationObserver.observe(globalThis.document.documentElement, {
|
|
||||||
childList: true,
|
|
||||||
subtree: true,
|
|
||||||
attributes: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateSubFrameOffsetsFromLayoutShiftEvent = (list: any) => {
|
private updateSubFrameOffsetsFromLayoutShiftEvent = (list: any) => {
|
||||||
@ -827,6 +822,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
};
|
};
|
||||||
|
|
||||||
private updateSubFrameForReflow = () => {
|
private updateSubFrameForReflow = () => {
|
||||||
|
// console.log("update sub frame reflow");
|
||||||
if (this.userInteractionEventTimeout) {
|
if (this.userInteractionEventTimeout) {
|
||||||
this.clearUserInteractionEventTimeout();
|
this.clearUserInteractionEventTimeout();
|
||||||
void this.toggleInlineMenuHidden(false, true);
|
void this.toggleInlineMenuHidden(false, true);
|
||||||
@ -1022,6 +1018,30 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
return documentRoot?.activeElement;
|
return documentRoot?.activeElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setupRebuildSubFrameOffsetsEventListeners = () => {
|
||||||
|
// console.log("setting up listeners");
|
||||||
|
globalThis.addEventListener(EVENTS.FOCUS, this.handleSubFrameFocusInEvent);
|
||||||
|
globalThis.document.body.addEventListener(EVENTS.MOUSEENTER, this.handleSubFrameFocusInEvent);
|
||||||
|
};
|
||||||
|
|
||||||
|
private handleSubFrameFocusInEvent = (event: FocusEvent) => {
|
||||||
|
// console.log("removing listeners", event);
|
||||||
|
this.updateSubFrameForReflow();
|
||||||
|
|
||||||
|
globalThis.removeEventListener(EVENTS.FOCUS, this.handleSubFrameFocusInEvent);
|
||||||
|
globalThis.document.body.removeEventListener(
|
||||||
|
EVENTS.MOUSEENTER,
|
||||||
|
this.handleSubFrameFocusInEvent,
|
||||||
|
);
|
||||||
|
globalThis.addEventListener(EVENTS.BLUR, this.handleSubFrameFocusOutEvent);
|
||||||
|
globalThis.document.body.addEventListener(EVENTS.MOUSELEAVE, this.handleSubFrameFocusOutEvent);
|
||||||
|
};
|
||||||
|
|
||||||
|
handleSubFrameFocusOutEvent = (event: FocusEvent) => {
|
||||||
|
// console.log(event);
|
||||||
|
this.setupRebuildSubFrameOffsetsEventListeners();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries all iframe elements within the document and returns the
|
* Queries all iframe elements within the document and returns the
|
||||||
* sub frame offsets for each iframe element.
|
* sub frame offsets for each iframe element.
|
||||||
|
@ -13,13 +13,16 @@ export const EVENTS = {
|
|||||||
BLUR: "blur",
|
BLUR: "blur",
|
||||||
CLICK: "click",
|
CLICK: "click",
|
||||||
FOCUS: "focus",
|
FOCUS: "focus",
|
||||||
|
FOCUSIN: "focusin",
|
||||||
|
FOCUSOUT: "focusout",
|
||||||
SCROLL: "scroll",
|
SCROLL: "scroll",
|
||||||
RESIZE: "resize",
|
RESIZE: "resize",
|
||||||
DOMCONTENTLOADED: "DOMContentLoaded",
|
DOMCONTENTLOADED: "DOMContentLoaded",
|
||||||
LOAD: "load",
|
LOAD: "load",
|
||||||
MESSAGE: "message",
|
MESSAGE: "message",
|
||||||
VISIBILITYCHANGE: "visibilitychange",
|
VISIBILITYCHANGE: "visibilitychange",
|
||||||
FOCUSOUT: "focusout",
|
MOUSEENTER: "mouseenter",
|
||||||
|
MOUSELEAVE: "mouseleave",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const ClearClipboardDelay = {
|
export const ClearClipboardDelay = {
|
||||||
|
Loading…
Reference in New Issue
Block a user