mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 09:18:42 +09:00
Issue #2837 - Implement prefers-reduced-motion media query.
Resolves #2837
This commit is contained in:
parent
fcc58bfbba
commit
df3b213459
5 changed files with 47 additions and 6 deletions
|
|
@ -47,9 +47,15 @@ static const nsCSSProps::KTableEntry kDisplayModeKeywords[] = {
|
|||
};
|
||||
|
||||
static const nsCSSProps::KTableEntry kPrefersColorSchemeKeywords[] = {
|
||||
{ eCSSKeyword_light, NS_STYLE_PREFERS_COLOR_SCHEME_LIGHT },
|
||||
{ eCSSKeyword_dark, NS_STYLE_PREFERS_COLOR_SCHEME_DARK },
|
||||
{ eCSSKeyword_UNKNOWN, -1 },
|
||||
{ eCSSKeyword_light, NS_STYLE_PREFERS_COLOR_SCHEME_LIGHT },
|
||||
{ eCSSKeyword_dark, NS_STYLE_PREFERS_COLOR_SCHEME_DARK },
|
||||
{ eCSSKeyword_UNKNOWN, -1 },
|
||||
};
|
||||
|
||||
static const nsCSSProps::KTableEntry kPrefersMotionKeywords[] = {
|
||||
{ eCSSKeyword_no_preference, NS_STYLE_PREFERS_FULL_MOTION },
|
||||
{ eCSSKeyword_reduce, NS_STYLE_PREFERS_REDUCED_MOTION },
|
||||
{ eCSSKeyword_UNKNOWN, -1 },
|
||||
};
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
|
@ -497,6 +503,22 @@ GetPrefersColorScheme(nsPresContext* aPresContext, const nsMediaFeature* aFeatur
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetPrefersMotion(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
|
||||
nsCSSValue& aResult)
|
||||
{
|
||||
switch(Preferences::GetInt("ui.prefersReducedMotion", 0)) {
|
||||
case 1:
|
||||
aResult.SetIntValue(NS_STYLE_PREFERS_REDUCED_MOTION,
|
||||
eCSSUnit_Enumerated);
|
||||
break;
|
||||
default:
|
||||
aResult.Reset();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
static nsresult
|
||||
GetDarkTheme(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
|
||||
nsCSSValue& aResult)
|
||||
|
|
@ -630,6 +652,14 @@ nsMediaFeatures::features[] = {
|
|||
{ kPrefersColorSchemeKeywords },
|
||||
GetPrefersColorScheme
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::prefers_reduced_motion,
|
||||
nsMediaFeature::eMinMaxNotAllowed,
|
||||
nsMediaFeature::eEnumerated,
|
||||
nsMediaFeature::eNoRequirements,
|
||||
{ kPrefersMotionKeywords },
|
||||
GetPrefersMotion
|
||||
},
|
||||
{
|
||||
&nsGkAtoms::resolution,
|
||||
nsMediaFeature::eMinMaxAllowed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue