<?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>167031</bug_id>
          
          <creation_ts>2017-01-13 16:11:32 -0800</creation_ts>
          <short_desc>Media Query should allow negation for media feature when media type is not specified</short_desc>
          <delta_ts>2023-02-21 07:20:56 -0800</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 10</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>180234</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Aaron Chu">aaron_chu</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>dino</cc>
    
    <cc>florian</cc>
    
    <cc>karlcow</cc>
    
    <cc>koivisto</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1266646</commentid>
    <comment_count>0</comment_count>
      <attachid>298806</attachid>
    <who name="Aaron Chu">aaron_chu</who>
    <bug_when>2017-01-13 16:11:32 -0800</bug_when>
    <thetext>Created attachment 298806
reduced test case

Currently, media query can be negated only when the the &quot;not&quot; token precedes the &lt;media-type&gt;. In cases where &lt;media-type&gt; is not specified, &lt;media-feature&gt; is not negated. According to &quot;2.5 Combining Media Features&quot;, a &lt;media-feature&gt; should be negated when it is preceded by the &quot;not&quot; token.

specs:
Syntax, BNF
https://www.w3.org/TR/mediaqueries-4/#mq-syntax

Combining Media Features
https://www.w3.org/TR/mediaqueries-4/#media-conditions</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1266647</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-01-13 16:14:34 -0800</bug_when>
    <thetext>&lt;rdar://problem/30022550&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267546</commentid>
    <comment_count>2</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2017-01-17 16:20:37 -0800</bug_when>
    <thetext>Here&apos;s how I&apos;m reading the spec....

Suppose we have:

div {
  width: 100px;
  height: 100px;
  background-color: red;
}

@media not (min-width: 600px) {
  div {
    background-color: blue;
  }
}

Then the @media rule follows

[[[
2.2.1. Negating a Media Query: the not keyword

An individual media query can have its result negated by prefixing it with the keyword not. If the media query would normally evaluate to true, prefixing it with not makes it evaluate to false, and vice versa.
]]]

And it gives an example.

However, I don&apos;t this this rule applies in this case. Check out Section 3. Syntax.

&lt;media-query&gt; = &lt;media-condition&gt;
             | [ not | only ]? &lt;media-type&gt; [ and &lt;media-condition-without-or&gt; ]?

In our example, it matches &lt;media-condition&gt;, rather than &quot;not &lt;media-type&gt;&quot;.

&lt;media-condition&gt; = &lt;media-not&gt; | &lt;media-and&gt; | &lt;media-or&gt; | &lt;media-in-parens&gt;

Cool. It looks like we are a &lt;media-not&gt;.

&lt;media-not&gt; = not &lt;media-in-parens&gt;
&lt;media-in-parens&gt; = ( &lt;media-condition&gt; ) | &lt;media-feature&gt; | &lt;general-enclosed&gt;

So this is a media-not, that has a media-in-parens that is a media-feature.

None of the browsers follow this behaviour though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267547</commentid>
    <comment_count>3</comment_count>
      <attachid>299080</attachid>
    <who name="Dean Jackson">dino</who>
    <bug_when>2017-01-17 16:21:15 -0800</bug_when>
    <thetext>Created attachment 299080
Simple test</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267559</commentid>
    <comment_count>4</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2017-01-17 16:36:05 -0800</bug_when>
    <thetext>https://github.com/w3c/csswg-drafts/issues/952</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267724</commentid>
    <comment_count>5</comment_count>
    <who name="Florian Rivoal">florian</who>
    <bug_when>2017-01-18 05:55:25 -0800</bug_when>
    <thetext>(spec co-editor here). This boils down to the fact that you only have support for the Media queries level 3 syntax, which unlike the level 4 syntax does not allow for arbitrary not/and/or nesting.

I agree the level 4 syntax is much better (that&apos;s why we specified it), and hope you&apos;ll implement it.

Also, note that there&apos;s a mistake in https://bugs.webkit.org/attachment.cgi?id=298806 :

@media not(max-width: 700px)

You need a space between not and the opening parenthesis, otherwise it gets parsed as a function token instead of the not keyword.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1935307</commentid>
    <comment_count>6</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-02-20 15:44:51 -0800</bug_when>
    <thetext>If I am not wrong, this is fixed by MQ4 landing and I can see &quot;Simple Test&quot; works fine in STP163 as well &quot;Red and Blue&quot; depending on window size.

Can we close this now? Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1935498</commentid>
    <comment_count>7</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2023-02-21 07:20:56 -0800</bug_when>
    <thetext>Ok, thanks!

*** This bug has been marked as a duplicate of bug 180234 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>298806</attachid>
            <date>2017-01-13 16:11:32 -0800</date>
            <delta_ts>2017-01-13 16:11:32 -0800</delta_ts>
            <desc>reduced test case</desc>
            <filename>negate-mq.html</filename>
            <type>text/html</type>
            <size>407</size>
            <attacher name="Aaron Chu">aaron_chu</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KCTx0aXRsZT48L3RpdGxlPgoJPHN0eWxlPgoJ
CWRpdiB7ZGlzcGxheTogbm9uZTt9CgkJQG1lZGlhIChtYXgtd2lkdGg6IDcwMHB4KSB7Lmx0e2Rp
c3BsYXk6IGJsb2NrO319CgkJIEBtZWRpYSBub3QgYWxsIGFuZCAobWF4LXdpZHRoOiA3MDBweCkg
ey5ndHtkaXNwbGF5OiBibG9jazt9fQoJCSAvKmRvZXMgbm90LCBidXQgc2hvdWxkLCB3b3JrKi8K
CQkgLypAbWVkaWEgbm90KG1heC13aWR0aDogNzAwcHgpIHsuZ3R7ZGlzcGxheTogYmxvY2s7fX0q
LwoJPC9zdHlsZT4KPC9oZWFkPgo8Ym9keT4KCjxkaXYgY2xhc3M9Imx0Ij5MZXNzIHRoYW4gNzAw
cHg7PC9kaXY+CjxkaXYgY2xhc3M9Imd0Ij5Nb3JlIHRoYW4gNzAwcHg7PC9kaXY+Cgo8L2JvZHk+
CjwvaHRtbD4=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>299080</attachid>
            <date>2017-01-17 16:21:15 -0800</date>
            <delta_ts>2017-01-17 16:21:15 -0800</delta_ts>
            <desc>Simple test</desc>
            <filename>mq.html</filename>
            <type>text/html</type>
            <size>275</size>
            <attacher name="Dean Jackson">dino</attacher>
            
              <data encoding="base64">PHN0eWxlPgpkaXYgewogIHdpZHRoOiAxMDBweDsKICBoZWlnaHQ6IDEwMHB4OwogIGJhY2tncm91
bmQtY29sb3I6IHJlZDsKfQoKQG1lZGlhIG5vdCAobWluLXdpZHRoOiA2MDBweCkgewogIGRpdiB7
CiAgICBiYWNrZ3JvdW5kLWNvbG9yOiBibHVlOwogIH0KfQo8L3N0eWxlPgoKPHA+Qm94IHNob3Vs
ZCBiZSByZWQgd2hlbiB0aGUgd2luZG93IGlzIG1vcmUgdGhhbiA2MDBweCB3aWRlLiBCbHVlIHdo
ZW4gaXQgaXMgbGVzcyB0aGFuIDYwMHB4IHdpZGUuPC9wPgo8ZGl2PjwvZGl2Pgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>