Bug 1591120 - Move print and color-scheme simulation to browsingContext. r=ochameau,nika,devtools-backward-compat-reviewers
We keep mMedium in nsPresContext rather than just looking it up in the browsing context because that's used quite more frequently. Differential Revision: https://phabricator.services.mozilla.com/D103782
This commit is contained in:
@@ -96,6 +96,13 @@ struct ParamTraits<mozilla::dom::DisplayMode>
|
||||
mozilla::dom::DisplayMode::Browser,
|
||||
mozilla::dom::DisplayMode::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::PrefersColorSchemeOverride>
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::dom::PrefersColorSchemeOverride,
|
||||
mozilla::dom::PrefersColorSchemeOverride::None,
|
||||
mozilla::dom::PrefersColorSchemeOverride::EndGuard_> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::ExplicitActiveStatus>
|
||||
: public ContiguousEnumSerializer<
|
||||
@@ -2476,10 +2483,42 @@ bool BrowsingContext::CanSet(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BrowsingContext::CanSet(FieldIndex<IDX_DisplayMode>,
|
||||
const enum DisplayMode& aDisplayMOde,
|
||||
ContentParent* aSource) {
|
||||
return IsTop();
|
||||
void BrowsingContext::DidSet(FieldIndex<IDX_PrefersColorSchemeOverride>,
|
||||
dom::PrefersColorSchemeOverride aOldValue) {
|
||||
MOZ_ASSERT(IsTop());
|
||||
if (PrefersColorSchemeOverride() == aOldValue) {
|
||||
return;
|
||||
}
|
||||
PreOrderWalk([&](BrowsingContext* aContext) {
|
||||
if (nsIDocShell* shell = aContext->GetDocShell()) {
|
||||
if (nsPresContext* pc = shell->GetPresContext()) {
|
||||
// This is a bit of a lie, but it's the code-path that gets taken for
|
||||
// regular system metrics changes via ThemeChanged().
|
||||
// TODO(emilio): The JustThisDocument is a bit suspect here,
|
||||
// prefers-color-scheme also applies to images or such, but the override
|
||||
// means that we could need to render the same image both with "light"
|
||||
// and "dark" appearance, so we just don't bother.
|
||||
pc->MediaFeatureValuesChanged(
|
||||
{MediaFeatureChangeReason::SystemMetricsChange},
|
||||
MediaFeatureChangePropagation::JustThisDocument);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void BrowsingContext::DidSet(FieldIndex<IDX_MediumOverride>,
|
||||
nsString&& aOldValue) {
|
||||
MOZ_ASSERT(IsTop());
|
||||
if (GetMediumOverride() == aOldValue) {
|
||||
return;
|
||||
}
|
||||
PreOrderWalk([&](BrowsingContext* aContext) {
|
||||
if (nsIDocShell* shell = aContext->GetDocShell()) {
|
||||
if (nsPresContext* pc = shell->GetPresContext()) {
|
||||
pc->RecomputeBrowsingContextDependentData();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void BrowsingContext::DidSet(FieldIndex<IDX_DisplayMode>,
|
||||
|
||||
Reference in New Issue
Block a user