<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>160166</bug_id>
          
          <creation_ts>2016-07-25 09:37:08 -0700</creation_ts>
          <short_desc>color-gamut media query returns incorrect results</short_desc>
          <delta_ts>2016-07-29 10:41:33 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.11</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Craig Hockenberry">craig.hockenberry</reporter>
          <assigned_to name="Dean Jackson">dino</assigned_to>
          <cc>dino</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1214212</commentid>
    <comment_count>0</comment_count>
    <who name="Craig Hockenberry">craig.hockenberry</who>
    <bug_when>2016-07-25 09:37:08 -0700</bug_when>
    <thetext>On an iMac (Retina 5K, 27-inch, Late 2014) with the default profile of &quot;iMac&quot; selected in System Preferences &gt; Display &gt; Color, the following media query matches even though the color-gamut is not Display P3:

@media (-webkit-min-device-pixel-ratio: 2) and (color-gamut: p3), (min-resolution: 2dppx) and (color-gamut: p3) {
	section.background {
		background-image: url(bkgd-p3@2x.png);
	}
}

Likewise, the first &lt;source&gt; in this &lt;picture&gt; container is selected:

&lt;picture&gt;
	&lt;source media=&quot;(-webkit-min-device-pixel-ratio: 2) and (min-width: 600px), (min-resolution: 2dppx) and (min-width: 600px)&quot; srcset=&quot;photo-p3@2x.jpg&quot;&gt;
	&lt;source media=&quot;(-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx)&quot; srcset=&quot;photo@2x.jpg&quot;&gt;
	&lt;source media=&quot;(min-width: 600px)&quot; srcset=&quot;photo-p3.jpg&quot;&gt;
	&lt;img src=&quot;photo.jpg&quot; srcset=&quot;photo@2x.jpg 2x&quot; alt=&quot;A photo that uses a media query to select a wider gamut image&quot;&gt;
&lt;/picture&gt;

Finally, the following JavaScript shows the &quot;Your screen color-gamut is Display P3&quot;:

function testColorGamut(event) {
	if (window.matchMedia(&apos;(color-gamut: rec2020)&apos;).matches) {
		alert(&apos;Your screen color-gamut is Rec. 2020&apos;);
	}
	else if (window.matchMedia(&apos;(color-gamut: p3)&apos;).matches) {
		alert(&apos;Your screen color-gamut is Display P3&apos;);
	}
	else if (window.matchMedia(&apos;(color-gamut: srgb)&apos;).matches) {
		alert(&apos;Your screen color-gamut is sRGB&apos;);
	}
	else {
		alert(&apos;The color gamut could not be determined&apos;);
	}
}

The following page demonstrates this issue:

	http://furbo.org/color/ResponsiveColor/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1214217</commentid>
    <comment_count>1</comment_count>
    <who name="Craig Hockenberry">craig.hockenberry</who>
    <bug_when>2016-07-25 09:44:14 -0700</bug_when>
    <thetext>Build is Release 9 (Safari 9.1.2, WebKit 11602.1.41)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1214350</commentid>
    <comment_count>2</comment_count>
    <who name="Craig Hockenberry">craig.hockenberry</who>
    <bug_when>2016-07-25 15:16:22 -0700</bug_when>
    <thetext>The media query appears to be working correctly on iOS 10. My iPad mini matches the color-gamut: srgb, while the iPad Pro 9.7 matches p3.

I haven&apos;t done extensive testing, but perhaps this problem is limited to the desktop browser.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1214428</commentid>
    <comment_count>3</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2016-07-25 18:15:49 -0700</bug_when>
    <thetext>It should work on macOS, so this is a bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1214429</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2016-07-25 18:16:18 -0700</bug_when>
    <thetext>&lt;rdar://problem/27537577&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1215466</commentid>
    <comment_count>5</comment_count>
      <attachid>284840</attachid>
    <who name="Dean Jackson">dino</who>
    <bug_when>2016-07-28 17:01:28 -0700</bug_when>
    <thetext>Created attachment 284840
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1215485</commentid>
    <comment_count>6</comment_count>
      <attachid>284840</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2016-07-28 19:24:15 -0700</bug_when>
    <thetext>Comment on attachment 284840
Patch

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

&gt; Source/WebCore/ChangeLog:11
&gt; +        to a customized color space collaboration on an external

calibration, you mean?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1215587</commentid>
    <comment_count>7</comment_count>
      <attachid>284840</attachid>
    <who name="Dean Jackson">dino</who>
    <bug_when>2016-07-29 10:38:51 -0700</bug_when>
    <thetext>Comment on attachment 284840
Patch

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

&gt;&gt; Source/WebCore/ChangeLog:11
&gt;&gt; +        to a customized color space collaboration on an external
&gt; 
&gt; calibration, you mean?

Yes! Thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1215588</commentid>
    <comment_count>8</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2016-07-29 10:41:33 -0700</bug_when>
    <thetext>Committed r203903: &lt;http://trac.webkit.org/changeset/203903&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>284840</attachid>
            <date>2016-07-28 17:01:28 -0700</date>
            <delta_ts>2016-07-28 19:23:42 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-160166-20160728170015.patch</filename>
            <type>text/plain</type>
            <size>2211</size>
            <attacher name="Dean Jackson">dino</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjAzODI1CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggMTU1M2FhZTI4MDIyYzA1
NjIxMjUyZDA5NWJjYjA0ZmU0MjU2ZmRmZi4uZGEyNjUyNDhiMmVmZDJlZGQ3ZDFhMmI4ZTc3MjY0
YmYxODRkOGZlMyAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSw1ICsxLDI2IEBACiAyMDE2LTA3LTI4ICBEZWFu
IEphY2tzb24gIDxkaW5vQGFwcGxlLmNvbT4KIAorICAgICAgICBjb2xvci1nYW11dCBtZWRpYSBx
dWVyeSByZXR1cm5zIGluY29ycmVjdCByZXN1bHRzCisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJr
aXQub3JnL3Nob3dfYnVnLmNnaT9pZD0xNjAxNjYKKyAgICAgICAgPHJkYXI6Ly9wcm9ibGVtLzI3
NTM3NTc3PgorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAg
IFdoaWxlIEkgd2FzIHVuYWJsZSB0byByZXByb2R1Y2UgdGhlIG9yaWdpbmF0b3IncyBpc3N1ZSwK
KyAgICAgICAgd2UgY29tbXVuaWNhdGVkIHZpYSBlbWFpbCBhbmQgaXQgbWlnaHQgaGF2ZSBiZWVu
IHJlbGF0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308500"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>