Implement prefers-reduced-motion media query
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Oct 2016 22:45:22 +0000 (22:45 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Oct 2016 22:45:22 +0000 (22:45 +0000)
commitf9c65890e0ac5c63f3a04455c097811582183989
tree4146093c5fd721c85c92130a24c9be8fa23c9567
parentd1908ac46e0716907cf8e44c1f03f03903342768
Implement prefers-reduced-motion media query
https://bugs.webkit.org/show_bug.cgi?id=163250
<rdar://problem/28704129>

Reviewed by Simon Fraser.

Source/WebCore:

Implement the prefers-reduced-motion media query, as
described in https://github.com/w3c/csswg-drafts/issues/442.

Tests: fast/media/mq-prefers-reduced-motion-forced-value.html
       fast/media/mq-prefers-reduced-motion.html

* Configurations/WebCoreTestSupport.xcconfig: Link against AppKit and UIKit.

* css/CSSValueKeywords.in: New keyword for "reduce".

* css/MediaFeatureNames.h: Add prefers-reduced-motion.
* css/MediaQueryEvaluator.cpp:
(WebCore::prefersReducedMotionEvaluate):
* css/MediaQueryExp.cpp:
(WebCore::featureWithValidIdent):
(WebCore::isFeatureValidWithoutValue):

* platform/Theme.h: New API to detect the system accessibility settings.
(WebCore::Theme::userPrefersReducedMotion):
* platform/ios/ThemeIOS.h:
* platform/ios/ThemeIOS.mm:
(WebCore::ThemeIOS::userPrefersReducedMotion):
* platform/mac/ThemeMac.h:
* platform/mac/ThemeMac.mm:
(WebCore::ThemeMac::userPrefersReducedMotion):

* testing/Internals.cpp: Expose the same API to internals, so that
a test can examine the value too.
(WebCore::Internals::userPrefersReducedMotion):
* testing/Internals.h:
* testing/Internals.idl:
* testing/Internals.mm:
(WebCore::Internals::userPrefersReducedMotion):

* page/Settings.h: New setting to override the system value...
* page/Settings.in:

* testing/InternalSettings.cpp: ... plumbed through internals.
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::forcedPrefersReducedMotionValue):
(WebCore::InternalSettings::setForcedPrefersReducedMotionValue):
* testing/InternalSettings.h:
* testing/InternalSettings.idl:
* testing/Internals.cpp:
(WebCore::Internals::userPrefersReducedMotion):
* testing/Internals.h:
* testing/Internals.idl:
* testing/Internals.mm:
(WebCore::Internals::userPrefersReducedMotion):

LayoutTests:

One test checks the system value. The other test overrides
the system values to make sure as much as possible is working.

* fast/media/mq-prefers-reduced-motion-expected.html: Added.
* fast/media/mq-prefers-reduced-motion-forced-value-expected.html: Added.
* fast/media/mq-prefers-reduced-motion-forced-value.html: Added.
* fast/media/mq-prefers-reduced-motion.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207173 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/media/mq-prefers-reduced-motion-expected.html [new file with mode: 0644]
LayoutTests/fast/media/mq-prefers-reduced-motion-forced-value-expected.html [new file with mode: 0644]
LayoutTests/fast/media/mq-prefers-reduced-motion-forced-value.html [new file with mode: 0644]
LayoutTests/fast/media/mq-prefers-reduced-motion.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Configurations/WebCoreTestSupport.xcconfig
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/MediaFeatureNames.h
Source/WebCore/css/MediaQueryEvaluator.cpp
Source/WebCore/css/MediaQueryExp.cpp
Source/WebCore/page/Settings.h
Source/WebCore/page/Settings.in
Source/WebCore/platform/Theme.h
Source/WebCore/platform/ios/ThemeIOS.h
Source/WebCore/platform/ios/ThemeIOS.mm
Source/WebCore/platform/mac/ThemeMac.h
Source/WebCore/platform/mac/ThemeMac.mm
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/InternalSettings.h
Source/WebCore/testing/InternalSettings.idl
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebCore/testing/Internals.mm