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

Re: [mediaqueries] User-defined Media Queries?

From: Kenneth Rohde Christiansen <kenneth.christiansen@gmail.com>
Date: Sun, 2 Jun 2013 13:16:56 +0200
Message-ID: <CAEC208u+BavU4kCY58aHdpb_FBF1hxc0pTpZz90TN4KJZGmaBg@mail.gmail.com>
To: Simon Sapin <simon.sapin@exyr.org>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, www-style list <www-style@w3.org>
Hi,

Can you explain to me what you mean with "parse-time declarative macros"?
like for instance give an example. 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.

Kenneth


On Sun, Jun 2, 2013 at 7:24 AM, Simon Sapin <simon.sapin@exyr.org> wrote:

> Le 01/06/2013 03:07, Tab Atkins Jr. a écrit :
>
>  Recently there was a thread about reducing the duplication in Media
>> Queries, which wanted to use Variables.  I pointed out that we
>> couldn't use CSS Variables as written, but I'd like to pursue lexical
>> variables at some point in the future for this kind of thing.
>>
>> Alex Russell just suggested another approach to me in a private email
>> - crack open MQs themselves and let authors plug into that
>> infrastructure.  Example syntax:
>>
>>  <html>
>>>    <script>
>>>      if (window.outerWidth >= 600)
>>>        document.css.properties["**inventedConditional"] = true;
>>>      }
>>>    </script>
>>>    <style>
>>>      @media (property("**inventedConditional")) {
>>>        .facet_sidebar {
>>>          display: none;
>>>        }
>>>      }
>>>    </style>
>>> </html>
>>>
>>
> Hi,
>
> I like the idea of custom MQs, but the downside of this approach is that
> it is not declarative. The example above is very misleading: unlike
> existing MQs, this one is not updated when the size of the viewport
> changes. The JS code would need to be inside some event handler.
>
> So this approach has the same kind of performance issues than JS
> animations vs. CSS Animations. When this is just a shorter and DRY way to
> write a condition that can be expressed with existing MQs, the perf cost
> could be greater than the maintenance cost of repetition.
>
> I think it is worthwhile to have both custom MQs like this (that probably
> can’t be made declarative without loosing expressive power) and parse-time
> declarative "macros" for MQs to avoid repeating complex expressions.
>
> --
> Simon Sapin
>
>


-- 
Kenneth Rohde Christiansen
Senior Engineer, WebKit, Qt, EFL
Phone  +45 4294 9458 / E-mail kenneth at webkit.org

﹆﹆﹆
Received on Sunday, 2 June 2013 11:17:23 UTC

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