W3C home > Mailing lists > Public > www-style@w3.org > June 2013

Re: [mediaqueries] User-defined Media Queries?

From: Simon Sapin <simon.sapin@exyr.org>
Date: Sun, 02 Jun 2013 21:41:41 +0900
Message-ID: <51AB3D85.7020701@exyr.org>
To: Kenneth Rohde Christiansen <kenneth.christiansen@gmail.com>
CC: "Tab Atkins Jr." <jackalmage@gmail.com>, www-style list <www-style@w3.org>
Le 02/06/2013 20:16, Kenneth Rohde Christiansen a écrit :
> Hi,
>
> Can you explain to me what you mean with "parse-time declarative
> macros"? like for instance give an example.

Declarative: when you state what happens but not how it happens, as 
opposed to imperative. In Selectors, :hover is declarative while 
adding/removing a class with mouse events is imperative.

Macro: a kind of variables, but I wanted another term because this is 
not CSS Variables a.k.a. Custom Properties. This is two parts: one that 
associates a name with a value, and one that uses the name, which is 
replaced by the value.

Parse-time: the replacement is done when the stylesheet is parsed, as 
opposed to eg. every time the result of the MQ needs to change.


Here is an example with made-up syntax:

     @macros { wide: (min-width: 700px) }
     @import "foo.css" $wide
     @media $wide { /* ... */ }


This kind of macro could potentially be used anywhere (MQs, Selectors, 
property names …) unlike var() that can only be used in property values.


> In WebKit/Blink the engine
> knows which media features change as a result of viewport changes and it
> only reevaluates those when the viewport changes (size, scale/zoom,
> etc). If the engine knows then invented conditionals change, we could do
> similar.

Yes, MQs being declarative allows the engine to do that and apply the 
change without going through JavaScript code.

-- 
Simon Sapin
Received on Sunday, 2 June 2013 12:42:09 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:12 UTC