@@ -170,11 +170,9 @@ Media Queries</h2>
170170 matches the media type of the device where the user agent is running, and
171171 * the <a>media condition</a> is true.
172172
173- Statements regarding media queries in this section assume the
174- <a href="#mq-syntax">syntax section</a> is followed. Media queries that do not
175- conform to the syntax are discussed in the
176- <a href="#error-handling">error handling section</a> . I.e. the syntax takes
177- precedence over requirements in this section.
173+ Statements regarding media queries in this section assume the <a href="#mq-syntax">syntax section</a> is followed.
174+ Media queries that do not conform to the syntax are discussed in [[#error-handling]] .
175+ I.e. the syntax takes precedence over requirements in this section.
178176
179177 <div class="example">
180178 Here is a simple example written in HTML:
@@ -714,7 +712,7 @@ Syntax</h2>
714712 <dfn><mf-name></dfn> = <<ident>>
715713 <dfn><mf-value></dfn> = <<number>> | <<dimension>> | <<ident>> | <<ratio>>
716714
717- <dfn><general-enclosed></dfn> = [ <<function-token>> | ( ] <<any-value>> * )
715+ <dfn><general-enclosed></dfn> = [ <<function-token>> <<any-value>> ) ] | ( <<ident>> <<any-value>> )
718716 </pre>
719717
720718 The <<media-type>> production does not include the keywords ''only'' , ''not'' , ''and'' , and ''or'' .
@@ -749,29 +747,30 @@ Syntax</h2>
749747 <dl>
750748 <dt> <<media-condition>>
751749 <dt> <<media-condition-without-or>>
750+ <dt> <<media-in-parens>>
752751 <dd>
753752 The result is the result of the child term.
754753
755754 <dt> <<media-not>>
756755 <dd>
757756 The result is the negation of the <<media-in-parens>> term.
757+ The negation of unknown is unknown.
758758
759759 <dt> <<media-and>>
760760 <dd>
761761 The result is true if all of the <<media-in-parens>> child terms are true,
762- and false otherwise.
762+ false if at least one of the <<media-in-parens>> child terms are false,
763+ and unknown otherwise.
763764
764765 <dt> <<media-or>>
765766 <dd>
766- The result is true if any of the <<media-in-parens>> child terms are true,
767- and false otherwise.
767+ The result is false if all of the <<media-in-parens>> child terms are false,
768+ true if at least one of the <<media-in-parens>> child terms are true,
769+ and unknown otherwise.
768770
769- <dt> <<media-in-parens >>
771+ <dt> <<general-enclosed >>
770772 <dd>
771- If it contains a <<media-in-parens>> or <<media-feature>> child term,
772- the result is the result of that child term.
773- If it contains a <<general-enclosed>> child term,
774- the result is false.
773+ The result is unknown.
775774
776775 Authors must not use <<general-enclosed>> in their stylesheets.
777776 <span class='note'> It exists only for future-compatibility,
@@ -782,6 +781,30 @@ Syntax</h2>
782781 The result is the result of evaluating the specified media feature.
783782 </dl>
784783
784+ If the result of a <a>media query</a> is unknown,
785+ it must be treated as false for the purpose of matching.
786+
787+ <div class="note">
788+ Media Queries use a three-value logic where terms can be "true", "false", or "unknown".
789+ Specifically, it uses the <a href="http://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics">Kleene 3-valued logic</a> .
790+ In this logic, "unknown" means "either true or false, but we're not sure which yet".
791+
792+ In general, an unknown value showing up in a formula will cause the formula to be unknown as well,
793+ as substituting "true" for the unknown will give the formula a different result than substituting "false".
794+ The only way to eliminate an unknown value is to use it in a formula that will give the same result
795+ whether the unknown is replaced with a true or false value.
796+ This occurs when you have "false AND unknown" (evaluates to false regardless)
797+ and "true OR unknown" (evaluates to true regardless).
798+
799+ This logic was adopted because <<general-enclosed>> needs to be assigned a truth value.
800+ In standard boolean logic, the only reasonable value is "false",
801+ but this means that ''not unknown(function)'' is true,
802+ which can be confusing an unwanted.
803+ Kleen's 3-valued logic ensures that unknown things will prevent a <a>media query</a> from matching,
804+ unless their value is irrelevant to the final result.
805+ </div>
806+
807+
785808<h3 id="error-handling">
786809Error Handling</h3>
787810
0 commit comments