AX: "(inverted-colors)" media query only matches on page reload; should match on...
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Nov 2016 02:51:15 +0000 (02:51 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Nov 2016 02:51:15 +0000 (02:51 +0000)
commitb3e61deb540733873050ddcb60c692d25c29c31c
tree1cedd8bee066ce21294a7e7947170edb15bef4de
parent8cf7b454dd1163b4e46e1225618071485c41b260
AX: "(inverted-colors)" media query only matches on page reload; should match on change
https://bugs.webkit.org/show_bug.cgi?id=163564
<rdar://problem/28807350>

Source/WebCore:

Reviewed by Simon Fraser.

Mark some media queries as responding to notifications that
system accessibility settings have changed. When Page gets told
that has happened, check if any of the results have changed.

Tests: fast/media/mq-inverted-colors-live-update.html
       fast/media/mq-monochrome-live-update.html
       fast/media/mq-prefers-reduced-motion-live-update.html

* css/MediaQueryEvaluator.cpp:
(WebCore::isAccessibilitySettingsDependent):
(WebCore::MediaQueryEvaluator::evaluate):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::addAccessibilitySettingsDependentMediaQueryResult):
(WebCore::StyleResolver::hasMediaQueriesAffectedByAccessibilitySettingsChange):
* css/StyleResolver.h:
(WebCore::StyleResolver::hasAccessibilitySettingsDependentMediaQueries):
* page/Page.cpp:
(WebCore::Page::accessibilitySettingsDidChange):
* page/Page.h:

Source/WebKit2:

Reviewed by Simon Fraser.

Listen for the appropriate notifications that accessibility settings
have changed. This is a single notification on macOS, which uses WebViewImpl,
and more fine-grained notifications on iOS, using WKWebView.

When we see the notification, send a message to the WebProcess which will
then tell the WebCore::Page.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
(-[WKWebView _accessibilitySettingsDidChange:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(-[WKAccessibilitySettingsObserver initWithImpl:]):
(-[WKAccessibilitySettingsObserver dealloc]):
(-[WKAccessibilitySettingsObserver _settingsDidChange:]):
(WebKit::WebViewImpl::WebViewImpl):
(WebKit::WebViewImpl::accessibilitySettingsDidChange):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::accessibilitySettingsDidChange):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::accessibilitySettingsDidChange):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

Reviewed by NOBODY (OOPS!).

Add a UIScriptController method that tricks WebKit into thinking
it has received a notification that accessibility settings have
changed. Combined with our forced overrides, this allows us to
test if a page would react to the notifications.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::simulateAccessibilitySettingsChangeNotification):
* DumpRenderTree/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::simulateAccessibilitySettingsChangeNotification):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::simulateAccessibilitySettingsChangeNotification):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::simulateAccessibilitySettingsChangeNotification):
* WebKitTestRunner/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::simulateAccessibilitySettingsChangeNotification):

LayoutTests:

Reviewed by Simon Fraser.

* fast/media/mq-inverted-colors-live-update-in-subframes-expected.html: Added.
* fast/media/mq-inverted-colors-live-update-in-subframes.html: Added.
* fast/media/mq-inverted-colors-live-update-expected.html: Added.
* fast/media/mq-inverted-colors-live-update.html: Added.
* fast/media/mq-monochrome-live-update-expected.html: Added.
* fast/media/mq-monochrome-live-update.html: Added.
* fast/media/mq-prefers-reduced-motion-live-update-expected.html: Added.
* fast/media/mq-prefers-reduced-motion-live-update.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208915 268f45cc-cd09-0410-ab3c-d52691b4dbfc
35 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/media/mq-inverted-colors-live-update-expected.html [new file with mode: 0644]
LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes-expected.html [new file with mode: 0644]
LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes.html [new file with mode: 0644]
LayoutTests/fast/media/mq-inverted-colors-live-update.html [new file with mode: 0644]
LayoutTests/fast/media/mq-monochrome-live-update-expected.html [new file with mode: 0644]
LayoutTests/fast/media/mq-monochrome-live-update.html [new file with mode: 0644]
LayoutTests/fast/media/mq-prefers-reduced-motion-live-update-expected.html [new file with mode: 0644]
LayoutTests/fast/media/mq-prefers-reduced-motion-live-update.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator-wk2/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/css/MediaQueryEvaluator.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
Tools/DumpRenderTree/mac/UIScriptControllerMac.mm
Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm