Re: [cssom-view] addMediumListener / removeMediumListener

Hi there,


> 2010/5/31 Anne van Kesteren <annevk@opera.com>
>>
>> On Thu, 27 May 2010 17:59:32 +0200, Simon Fraser <smfr@me.com> wrote:
>>> It would be better to change it to matchMedia() now, rather than later,
>>> since not many people are using this yet. I hope we can avoid more renames,
>>> though. Or, if we accept media query lists, maybe it should just be be
>>> matchQueryList(), which I think is easier to read than the awkward
>>> "matchMedium". matchQuery() would also work OK.
>>
>> Given those I guess we should go with matchMedia / addMediaListener /
>> removeMediaListener to match @media and media="" which both also accept
>> media query lists.
>
> I prefer Media instead of Medium as well.

Could we agree on this then? Anne?


>> Does that give a convenient API though? You would need to keep some table
>> around with the mapping from token to media query list.
>
> To be able to use the context information in the callbacks it is needed to
> store it somehow anyway. The query may be stored in its canonical form or it
> may be stored in its original form and converted every time a callback is
> received. As the query serialization may be quite expensive that later
> option may be not that good.
> I think that to return a token to be used later to identify the callback is
> ok.

Sounds sensible to me.

> We could make addMediaListener return the serialized media query. It could
> then be used in the callbacks as a token, without considering its contents,
> or as the media query if wanted. The parameters of removeMediaListener would
> then be the pair (addMediaListener result, callback handler function) and
> the parameters of the callback handlers would be the pair (addMediaListener
> result, query result).

What do you think about that Simon? How would that fit with your bindings?

Kenneth

Received on Sunday, 4 July 2010 16:30:39 UTC