Bug 42972 - screen.colorDepth and screen.pixelDepth return 32 on Windows, but should return 24 (according to CSSOM View and Firefox)
Summary: screen.colorDepth and screen.pixelDepth return 32 on Windows, but should retu...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows XP
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar, PlatformOnly
Depends on:
Blocks:
 
Reported: 2010-07-26 06:22 PDT by Adam Roben (:aroben)
Modified: 2010-09-30 11:30 PDT (History)
5 users (show)

See Also:


Attachments
Make sure screen.colorDepth/screen.pixelDepth don't include the bits used for alpha (4.50 KB, patch)
2010-09-29 14:26 PDT, Adam Roben (:aroben)
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Roben (:aroben) 2010-07-26 06:22:33 PDT
To reproduce:

1. Load this URL: javascript:alert(screen.colorDepth + "\n" + screen.pixelDepth)

Both values are 32. But according to CSSOM View [1], they should be 24. Firefox returns 24. WebKit returns 24 on Mac, too.
Comment 1 Adam Roben (:aroben) 2010-07-26 06:22:48 PDT
1. http://dev.w3.org/csswg/cssom-view/#dom-screen-colordepth
Comment 2 Adam Roben (:aroben) 2010-07-26 06:26:11 PDT
It looks like we should fix this in the screenDepth function in PlatformScreenWin.cpp.

See <https://bugzilla.mozilla.org/show_bug.cgi?id=424386> and <https://bugzilla.mozilla.org/show_bug.cgi?id=466669> for Mozilla's discussion of this issue.
Comment 3 Adam Roben (:aroben) 2010-07-26 06:33:30 PDT
(In reply to comment #2)
> It looks like we should fix this in the screenDepth function in PlatformScreenWin.cpp.

Here's the screenDepth function: <http://trac.webkit.org/browser/trunk/WebCore/platform/win/PlatformScreenWin.cpp?rev=52791#L68>.

The problem is that deviceInfo.dmBitsPerPel is 32 rather than 24 as we expect. We should notice this and return 24 instead.
Comment 4 Adam Roben (:aroben) 2010-07-26 06:35:37 PDT
See also <http://dbaron.org/log/20100725-colorDepth>
Comment 5 Adam Roben (:aroben) 2010-07-26 06:36:16 PDT
<rdar://problem/8234071>
Comment 6 Adam Roben (:aroben) 2010-09-29 14:26:10 PDT
Created attachment 69249 [details]
Make sure screen.colorDepth/screen.pixelDepth don't include the bits used for alpha
Comment 7 Adam Roben (:aroben) 2010-09-29 14:33:51 PDT
Comment on attachment 69249 [details]
Make sure screen.colorDepth/screen.pixelDepth don't include the bits used for alpha

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

> LayoutTests/fast/dom/Window/window-screen-properties.html:6
> +if (depth == 16 || depth == 24) {
> +  document.write("PASS: window.screen.pixelDepth is either 16 or 24");

Hm, is 16 really an OK value? I guess that could mean 6+5+5 or something, but that seems strange.
Comment 8 Adam Roben (:aroben) 2010-09-29 14:44:57 PDT
(In reply to comment #7)
> (From update of attachment 69249 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=69249&action=review
> 
> > LayoutTests/fast/dom/Window/window-screen-properties.html:6
> > +if (depth == 16 || depth == 24) {
> > +  document.write("PASS: window.screen.pixelDepth is either 16 or 24");
> 
> Hm, is 16 really an OK value? I guess that could mean 6+5+5 or something, but that seems strange.

http://en.wikipedia.org/wiki/Color_depth#HighColor says that is exactly what happens (6 bits for green, 5 for red, 5 for blue). That page also implies we should be allowing many more values.
Comment 9 Adam Roben (:aroben) 2010-09-30 10:10:31 PDT
Comment on attachment 69249 [details]
Make sure screen.colorDepth/screen.pixelDepth don't include the bits used for alpha

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

>>> LayoutTests/fast/dom/Window/window-screen-properties.html:6
>>> +  document.write("PASS: window.screen.pixelDepth is either 16 or 24");
>> 
>> Hm, is 16 really an OK value? I guess that could mean 6+5+5 or something, but that seems strange.
> 
> http://en.wikipedia.org/wiki/Color_depth#HighColor says that is exactly what happens (6 bits for green, 5 for red, 5 for blue). That page also implies we should be allowing many more values.

Hyatt and I decided to change the test only to allow 24, since bug 42973 imposes that requirement, too.
Comment 10 Adam Roben (:aroben) 2010-09-30 11:30:56 PDT
Committed r68808: <http://trac.webkit.org/changeset/68808>