Bug 163564 - AX: "(inverted-colors)" media query only matches on page reload; should match on change
Summary: AX: "(inverted-colors)" media query only matches on page reload; should match...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Dean Jackson
URL:
Keywords: InRadar
Depends on:
Blocks: 168491
  Show dependency treegraph
 
Reported: 2016-10-17 13:56 PDT by James Craig
Modified: 2017-09-15 12:37 PDT (History)
3 users (show)

See Also:


Attachments
test case (475 bytes, text/html)
2016-10-17 14:02 PDT, James Craig
no flags Details
Patch (39.02 KB, patch)
2016-11-18 15:47 PST, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (39.31 KB, patch)
2016-11-18 16:31 PST, Dean Jackson
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>