W3C home > Mailing lists > Public > www-style@w3.org > July 2010

[cssom-view] comments on StyleMedia interface

From: L. David Baron <dbaron@dbaron.org>
Date: Sat, 17 Jul 2010 16:18:55 -0700
To: www-style@w3.org
Cc: Anne van Kesteren <annevk@opera.com>
Message-ID: <20100717231855.GA5294@pickering.dbaron.org>
http://dev.w3.org/csswg/cssom-view/#extensions-to-the-window-interface
says:
  # The styleMedia attribute must return the StyleMedia object
  # associated with the Window object. It always returns the same
  # object. 

Given the mess around what exactly is a window object, this should
probably be extra-precise, and say it returns the same object for
each Window object, but accessing it through a WindowProxy object
http://www.w3.org/TR/2010/WD-html5-20100624/browsers.html#the-windowproxy-object
will yield different results when the document is navigated.
Returning the same result for each WindowProxy would lead to
confusion of listeners between different documents in the same
browsing context, which would be bad (and might even have security
implications).


http://dev.w3.org/csswg/cssom-view/#the-stylemedia-interface says:
  # 2.  If parsed_mq_list is null terminate these steps. 
It's not clear to me what this means.  [CSSOM]'s description of
"parse a list of media queries" does not return null.  But if it
did, this item would need to say whether the method returns true or
false or throws an exception.

  # 3.  If parsed_mq_list matches the state of the rendered Document
  # return true and terminate this algorithm.
  # 
  # 4.  Otherwise, return false. 
"matches the state of the rendered Document" doesn't seem to be a
term defined anywhere, though it sort of looks like it ought to be.
I'm not sure if it's worth trying to fix, though.  But perhaps these
two steps could be combined in the form "return whether ...".


I'd also note that I find the observer mechanism somewhat awkward,
for two reasons:  first, the limited amount of information provided
by the callback, and second, the need to have a query comparison
mechanism in order to add/remove listeners.

I can think of an alternative that would fix both of these problems,
although I'm not sure if I like it any better than what's now in the
spec.  But, in case anyone else likes it, the idea is to, in place
of addMediaListener, removeMediaListener, and BooleanCallback, add a
method to StyleMedia that takes a string and returns a new
MediaQuery object, implementing:
  interface MediaQuery {
    // The serialized form of the query list used to create this object.
    readonly attribute DOMString query;
    // The current result of the query.
    readonly attribute boolean result;
    // add and remove listeners (should it ensure uniqueness or not?)
    void addListener(MediaQueryChangeListener listener);
    void removeListener(MediaQueryChangeListener listener);
  };
  [Callback=FunctionOnly, NoInterfaceObject]
  interface MediaQueryChangeListener {
    void queryChanged(MediaQuery query);
  };

-David

-- 
L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/
Received on Saturday, 17 July 2010 23:19:38 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:29 GMT