Bug 1662839 - Set author style disabled state correctly on newly created iframes. r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D90953
This commit is contained in:
Cameron McCormack
2020-09-24 01:24:57 +00:00
parent 997f1ea618
commit bbad6d2354
12 changed files with 135 additions and 18 deletions

View File

@@ -7274,10 +7274,8 @@ nsresult nsDocShell::RestoreFromHistory() {
nsCOMPtr<nsIContentViewer> newCv(viewer);
float overrideDPPX = 0.0f;
bool styleDisabled = false;
if (oldCv && newCv) {
if (oldCv) {
oldCv->GetOverrideDPPX(&overrideDPPX);
oldCv->GetAuthorStyleDisabled(&styleDisabled);
}
// Protect against mLSHE going away via a load triggered from
@@ -7502,11 +7500,15 @@ nsresult nsDocShell::RestoreFromHistory() {
FavorPerformanceHint(true);
}
if (oldCv && newCv) {
if (oldCv) {
newCv->SetOverrideDPPX(overrideDPPX);
newCv->SetAuthorStyleDisabled(styleDisabled);
}
// Take the author style disabled state from the top browsing context.
// (PageStyleChild.jsm ensures this is up to date.)
bool styleDisabled = GetBrowsingContext()->Top()->AuthorStyleDisabledDefault();
newCv->SetAuthorStyleDisabled(styleDisabled);
if (document) {
RefPtr<nsDocShell> parent = GetInProcessParentDocshell();
if (parent) {
@@ -8072,7 +8074,6 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
const Encoding* hintCharset = nullptr;
int32_t hintCharsetSource = kCharsetUninitialized;
float overrideDPPX = 1.0;
bool styleDisabled = false;
// |newMUDV| also serves as a flag to set the data from the above vars
nsCOMPtr<nsIContentViewer> newCv;
@@ -8106,8 +8107,6 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(oldCv->GetOverrideDPPX(&overrideDPPX),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(oldCv->GetAuthorStyleDisabled(&styleDisabled),
NS_ERROR_FAILURE);
}
}
}
@@ -8165,10 +8164,13 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
NS_ENSURE_SUCCESS(newCv->SetHintCharacterSetSource(hintCharsetSource),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(newCv->SetOverrideDPPX(overrideDPPX), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(newCv->SetAuthorStyleDisabled(styleDisabled),
NS_ERROR_FAILURE);
}
// Take the author style disabled state from the top browsing context.
// (PageStyleChild.jsm ensures this is up to date.)
bool styleDisabled = GetBrowsingContext()->Top()->AuthorStyleDisabledDefault();
mContentViewer->SetAuthorStyleDisabled(styleDisabled);
// Stuff the bgcolor from the old pres shell into the new
// pres shell. This improves page load continuity.
if (RefPtr<PresShell> presShell = mContentViewer->GetPresShell()) {