Extending CSSOM Views matchMedium with callback

The consensus on the W3C Extending CSSOM Views matchMedium with
callbacks [1] mailing list was that instead of adding individual DOM
events for changes to media features, we should instead make it
possible to get notified when a user defined media query has changed.

The idea was making it possible to supply a JavaScript function to the
styleMedia.matchMedium(...) function.

As no exact IDL was proposed, I came up with one myself which I think fits the
use-case, and implemented the feature for WebKit.

The result of my work became the following IDL, for which I would like
comments/feedback:

    interface MediaChangeListener {
        void mediaChanged(in boolean queryResult);
    };

    interface StyleMedia {
        readonly attribute DOMString type;
        boolean matchMedium(in DOMString mediaquery, in MediaChangeListener
listener);
    };

If listener is supplied to the  matchMedium call then its mediaChanged method
will be called every time when then result of the expression given in
'mediaquery' changes. mediaChanged parameter queryResult receives the
current value (true/false) of the corresponding mediaquery.

The idea and actual implementation has already gone through some initial
feedback rounds in WebKit Bugzilla
(https://bugs.webkit.org/show_bug.cgi?id=37205)

Luiz

[1] http://lists.w3.org/Archives/Public/public-webapps/2010AprJun/0071.html

Received on Monday, 10 May 2010 13:48:13 UTC