зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1706027 - Perform readability check immediately when coming from the BFCache. r=Gijs
Pages that come from the BFCache are already laid out and so a main-thread paint is not guaranteed to happen. Before the Fission+BFCache implementation, browser_readerMode.js didn't trigger the bfcache codepath, so we were getting a paint fast enough when leaving reader mode. Differential Revision: https://phabricator.services.mozilla.com/D112527
This commit is contained in:
Родитель
468eca32ee
Коммит
b063ff13cb
|
@ -127,16 +127,14 @@ class AboutReaderChild extends JSWindowActorChild {
|
|||
this.sendAsyncMessage("Reader:UpdateReaderButton", {
|
||||
isArticle: this._isLeavingReaderableReaderMode,
|
||||
});
|
||||
if (this._isLeavingReaderableReaderMode) {
|
||||
this._isLeavingReaderableReaderMode = false;
|
||||
}
|
||||
this._isLeavingReaderableReaderMode = false;
|
||||
break;
|
||||
|
||||
case "pageshow":
|
||||
// If a page is loaded from the bfcache, we won't get a "DOMContentLoaded"
|
||||
// event, so we need to rely on "pageshow" in this case.
|
||||
if (aEvent.persisted) {
|
||||
this.updateReaderButton();
|
||||
if (aEvent.persisted && this.canDoReadabilityCheck()) {
|
||||
this.performReadabilityCheckNow();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -149,20 +147,24 @@ class AboutReaderChild extends JSWindowActorChild {
|
|||
* painted is not going to work.
|
||||
*/
|
||||
updateReaderButton(forceNonArticle) {
|
||||
if (
|
||||
!Readerable.isEnabledForParseOnLoad ||
|
||||
this.isAboutReader ||
|
||||
!this.contentWindow ||
|
||||
!this.contentWindow.windowRoot ||
|
||||
!(this.document instanceof this.contentWindow.HTMLDocument) ||
|
||||
this.document.mozSyntheticDocument
|
||||
) {
|
||||
if (!this.canDoReadabilityCheck()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.scheduleReadabilityCheckPostPaint(forceNonArticle);
|
||||
}
|
||||
|
||||
canDoReadabilityCheck() {
|
||||
return (
|
||||
Readerable.isEnabledForParseOnLoad &&
|
||||
!this.isAboutReader &&
|
||||
this.contentWindow &&
|
||||
this.contentWindow.windowRoot &&
|
||||
this.document instanceof this.contentWindow.HTMLDocument &&
|
||||
!this.document.mozSyntheticDocument
|
||||
);
|
||||
}
|
||||
|
||||
cancelPotentialPendingReadabilityCheck() {
|
||||
if (this._pendingReadabilityCheck) {
|
||||
if (this._listenerWindow) {
|
||||
|
@ -204,6 +206,10 @@ class AboutReaderChild extends JSWindowActorChild {
|
|||
return;
|
||||
}
|
||||
|
||||
this.performReadabilityCheckNow(forceNonArticle);
|
||||
}
|
||||
|
||||
performReadabilityCheckNow(forceNonArticle) {
|
||||
this.cancelPotentialPendingReadabilityCheck();
|
||||
|
||||
// Ignore errors from actors that have been unloaded before the
|
||||
|
|
Загрузка…
Ссылка в новой задаче