зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1479239: prefers-reduced-motion should be sensible re. unsupported platforms / resistFingerprinting. r=hiro
With the current early-returning behavior, the expression will unconditionally evaluate to false, which is a bit of a footgun. Make sure to always return no-preference in unsupported platforms or when resisting fingerprinting. Differential Revision: https://phabricator.services.mozilla.com/D2491 MozReview-Commit-ID: 41uUudut7b4
This commit is contained in:
Родитель
c13281e92a
Коммит
051e9a8579
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>prefers-reduced-motion</title>
|
||||
<style>
|
||||
div {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
div { background-color: green; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion) {
|
||||
div { background-color: green; }
|
||||
}
|
||||
</style>
|
||||
<div></div>
|
|
@ -21,3 +21,4 @@ test-pref(ui.prefersReducedMotion,1) == mq_prefers_reduced_motion_no_preference.
|
|||
test-pref(ui.prefersReducedMotion,0) == mq_prefers_reduced_motion_reduce.html about:blank
|
||||
test-pref(ui.prefersReducedMotion,1) == mq_prefers_reduced_motion_reduce.html greenbox.html
|
||||
test-pref(privacy.resistFingerprinting,true) test-pref(ui.prefersReducedMotion,1) == mq_prefers_reduced_motion_reduce.html about:blank
|
||||
test-pref(privacy.resistFingerprinting,true) == mq_prefers_reduced_motion_both.html greenbox.html
|
||||
|
|
|
@ -520,27 +520,23 @@ GetIsGlyph(nsIDocument* aDocument, const nsMediaFeature* aFeature,
|
|||
aResult.SetIntValue(aDocument->IsSVGGlyphsDocument() ? 1 : 0, eCSSUnit_Integer);
|
||||
}
|
||||
|
||||
static void
|
||||
GetPrefersReducedMotion(nsIDocument* aDocument,
|
||||
const nsMediaFeature* aFeature,
|
||||
nsCSSValue& aResult)
|
||||
static bool
|
||||
PrefersReducedMotion(nsIDocument* aDocument)
|
||||
{
|
||||
if (nsContentUtils::ShouldResistFingerprinting(aDocument)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
return LookAndFeel::GetInt(LookAndFeel::eIntID_PrefersReducedMotion, 0) == 1;
|
||||
}
|
||||
|
||||
auto prefersReducedMotion = StylePrefersReducedMotion::NoPreference;
|
||||
|
||||
switch (LookAndFeel::GetInt(LookAndFeel::eIntID_PrefersReducedMotion, 0)) {
|
||||
case 0:
|
||||
prefersReducedMotion = StylePrefersReducedMotion::NoPreference;
|
||||
break;
|
||||
case 1:
|
||||
prefersReducedMotion = StylePrefersReducedMotion::Reduce;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
static void
|
||||
GetPrefersReducedMotion(nsIDocument* aDocument,
|
||||
const nsMediaFeature*,
|
||||
nsCSSValue& aResult)
|
||||
{
|
||||
auto prefersReducedMotion = PrefersReducedMotion(aDocument)
|
||||
? StylePrefersReducedMotion::Reduce
|
||||
: StylePrefersReducedMotion::NoPreference;
|
||||
|
||||
aResult.SetEnumValue(prefersReducedMotion);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче