cache closed shadow dom content windows

This commit is contained in:
siikamiika 2020-04-18 17:54:49 +03:00
parent 66354f1f9e
commit 691b739849

View File

@ -23,6 +23,7 @@ class FrameOffsetForwarder {
constructor() { constructor() {
this._started = false; this._started = false;
this._frameCache = new Set(); this._frameCache = new Set();
this._unreachableContentWindowCache = new Set();
this._forwardFrameOffset = ( this._forwardFrameOffset = (
window !== window.parent ? window !== window.parent ?
@ -74,9 +75,13 @@ class FrameOffsetForwarder {
} }
_onGetFrameOffset(offset, uniqueId, e) { _onGetFrameOffset(offset, uniqueId, e) {
const sourceFrame = this._findFrameWithContentWindow(e.source); let sourceFrame = null;
if (!this._unreachableContentWindowCache.has(e.source)) {
sourceFrame = this._findFrameWithContentWindow(e.source);
}
if (sourceFrame === null) { if (sourceFrame === null) {
// closed shadow root etc. // closed shadow root etc.
this._unreachableContentWindowCache.add(e.source);
this._forwardFrameOffsetOrigin(null, uniqueId); this._forwardFrameOffsetOrigin(null, uniqueId);
return; return;
} }