Bug 137535 - [Mac] Support "inverted-colors" and "monochrome" media feature.
Summary: [Mac] Support "inverted-colors" and "monochrome" media feature.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dean Jackson
URL:
Keywords: InRadar
Depends on:
Blocks: 137868
  Show dependency treegraph
 
Reported: 2014-10-08 13:08 PDT by James Craig
Modified: 2014-10-20 12:38 PDT (History)
5 users (show)

See Also:


Attachments
Patch (8.62 KB, patch)
2014-10-19 08:19 PDT, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (16.07 KB, patch)
2014-10-20 12:18 PDT, Dean Jackson
bfulgham: 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 2014-10-08 13:08:36 PDT
CSS4: Support "inverted" media feature.
http://dev.w3.org/csswg/mediaqueries-4/#inverted

Based on IndieUI, which uses old name "colors-inverted":
http://www.w3.org/TR/indie-ui-context/#media-feature-colors-inverted
Comment 1 Radar WebKit Bug Importer 2014-10-08 13:08:46 PDT
<rdar://problem/18586398>
Comment 2 James Craig 2014-10-08 13:09:53 PDT
Apple UIKit API for detecting color inversion on iOS
// From <UIKit/UIAccessibility.h>
// Returns whether the system preference for invert colors is enabled.
UIKIT_EXTERN BOOL UIAccessibilityIsInvertColorsEnabled() NS_AVAILABLE_IOS(6_0);
UIKIT_EXTERN NSString *const UIAccessibilityInvertColorsStatusDidChangeNotification NS_AVAILABLE_IOS(6_0);
Comment 3 Dean Jackson 2014-10-19 08:19:30 PDT
Created attachment 240086 [details]
Patch
Comment 4 Dean Jackson 2014-10-19 08:22:43 PDT
Not for review yet, but it works fine. I need to write the ChangeLog and make sure it compiles on other platforms.

Oh, I did the monochrome media query as well, although I need to read the spec to make sure we do the right thing if the rule asks for particular bit depths.

I'm not sure we can test this. We'd have to expose an internals API to invert the screen. Is this a completely safe thing to do?

Also, the media query does not re-evaluate as the screen swaps. The page needs to be reloaded. We can detect the change on iOS, but I have not found any notification for OS X.
Comment 5 WebKit Commit Bot 2014-10-19 08:24:45 PDT
Attachment 240086 [details] did not pass style-queue:


ERROR: Source/WebCore/css/MediaQueryEvaluator.cpp:240:  inverted_colorsMediaFeatureEval is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/WebCore/ChangeLog:8:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 2 in 11 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Dean Jackson 2014-10-20 12:18:49 PDT
Created attachment 240137 [details]
Patch
Comment 7 WebKit Commit Bot 2014-10-20 12:21:38 PDT
Attachment 240137 [details] did not pass style-queue:


ERROR: Source/WebCore/css/MediaQueryEvaluator.cpp:240:  inverted_colorsMediaFeatureEval is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
Total errors found: 1 in 16 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Brent Fulgham 2014-10-20 12:28:34 PDT
Comment on attachment 240137 [details]
Patch

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

r=me. I think you could support Windows here with the change I suggested below.

> Source/WebCore/platform/win/PlatformScreenWin.cpp:89
> +    return false;

I think this could be

#if USE(CG)
return CGDisplayUsesInvertedPolarity();
#else
return false;
#endif
Comment 9 Dean Jackson 2014-10-20 12:38:39 PDT
Committed r174901: <http://trac.webkit.org/changeset/174901>