Skip to content

Commit f165859

Browse files
authored
Merge pull request w3c#994 from mounirlamouri/colorpixeldepth
[cssom-view] Return real values for colorDepth and pixelDepth (closes w3c#993)
2 parents 0047ee3 + e026386 commit f165859

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

cssom-view/Overview.bs

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ urlPrefix: http://heycam.github.io/webidl/
8181
text: long
8282
type: dfn; text: converted to an IDL value; url: dfn-convert-ecmascript-to-idl-value
8383
url: https://www.w3.org/TR/DOM-Level-3-Events/#interface-MouseEvent; type: interface; text: MouseEvent
84+
url: https://drafts.csswg.org/mediaqueries-4/#mf-colors; type: dfn; text: color media query
8485
</pre>
8586

8687
<pre class='link-defaults'>
@@ -896,13 +897,38 @@ screen area</a>. <!--fingerprint-->
896897
The <dfn attribute for=Screen>height</dfn> attribute must return the height of the <a>Web-exposed
897898
screen area</a>. <!--fingerprint-->
898899

899-
The <dfn attribute for=Screen>colorDepth</dfn> attribute must return 24.
900-
901-
The <dfn attribute for=Screen>pixelDepth</dfn> attribute must return 24.
902-
903-
Note: The {{colorDepth}} and {{pixelDepth}} attributes are useless but are
904-
included for compatibility.
900+
The <dfn attribute for=Screen>colorDepth</dfn> and <dfn attribute
901+
for=Screen>pixelDepth</dfn> attributes should return the number of bits
902+
allocated to colors for a pixel in the output device, excluding the alpha
903+
channel. If the user agent is not able to return the number of bits used by the
904+
output device, it should return the closest estimation such as, for example, the
905+
number of bits used by the frame buffer sent to the display or any internal
906+
representation that would be the closest to the value the output device would
907+
use. The user agent must return a value for these attributes at least equal to
908+
the value of <a>color media query</a> multiplied by three. If the different
909+
color components are not represented with the same number of bits, the returned
910+
value may be greater than three times <a>color media query</a>. If the user
911+
agent does not know the color depth or does not want to return it for privacy
912+
considerations, it should return 24.
913+
914+
Note: The {{colorDepth}} and {{pixelDepth}} attributes return the same value for
915+
compatibility reasons.
916+
917+
Note: Some non-conforming implementations are known to return 32 instead of 24.
905918

919+
<div class='example'>
920+
<code>colorDepth</code> can be used in the context of selecting SDR/HDR in
921+
addition with other information. For example, combined with color gamut.
922+
923+
<pre class='lang-javascript'>
924+
if (screen.colorDepth >= 48 && window.matchMedia('(color-gamut: p3)').matches &&
925+
/* other checks */) {
926+
// Use HDR content.
927+
} else {
928+
// Use SDR content.
929+
}
930+
</pre>
931+
</div>
906932

907933
Extensions to the {{Document}} Interface {#extensions-to-the-document-interface}
908934
================================================================================

0 commit comments

Comments
 (0)