mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1846500 - Inherit color scheme override from opener. r=pbz
Differential Revision: https://phabricator.services.mozilla.com/D185166
This commit is contained in:
parent
37b4c74f93
commit
47427950b9
@ -13,20 +13,6 @@ ChromeUtils.defineESModuleGetters(this, {
|
||||
E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs",
|
||||
});
|
||||
|
||||
// Inherit color scheme overrides from parent window. This is to inherit the
|
||||
// color scheme of dark themed PBM windows.
|
||||
{
|
||||
let openerColorSchemeOverride =
|
||||
window.opener?.browsingContext?.top.prefersColorSchemeOverride;
|
||||
if (
|
||||
openerColorSchemeOverride &&
|
||||
window.browsingContext == window.browsingContext.top
|
||||
) {
|
||||
window.browsingContext.prefersColorSchemeOverride =
|
||||
openerColorSchemeOverride;
|
||||
}
|
||||
}
|
||||
|
||||
// define a js object to implement nsITreeView
|
||||
function pageInfoTreeView(treeid, copycol) {
|
||||
// copycol is the index number for the column that we want to add to
|
||||
|
@ -365,6 +365,12 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
|
||||
MOZ_DIAGNOSTIC_ASSERT(aOpener->mType == aType);
|
||||
fields.Get<IDX_OpenerId>() = aOpener->Id();
|
||||
fields.Get<IDX_HadOriginalOpener>() = true;
|
||||
|
||||
if (aType == Type::Chrome && !aParent) {
|
||||
// See SetOpener for why we do this inheritance.
|
||||
fields.Get<IDX_PrefersColorSchemeOverride>() =
|
||||
aOpener->Top()->GetPrefersColorSchemeOverride();
|
||||
}
|
||||
}
|
||||
|
||||
if (aParent) {
|
||||
@ -1076,6 +1082,23 @@ bool BrowsingContext::IsTargetable() const {
|
||||
return !GetClosed() && AncestorsAreCurrent();
|
||||
}
|
||||
|
||||
void BrowsingContext::SetOpener(BrowsingContext* aOpener) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(!aOpener || aOpener->Group() == Group());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!aOpener || aOpener->mType == mType);
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(SetOpenerId(aOpener ? aOpener->Id() : 0));
|
||||
|
||||
if (IsChrome() && IsTop() && aOpener) {
|
||||
// Inherit color scheme overrides from parent window. This is to inherit the
|
||||
// color scheme of dark themed PBM windows in dialogs opened by such
|
||||
// windows.
|
||||
auto openerOverride = aOpener->Top()->PrefersColorSchemeOverride();
|
||||
if (openerOverride != PrefersColorSchemeOverride()) {
|
||||
MOZ_ALWAYS_SUCCEEDS(SetPrefersColorSchemeOverride(openerOverride));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BrowsingContext::HasOpener() const {
|
||||
return sBrowsingContexts->Contains(GetOpenerId());
|
||||
}
|
||||
|
@ -486,13 +486,7 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
void SetOpener(BrowsingContext* aOpener) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(!aOpener || aOpener->Group() == Group());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!aOpener || aOpener->mType == mType);
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(SetOpenerId(aOpener ? aOpener->Id() : 0));
|
||||
}
|
||||
|
||||
void SetOpener(BrowsingContext* aOpener);
|
||||
bool HasOpener() const;
|
||||
|
||||
bool HadOriginalOpener() const { return GetHadOriginalOpener(); }
|
||||
|
@ -11,20 +11,6 @@ const { CommonDialog } = ChromeUtils.importESModule(
|
||||
|
||||
var propBag, args, Dialog;
|
||||
|
||||
// Inherit color scheme overrides from parent window. This is to inherit the
|
||||
// color scheme of dark themed PBM windows.
|
||||
{
|
||||
let openerColorSchemeOverride =
|
||||
window.opener?.browsingContext?.top.prefersColorSchemeOverride;
|
||||
if (
|
||||
openerColorSchemeOverride &&
|
||||
window.browsingContext == window.browsingContext.top
|
||||
) {
|
||||
window.browsingContext.prefersColorSchemeOverride =
|
||||
openerColorSchemeOverride;
|
||||
}
|
||||
}
|
||||
|
||||
function commonDialogOnLoad() {
|
||||
propBag = window.arguments[0]
|
||||
.QueryInterface(Ci.nsIWritablePropertyBag2)
|
||||
|
@ -24,18 +24,6 @@ var gProfileDisplay;
|
||||
|
||||
// Called once when the wizard is opened.
|
||||
function initWizard() {
|
||||
// Inherit color scheme overrides from parent window. This is to inherit the
|
||||
// color scheme of dark themed PBM windows.
|
||||
let openerColorSchemeOverride =
|
||||
window.opener?.browsingContext?.top.prefersColorSchemeOverride;
|
||||
if (
|
||||
openerColorSchemeOverride &&
|
||||
window.browsingContext == window.browsingContext.top
|
||||
) {
|
||||
window.browsingContext.prefersColorSchemeOverride =
|
||||
openerColorSchemeOverride;
|
||||
}
|
||||
|
||||
try {
|
||||
gProfileService = C[ToolkitProfileService].getService(
|
||||
I.nsIToolkitProfileService
|
||||
|
Loading…
Reference in New Issue
Block a user