Re: [cssom-view] addMediumListener / removeMediumListener

Hi Anne,

Could we use the names addMediaListener, removeMediaListener and matchMedia
and accept media query lists?

If we do that we will need to specify how to compare media query lists. A
preliminary suggestion is:

Media query list serialization:

1 - if the media query list is empty return "all".

2 - fill a list with all distinct serializations[1] of the media queries in
the media query list that would not be ignored[2] in an evaluation. let that
list be called serialization list.

3 - if the serialization list is empty return "not all"

4 - sort the serialization list in lexicographical order

5 - return the serialization list serialized as a comma-separated list[3]

Comparing media query lists:

To compare two media query lists means to serialize both of them and return
true if they are a case sensitive match or false if they are not.

[1] - http://dev.w3.org/csswg/cssom/#serialize-a-media-query
[2] - http://www.w3.org/TR/css3-mediaqueries/#error-handling
[3] - http://dev.w3.org/csswg/cssom/#serialize-a-comma-separated-list

br,
Luiz

2010/5/26 Anne van Kesteren <annevk@opera.com>

> On Wed, 26 May 2010 16:07:06 +0200, Luiz Agostini <
> luiz.agostini@openbossa.org> wrote:
>
>> Is there any compelling reasons to not accept media query lists?
>>
>
> I mainly did it for consistency with matchMedium() which in turn was based
> on appendMedium() and all.
>
>
>
>  A useful notification may be related to a list and not to a specific
>> query.
>> For example I could have
>>
>> @media (min-width: 300px), (orientation:landscape) {
>>    body {background-color: red}
>> }
>>
>> and be interested on receiving a callback when the background color of the
>> body changes. It is of course possible to make it just having callbacks to
>> each query but having a callback to the list would make it somewhat easier.
>>
>> On a side note, the matchMedium implementation in WebKit accepts media
>> query lists, is that to be considered a bug?
>>
>
> I guess it makes sense if they both accept lists of media queries, but then
> the name is somewhat wrong and out of line with appendMedium(). (Though we
> could change that one too.)
>
>
>
> --
> Anne van Kesteren
> http://annevankesteren.nl/
>

Received on Wednesday, 26 May 2010 15:10:42 UTC