<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[208915] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/208915">208915</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2016-11-18 18:51:15 -0800 (Fri, 18 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>AX: &quot;(inverted-colors)&quot; media query only matches on page reload; should match on change
https://bugs.webkit.org/show_bug.cgi?id=163564
&lt;rdar://problem/28807350&gt;

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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk2TestExpectations">trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2TestExpectations">trunk/LayoutTests/platform/mac-wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssMediaQueryEvaluatorcpp">trunk/Source/WebCore/css/MediaQueryEvaluator.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolverh">trunk/Source/WebCore/css/StyleResolver.h</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageh">trunk/Source/WebCore/page/Page.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplh">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplmm">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreeiosUIScriptControllerIOSmm">trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm</a></li>
<li><a href="#trunkToolsDumpRenderTreemacUIScriptControllerMacmm">trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm</a></li>
<li><a href="#trunkToolsTestRunnerSharedUIScriptContextBindingsUIScriptControlleridl">trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl</a></li>
<li><a href="#trunkToolsTestRunnerSharedUIScriptContextUIScriptControllercpp">trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp</a></li>
<li><a href="#trunkToolsTestRunnerSharedUIScriptContextUIScriptControllerh">trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h</a></li>
<li><a href="#trunkToolsWebKitTestRunneriosUIScriptControllerIOSmm">trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunnermacUIScriptControllerMacmm">trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastmediamqinvertedcolorsliveupdateexpectedhtml">trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastmediamqinvertedcolorsliveupdateinsubframesexpectedhtml">trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastmediamqinvertedcolorsliveupdateinsubframeshtml">trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes.html</a></li>
<li><a href="#trunkLayoutTestsfastmediamqinvertedcolorsliveupdatehtml">trunk/LayoutTests/fast/media/mq-inverted-colors-live-update.html</a></li>
<li><a href="#trunkLayoutTestsfastmediamqmonochromeliveupdateexpectedhtml">trunk/LayoutTests/fast/media/mq-monochrome-live-update-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastmediamqmonochromeliveupdatehtml">trunk/LayoutTests/fast/media/mq-monochrome-live-update.html</a></li>
<li><a href="#trunkLayoutTestsfastmediamqprefersreducedmotionliveupdateexpectedhtml">trunk/LayoutTests/fast/media/mq-prefers-reduced-motion-live-update-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastmediamqprefersreducedmotionliveupdatehtml">trunk/LayoutTests/fast/media/mq-prefers-reduced-motion-live-update.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/LayoutTests/ChangeLog        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-11-18  Dean Jackson  &lt;dino@apple.com&gt;
+
+        AX: &quot;(inverted-colors)&quot; media query only matches on page reload; should match on change
+        https://bugs.webkit.org/show_bug.cgi?id=163564
+        &lt;rdar://problem/28807350&gt;
+
+        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.
+
</ins><span class="cx"> 2016-11-18  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WebGL2] Implement texStorage2D()
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/LayoutTests/TestExpectations        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -70,6 +70,12 @@
</span><span class="cx"> # This test is for ios-simulator-wk1
</span><span class="cx"> editing/input/focus-change-with-marked-text.html [ Skip ]
</span><span class="cx"> 
</span><ins>+# These only run on Mac and iOS WK2
+fast/media/mq-inverted-colors-live-update.html [ Skip ]
+fast/media/mq-inverted-colors-live-update-in-subframes.html [ Skip ]
+fast/media/mq-monochrome-live-update.html [ Skip ]
+fast/media/mq-prefers-reduced-motion-live-update.html [ Skip ]
+
</ins><span class="cx"> #//////////////////////////////////////////////////////////////////////////////////////////
</span><span class="cx"> # End platform-specific tests.
</span><span class="cx"> #//////////////////////////////////////////////////////////////////////////////////////////
</span></span></pre></div>
<a id="trunkLayoutTestsfastmediamqinvertedcolorsliveupdateexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-expected.html (0 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-expected.html        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;CSS4 media query test: inverted-colors.&lt;/title&gt;
+&lt;style type=&quot;text/css&quot;&gt;
+p { color: black; }
+#a { color: green; }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;p id=&quot;a&quot;&gt;&lt;/p&gt;
+  &lt;p&gt;Before was: rgb(0, 0, 0) - should be rgb(0, 0, 0)&lt;/p&gt;
+  &lt;p&gt;After was: rgb(0, 128, 0) - should be rgb(0, 128, 0)&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-expected.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfastmediamqinvertedcolorsliveupdateinsubframesexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes-expected.html (0 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes-expected.html        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;CSS4 media query test: inverted-colors.&lt;/title&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;iframe srcdoc='
+  &lt;style type=&quot;text/css&quot;&gt;
+  p { color: black; }
+
+  @media (inverted-colors) {
+      #a { color: green; }
+  }
+  &lt;/style&gt;
+  &lt;p id=&quot;a&quot;&gt;&lt;/p&gt;
+  '&gt;&lt;/iframe&gt;
+  &lt;p&gt;Before was: &lt;span id=&quot;before&quot;&gt;rgb(0, 0, 0)&lt;/span&gt; - should be rgb(0, 0, 0)&lt;/p&gt;
+  &lt;p&gt;After was: &lt;span id=&quot;after&quot;&gt;rgb(0, 128, 0)&lt;/span&gt; - should be rgb(0, 128, 0)&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes-expected.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfastmediamqinvertedcolorsliveupdateinsubframeshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes.html (0 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes.html                                (rev 0)
+++ trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes.html        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;CSS4 media query test: inverted-colors.&lt;/title&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+function getUIScript()
+{
+    return `
+    (function() {
+        uiController.simulateAccessibilitySettingsChangeNotification(function() {
+            uiController.uiScriptComplete(&quot;Done&quot;);
+        });
+    })();`
+}
+
+function runTest()
+{
+    if (!window.internals)
+        return;
+
+    var frame = document.querySelector(&quot;iframe&quot;);
+    frame.contentWindow.postMessage({ type: &quot;before&quot; }, &quot;*&quot;);
+}
+
+window.addEventListener(&quot;load&quot;, runTest, false);
+
+window.addEventListener(&quot;message&quot;, function (event) {
+    if (event.data.type == &quot;beforeResponse&quot;) {
+        document.getElementById(&quot;before&quot;).textContent = event.data.color;
+        window.internals.settings.forcedColorsAreInvertedAccessibilityValue = &quot;on&quot;;
+        if (testRunner.runUIScript) {
+            testRunner.runUIScript(getUIScript(), function(result) {
+                var frame = document.querySelector(&quot;iframe&quot;);
+                frame.contentWindow.postMessage({ type: &quot;after&quot; }, &quot;*&quot;);
+            });
+        }
+    } else if (event.data.type == &quot;afterResponse&quot;) {
+        document.getElementById(&quot;after&quot;).textContent = event.data.color;
+        testRunner.notifyDone();
+    }
+}, false);
+
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;iframe srcdoc='
+  &lt;style type=&quot;text/css&quot;&gt;
+  p { color: black; }
+
+  @media (inverted-colors) {
+      #a { color: green; }
+  }
+  &lt;/style&gt;
+  &lt;script&gt;
+      window.addEventListener(&quot;message&quot;, function (event) {
+          var element = document.getElementById(&quot;a&quot;);
+          if (event.data.type == &quot;before&quot;) {
+             event.source.postMessage({
+                 type: &quot;beforeResponse&quot;,
+                 color: window.getComputedStyle(element).color
+             }, event.origin);
+          } else if (event.data.type == &quot;after&quot;) {
+             event.source.postMessage({
+                 type: &quot;afterResponse&quot;,
+                 color: window.getComputedStyle(element).color
+             }, event.origin);
+          }
+      }, false);
+  &lt;/script&gt;
+  &lt;p id=&quot;a&quot;&gt;&lt;/p&gt;
+  '&gt;&lt;/iframe&gt;
+  &lt;p&gt;Before was: &lt;span id=&quot;before&quot;&gt;&lt;/span&gt; - should be rgb(0, 0, 0)&lt;/p&gt;
+  &lt;p&gt;After was: &lt;span id=&quot;after&quot;&gt;&lt;/span&gt; - should be rgb(0, 128, 0)&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/media/mq-inverted-colors-live-update-in-subframes.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfastmediamqinvertedcolorsliveupdatehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/media/mq-inverted-colors-live-update.html (0 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/media/mq-inverted-colors-live-update.html                                (rev 0)
+++ trunk/LayoutTests/fast/media/mq-inverted-colors-live-update.html        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;CSS4 media query test: inverted-colors.&lt;/title&gt;
+&lt;style type=&quot;text/css&quot;&gt;
+p { color: black; }
+
+@media (inverted-colors) {
+    #a { color: green; }
+}
+&lt;/style&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+function getUIScript()
+{
+    return `
+    (function() {
+        uiController.simulateAccessibilitySettingsChangeNotification(function() {
+            uiController.uiScriptComplete(&quot;Done&quot;);
+        });
+    })();`
+}
+
+function runTest()
+{
+    if (!window.internals)
+        return;
+
+    var element = document.getElementById(&quot;a&quot;);
+
+    window.internals.settings.forcedColorsAreInvertedAccessibilityValue = &quot;on&quot;;
+    document.getElementById(&quot;before&quot;).textContent = window.getComputedStyle(element).color;
+    if (testRunner.runUIScript) {
+        testRunner.runUIScript(getUIScript(), function(result) {
+            document.getElementById(&quot;after&quot;).textContent = window.getComputedStyle(element).color;
+            testRunner.notifyDone();
+        });
+    }
+}
+
+window.addEventListener(&quot;load&quot;, runTest, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;p id=&quot;a&quot;&gt;&lt;/p&gt;
+  &lt;p&gt;Before was: &lt;span id=&quot;before&quot;&gt;&lt;/span&gt; - should be rgb(0, 0, 0)&lt;/p&gt;
+  &lt;p&gt;After was: &lt;span id=&quot;after&quot;&gt;&lt;/span&gt; - should be rgb(0, 128, 0)&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/media/mq-inverted-colors-live-update.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfastmediamqmonochromeliveupdateexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/media/mq-monochrome-live-update-expected.html (0 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/media/mq-monochrome-live-update-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/media/mq-monochrome-live-update-expected.html        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;CSS4 media query test: monochrome.&lt;/title&gt;
+&lt;style type=&quot;text/css&quot;&gt;
+p { color: black; }
+#a { color: green; }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;p id=&quot;a&quot;&gt;&lt;/p&gt;
+  &lt;p&gt;Before was: rgb(0, 0, 0) - should be rgb(0, 0, 0)&lt;/p&gt;
+  &lt;p&gt;After was: rgb(0, 128, 0) - should be rgb(0, 128, 0)&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/media/mq-monochrome-live-update-expected.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfastmediamqmonochromeliveupdatehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/media/mq-monochrome-live-update.html (0 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/media/mq-monochrome-live-update.html                                (rev 0)
+++ trunk/LayoutTests/fast/media/mq-monochrome-live-update.html        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;CSS4 media query test: monochrome.&lt;/title&gt;
+&lt;style type=&quot;text/css&quot;&gt;
+p { color: black; }
+
+@media (monochrome) {
+    #a { color: green; }
+}
+&lt;/style&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+function getUIScript()
+{
+    return `
+    (function() {
+        uiController.simulateAccessibilitySettingsChangeNotification(function() {
+            uiController.uiScriptComplete(&quot;Done&quot;);
+        });
+    })();`
+}
+
+function runTest()
+{
+    if (!window.internals)
+        return;
+
+    var element = document.getElementById(&quot;a&quot;);
+
+    window.internals.settings.forcedDisplayIsMonochromeAccessibilityValue = &quot;on&quot;;
+    document.getElementById(&quot;before&quot;).textContent = window.getComputedStyle(element).color;
+    if (testRunner.runUIScript) {
+        testRunner.runUIScript(getUIScript(), function(result) {
+            document.getElementById(&quot;after&quot;).textContent = window.getComputedStyle(element).color;
+            testRunner.notifyDone();
+        });
+    }
+}
+
+window.addEventListener(&quot;load&quot;, runTest, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;p id=&quot;a&quot;&gt;&lt;/p&gt;
+  &lt;p&gt;Before was: &lt;span id=&quot;before&quot;&gt;&lt;/span&gt; - should be rgb(0, 0, 0)&lt;/p&gt;
+  &lt;p&gt;After was: &lt;span id=&quot;after&quot;&gt;&lt;/span&gt; - should be rgb(0, 128, 0)&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/media/mq-monochrome-live-update.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfastmediamqprefersreducedmotionliveupdateexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/media/mq-prefers-reduced-motion-live-update-expected.html (0 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/media/mq-prefers-reduced-motion-live-update-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/media/mq-prefers-reduced-motion-live-update-expected.html        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;CSS4 media query test: prefers-reduced-motion.&lt;/title&gt;
+&lt;style type=&quot;text/css&quot;&gt;
+p { color: black; }
+#a { color: green; }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;p id=&quot;a&quot;&gt;&lt;/p&gt;
+  &lt;p&gt;Before was: rgb(0, 0, 0) - should be rgb(0, 0, 0)&lt;/p&gt;
+  &lt;p&gt;After was: rgb(0, 128, 0) - should be rgb(0, 128, 0)&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/media/mq-prefers-reduced-motion-live-update-expected.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsfastmediamqprefersreducedmotionliveupdatehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/media/mq-prefers-reduced-motion-live-update.html (0 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/media/mq-prefers-reduced-motion-live-update.html                                (rev 0)
+++ trunk/LayoutTests/fast/media/mq-prefers-reduced-motion-live-update.html        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;CSS4 media query test: prefers-reduced-motion.&lt;/title&gt;
+&lt;style type=&quot;text/css&quot;&gt;
+p { color: black; }
+
+@media (prefers-reduced-motion) {
+    #a { color: green; }
+}
+&lt;/style&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+function getUIScript()
+{
+    return `
+    (function() {
+        uiController.simulateAccessibilitySettingsChangeNotification(function() {
+            uiController.uiScriptComplete(&quot;Done&quot;);
+        });
+    })();`
+}
+
+function runTest()
+{
+    if (!window.internals)
+        return;
+
+    var element = document.getElementById(&quot;a&quot;);
+
+    window.internals.settings.forcedPrefersReducedMotionAccessibilityValue = &quot;on&quot;;
+    document.getElementById(&quot;before&quot;).textContent = window.getComputedStyle(element).color;
+    if (testRunner.runUIScript) {
+        testRunner.runUIScript(getUIScript(), function(result) {
+            document.getElementById(&quot;after&quot;).textContent = window.getComputedStyle(element).color;
+            testRunner.notifyDone();
+        });
+    }
+}
+
+window.addEventListener(&quot;load&quot;, runTest, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;p id=&quot;a&quot;&gt;&lt;/p&gt;
+  &lt;p&gt;Before was: &lt;span id=&quot;before&quot;&gt;&lt;/span&gt; - should be rgb(0, 0, 0)&lt;/p&gt;
+  &lt;p&gt;After was: &lt;span id=&quot;after&quot;&gt;&lt;/span&gt; - should be rgb(0, 128, 0)&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/media/mq-prefers-reduced-motion-live-update.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<ins>+Date Revision
</ins><span class="cx">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<ins>+text/html
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestsplatformiossimulatorwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -11,6 +11,11 @@
</span><span class="cx"> scrollingcoordinator/ios [ Pass ]
</span><span class="cx"> editing/selection/character-granularity-rect.html [ Pass ]
</span><span class="cx"> 
</span><ins>+fast/media/mq-inverted-colors-live-update.html [ Pass ]
+fast/media/mq-inverted-colors-live-update-in-subframes.html [ Pass ]
+fast/media/mq-monochrome-live-update.html [ Pass ]
+fast/media/mq-prefers-reduced-motion-live-update.html [ Pass ]
+
</ins><span class="cx"> #//////////////////////////////////////////////////////////////////////////////////////////
</span><span class="cx"> # End platform-specific directories.
</span><span class="cx"> #//////////////////////////////////////////////////////////////////////////////////////////
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/TestExpectations        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -14,6 +14,11 @@
</span><span class="cx"> fast/events/force-click-on-link-navigation.html [ Pass ]
</span><span class="cx"> fast/events/force-click-text-selection-behavior.html [ Failure ]
</span><span class="cx"> 
</span><ins>+fast/media/mq-inverted-colors-live-update.html [ Pass ]
+fast/media/mq-inverted-colors-live-update-in-subframes.html [ Pass ]
+fast/media/mq-monochrome-live-update.html [ Pass ]
+fast/media/mq-prefers-reduced-motion-live-update.html [ Pass ]
+
</ins><span class="cx"> #//////////////////////////////////////////////////////////////////////////////////////////
</span><span class="cx"> # End platform-specific directories.
</span><span class="cx"> #//////////////////////////////////////////////////////////////////////////////////////////
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebCore/ChangeLog        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2016-11-18  Dean Jackson  &lt;dino@apple.com&gt;
+
+        AX: &quot;(inverted-colors)&quot; media query only matches on page reload; should match on change
+        https://bugs.webkit.org/show_bug.cgi?id=163564
+        &lt;rdar://problem/28807350&gt;
+
+        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:
+
</ins><span class="cx"> 2016-11-18  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rename the 'other' Apple Pay Button type to 'donate'
</span></span></pre></div>
<a id="trunkSourceWebCorecssMediaQueryEvaluatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/MediaQueryEvaluator.cpp (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/MediaQueryEvaluator.cpp        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebCore/css/MediaQueryEvaluator.cpp        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -63,6 +63,15 @@
</span><span class="cx"> typedef bool (*MediaQueryFunction)(CSSValue*, const CSSToLengthConversionData&amp;, Frame&amp;, MediaFeaturePrefix);
</span><span class="cx"> typedef HashMap&lt;AtomicStringImpl*, MediaQueryFunction&gt; MediaQueryFunctionMap;
</span><span class="cx"> 
</span><ins>+static bool isAccessibilitySettingsDependent(const AtomicString&amp; mediaFeature)
+{
+    return mediaFeature == MediaFeatureNames::invertedColors
+        || mediaFeature == MediaFeatureNames::maxMonochrome
+        || mediaFeature == MediaFeatureNames::minMonochrome
+        || mediaFeature == MediaFeatureNames::monochrome
+        || mediaFeature == MediaFeatureNames::prefersReducedMotion;
+}
+
</ins><span class="cx"> static bool isViewportDependent(const AtomicString&amp; mediaFeature)
</span><span class="cx"> {
</span><span class="cx">     return mediaFeature == MediaFeatureNames::width
</span><span class="lines">@@ -120,9 +129,9 @@
</span><span class="cx"> {
</span><span class="cx">     auto&amp; queries = querySet.queryVector();
</span><span class="cx">     if (!queries.size())
</span><del>-        return true; // empty query list evaluates to true
</del><ins>+        return true; // Empty query list evaluates to true.
</ins><span class="cx"> 
</span><del>-    // iterate over queries, stop if any of them eval to true (OR semantics)
</del><ins>+    // Iterate over queries, stop if any of them eval to true (OR semantics).
</ins><span class="cx">     bool result = false;
</span><span class="cx">     for (size_t i = 0; i &lt; queries.size() &amp;&amp; !result; ++i) {
</span><span class="cx">         auto&amp; query = queries[i];
</span><span class="lines">@@ -132,18 +141,19 @@
</span><span class="cx"> 
</span><span class="cx">         if (mediaTypeMatch(query.mediaType())) {
</span><span class="cx">             auto&amp; expressions = query.expressions();
</span><del>-            // iterate through expressions, stop if any of them eval to false (AND semantics)
</del><ins>+            // Iterate through expressions, stop if any of them eval to false (AND semantics).
</ins><span class="cx">             size_t j = 0;
</span><span class="cx">             for (; j &lt; expressions.size(); ++j) {
</span><span class="cx">                 bool expressionResult = evaluate(expressions[j]);
</span><span class="cx">                 if (styleResolver &amp;&amp; isViewportDependent(expressions[j].mediaFeature()))
</span><span class="cx">                     styleResolver-&gt;addViewportDependentMediaQueryResult(expressions[j], expressionResult);
</span><ins>+                if (styleResolver &amp;&amp; isAccessibilitySettingsDependent(expressions[j].mediaFeature()))
+                    styleResolver-&gt;addAccessibilitySettingsDependentMediaQueryResult(expressions[j], expressionResult);
</ins><span class="cx">                 if (!expressionResult)
</span><span class="cx">                     break;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            // assume true if we are at the end of the list,
-            // otherwise assume false
</del><ins>+            // Assume true if we are at the end of the list, otherwise assume false.
</ins><span class="cx">             result = applyRestrictor(query.restrictor(), expressions.size() == j);
</span><span class="cx">         } else
</span><span class="cx">             result = applyRestrictor(query.restrictor(), false);
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -1850,6 +1850,20 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void StyleResolver::addAccessibilitySettingsDependentMediaQueryResult(const MediaQueryExpression&amp; expression, bool result)
+{
+    m_accessibilitySettingsDependentMediaQueryResults.append(MediaQueryResult { expression, result });
+}
+
+bool StyleResolver::hasMediaQueriesAffectedByAccessibilitySettingsChange() const
+{
+    for (auto&amp; result : m_accessibilitySettingsDependentMediaQueryResults) {
+        if (m_mediaQueryEvaluator.evaluate(result.expression) != result.result)
+            return true;
+    }
+    return false;
+}
+
</ins><span class="cx"> static FilterOperation::OperationType filterOperationForType(CSSValueID type)
</span><span class="cx"> {
</span><span class="cx">     switch (type) {
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.h (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.h        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebCore/css/StyleResolver.h        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -207,6 +207,10 @@
</span><span class="cx">     bool hasViewportDependentMediaQueries() const { return !m_viewportDependentMediaQueryResults.isEmpty(); }
</span><span class="cx">     bool hasMediaQueriesAffectedByViewportChange() const;
</span><span class="cx"> 
</span><ins>+    void addAccessibilitySettingsDependentMediaQueryResult(const MediaQueryExpression&amp;, bool result);
+    bool hasAccessibilitySettingsDependentMediaQueries() const { return !m_accessibilitySettingsDependentMediaQueryResults.isEmpty(); }
+    bool hasMediaQueriesAffectedByAccessibilitySettingsChange() const;
+
</ins><span class="cx">     void addKeyframeStyle(Ref&lt;StyleRuleKeyframes&gt;&amp;&amp;);
</span><span class="cx"> 
</span><span class="cx">     bool checkRegionStyle(const Element* regionElement);
</span><span class="lines">@@ -503,6 +507,7 @@
</span><span class="cx">     RenderStyle* m_overrideDocumentElementStyle { nullptr };
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;MediaQueryResult&gt; m_viewportDependentMediaQueryResults;
</span><ins>+    Vector&lt;MediaQueryResult&gt; m_accessibilitySettingsDependentMediaQueryResults;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(CSS_DEVICE_ADAPTATION)
</span><span class="cx">     RefPtr&lt;ViewportStyleResolver&gt; m_viewportStyleResolver;
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebCore/page/Page.cpp        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -2058,4 +2058,24 @@
</span><span class="cx">     invalidateInjectedStyleSheetCacheInAllFrames();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Page::accessibilitySettingsDidChange()
+{
+    bool neededRecalc = false;
+
+    for (Frame* frame = &amp;mainFrame(); frame; frame = frame-&gt;tree().traverseNext()) {
+        if (Document* document = frame-&gt;document()) {
+            auto* styleResolver = document-&gt;styleScope().resolverIfExists();
+            if (styleResolver &amp;&amp; styleResolver-&gt;hasMediaQueriesAffectedByAccessibilitySettingsChange()) {
+                document-&gt;styleScope().didChangeStyleSheetEnvironment();
+                neededRecalc = true;
+                // FIXME: This instrumentation event is not strictly accurate since cached media query results do not persist across StyleResolver rebuilds.
+                InspectorInstrumentation::mediaQueryResultChanged(*document);
+            }
+        }
+    }
+
+    if (neededRecalc)
+        LOG(Layout, &quot;hasMediaQueriesAffectedByAccessibilitySettingsChange, enqueueing style recalc&quot;);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.h (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.h        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebCore/page/Page.h        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -317,7 +317,9 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void setHorizontalScrollElasticity(ScrollElasticity);
</span><span class="cx">     ScrollElasticity horizontalScrollElasticity() const { return static_cast&lt;ScrollElasticity&gt;(m_horizontalScrollElasticity); }
</span><del>-    
</del><ins>+
+    WEBCORE_EXPORT void accessibilitySettingsDidChange();
+
</ins><span class="cx">     // Page and FrameView both store a Pagination value. Page::pagination() is set only by API,
</span><span class="cx">     // and FrameView::pagination() is set only by CSS. Page::pagination() will affect all
</span><span class="cx">     // FrameViews in the page cache, but FrameView::pagination() only affects the current
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebKit2/ChangeLog        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2016-11-18  Dean Jackson  &lt;dino@apple.com&gt;
+
+        AX: &quot;(inverted-colors)&quot; media query only matches on page reload; should match on change
+        https://bugs.webkit.org/show_bug.cgi?id=163564
+        &lt;rdar://problem/28807350&gt;
+
+        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:
+
</ins><span class="cx"> 2016-11-18  Jeremy Jones  &lt;jeremyj@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         USE WK_MAC_TBA for version number in _webViewRequestPointerLock:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.12))
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -540,6 +540,10 @@
</span><span class="cx">     [center addObserver:self selector:@selector(_contentSizeCategoryDidChange:) name:UIContentSizeCategoryDidChangeNotification object:nil];
</span><span class="cx">     _page-&gt;contentSizeCategoryDidChange([self _contentSizeCategory]);
</span><span class="cx"> 
</span><ins>+    [center addObserver:self selector:@selector(_accessibilitySettingsDidChange:) name:UIAccessibilityGrayscaleStatusDidChangeNotification object:nil];
+    [center addObserver:self selector:@selector(_accessibilitySettingsDidChange:) name:UIAccessibilityInvertColorsStatusDidChangeNotification object:nil];
+    [center addObserver:self selector:@selector(_accessibilitySettingsDidChange:) name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil];
+
</ins><span class="cx">     [[_configuration _contentProviderRegistry] addPage:*_page];
</span><span class="cx">     _page-&gt;setForceAlwaysUserScalable([_configuration ignoresViewportScaleLimits]);
</span><span class="cx"> #endif
</span><span class="lines">@@ -2248,6 +2252,11 @@
</span><span class="cx">     return [[UIApplication sharedApplication] preferredContentSizeCategory];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_accessibilitySettingsDidChange:(NSNotification *)notification
+{
+    _page-&gt;accessibilitySettingsDidChange();
+}
+
</ins><span class="cx"> - (void)setAllowsBackForwardNavigationGestures:(BOOL)allowsBackForwardNavigationGestures
</span><span class="cx"> {
</span><span class="cx">     if (_allowsBackForwardNavigationGestures == allowsBackForwardNavigationGestures)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> OBJC_CLASS NSImmediateActionGestureRecognizer;
</span><span class="cx"> OBJC_CLASS NSTextInputContext;
</span><span class="cx"> OBJC_CLASS NSView;
</span><ins>+OBJC_CLASS WKAccessibilitySettingsObserver;
</ins><span class="cx"> OBJC_CLASS WKBrowsingContextController;
</span><span class="cx"> OBJC_CLASS WKEditorUndoTargetObjC;
</span><span class="cx"> OBJC_CLASS WKFullScreenWindowController;
</span><span class="lines">@@ -208,6 +209,8 @@
</span><span class="cx">     bool shouldDelayWindowOrderingForEvent(NSEvent *);
</span><span class="cx">     bool windowResizeMouseLocationIsInVisibleScrollerThumb(CGPoint);
</span><span class="cx"> 
</span><ins>+    void accessibilitySettingsDidChange();
+
</ins><span class="cx">     // -[NSView mouseDownCanMoveWindow] returns YES when the NSView is transparent,
</span><span class="cx">     // but we don't want a drag in the NSView to move the window, even if it's transparent.
</span><span class="cx">     static bool mouseDownCanMoveWindow() { return false; }
</span><span class="lines">@@ -631,6 +634,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;WKWindowVisibilityObserver&gt; m_windowVisibilityObserver;
</span><ins>+    RetainPtr&lt;WKAccessibilitySettingsObserver&gt; m_accessibilitySettingsObserver;
</ins><span class="cx"> 
</span><span class="cx">     bool m_shouldDeferViewInWindowChanges { false };
</span><span class="cx">     bool m_viewInWindowChangeWasDeferred { false };
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -122,6 +122,46 @@
</span><span class="cx"> - (BOOL)handleEventByKeyboardLayout:(NSEvent *)event;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+@interface WKAccessibilitySettingsObserver : NSObject {
+    WebKit::WebViewImpl *_impl;
+}
+
+- (instancetype)initWithImpl:(WebKit::WebViewImpl&amp;)impl;
+@end
+
+@implementation WKAccessibilitySettingsObserver
+
+- (instancetype)initWithImpl:(WebKit::WebViewImpl&amp;)impl
+{
+    self = [super init];
+    if (!self)
+        return nil;
+
+    _impl = &amp;impl;
+
+    NSNotificationCenter* workspaceNotificationCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
+    [workspaceNotificationCenter addObserver:self selector:@selector(_settingsDidChange:) name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:nil];
+
+    return self;
+}
+
+- (void)dealloc
+{
+    NSNotificationCenter *workspaceNotificationCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
+    [workspaceNotificationCenter removeObserver:self name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:nil];
+
+    [super dealloc];
+}
+
+- (void)_settingsDidChange:(NSNotification *)notification
+{
+    WTFLogAlways(&quot;received notification&quot;);
+
+    _impl-&gt;accessibilitySettingsDidChange();
+}
+
+@end
+
</ins><span class="cx"> @interface WKWindowVisibilityObserver : NSObject {
</span><span class="cx">     NSView *_view;
</span><span class="cx">     WebKit::WebViewImpl *_impl;
</span><span class="lines">@@ -134,7 +174,6 @@
</span><span class="cx"> - (void)startObservingLookupDismissal;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> @implementation WKWindowVisibilityObserver
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)initWithView:(NSView *)view impl:(WebKit::WebViewImpl&amp;)impl
</span><span class="lines">@@ -1180,6 +1219,7 @@
</span><span class="cx">     , m_layoutStrategy([WKViewLayoutStrategy layoutStrategyWithPage:m_page view:m_view viewImpl:*this mode:kWKLayoutModeViewSize])
</span><span class="cx">     , m_undoTarget(adoptNS([[WKEditorUndoTargetObjC alloc] init]))
</span><span class="cx">     , m_windowVisibilityObserver(adoptNS([[WKWindowVisibilityObserver alloc] initWithView:view impl:*this]))
</span><ins>+    , m_accessibilitySettingsObserver(adoptNS([[WKAccessibilitySettingsObserver alloc] initWithImpl:*this]))
</ins><span class="cx">     , m_primaryTrackingArea(adoptNS([[NSTrackingArea alloc] initWithRect:m_view.frame options:trackingAreaOptions() owner:m_view userInfo:nil]))
</span><span class="cx"> {
</span><span class="cx">     static_cast&lt;PageClientImpl&amp;&gt;(*m_pageClient).setImpl(*this);
</span><span class="lines">@@ -1839,6 +1879,11 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebViewImpl::accessibilitySettingsDidChange()
+{
+    m_page-&gt;accessibilitySettingsDidChange();
+}
+
</ins><span class="cx"> bool WebViewImpl::acceptsFirstMouse(NSEvent *event)
</span><span class="cx"> {
</span><span class="cx">     if (!mightBeginDragWhileInactive() &amp;&amp; !mightBeginScrollWhileInactive())
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -2603,6 +2603,14 @@
</span><span class="cx">         m_drawingArea-&gt;deviceScaleFactorDidChange();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::accessibilitySettingsDidChange()
+{
+    if (!isValid())
+        return;
+
+    m_process-&gt;send(Messages::WebPage::AccessibilitySettingsDidChange(), m_pageID);
+}
+
</ins><span class="cx"> void WebPageProxy::setUseFixedLayout(bool fixed)
</span><span class="cx"> {
</span><span class="cx">     if (!isValid())
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -684,6 +684,7 @@
</span><span class="cx">     void setIntrinsicDeviceScaleFactor(float);
</span><span class="cx">     void setCustomDeviceScaleFactor(float);
</span><span class="cx">     void windowScreenDidChange(WebCore::PlatformDisplayID);
</span><ins>+    void accessibilitySettingsDidChange();
</ins><span class="cx"> 
</span><span class="cx">     void setUseFixedLayout(bool);
</span><span class="cx">     void setFixedLayoutSize(const WebCore::IntSize&amp;);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -1674,6 +1674,11 @@
</span><span class="cx">     return m_page-&gt;deviceScaleFactor();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::accessibilitySettingsDidChange()
+{
+    m_page-&gt;accessibilitySettingsDidChange();
+}
+
</ins><span class="cx"> void WebPage::setUseFixedLayout(bool fixed)
</span><span class="cx"> {
</span><span class="cx">     // Do not overwrite current settings if initially setting it to false.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -391,6 +391,8 @@
</span><span class="cx">     void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor);
</span><span class="cx">     void windowScreenDidChange(uint32_t);
</span><span class="cx"> 
</span><ins>+    void accessibilitySettingsDidChange();
+
</ins><span class="cx">     void scalePage(double scale, const WebCore::IntPoint&amp; origin);
</span><span class="cx">     void scalePageInViewCoordinates(double scale, WebCore::IntPoint centerInViewCoordinates);
</span><span class="cx">     double pageScaleFactor() const;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -201,6 +201,8 @@
</span><span class="cx">     SetTextZoomFactor(double zoomFactor)
</span><span class="cx">     WindowScreenDidChange(uint32_t displayID)
</span><span class="cx"> 
</span><ins>+    AccessibilitySettingsDidChange()
+
</ins><span class="cx">     ScalePage(double scale, WebCore::IntPoint origin)
</span><span class="cx">     ScalePageInViewCoordinates(double scale, WebCore::IntPoint centerInViewCoordinates)
</span><span class="cx">     ScaleView(double scale)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Tools/ChangeLog        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2016-11-18  Dean Jackson  &lt;dino@apple.com&gt;
+
+        AX: &quot;(inverted-colors)&quot; media query only matches on page reload; should match on change
+        https://bugs.webkit.org/show_bug.cgi?id=163564
+        &lt;rdar://problem/28807350&gt;
+
+        Reviewed by Simon Fraser.
+
+        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):
+
</ins><span class="cx"> 2016-11-18  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix API test after r208902
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreeiosUIScriptControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -63,6 +63,10 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef)
+{
+}
+
</ins><span class="cx"> double UIScriptController::zoomScale() const
</span><span class="cx"> {
</span><span class="cx">     return gWebScrollView.zoomScale;
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreemacUIScriptControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -64,6 +64,10 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef)
+{
+}
+
</ins><span class="cx"> JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const
</span><span class="cx"> {
</span><span class="cx">     return nullptr;
</span></span></pre></div>
<a id="trunkToolsTestRunnerSharedUIScriptContextBindingsUIScriptControlleridl"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -29,6 +29,8 @@
</span><span class="cx"> 
</span><span class="cx">     void zoomToScale(double scale, object callback);
</span><span class="cx"> 
</span><ins>+    void simulateAccessibilitySettingsChangeNotification(object callback);
+
</ins><span class="cx">     // Interaction.
</span><span class="cx">     // These functions post events asynchronously. The callback is fired when the events have been dispatched, but any
</span><span class="cx">     // resulting behavior may also be asynchronous.
</span></span></pre></div>
<a id="trunkToolsTestRunnerSharedUIScriptContextUIScriptControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -56,6 +56,10 @@
</span><span class="cx"> void UIScriptController::doAsyncTask(JSValueRef)
</span><span class="cx"> {
</span><span class="cx"> }
</span><ins>+
+void simulateAccessibilitySettingsChangeNotification(JSValueRef)
+{
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> void UIScriptController::setDidStartFormControlInteractionCallback(JSValueRef callback)
</span><span class="lines">@@ -162,6 +166,10 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef)
+{
+}
+
</ins><span class="cx"> JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const
</span><span class="cx"> {
</span><span class="cx">     return nullptr;
</span></span></pre></div>
<a id="trunkToolsTestRunnerSharedUIScriptContextUIScriptControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -52,6 +52,8 @@
</span><span class="cx">     void doAsyncTask(JSValueRef callback);
</span><span class="cx">     void zoomToScale(double scale, JSValueRef callback);
</span><span class="cx"> 
</span><ins>+    void simulateAccessibilitySettingsChangeNotification(JSValueRef callback);
+
</ins><span class="cx">     void touchDownAtPoint(long x, long y, long touchCount, JSValueRef callback);
</span><span class="cx">     void liftUpAtPoint(long x, long y, long touchCount, JSValueRef callback);
</span><span class="cx">     void singleTapAtPoint(long x, long y, JSValueRef callback);
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunneriosUIScriptControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -68,6 +68,21 @@
</span><span class="cx">     }];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef callback)
+{
+    unsigned callbackID = m_context-&gt;prepareForAsyncTask(callback, CallbackTypeNonPersistent);
+
+    auto* webView = TestController::singleton().mainWebView()-&gt;platformView();
+    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+    [center postNotificationName:UIAccessibilityInvertColorsStatusDidChangeNotification object:webView];
+
+    [webView _doAfterNextPresentationUpdate: ^{
+        if (!m_context)
+            return;
+        m_context-&gt;asyncTaskComplete(callbackID);
+    }];
+}
+
</ins><span class="cx"> double UIScriptController::zoomScale() const
</span><span class="cx"> {
</span><span class="cx">     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()-&gt;platformView();
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnermacUIScriptControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm (208914 => 208915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm        2016-11-19 02:45:25 UTC (rev 208914)
+++ trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm        2016-11-19 02:51:15 UTC (rev 208915)
</span><span class="lines">@@ -90,6 +90,25 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef callback)
+{
+#if WK_API_ENABLED
+    unsigned callbackID = m_context-&gt;prepareForAsyncTask(callback, CallbackTypeNonPersistent);
+
+    auto* webView = TestController::singleton().mainWebView()-&gt;platformView();
+    NSNotificationCenter *center = [[NSWorkspace sharedWorkspace] notificationCenter];
+    [center postNotificationName:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:webView];
+
+    [webView _doAfterNextPresentationUpdate: ^{
+        if (!m_context)
+            return;
+        m_context-&gt;asyncTaskComplete(callbackID);
+    }];
+#else
+    UNUSED_PARAM(callback);
+#endif
+}
+
</ins><span class="cx"> JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const
</span><span class="cx"> {
</span><span class="cx"> #if WK_API_ENABLED
</span></span></pre>
</div>
</div>

</body>
</html>