Bug 163564

Summary: AX: "(inverted-colors)" media query only matches on page reload; should match on change
Product: WebKit Reporter: James Craig <jcraig>
Component: AccessibilityAssignee: Dean Jackson <dino>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, jcraig, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 168491    
Attachments:
Description Flags
test case
none
Patch
none
Patch simon.fraser: review+

Description James Craig 2016-10-17 13:56:17 PDT
Given the following CSS, the media query only matches on page reload if colors are inverted. It does not match when the setting changes.

```
html, body {
  color: #000;
  background-color: #fff;
}
@media (inverted-colors) {
  html, body {
    color: #006;
    background-color: #ffa;
  }
  img, video {
    filter: invert(100%);
  }
}
```
Comment 1 Radar WebKit Bug Importer 2016-10-17 13:56:52 PDT
<rdar://problem/28807350>
Comment 2 James Craig 2016-10-17 14:02:49 PDT
Created attachment 291870 [details]
test case
Comment 3 Dean Jackson 2016-10-17 18:41:12 PDT
I commented in radar, but I'll get to this in a couple of weeks. I'll fix this, monochrome, and prefers-reduced-motion at the same time.
Comment 4 Dean Jackson 2016-11-18 15:47:41 PST
Created attachment 295203 [details]
Patch
Comment 5 Dean Jackson 2016-11-18 16:31:01 PST
Created attachment 295215 [details]
Patch
Comment 6 Simon Fraser (smfr) 2016-11-18 17:26:07 PST
Comment on attachment 295215 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=295215&action=review

> Source/WebCore/page/Page.cpp:2072
> +    auto* styleResolver = document->styleScope().resolverIfExists();
> +    if (styleResolver && styleResolver->hasMediaQueriesAffectedByAccessibilitySettingsChange()) {
> +        LOG(Layout, "hasMediaQueriesAffectedByAccessibilitySettingsChange, enqueueing style recalc");
> +        document->styleScope().didChangeStyleSheetEnvironment();
> +        // FIXME: This instrumentation event is not strictly accurate since cached media query results do not persist across StyleResolver rebuilds.
> +        InspectorInstrumentation::mediaQueryResultChanged(*document);

Don't you need to do this for all subframes?

> Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:55
> +    void simulateAccessibilitySettingsChangeNotification(JSValueRef callback);

Do you want to make it possible to test individual settings?

> Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:78
> +    [webView _doAfterNextPresentationUpdate: ^ {

Ignore the style checker.  ^{

> Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm:101
> +    [webView _doAfterNextPresentationUpdate: ^ {

Ignore the style checker.  ^{
Comment 7 Dean Jackson 2016-11-18 17:47:10 PST
Comment on attachment 295215 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=295215&action=review

>> Source/WebCore/page/Page.cpp:2072
>> +        InspectorInstrumentation::mediaQueryResultChanged(*document);
> 
> Don't you need to do this for all subframes?

Fixed.

>> Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:55
>> +    void simulateAccessibilitySettingsChangeNotification(JSValueRef callback);
> 
> Do you want to make it possible to test individual settings?

I can do that on iOS, but macOS has a single notification for all Accessibility changes.
Comment 8 Dean Jackson 2016-11-18 18:52:36 PST
Committed r208915: <http://trac.webkit.org/changeset/208915>