Bug 1787127 - Use used color-scheme (not preferred) to determine canvas background adjustments. r=tnikkel
As per spec, see https://drafts.csswg.org/css-color-adjust/#color-scheme-effect: > In order to preserve expected color contrasts, in the case of embedded > documents typically rendered over a transparent canvas (such as > provided via an HTML iframe element), if the used color scheme of the > element and the used color scheme of the embedded document’s root > element do not match, then the UA must use an opaque canvas of the > Canvas color appropriate to the embedded document’s used color scheme > instead of a transparent canvas. After bug 1782596 we were using the preferred rather than used color-scheme, which is the right thing to do for prefers-color-scheme, but not for the canvas background. Differential Revision: https://phabricator.services.mozilla.com/D155831
This commit is contained in:
@@ -830,28 +830,20 @@ void nsSubDocumentFrame::MaybeUpdateEmbedderColorScheme() {
|
||||
return;
|
||||
}
|
||||
|
||||
auto preferredColorScheme =
|
||||
LookAndFeel::ColorSchemeForFrame(this, ColorSchemeMode::Preferred);
|
||||
bool needUpdate = [&] {
|
||||
switch (bc->GetEmbedderColorScheme()) {
|
||||
case PrefersColorSchemeOverride::Light:
|
||||
return preferredColorScheme != ColorScheme::Light;
|
||||
case PrefersColorSchemeOverride::Dark:
|
||||
return preferredColorScheme != ColorScheme::Dark;
|
||||
case PrefersColorSchemeOverride::None:
|
||||
case PrefersColorSchemeOverride::EndGuard_:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}();
|
||||
if (!needUpdate) {
|
||||
auto ToOverride = [](ColorScheme aScheme) -> PrefersColorSchemeOverride {
|
||||
return aScheme == ColorScheme::Dark ? PrefersColorSchemeOverride::Dark
|
||||
: PrefersColorSchemeOverride::Light;
|
||||
};
|
||||
|
||||
EmbedderColorSchemes schemes{
|
||||
ToOverride(LookAndFeel::ColorSchemeForFrame(this, ColorSchemeMode::Used)),
|
||||
ToOverride(
|
||||
LookAndFeel::ColorSchemeForFrame(this, ColorSchemeMode::Preferred))};
|
||||
if (bc->GetEmbedderColorSchemes() == schemes) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto value = preferredColorScheme == ColorScheme::Dark
|
||||
? PrefersColorSchemeOverride::Dark
|
||||
: PrefersColorSchemeOverride::Light;
|
||||
Unused << bc->SetEmbedderColorScheme(value);
|
||||
Unused << bc->SetEmbedderColorSchemes(schemes);
|
||||
}
|
||||
|
||||
void nsSubDocumentFrame::MaybeUpdateRemoteStyle(
|
||||
|
||||
Reference in New Issue
Block a user