2010-10-21 Luiz Agostini <luiz.agostini@openbossa.org>
authorluiz@webkit.org <luiz@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Nov 2010 21:02:27 +0000 (21:02 +0000)
committerluiz@webkit.org <luiz@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Nov 2010 21:02:27 +0000 (21:02 +0000)
        Reviewed by Darin Adler.

        Implement CSSOM View matchMedia interface
        https://bugs.webkit.org/show_bug.cgi?id=37205

        New property matchMedia was added to window.

        * fast/dom/Window/window-properties-expected.txt:
        * fast/dom/Window/window-property-descriptors-expected.txt:

        window.matchMedia and MediaQueryList tests.

        * fast/media/media-query-list-01-expected.txt: Added.
        * fast/media/media-query-list-01.html: Added.

        The following tests depend on LayoutTestController::setViewModeMediaFeature() to work.
        As it is only implemented by Qt and Gtk the tests needed to be skipped in all other platforms.

        * fast/media/media-query-list-02-expected.txt: Added.
        * fast/media/media-query-list-02.html: Added.
        * fast/media/media-query-list-03-expected.txt: Added.
        * fast/media/media-query-list-03.html: Added.
        * fast/media/media-query-list-04-expected.txt: Added.
        * fast/media/media-query-list-04.html: Added.
        * fast/media/media-query-list-05-expected.txt: Added.
        * fast/media/media-query-list-05.html: Added.
        * fast/media/media-query-list-06-expected.txt: Added.
        * fast/media/media-query-list-06.html: Added.
        * fast/media/media-query-list-07-expected.txt: Added.
        * fast/media/media-query-list-07.html: Added.
        * platform/chromium/test_expectations.txt:
        * platform/mac/Skipped:
        * platform/win/Skipped:
2010-10-21  Luiz Agostini  <luiz.agostini@openbossa.org>

        Reviewed by Darin Adler.

        Implement CSSOM View matchMedia interface
        https://bugs.webkit.org/show_bug.cgi?id=37205

        New interfaces may be used to evaluate media queries and to associate listeners
        to media queries. Those listeners are called whenever the associated query changes.
        Specification may be found at http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface

        operator== added to JS version of ScriptValue.
        Method isFunction added to JS and V8 versions of ScriptValue.

        * bindings/js/ScriptValue.cpp:
        (WebCore::ScriptValue::isFunction):
        * bindings/js/ScriptValue.h:
        (WebCore::ScriptValue::operator==):
        * bindings/v8/ScriptValue.h:
        (WebCore::ScriptValue::isFunction):

        Some changes were needed to the code generators to handle type MediaQueryListListener.

        * bindings/scripts/CodeGeneratorGObject.pm:
        * bindings/scripts/CodeGeneratorJS.pm:
        * bindings/scripts/CodeGeneratorV8.pm:

        Some changes to the bindings test results that were previously added.

        * bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp:
        * bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h:
        * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
        (WebCore::jsTestMediaQueryListListenerPrototypeFunctionMethod):
        * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
        (WebCore::TestMediaQueryListListenerInternal::methodCallback):
        (WebCore::ConfigureV8TestMediaQueryListListenerTemplate):

        New interfaces:

        * css/MediaQueryList.cpp: Added.
        * css/MediaQueryList.h: Added.
        * css/MediaQueryList.idl: Added.

        * css/MediaQueryListListener.cpp: Added.
        * css/MediaQueryListListener.h: Added.
        * css/MediaQueryListListener.idl: Added.

        To avoid adding code to classes DOMWindow and Document a new class MediaQueryMatcher was created.

        * css/MediaQueryMatcher.cpp: Added.
        * css/MediaQueryMatcher.h: Added.

        Document and DOMWindow have changed to support new features. DOMWindow is the class that
        publishes methods matchMedia but for page cache to work properly the reference to the
        MediaQueryMatcher must be in Document.

        * dom/Document.cpp:
        (WebCore::Document::~Document):
        (WebCore::Document::mediaQueryMatcher):
        (WebCore::Document::styleSelectorChanged):
        * dom/Document.h:
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::matchMedia):
        * page/DOMWindow.h:
        * page/DOMWindow.idl:

        Build systems

        * CMakeLists.txt:
        * DerivedSources.make:
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pri:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/gobject/GNUmakefile.am:

        Tests: fast/media/media-query-list-01.html
               fast/media/media-query-list-02.html
               fast/media/media-query-list-03.html
               fast/media/media-query-list-04.html
               fast/media/media-query-list-05.html
               fast/media/media-query-list-06.html
               fast/media/media-query-list-07.html

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@72552 268f45cc-cd09-0410-ab3c-d52691b4dbfc

53 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Window/window-properties-expected.txt
LayoutTests/fast/dom/Window/window-property-descriptors-expected.txt
LayoutTests/fast/media/media-query-list-01-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-01.html [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-02-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-02.html [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-03-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-03.html [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-04-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-04.html [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-05-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-05.html [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-06-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-06.html [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-07-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/media-query-list-07.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/Skipped
LayoutTests/platform/win/Skipped
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/DerivedSources.make
WebCore/GNUmakefile.am
WebCore/WebCore.gypi
WebCore/WebCore.pri
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj [changed mode: 0644->0755]
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/gobject/GNUmakefile.am
WebCore/bindings/js/ScriptValue.cpp
WebCore/bindings/js/ScriptValue.h
WebCore/bindings/scripts/CodeGeneratorGObject.pm
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/bindings/scripts/CodeGeneratorV8.pm
WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp
WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h
WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp
WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp
WebCore/bindings/v8/ScriptValue.h
WebCore/css/MediaQueryList.cpp [new file with mode: 0644]
WebCore/css/MediaQueryList.h [new file with mode: 0644]
WebCore/css/MediaQueryList.idl [new file with mode: 0644]
WebCore/css/MediaQueryListListener.cpp [new file with mode: 0644]
WebCore/css/MediaQueryListListener.h [new file with mode: 0644]
WebCore/css/MediaQueryListListener.idl [new file with mode: 0644]
WebCore/css/MediaQueryMatcher.cpp [new file with mode: 0644]
WebCore/css/MediaQueryMatcher.h [new file with mode: 0644]
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/page/DOMWindow.cpp
WebCore/page/DOMWindow.h
WebCore/page/DOMWindow.idl

index 6197949..2d122fe 100644 (file)
@@ -1,3 +1,39 @@
+2010-10-21  Luiz Agostini  <luiz.agostini@openbossa.org>
+
+        Reviewed by Darin Adler.
+
+        Implement CSSOM View matchMedia interface
+        https://bugs.webkit.org/show_bug.cgi?id=37205
+
+        New property matchMedia was added to window.
+
+        * fast/dom/Window/window-properties-expected.txt:
+        * fast/dom/Window/window-property-descriptors-expected.txt:
+
+        window.matchMedia and MediaQueryList tests.
+
+        * fast/media/media-query-list-01-expected.txt: Added.
+        * fast/media/media-query-list-01.html: Added.
+
+        The following tests depend on LayoutTestController::setViewModeMediaFeature() to work.
+        As it is only implemented by Qt and Gtk the tests needed to be skipped in all other platforms.
+
+        * fast/media/media-query-list-02-expected.txt: Added.
+        * fast/media/media-query-list-02.html: Added.
+        * fast/media/media-query-list-03-expected.txt: Added.
+        * fast/media/media-query-list-03.html: Added.
+        * fast/media/media-query-list-04-expected.txt: Added.
+        * fast/media/media-query-list-04.html: Added.
+        * fast/media/media-query-list-05-expected.txt: Added.
+        * fast/media/media-query-list-05.html: Added.
+        * fast/media/media-query-list-06-expected.txt: Added.
+        * fast/media/media-query-list-06.html: Added.
+        * fast/media/media-query-list-07-expected.txt: Added.
+        * fast/media/media-query-list-07.html: Added.
+        * platform/chromium/test_expectations.txt:
+        * platform/mac/Skipped:
+        * platform/win/Skipped:
+
 2010-11-22  Ryosuke Niwa  <rniwa@webkit.org>
 
         Unreviewed update of Windows Skipped list.
index 5cab84b..c7b099a 100644 (file)
@@ -2281,6 +2281,7 @@ window.locationbar.visible [boolean]
 window.log [function]
 window.logProperties [function]
 window.logValue [function]
+window.matchMedia [function]
 window.menubar [object BarInfo]
 window.menubar.visible [boolean]
 window.moveBy [function]
index 1d9c4df..68315ad 100644 (file)
@@ -507,6 +507,7 @@ PASS Object.getOwnPropertyDescriptor(window, 'getMatchedCSSRules') is undefined.
 PASS Object.getOwnPropertyDescriptor(window, 'getSelection') is undefined.
 PASS Object.getOwnPropertyDescriptor(window, 'hasOwnProperty') is undefined.
 PASS Object.getOwnPropertyDescriptor(window, 'isPrototypeOf') is undefined.
+PASS Object.getOwnPropertyDescriptor(window, 'matchMedia') is undefined.
 PASS Object.getOwnPropertyDescriptor(window, 'moveBy') is undefined.
 PASS Object.getOwnPropertyDescriptor(window, 'moveTo') is undefined.
 PASS Object.getOwnPropertyDescriptor(window, 'open') is undefined.
diff --git a/LayoutTests/fast/media/media-query-list-01-expected.txt b/LayoutTests/fast/media/media-query-list-01-expected.txt
new file mode 100644 (file)
index 0000000..4eba3f5
--- /dev/null
@@ -0,0 +1,15 @@
+Test the MediaQueryList interface: http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface.
+
+"screen" evaluates to true: PASS
+"projection" evaluates to false: PASS
+"all and (color)" evaluates to true: PASS
+"not projection and (color)" evaluates to true: PASS
+"(color)" evaluates to true: PASS
+"(color" evaluates to false: PASS
+"color" evaluates to false: PASS
+"garbage" evaluates to false: PASS
+"(min-device-width: 100px)" evaluates to true: PASS
+"(min-device-width: 50000px)" evaluates to false: PASS
+"(-webkit-animation: 1)" evaluates to true: PASS
+"(-webkit-transform-2d)" evaluates to true: PASS
+
diff --git a/LayoutTests/fast/media/media-query-list-01.html b/LayoutTests/fast/media/media-query-list-01.html
new file mode 100644 (file)
index 0000000..33dcc67
--- /dev/null
@@ -0,0 +1,52 @@
+<html>
+<head>
+<title>Test CSSOM View module: MediaQueryList interface</title>
+<style type="text/css">
+
+</style>
+<script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    function log(m)
+    {
+        var results = document.getElementById('results');
+        results.innerHTML += m + '<br>';
+    }
+
+    function testQuery(query, expected)
+    {
+        var isTrue = window.matchMedia(query).matches;
+        var message = '\"' + query + '\" evaluates to ' + (isTrue ? 'true' : 'false');
+        message += (isTrue == expected) ? ': PASS' : ': FAIL';
+        log(message);
+    }
+
+    function runTests()
+    {
+        testQuery('screen', true);
+        testQuery('projection', false);
+
+        testQuery('all and (color)', true);
+        testQuery('not projection and (color)', true);
+        testQuery('(color)', true);
+        testQuery('(color', false);
+        testQuery('color', false);
+
+        testQuery('garbage', false);
+
+        testQuery('(min-device-width: 100px)', true);
+        testQuery('(min-device-width: 50000px)', false);
+
+        testQuery('(-webkit-animation: 1)', true);
+        testQuery('(-webkit-transform-2d)', true);
+    }
+
+</script>
+</head>
+<body onload="runTests()">
+    <p>Test the MediaQueryList interface: <a href="http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface" title="CSSOM View Module">http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface</a>.</p>
+    <div id="results">
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/media-query-list-02-expected.txt b/LayoutTests/fast/media/media-query-list-02-expected.txt
new file mode 100644 (file)
index 0000000..63643d8
--- /dev/null
@@ -0,0 +1,25 @@
+Test the MediaQueryList interface: http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface.
+
+Testing addListener in different MediaQueryList objects and the callback call sequence
+
+------------- minimized -------------
+[1] - query (-webkit-view-mode: windowed) changed to false
+[1] - query (-webkit-view-mode: minimized) changed to true
+[2] - query (-webkit-view-mode: windowed) changed to false
+[2] - query (-webkit-view-mode: minimized) changed to true
+------------- maximized -------------
+[1] - query (-webkit-view-mode: minimized) changed to false
+[1] - query (-webkit-view-mode: maximized) changed to true
+[2] - query (-webkit-view-mode: minimized) changed to false
+[2] - query (-webkit-view-mode: maximized) changed to true
+------------- windowed -------------
+[1] - query (-webkit-view-mode: windowed) changed to true
+[1] - query (-webkit-view-mode: maximized) changed to false
+[2] - query (-webkit-view-mode: windowed) changed to true
+[2] - query (-webkit-view-mode: maximized) changed to false
+------------- floating -------------
+[1] - query (-webkit-view-mode: windowed) changed to false
+[1] - query (-webkit-view-mode: floating) changed to true
+[2] - query (-webkit-view-mode: windowed) changed to false
+[2] - query (-webkit-view-mode: floating) changed to true
+
diff --git a/LayoutTests/fast/media/media-query-list-02.html b/LayoutTests/fast/media/media-query-list-02.html
new file mode 100644 (file)
index 0000000..7093ca1
--- /dev/null
@@ -0,0 +1,63 @@
+<html>
+<head>
+<title>Test CSSOM View module: MediaQueryList interface</title>
+<style type="text/css">
+
+</style>
+<script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    function log(m) {
+        document.getElementById('results').innerHTML += m + '<br>';
+    }
+
+    function callback1(query) {
+        log("[1] - query " + query.media + " changed to " + (query.matches ? "true" : "false"));
+    }
+
+    function callback2(query) {
+        log("[2] - query " + query.media + " changed to " + (query.matches ? "true" : "false"));
+    }
+
+    function runTests()
+    {
+        if (!window.layoutTestController)
+            return;
+
+        layoutTestController.setViewModeMediaFeature("windowed");
+
+        windowedQuery = window.matchMedia("(-webkit-view-mode: windowed)");
+        floatingQuery = window.matchMedia("(-webkit-view-mode: floating)");
+        minimizedQuery = window.matchMedia("(-webkit-view-mode: minimized)");
+        maximizedQuery = window.matchMedia("(-webkit-view-mode: maximized)");
+
+        windowedQuery.addListener(callback1);
+        floatingQuery.addListener(callback1);
+        minimizedQuery.addListener(callback1);
+        maximizedQuery.addListener(callback1);
+
+        windowedQuery.addListener(callback2);
+        floatingQuery.addListener(callback2);
+        minimizedQuery.addListener(callback2);
+        maximizedQuery.addListener(callback2);
+
+        log("------------- minimized -------------");
+        layoutTestController.setViewModeMediaFeature("minimized");
+        log("------------- maximized -------------");
+        layoutTestController.setViewModeMediaFeature("maximized");
+        log("------------- windowed -------------");
+        layoutTestController.setViewModeMediaFeature("windowed");
+        log("------------- floating -------------");
+        layoutTestController.setViewModeMediaFeature("floating");
+    }
+
+</script>
+</head>
+<body onload="runTests()">
+    <p>Test the MediaQueryList interface: <a href="http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface" title="CSSOM View Module">http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface</a>.</p>
+    <p>Testing addListener in different MediaQueryList objects and the callback call sequence</p>
+    <div id="results">
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/media-query-list-03-expected.txt b/LayoutTests/fast/media/media-query-list-03-expected.txt
new file mode 100644 (file)
index 0000000..f24e206
--- /dev/null
@@ -0,0 +1,41 @@
+Test the MediaQueryList interface: http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface.
+
+Testing removeListener in different MediaQueryList objects and the callback call sequence
+
+adding windowed[1], minimized[1], windowed[2] and minimized[2]
+
+------------- minimized -------------
+[1] - query (-webkit-view-mode: windowed) changed to false
+[1] - query (-webkit-view-mode: minimized) changed to true
+[2] - query (-webkit-view-mode: windowed) changed to false
+[2] - query (-webkit-view-mode: minimized) changed to true
+------------- windowed -------------
+[1] - query (-webkit-view-mode: windowed) changed to true
+[1] - query (-webkit-view-mode: minimized) changed to false
+[2] - query (-webkit-view-mode: windowed) changed to true
+[2] - query (-webkit-view-mode: minimized) changed to false
+
+
+removing windowed[1] and minimized[2]
+
+------------- minimized -------------
+[1] - query (-webkit-view-mode: minimized) changed to true
+[2] - query (-webkit-view-mode: windowed) changed to false
+------------- windowed -------------
+[1] - query (-webkit-view-mode: minimized) changed to false
+[2] - query (-webkit-view-mode: windowed) changed to true
+
+
+adding windowed[1] and minimized[2]
+
+------------- minimized -------------
+[1] - query (-webkit-view-mode: minimized) changed to true
+[2] - query (-webkit-view-mode: windowed) changed to false
+[1] - query (-webkit-view-mode: windowed) changed to false
+[2] - query (-webkit-view-mode: minimized) changed to true
+------------- windowed -------------
+[1] - query (-webkit-view-mode: minimized) changed to false
+[2] - query (-webkit-view-mode: windowed) changed to true
+[1] - query (-webkit-view-mode: windowed) changed to true
+[2] - query (-webkit-view-mode: minimized) changed to false
+
diff --git a/LayoutTests/fast/media/media-query-list-03.html b/LayoutTests/fast/media/media-query-list-03.html
new file mode 100644 (file)
index 0000000..833bdde
--- /dev/null
@@ -0,0 +1,72 @@
+<html>
+<head>
+<title>Test CSSOM View module: MediaQueryList interface</title>
+<style type="text/css">
+
+</style>
+<script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    function log(m) {
+        document.getElementById('results').innerHTML += m + '<br>';
+    }
+
+    function callback1(query) {
+        log("[1] - query " + query.media + " changed to " + (query.matches ? "true" : "false"));
+    }
+
+    function callback2(query) {
+        log("[2] - query " + query.media + " changed to " + (query.matches ? "true" : "false"));
+    }
+
+    function runTests()
+    {
+        if (!window.layoutTestController)
+            return;
+
+        layoutTestController.setViewModeMediaFeature("windowed");
+
+        windowedQuery = window.matchMedia("(-webkit-view-mode: windowed)");
+        minimizedQuery = window.matchMedia("(-webkit-view-mode: minimized)");
+
+        log("adding windowed[1], minimized[1], windowed[2] and minimized[2]<br>");
+        windowedQuery.addListener(callback1);
+        minimizedQuery.addListener(callback1);
+        windowedQuery.addListener(callback2);
+        minimizedQuery.addListener(callback2);
+
+        log("------------- minimized -------------");
+        layoutTestController.setViewModeMediaFeature("minimized");
+        log("------------- windowed -------------");
+        layoutTestController.setViewModeMediaFeature("windowed");
+
+        log("<br><br>removing windowed[1] and minimized[2]<br>");
+        windowedQuery.removeListener(callback1);
+        minimizedQuery.removeListener(callback2);
+
+        log("------------- minimized -------------");
+        layoutTestController.setViewModeMediaFeature("minimized");
+        log("------------- windowed -------------");
+        layoutTestController.setViewModeMediaFeature("windowed");
+
+        log("<br><br>adding windowed[1] and minimized[2]<br>");
+        windowedQuery.addListener(callback1);
+        minimizedQuery.addListener(callback2);
+
+        log("------------- minimized -------------");
+        layoutTestController.setViewModeMediaFeature("minimized");
+        log("------------- windowed -------------");
+        layoutTestController.setViewModeMediaFeature("windowed");
+
+    }
+
+</script>
+</head>
+<body onload="runTests()">
+    <p>Test the MediaQueryList interface: <a href="http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface" title="CSSOM View Module">http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface</a>.</p>
+    <p>Testing removeListener in different MediaQueryList objects and the callback call sequence</p>
+    <div id="results">
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/media-query-list-04-expected.txt b/LayoutTests/fast/media/media-query-list-04-expected.txt
new file mode 100644 (file)
index 0000000..3a6d0db
--- /dev/null
@@ -0,0 +1,25 @@
+Test the MediaQueryList interface: http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface.
+
+Testing page cache
+
+------------- minimized -------------
+[1] - query (-webkit-view-mode: windowed) changed to false
+[1] - query (-webkit-view-mode: minimized) changed to true
+[2] - query (-webkit-view-mode: windowed) changed to false
+[2] - query (-webkit-view-mode: minimized) changed to true
+------------- maximized -------------
+[1] - query (-webkit-view-mode: minimized) changed to false
+[1] - query (-webkit-view-mode: maximized) changed to true
+[2] - query (-webkit-view-mode: minimized) changed to false
+[2] - query (-webkit-view-mode: maximized) changed to true
+------------- windowed -------------
+[1] - query (-webkit-view-mode: windowed) changed to true
+[1] - query (-webkit-view-mode: maximized) changed to false
+[2] - query (-webkit-view-mode: windowed) changed to true
+[2] - query (-webkit-view-mode: maximized) changed to false
+------------- floating -------------
+[1] - query (-webkit-view-mode: windowed) changed to false
+[1] - query (-webkit-view-mode: floating) changed to true
+[2] - query (-webkit-view-mode: windowed) changed to false
+[2] - query (-webkit-view-mode: floating) changed to true
+
diff --git a/LayoutTests/fast/media/media-query-list-04.html b/LayoutTests/fast/media/media-query-list-04.html
new file mode 100644 (file)
index 0000000..a877a5a
--- /dev/null
@@ -0,0 +1,75 @@
+<html>
+<head>
+<title>Test CSSOM View module: MediaQueryList interface</title>
+<script type="text/javascript" charset="utf-8">
+
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+        layoutTestController.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+    }
+
+    function log(m) {
+        document.getElementById('results').innerHTML += m + '<br>';
+    }
+
+    function callback1(query) {
+        log("[1] - query " + query.media + " changed to " + (query.matches ? "true" : "false"));
+    }
+
+    function callback2(query) {
+        log("[2] - query " + query.media + " changed to " + (query.matches ? "true" : "false"));
+    }
+
+    function pageshow(evt)
+    {
+        if (!evt.persisted) {
+            // this will run only when the page is loaded for the first time.
+
+            windowedQuery = window.matchMedia("(-webkit-view-mode: windowed)");
+            floatingQuery = window.matchMedia("(-webkit-view-mode: floating)");
+            minimizedQuery = window.matchMedia("(-webkit-view-mode: minimized)");
+            maximizedQuery = window.matchMedia("(-webkit-view-mode: maximized)");
+
+            windowedQuery.addListener(callback1);
+            floatingQuery.addListener(callback1);
+            minimizedQuery.addListener(callback1);
+            maximizedQuery.addListener(callback1);
+
+            windowedQuery.addListener(callback2);
+            floatingQuery.addListener(callback2);
+            minimizedQuery.addListener(callback2);
+            maximizedQuery.addListener(callback2);
+
+            setTimeout('window.location = "data:text/html,<script>history.back()<" + "/script>"', 0);
+
+        } else {
+            // if this point is reached the page is comming from the page cache.
+
+            log("------------- minimized -------------");
+            layoutTestController.setViewModeMediaFeature("minimized");
+            log("------------- maximized -------------");
+            layoutTestController.setViewModeMediaFeature("maximized");
+            log("------------- windowed -------------");
+            layoutTestController.setViewModeMediaFeature("windowed");
+            log("------------- floating -------------");
+            layoutTestController.setViewModeMediaFeature("floating");
+
+            setTimeout(function() { if (window.layoutTestController) layoutTestController.notifyDone(); }, 0);
+
+        }
+    }
+
+    if (window.layoutTestController) {
+        layoutTestController.setViewModeMediaFeature("windowed");
+        window.onpageshow = pageshow;
+    }
+
+</script>
+</head>
+<body>
+    <p>Test the MediaQueryList interface: <a href="http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface" title="CSSOM View Module">http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface</a>.</p>
+    <p>Testing page cache</p>
+    <div id="results"></div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/media-query-list-05-expected.txt b/LayoutTests/fast/media/media-query-list-05-expected.txt
new file mode 100644 (file)
index 0000000..047e106
--- /dev/null
@@ -0,0 +1,7 @@
+Test the MediaQueryList interface: http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface.
+
+Testing listener comparison. Two callbacks are expected.
+
+[1] - query (-webkit-view-mode: windowed) changed to false
+[2] - query (-webkit-view-mode: windowed) changed to false
+
diff --git a/LayoutTests/fast/media/media-query-list-05.html b/LayoutTests/fast/media/media-query-list-05.html
new file mode 100644 (file)
index 0000000..6b66b0a
--- /dev/null
@@ -0,0 +1,47 @@
+<html>
+<head>
+<title>Test CSSOM View module: MediaQueryList interface</title>
+<style type="text/css">
+
+</style>
+<script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    function log(m) {
+        document.getElementById('results').innerHTML += m + '<br>';
+    }
+
+    function callback1(query) {
+        log("[1] - query " + query.media + " changed to " + (query.matches ? "true" : "false"));
+    }
+
+    function callback2(query) {
+        log("[2] - query " + query.media + " changed to " + (query.matches ? "true" : "false"));
+    }
+
+    function runTests()
+    {
+        if (!window.layoutTestController)
+            return;
+
+        layoutTestController.setViewModeMediaFeature("windowed");
+
+        var query = window.matchMedia("(-webkit-view-mode: windowed)");
+
+        query.addListener(callback1);
+        query.addListener(callback1);
+        query.addListener(callback2);
+
+        layoutTestController.setViewModeMediaFeature("minimized");
+    }
+
+</script>
+</head>
+<body onload="runTests()">
+    <p>Test the MediaQueryList interface: <a href="http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface" title="CSSOM View Module">http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface</a>.</p>
+    <p>Testing listener comparison. Two callbacks are expected.</p>
+    <div id="results">
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/media-query-list-06-expected.txt b/LayoutTests/fast/media/media-query-list-06-expected.txt
new file mode 100644 (file)
index 0000000..1c65465
--- /dev/null
@@ -0,0 +1,7 @@
+Test the MediaQueryList interface: http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface.
+
+Testing queries that have no registered listener.
+
+Query result before changing view-mode: true
+Query result after changing view-mode: false
+
diff --git a/LayoutTests/fast/media/media-query-list-06.html b/LayoutTests/fast/media/media-query-list-06.html
new file mode 100644 (file)
index 0000000..5913e56
--- /dev/null
@@ -0,0 +1,36 @@
+<html>
+<head>
+<title>Test CSSOM View module: MediaQueryList interface</title>
+<style type="text/css">
+
+</style>
+<script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    function log(m) {
+        document.getElementById('results').innerHTML += m + '<br>';
+    }
+
+    function runTests()
+    {
+        if (!window.layoutTestController)
+            return;
+
+        layoutTestController.setViewModeMediaFeature("windowed");
+
+        var query = window.matchMedia("(-webkit-view-mode: windowed)");
+        log('Query result before changing view-mode: ' + query.matches);
+        layoutTestController.setViewModeMediaFeature("minimized");
+        log('Query result after changing view-mode: ' + query.matches);
+    }
+
+</script>
+</head>
+<body onload="runTests()">
+    <p>Test the MediaQueryList interface: <a href="http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface" title="CSSOM View Module">http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface</a>.</p>
+    <p>Testing queries that have no registered listener.</p>
+    <div id="results">
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/media-query-list-07-expected.txt b/LayoutTests/fast/media/media-query-list-07-expected.txt
new file mode 100644 (file)
index 0000000..8b0e7f9
--- /dev/null
@@ -0,0 +1,7 @@
+Test the MediaQueryList interface: http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface.
+
+Invalid listeners. Two callbacks are expected.
+
+[1] - query (-webkit-view-mode: windowed) changed to false
+[2] - query (-webkit-view-mode: windowed) changed to false
+
diff --git a/LayoutTests/fast/media/media-query-list-07.html b/LayoutTests/fast/media/media-query-list-07.html
new file mode 100644 (file)
index 0000000..0344263
--- /dev/null
@@ -0,0 +1,49 @@
+<html>
+<head>
+<title>Test CSSOM View module: MediaQueryList interface</title>
+<style type="text/css">
+
+</style>
+<script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    function log(m) {
+        document.getElementById('results').innerHTML += m + '<br>';
+    }
+
+    function callback1(query) {
+        log("[1] - query " + query.media + " changed to " + (query.matches ? "true" : "false"));
+    }
+
+    function callback2(query) {
+        log("[2] - query " + query.media + " changed to " + (query.matches ? "true" : "false"));
+    }
+
+    function runTests()
+    {
+        if (!window.layoutTestController)
+            return;
+
+        layoutTestController.setViewModeMediaFeature("windowed");
+
+        var query = window.matchMedia("(-webkit-view-mode: windowed)");
+
+        query.addListener(callback1);
+        query.addListener(5);
+        query.addListener('cinco');
+        query.addListener([1,2]);
+        query.addListener(callback2);
+
+        layoutTestController.setViewModeMediaFeature("minimized");
+    }
+
+</script>
+</head>
+<body onload="runTests()">
+    <p>Test the MediaQueryList interface: <a href="http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface" title="CSSOM View Module">http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface</a>.</p>
+    <p>Invalid listeners. Two callbacks are expected.</p>
+    <div id="results">
+    </div>
+</body>
+</html>
index 218ed1c..cab652a 100644 (file)
@@ -2252,8 +2252,14 @@ BUG38578 : plugins/override-node-method.html = TEXT
 // Needs layoutTestController.setMediaType() (implemented on Qt only)
 BUG38656 : fast/media/print-restores-previous-mediatype.html = TEXT
 
-// Needs layoutTestController.setViewModeMediaFeature() (implemented on Qt only)
+// Needs layoutTestController.setViewModeMediaFeature()
 BUG40680 SKIP : fast/media/view-mode-media-feature.html = FAIL
+BUG40680 SKIP : fast/media/media-query-list-02.html = FAIL
+BUG40680 SKIP : fast/media/media-query-list-03.html = FAIL
+BUG40680 SKIP : fast/media/media-query-list-04.html = FAIL
+BUG40680 SKIP : fast/media/media-query-list-05.html = FAIL
+BUG40680 SKIP : fast/media/media-query-list-06.html = FAIL
+BUG40680 SKIP : fast/media/media-query-list-07.html = FAIL
 
 // Unknown flakiness.
 BUG38706 : svg/custom/deep-dynamic-updates.svg = IMAGE+TEXT IMAGE PASS
index 5a72d3b..fe9d7ee 100644 (file)
@@ -124,8 +124,14 @@ http/tests/plugins/plugin-document-has-focus.html
 # Misses setMediaType() and implementation
 fast/media/print-restores-previous-mediatype.html
 
-# view mode media feature
+# Needs layoutTestController.setViewModeMediaFeature()
 fast/media/view-mode-media-feature.html
+fast/media/media-query-list-02.html
+fast/media/media-query-list-03.html
+fast/media/media-query-list-04.html
+fast/media/media-query-list-05.html
+fast/media/media-query-list-06.html
+fast/media/media-query-list-07.html
 
 # Test is flaky and thus not useful until fixed.
 # https://bugs.webkit.org/show_bug.cgi?id=36642
index 25cce52..a341908 100644 (file)
@@ -892,6 +892,12 @@ fast/forms/form-attribute.html
 
 # view mode media feature
 fast/media/view-mode-media-feature.html
+fast/media/media-query-list-02.html
+fast/media/media-query-list-03.html
+fast/media/media-query-list-04.html
+fast/media/media-query-list-05.html
+fast/media/media-query-list-06.html
+fast/media/media-query-list-07.html
 
 # Need expectations. See https://bugs.webkit.org/show_bug.cgi?id=36461
 fast/repaint/overflow-scroll-body-appear.html
index 3fbc7b5..f39556d 100644 (file)
@@ -128,6 +128,7 @@ SET(WebCore_IDL_FILES
     css/CSSValue.idl
     css/CSSValueList.idl
     css/MediaList.idl
+    css/MediaQueryList.idl
     css/Rect.idl
     css/RGBColor.idl
     css/StyleMedia.idl
@@ -765,6 +766,9 @@ SET(WebCore_SOURCES
     css/MediaQuery.cpp
     css/MediaQueryEvaluator.cpp
     css/MediaQueryExp.cpp
+    css/MediaQueryList.cpp
+    css/MediaQueryListListener.cpp
+    css/MediaQueryMatcher.cpp
     css/RGBColor.cpp
     css/ShadowValue.cpp
     css/StyleBase.cpp
index dbdb1b7..f107d92 100644 (file)
@@ -1,3 +1,89 @@
+2010-10-21  Luiz Agostini  <luiz.agostini@openbossa.org>
+
+        Reviewed by Darin Adler.
+
+        Implement CSSOM View matchMedia interface
+        https://bugs.webkit.org/show_bug.cgi?id=37205
+
+        New interfaces may be used to evaluate media queries and to associate listeners
+        to media queries. Those listeners are called whenever the associated query changes.
+        Specification may be found at http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface
+
+        operator== added to JS version of ScriptValue.
+        Method isFunction added to JS and V8 versions of ScriptValue.
+
+        * bindings/js/ScriptValue.cpp:
+        (WebCore::ScriptValue::isFunction):
+        * bindings/js/ScriptValue.h:
+        (WebCore::ScriptValue::operator==):
+        * bindings/v8/ScriptValue.h:
+        (WebCore::ScriptValue::isFunction):
+
+        Some changes were needed to the code generators to handle type MediaQueryListListener.
+
+        * bindings/scripts/CodeGeneratorGObject.pm:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * bindings/scripts/CodeGeneratorV8.pm:
+
+        Some changes to the bindings test results that were previously added.
+
+        * bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp:
+        * bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h:
+        * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
+        (WebCore::jsTestMediaQueryListListenerPrototypeFunctionMethod):
+        * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
+        (WebCore::TestMediaQueryListListenerInternal::methodCallback):
+        (WebCore::ConfigureV8TestMediaQueryListListenerTemplate):
+
+        New interfaces:
+
+        * css/MediaQueryList.cpp: Added.
+        * css/MediaQueryList.h: Added.
+        * css/MediaQueryList.idl: Added.
+
+        * css/MediaQueryListListener.cpp: Added.
+        * css/MediaQueryListListener.h: Added.
+        * css/MediaQueryListListener.idl: Added.
+
+        To avoid adding code to classes DOMWindow and Document a new class MediaQueryMatcher was created.
+
+        * css/MediaQueryMatcher.cpp: Added.
+        * css/MediaQueryMatcher.h: Added.
+
+        Document and DOMWindow have changed to support new features. DOMWindow is the class that
+        publishes methods matchMedia but for page cache to work properly the reference to the
+        MediaQueryMatcher must be in Document.
+
+        * dom/Document.cpp:
+        (WebCore::Document::~Document):
+        (WebCore::Document::mediaQueryMatcher):
+        (WebCore::Document::styleSelectorChanged):
+        * dom/Document.h:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::matchMedia):
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+
+        Build systems
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pri:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/gobject/GNUmakefile.am:
+
+        Tests: fast/media/media-query-list-01.html
+               fast/media/media-query-list-02.html
+               fast/media/media-query-list-03.html
+               fast/media/media-query-list-04.html
+               fast/media/media-query-list-05.html
+               fast/media/media-query-list-06.html
+               fast/media/media-query-list-07.html
+
 2010-11-22  Alexander Pavlov  <apavlov@chromium.org>
 
         Reviewed by Pavel Feldman.
index 793e155..5b0fb09 100644 (file)
@@ -268,6 +268,8 @@ DOM_CLASSES = \
     Location \
     MediaError \
     MediaList \
+    MediaQueryList \
+    MediaQueryListListener \
     MemoryInfo \
     MessageChannel \
     MessageEvent \
@@ -502,7 +504,7 @@ DOM_CLASSES = \
 
 .PHONY : all
 
-JS_DOM_HEADERS=$(filter-out JSEventListener.h JSEventTarget.h,$(DOM_CLASSES:%=JS%.h))
+JS_DOM_HEADERS=$(filter-out JSMediaQueryListListener.h JSEventListener.h JSEventTarget.h,$(DOM_CLASSES:%=JS%.h))
 
 WEB_DOM_HEADERS :=
 ifeq ($(findstring BUILDING_WX,$(FEATURE_DEFINES)), BUILDING_WX)
index e5fe2a7..ec2c5c1 100644 (file)
@@ -429,6 +429,8 @@ webcore_built_sources += \
        DerivedSources/WebCore/JSMediaError.h \
        DerivedSources/WebCore/JSMediaList.cpp \
        DerivedSources/WebCore/JSMediaList.h \
+       DerivedSources/WebCore/JSMediaQueryList.cpp \
+       DerivedSources/WebCore/JSMediaQueryList.h \
        DerivedSources/WebCore/JSMemoryInfo.cpp \
        DerivedSources/WebCore/JSMemoryInfo.h \
        DerivedSources/WebCore/JSMessageChannel.cpp \
@@ -994,11 +996,17 @@ webcore_sources += \
        WebCore/css/MediaList.cpp \
        WebCore/css/MediaList.h \
        WebCore/css/MediaQuery.cpp \
+       WebCore/css/MediaQuery.h \
        WebCore/css/MediaQueryEvaluator.cpp \
        WebCore/css/MediaQueryEvaluator.h \
        WebCore/css/MediaQueryExp.cpp \
        WebCore/css/MediaQueryExp.h \
-       WebCore/css/MediaQuery.h \
+       WebCore/css/MediaQueryList.cpp \
+       WebCore/css/MediaQueryList.h \
+       WebCore/css/MediaQueryListListener.cpp \
+       WebCore/css/MediaQueryListListener.h \
+       WebCore/css/MediaQueryMatcher.cpp \
+       WebCore/css/MediaQueryMatcher.h \
        WebCore/css/Pair.h \
        WebCore/css/Rect.h \
        WebCore/css/RGBColor.cpp \
index af782a6..0011516 100644 (file)
@@ -17,6 +17,7 @@
             'css/CSSValueList.idl',
             'css/Counter.idl',
             'css/MediaList.idl',
+            'css/MediaQueryList.idl',
             'css/Rect.idl',
             'css/RGBColor.idl',
             'css/StyleMedia.idl',
             'css/MediaList.cpp',
             'css/MediaList.h',
             'css/MediaQuery.cpp',
+            'css/MediaQuery.h',
             'css/MediaQueryEvaluator.cpp',
             'css/MediaQueryEvaluator.h',
             'css/MediaQueryExp.cpp',
             'css/MediaQueryExp.h',
-            'css/MediaQuery.h',
+            'css/MediaQueryList.cpp',
+            'css/MediaQueryList.h',
+            'css/MediaQueryListListener.cpp',
+            'css/MediaQueryListListener.h',
+            'css/MediaQueryMatcher.cpp',
+            'css/MediaQueryMatcher.h',
             'css/Pair.h',
             'css/Rect.h',
             'css/RGBColor.cpp',
index ec213d6..fa73ca4 100644 (file)
@@ -84,6 +84,7 @@ IDL_BINDINGS += \
     css/CSSValue.idl \
     css/CSSValueList.idl \
     css/MediaList.idl \
+    css/MediaQueryList.idl \
     css/Rect.idl \
     css/RGBColor.idl \
     css/StyleMedia.idl \
index 6714893..8648650 100644 (file)
@@ -654,6 +654,9 @@ SOURCES += \
     css/MediaQuery.cpp \
     css/MediaQueryEvaluator.cpp \
     css/MediaQueryExp.cpp \
+    css/MediaQueryList.cpp \
+    css/MediaQueryListListener.cpp \
+    css/MediaQueryMatcher.cpp \
     css/RGBColor.cpp \
     css/ShadowValue.cpp \
     css/StyleBase.cpp \
@@ -1566,9 +1569,12 @@ HEADERS += \
     css/FontValue.h \
     css/MediaFeatureNames.h \
     css/MediaList.h \
+    css/MediaQuery.h \
     css/MediaQueryEvaluator.h \
     css/MediaQueryExp.h \
-    css/MediaQuery.h \
+    css/MediaQueryList.h \
+    css/MediaQueryListListener.h \
+    css/MediaQueryMatcher.h \
     css/RGBColor.h \
     css/ShadowValue.h \
     css/StyleBase.h \
old mode 100644 (file)
new mode 100755 (executable)
index 9cce6bb..519e336
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSMediaQueryList.cpp"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug_Internal|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug_Cairo|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release_Cairo|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug_All|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSMediaQueryList.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSKeyboardEvent.cpp"\r
                                >\r
                                <FileConfiguration\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\css\MediaQueryList.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\css\MediaQueryList.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\css\MediaQueryListListener.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\css\MediaQueryListListener.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\css\MediaQueryMatcher.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\css\MediaQueryMatcher.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\css\Pair.h"\r
                                >\r
                        </File>\r
index c3266a1..8531d74 100644 (file)
                D23CA55D0AB0EAAE005108A5 /* JSRangeException.h in Headers */ = {isa = PBXBuildFile; fileRef = D23CA55C0AB0EAAE005108A5 /* JSRangeException.h */; };
                D23CA55F0AB0EAB6005108A5 /* JSRangeException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D23CA55E0AB0EAB6005108A5 /* JSRangeException.cpp */; };
                D23CA56C0AB0EB8D005108A5 /* RangeException.h in Headers */ = {isa = PBXBuildFile; fileRef = D23CA56B0AB0EB8D005108A5 /* RangeException.h */; };
+               D340629B1253BC8C009E4259 /* MediaQueryListListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D340629A1253BC8C009E4259 /* MediaQueryListListener.cpp */; };
                D39D006D11F8E308006041F2 /* PopupMenuMac.h in Headers */ = {isa = PBXBuildFile; fileRef = D39D006C11F8E308006041F2 /* PopupMenuMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                D39D009D11F907E6006041F2 /* SearchPopupMenuMac.h in Headers */ = {isa = PBXBuildFile; fileRef = D39D009C11F907E6006041F2 /* SearchPopupMenuMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               D3A94A38122DABAC00A37BBC /* MediaQueryList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3A94A31122DABAC00A37BBC /* MediaQueryList.cpp */; };
+               D3A94A39122DABAC00A37BBC /* MediaQueryList.h in Headers */ = {isa = PBXBuildFile; fileRef = D3A94A32122DABAC00A37BBC /* MediaQueryList.h */; };
+               D3A94A3B122DABAC00A37BBC /* MediaQueryListListener.h in Headers */ = {isa = PBXBuildFile; fileRef = D3A94A34122DABAC00A37BBC /* MediaQueryListListener.h */; };
+               D3A94A46122DC40F00A37BBC /* JSMediaQueryList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3A94A42122DC40F00A37BBC /* JSMediaQueryList.cpp */; };
+               D3A94A47122DC40F00A37BBC /* JSMediaQueryList.h in Headers */ = {isa = PBXBuildFile; fileRef = D3A94A43122DC40F00A37BBC /* JSMediaQueryList.h */; };
+               D3AA10F3123A98AA0092152B /* MediaQueryMatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3AA10F1123A98AA0092152B /* MediaQueryMatcher.cpp */; };
+               D3AA10F4123A98AA0092152B /* MediaQueryMatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = D3AA10F2123A98AA0092152B /* MediaQueryMatcher.h */; };
                D8B6152F1032495100C8554A /* Cookie.h in Headers */ = {isa = PBXBuildFile; fileRef = D8B6152E1032495100C8554A /* Cookie.h */; settings = {ATTRIBUTES = (Private, ); }; };
                DB23C2CB0A508D29002489EB /* IndentOutdentCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DB23C2C90A508D29002489EB /* IndentOutdentCommand.cpp */; };
                DB23C2CC0A508D29002489EB /* IndentOutdentCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = DB23C2CA0A508D29002489EB /* IndentOutdentCommand.h */; };
                D23CA55C0AB0EAAE005108A5 /* JSRangeException.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSRangeException.h; sourceTree = "<group>"; };
                D23CA55E0AB0EAB6005108A5 /* JSRangeException.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSRangeException.cpp; sourceTree = "<group>"; };
                D23CA56B0AB0EB8D005108A5 /* RangeException.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RangeException.h; sourceTree = "<group>"; };
+               D340629A1253BC8C009E4259 /* MediaQueryListListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryListListener.cpp; sourceTree = "<group>"; };
                D39D006C11F8E308006041F2 /* PopupMenuMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopupMenuMac.h; sourceTree = "<group>"; };
                D39D009C11F907E6006041F2 /* SearchPopupMenuMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchPopupMenuMac.h; sourceTree = "<group>"; };
+               D3A94A31122DABAC00A37BBC /* MediaQueryList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryList.cpp; sourceTree = "<group>"; };
+               D3A94A32122DABAC00A37BBC /* MediaQueryList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaQueryList.h; sourceTree = "<group>"; };
+               D3A94A33122DABAC00A37BBC /* MediaQueryList.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaQueryList.idl; sourceTree = "<group>"; };
+               D3A94A34122DABAC00A37BBC /* MediaQueryListListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaQueryListListener.h; sourceTree = "<group>"; };
+               D3A94A35122DABAC00A37BBC /* MediaQueryListListener.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaQueryListListener.idl; sourceTree = "<group>"; };
+               D3A94A42122DC40F00A37BBC /* JSMediaQueryList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaQueryList.cpp; sourceTree = "<group>"; };
+               D3A94A43122DC40F00A37BBC /* JSMediaQueryList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaQueryList.h; sourceTree = "<group>"; };
+               D3AA10F1123A98AA0092152B /* MediaQueryMatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryMatcher.cpp; sourceTree = "<group>"; };
+               D3AA10F2123A98AA0092152B /* MediaQueryMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaQueryMatcher.h; sourceTree = "<group>"; };
                D8B6152E1032495100C8554A /* Cookie.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cookie.h; sourceTree = "<group>"; };
                DB23C2C90A508D29002489EB /* IndentOutdentCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IndentOutdentCommand.cpp; sourceTree = "<group>"; };
                DB23C2CA0A508D29002489EB /* IndentOutdentCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IndentOutdentCommand.h; sourceTree = "<group>"; };
                                A8D05FA90A23B30F005E7203 /* JSCSSValueList.cpp */,
                                A8D05FAA0A23B30F005E7203 /* JSCSSValueList.h */,
                                BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */,
+                               D3A94A42122DC40F00A37BBC /* JSMediaQueryList.cpp */,
+                               D3A94A43122DC40F00A37BBC /* JSMediaQueryList.h */,
                                BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */,
                                BCFE2F0F0C1B58370020235F /* JSRect.cpp */,
                                BCFE2F100C1B58370020235F /* JSRect.h */,
                                4E1959260A39DACC00220FE5 /* MediaQueryEvaluator.h */,
                                4E1959270A39DACC00220FE5 /* MediaQueryExp.cpp */,
                                4E1959280A39DACC00220FE5 /* MediaQueryExp.h */,
+                               D3A94A31122DABAC00A37BBC /* MediaQueryList.cpp */,
+                               D3A94A32122DABAC00A37BBC /* MediaQueryList.h */,
+                               D3A94A33122DABAC00A37BBC /* MediaQueryList.idl */,
+                               D3A94A34122DABAC00A37BBC /* MediaQueryListListener.h */,
+                               D340629A1253BC8C009E4259 /* MediaQueryListListener.cpp */,
+                               D3A94A35122DABAC00A37BBC /* MediaQueryListListener.idl */,
+                               D3AA10F1123A98AA0092152B /* MediaQueryMatcher.cpp */,
+                               D3AA10F2123A98AA0092152B /* MediaQueryMatcher.h */,
                                A80E6CD10A1989CA007FB8C5 /* Pair.h */,
                                93CA4C9F09DF93FA00DF8677 /* quirks.css */,
                                BC4368E70C226E32005EFB5F /* Rect.h */,
                                E1AD14211295EA6B00ACA989 /* JSHTMLEmbedElementCustom.h in Headers */,
                                E1AD14231295EA7F00ACA989 /* JSHTMLInputElementCustom.h in Headers */,
                                E1AD14251295EA9500ACA989 /* JSHTMLObjectElementCustom.h in Headers */,
+                               D3A94A39122DABAC00A37BBC /* MediaQueryList.h in Headers */,
+                               D3A94A3B122DABAC00A37BBC /* MediaQueryListListener.h in Headers */,
+                               D3A94A47122DC40F00A37BBC /* JSMediaQueryList.h in Headers */,
+                               D3AA10F4123A98AA0092152B /* MediaQueryMatcher.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                E1AD12D61295D0BD00ACA989 /* JSProcessingInstructionCustom.cpp in Sources */,
                                E1AD139B1295D92600ACA989 /* JSHTMLLinkElementCustom.cpp in Sources */,
                                E1AD139E1295D96100ACA989 /* JSHTMLStyleElementCustom.cpp in Sources */,
+                               D3A94A38122DABAC00A37BBC /* MediaQueryList.cpp in Sources */,
+                               D3A94A46122DC40F00A37BBC /* JSMediaQueryList.cpp in Sources */,
+                               D3AA10F3123A98AA0092152B /* MediaQueryMatcher.cpp in Sources */,
+                               D340629B1253BC8C009E4259 /* MediaQueryListListener.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 338d7f9..bf896bd 100644 (file)
@@ -196,6 +196,8 @@ webkitgtk_gdom_built_sources += \
        DerivedSources/webkit/WebKitDOMMediaErrorPrivate.h \
        DerivedSources/webkit/WebKitDOMMediaList.cpp \
        DerivedSources/webkit/WebKitDOMMediaListPrivate.h \
+       DerivedSources/webkit/WebKitDOMMediaQueryList.cpp \
+       DerivedSources/webkit/WebKitDOMMediaQueryListPrivate.h \
        DerivedSources/webkit/WebKitDOMMemoryInfo.cpp \
        DerivedSources/webkit/WebKitDOMMemoryInfoPrivate.h \
        DerivedSources/webkit/WebKitDOMMessagePort.cpp \
@@ -254,6 +256,7 @@ webkitgtk_built_h_api += \
        DerivedSources/webkit/WebKitDOMCSSStyleSheet.h \
        DerivedSources/webkit/WebKitDOMCSSValue.h \
        DerivedSources/webkit/WebKitDOMMediaList.h \
+       DerivedSources/webkit/WebKitDOMMediaQueryList.h \
        DerivedSources/webkit/WebKitDOMStyleMedia.h \
        DerivedSources/webkit/WebKitDOMStyleSheet.h \
        DerivedSources/webkit/WebKitDOMStyleSheetList.h \
index a58e0c7..a2a72b6 100644 (file)
@@ -84,6 +84,12 @@ bool ScriptValue::isObject() const
     return m_value.get().isObject();
 }
 
+bool ScriptValue::isFunction() const
+{
+    CallData callData;
+    return getCallData(m_value, callData) != CallTypeNone;
+}
+
 PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState)
 {
     return SerializedScriptValue::create(scriptState, jsValue());
index b170fcf..5746c3f 100644 (file)
@@ -55,8 +55,11 @@ public:
     bool isNull() const;
     bool isUndefined() const;
     bool isObject() const;
+    bool isFunction() const;
     bool hasNoValue() const { return m_value == JSC::JSValue(); }
 
+    bool operator==(const ScriptValue& other) const { return m_value == other.m_value; }
+
     PassRefPtr<SerializedScriptValue> serialize(ScriptState*);
     static ScriptValue deserialize(ScriptState*, SerializedScriptValue*);
 
index ca2bd9c..dd5c05c 100644 (file)
@@ -210,8 +210,11 @@ sub SkipFunction {
 
     # Skip functions that have ["Callback"] parameters, because this
     # code generator doesn't know how to auto-generate callbacks.
+    # Skip functions that have "MediaQueryListListener" parameters, because this
+    # code generator doesn't know how to auto-generate MediaQueryListListener.
     foreach my $param (@{$function->parameters}) {
-        if ($param->extendedAttributes->{"Callback"}) {
+        if ($param->extendedAttributes->{"Callback"} ||
+            $param->type eq "MediaQueryListListener") {
             return 1;
         }
     }
@@ -599,7 +602,8 @@ EOF
     push(@txtSetProps, $txtSetProps);
 
     foreach my $attribute (@readableProperties) {
-        if ($attribute->signature->type ne "EventListener") {
+        if ($attribute->signature->type ne "EventListener" &&
+            $attribute->signature->type ne "MediaQueryListListener") {
             GenerateProperty($attribute, $interfaceName, \@writeableProperties);
         }
     }
@@ -766,6 +770,7 @@ sub getIncludeHeader {
     return "" if $type eq "unsigned short";
     return "" if $type eq "DOMTimeStamp";
     return "" if $type eq "EventListener";
+    return "" if $type eq "MediaQueryListListener";
     return "" if $type eq "unsigned char";
     return "" if $type eq "DOMString";
     return "" if $type eq "float";
@@ -800,6 +805,10 @@ sub GenerateFunction {
 
     my $decamelize = FixUpDecamelizedName(decamelize($interfaceName));
 
+    if ($object eq "MediaQueryListListener") {
+        return;
+    }
+
     if (SkipFunction($function, $decamelize, $prefix)) {
         return;
     }
@@ -821,7 +830,7 @@ sub GenerateFunction {
 
     foreach my $param (@{$function->parameters}) {
         my $paramIDLType = $param->type;
-        if ($paramIDLType eq "EventListener") {
+        if ($paramIDLType eq "EventListener" || $paramIDLType eq "MediaQueryListListener") {
             push(@hBody, "\n/* TODO: event function ${functionName} */\n\n");
             push(@cBody, "\n/* TODO: event function ${functionName} */\n\n");
             return;
@@ -1075,7 +1084,9 @@ sub GenerateFunctions {
 
     TOP:
     foreach my $attribute (@{$dataNode->attributes}) {
-        if (SkipAttribute($attribute) || $attribute->signature->type eq "EventListener") {
+        if (SkipAttribute($attribute) ||
+            $attribute->signature->type eq "EventListener" ||
+            $attribute->signature->type eq "MediaQueryListListener") {
             next TOP;
         }
         
index b4b03bb..95cdf30 100644 (file)
@@ -6,6 +6,7 @@
 # Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
+# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -273,6 +274,10 @@ sub AddIncludesForType
     if ($type eq "Document") {
         $implIncludes{"NodeFilter.h"} = 1;
     }
+
+    if ($type eq "MediaQueryListListener") {
+        $implIncludes{"MediaQueryListListener.h"} = 1;
+    }
 }
 
 # FIXME: This method will go away once all SVG animated properties are converted to the new scheme.
@@ -2364,6 +2369,7 @@ my %nativeType = (
     "unsigned short" => "unsigned short",
     "long long" => "long long",
     "unsigned long long" => "unsigned long long",
+    "MediaQueryListListener" => "RefPtr<MediaQueryListListener>"
 );
 
 sub GetNativeType
@@ -2452,6 +2458,11 @@ sub JSValueToNative
         return "$value";
     }
 
+    if ($type eq "MediaQueryListListener") {
+        $implIncludes{"MediaQueryListListener.h"} = 1;
+        return "MediaQueryListListener::create(" . $value .")";
+    }
+
     if ($type eq "SerializedScriptValue" or $type eq "any") {
         $implIncludes{"SerializedScriptValue.h"} = 1;
         return "SerializedScriptValue::create(exec, $value)";
index 049f765..7ea4c63 100644 (file)
@@ -7,6 +7,7 @@
 # Copyright (C) 2007, 2008, 2009 Google Inc.
 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
+# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -2820,6 +2821,8 @@ sub GetNativeType
 
     return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter;
 
+    return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener";
+
     # Default, assume native type is a pointer with same type name as idl type
     return "${type}*";
 }
@@ -2899,6 +2902,11 @@ sub JSValueToNative
         $implIncludes{"FloatRect.h"} = 1;
     }
 
+    if ($type eq "MediaQueryListListener") {
+        $implIncludes{"MediaQueryListListener.h"} = 1;
+        return "MediaQueryListListener::create(" . $value . ")";
+    }
+
     # Default, assume autogenerated type conversion routines
     if ($type eq "EventTarget") {
         $implIncludes{"V8Node.h"} = 1;
@@ -3026,7 +3034,8 @@ my %non_wrapper_types = (
     'NodeFilter' => 1,
     'EventListener' => 1,
     'IDBKey' => 1,
-    'Date' => 1
+    'Date' => 1,
+    'MediaQueryListListener' => 1
 );
 
 
index 7956e30..f5ded79 100644 (file)
@@ -28,8 +28,6 @@
 #include "TestMediaQueryListListener.h"
 #include "WebKitDOMBinding.h"
 #include "gobject/ConvertToUTF8String.h"
-#include "webkit/WebKitDOMMediaQueryListListener.h"
-#include "webkit/WebKitDOMMediaQueryListListenerPrivate.h"
 #include "webkit/WebKitDOMTestMediaQueryListListener.h"
 #include "webkit/WebKitDOMTestMediaQueryListListenerPrivate.h"
 #include "webkitmarshal.h"
@@ -49,21 +47,6 @@ gpointer kit(WebCore::TestMediaQueryListListener* obj)
     
 } // namespace WebKit //
 
-void
-webkit_dom_test_media_query_list_listener_method(WebKitDOMTestMediaQueryListListener* self, WebKitDOMMediaQueryListListener* listener)
-{
-    g_return_if_fail(self);
-    WebCore::JSMainThreadNullState state;
-    WebCore::TestMediaQueryListListener * item = WebKit::core(self);
-    g_return_if_fail(listener);
-    WebCore::MediaQueryListListener * converted_listener = NULL;
-    if (listener != NULL) {
-        converted_listener = WebKit::core(listener);
-        g_return_if_fail(converted_listener);
-    }
-    item->method(converted_listener);
-}
-
 
 G_DEFINE_TYPE(WebKitDOMTestMediaQueryListListener, webkit_dom_test_media_query_list_listener, WEBKIT_TYPE_DOM_OBJECT)
 
index 94e825e..612439b 100644 (file)
@@ -46,9 +46,6 @@ struct _WebKitDOMTestMediaQueryListListenerClass {
 WEBKIT_API GType
 webkit_dom_test_media_query_list_listener_get_type (void);
 
-WEBKIT_API void
-webkit_dom_test_media_query_list_listener_method(WebKitDOMTestMediaQueryListListener* self, WebKitDOMMediaQueryListListener* listener);
-
 G_END_DECLS
 
 #endif /* WebKitDOMTestMediaQueryListListener_h */
index cde9672..e505ed2 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "ExceptionCode.h"
 #include "JSDOMBinding.h"
-#include "JSMediaQueryListListener.h"
+#include "MediaQueryListListener.h"
 #include "TestMediaQueryListListener.h"
 #include <runtime/Error.h>
 #include <wtf/GetPtr.h>
@@ -174,7 +174,7 @@ EncodedJSValue JSC_HOST_CALL jsTestMediaQueryListListenerPrototypeFunctionMethod
         return throwVMTypeError(exec);
     JSTestMediaQueryListListener* castedThis = static_cast<JSTestMediaQueryListListener*>(asObject(thisValue));
     TestMediaQueryListListener* imp = static_cast<TestMediaQueryListListener*>(castedThis->impl());
-    MediaQueryListListener* listener = toMediaQueryListListener(exec->argument(0));
+    RefPtr<MediaQueryListListener> listener = MediaQueryListListener::create(exec->argument(0));
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
 
index 1f78f39..f1c4e2b 100644 (file)
 #include "V8TestMediaQueryListListener.h"
 
 #include "ExceptionCode.h"
+#include "MediaQueryListListener.h"
 #include "RuntimeEnabledFeatures.h"
 #include "V8Binding.h"
 #include "V8BindingMacros.h"
 #include "V8BindingState.h"
 #include "V8DOMWrapper.h"
 #include "V8IsolatedContext.h"
-#include "V8MediaQueryListListener.h"
 #include "V8Proxy.h"
 
 namespace WebCore {
@@ -43,28 +43,25 @@ static v8::Handle<v8::Value> methodCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.TestMediaQueryListListener.method");
     TestMediaQueryListListener* imp = V8TestMediaQueryListListener::toNative(args.Holder());
-    EXCEPTION_BLOCK(MediaQueryListListener*, listener, V8MediaQueryListListener::HasInstance(args[0]) ? V8MediaQueryListListener::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
+    EXCEPTION_BLOCK(RefPtr<MediaQueryListListener>, listener, MediaQueryListListener::create(args[0]));
     imp->method(listener);
     return v8::Handle<v8::Value>();
 }
 
 } // namespace TestMediaQueryListListenerInternal
 
+static const BatchedCallback TestMediaQueryListListenerCallbacks[] = {
+    {"method", TestMediaQueryListListenerInternal::methodCallback},
+};
 static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestMediaQueryListListenerTemplate(v8::Persistent<v8::FunctionTemplate> desc)
 {
     v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "TestMediaQueryListListener", v8::Persistent<v8::FunctionTemplate>(), V8TestMediaQueryListListener::internalFieldCount,
         0, 0,
-        0, 0);
+        TestMediaQueryListListenerCallbacks, sizeof(TestMediaQueryListListenerCallbacks) / sizeof(*TestMediaQueryListListenerCallbacks));
     v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
     v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
     
 
-    // Custom Signature 'method'
-    const int methodArgc = 1;
-    v8::Handle<v8::FunctionTemplate> methodArgv[methodArgc] = { V8MediaQueryListListener::GetRawTemplate() };
-    v8::Handle<v8::Signature> methodSignature = v8::Signature::New(desc, methodArgc, methodArgv);
-    proto->Set(v8::String::New("method"), v8::FunctionTemplate::New(TestMediaQueryListListenerInternal::methodCallback, v8::Handle<v8::Value>(), methodSignature));
-
     // Custom toString template
     desc->Set(getToStringName(), getToStringTemplate());
     return desc;
index 1743da0..d412901 100644 (file)
@@ -100,6 +100,11 @@ public:
         return m_value == value.m_value;
     }
 
+    bool isFunction() const
+    {
+        return m_value->IsFunction();
+    }
+
     bool operator!=(const ScriptValue value) const
     {
         return !operator==(value);
diff --git a/WebCore/css/MediaQueryList.cpp b/WebCore/css/MediaQueryList.cpp
new file mode 100644 (file)
index 0000000..aa3ef60
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "MediaQueryList.h"
+
+#include "MediaList.h"
+#include "MediaQueryEvaluator.h"
+#include "MediaQueryListListener.h"
+#include "MediaQueryMatcher.h"
+
+namespace WebCore {
+
+PassRefPtr<MediaQueryList> MediaQueryList::create(PassRefPtr<MediaQueryMatcher> vector, PassRefPtr<MediaList> media, bool matches)
+{
+    return adoptRef(new MediaQueryList(vector, media, matches));
+}
+
+MediaQueryList::MediaQueryList(PassRefPtr<MediaQueryMatcher> vector, PassRefPtr<MediaList> media, bool matches)
+    : m_matcher(vector)
+    , m_media(media)
+    , m_evaluationRound(m_matcher->evaluationRound())
+    , m_changeRound(m_evaluationRound - 1) // m_evaluationRound and m_changeRound initial values must be different.
+    , m_matches(matches)
+{
+}
+
+MediaQueryList::~MediaQueryList()
+{
+}
+
+String MediaQueryList::media() const
+{
+    return m_media->mediaText();
+}
+
+void MediaQueryList::addListener(PassRefPtr<MediaQueryListListener> listener)
+{
+    if (!listener)
+        return;
+
+    m_matcher->addListener(listener, this);
+}
+
+void MediaQueryList::removeListener(PassRefPtr<MediaQueryListListener> listener)
+{
+    if (!listener)
+        return;
+
+    m_matcher->removeListener(listener.get(), this);
+}
+
+void MediaQueryList::evaluate(MediaQueryEvaluator* evaluator, bool& notificationNeeded)
+{
+    if (m_evaluationRound != m_matcher->evaluationRound() && evaluator)
+        setMatches(evaluator->eval(m_media.get()));
+    notificationNeeded = m_changeRound == m_matcher->evaluationRound();
+}
+
+void MediaQueryList::setMatches(bool newValue)
+{
+    m_evaluationRound = m_matcher->evaluationRound();
+
+    if (newValue == m_matches)
+        return;
+
+    m_matches = newValue;
+    m_changeRound = m_evaluationRound;
+}
+
+bool MediaQueryList::matches()
+{
+    if (m_evaluationRound != m_matcher->evaluationRound())
+        setMatches(m_matcher->evaluate(m_media.get()));
+    return m_matches;
+}
+
+}
diff --git a/WebCore/css/MediaQueryList.h b/WebCore/css/MediaQueryList.h
new file mode 100644 (file)
index 0000000..8ff4988
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef MediaQueryList_h
+#define MediaQueryList_h
+
+#include <wtf/Forward.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class MediaList;
+class MediaQueryListListener;
+class MediaQueryEvaluator;
+class MediaQueryMatcher;
+
+// MediaQueryList interface is specified at http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface
+// The objects of this class are returned by window.matchMedia. They may be used to
+// retrieve the current value of the given media query and to add/remove listeners that
+// will be called whenever the value of the query changes.
+
+class MediaQueryList : public RefCounted<MediaQueryList> {
+public:
+    static PassRefPtr<MediaQueryList> create(PassRefPtr<MediaQueryMatcher>, PassRefPtr<MediaList>, bool);
+    ~MediaQueryList();
+
+    String media() const;
+    bool matches();
+
+    void addListener(PassRefPtr<MediaQueryListListener>);
+    void removeListener(PassRefPtr<MediaQueryListListener>);
+
+    void evaluate(MediaQueryEvaluator*, bool& notificationNeeded);
+
+private:
+    MediaQueryList(PassRefPtr<MediaQueryMatcher>, PassRefPtr<MediaList>, bool matches);
+    void setMatches(bool);
+
+    RefPtr<MediaQueryMatcher> m_matcher;
+    RefPtr<MediaList> m_media;
+    unsigned m_evaluationRound; // Indicates if the query has been evaluated after the last style selector change.
+    unsigned m_changeRound; // Used to know if the query has changed in the last style selector change.
+    bool m_matches;
+};
+
+}
+
+#endif // MediaQueryList_h
diff --git a/WebCore/css/MediaQueryList.idl b/WebCore/css/MediaQueryList.idl
new file mode 100644 (file)
index 0000000..e775db8
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+module view {
+    interface MediaQueryList {
+        readonly attribute DOMString media;
+        readonly attribute boolean matches;
+        void addListener(in MediaQueryListListener listener);
+        void removeListener(in MediaQueryListListener listener);
+    };
+}
diff --git a/WebCore/css/MediaQueryListListener.cpp b/WebCore/css/MediaQueryListListener.cpp
new file mode 100644 (file)
index 0000000..ab73b1d
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "MediaQueryListListener.h"
+
+#include "MediaQueryList.h"
+#include "ScriptFunctionCall.h"
+
+#if USE(JSC)
+#include "JSMediaQueryList.h"
+#else
+#include "V8MediaQueryList.h"
+#endif
+
+namespace WebCore {
+
+void MediaQueryListListener::queryChanged(ScriptState* state, MediaQueryList* query)
+{
+    ScriptCallback callback(state, m_value);
+#if USE(JSC)
+    callback.appendArgument(toJS(state, query));
+#else
+    callback.appendArgument(toV8(query));
+#endif
+    callback.call();
+}
+
+}
diff --git a/WebCore/css/MediaQueryListListener.h b/WebCore/css/MediaQueryListListener.h
new file mode 100644 (file)
index 0000000..de62683
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef MediaQueryListListener_h
+#define MediaQueryListListener_h
+
+#include "PlatformString.h"
+#include "ScriptState.h"
+#include "ScriptValue.h"
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class MediaQueryList;
+
+// See http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface
+
+class MediaQueryListListener : public RefCounted<MediaQueryListListener> {
+public:
+    static PassRefPtr<MediaQueryListListener> create(ScriptValue value)
+    {
+        if (!value.isFunction())
+            return 0;
+        return adoptRef(new MediaQueryListListener(value));
+    }
+    void queryChanged(ScriptState*, MediaQueryList*);
+
+    bool operator==(const MediaQueryListListener& other) const { return m_value == other.m_value; }
+
+private:
+    MediaQueryListListener(ScriptValue value) : m_value(value) { }
+
+    ScriptValue m_value;
+};
+
+}
+
+#endif // MediaQueryListListener_h
diff --git a/WebCore/css/MediaQueryListListener.idl b/WebCore/css/MediaQueryListListener.idl
new file mode 100644 (file)
index 0000000..7031557
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+module view {
+    interface [
+        NoStaticTables,
+        ObjCProtocol,
+        PureInterface,
+        OmitConstructor
+    ] MediaQueryListListener {
+        void queryChanged(in MediaQueryList list);
+    };
+}
diff --git a/WebCore/css/MediaQueryMatcher.cpp b/WebCore/css/MediaQueryMatcher.cpp
new file mode 100644 (file)
index 0000000..e076837
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "MediaQueryMatcher.h"
+
+#include "CSSStyleSelector.h"
+#include "Document.h"
+#include "Element.h"
+#include "FrameView.h"
+#include "MediaList.h"
+#include "MediaQueryEvaluator.h"
+#include "MediaQueryList.h"
+#include "MediaQueryListListener.h"
+
+namespace WebCore {
+
+MediaQueryMatcher::Listener::Listener(PassRefPtr<MediaQueryListListener> listener, PassRefPtr<MediaQueryList> query)
+    : m_listener(listener)
+    , m_query(query)
+{
+}
+
+MediaQueryMatcher::Listener::~Listener()
+{
+}
+
+void MediaQueryMatcher::Listener::evaluate(ScriptState* state, MediaQueryEvaluator* evaluator)
+{
+    bool notify;
+    m_query->evaluate(evaluator, notify);
+    if (notify)
+        m_listener->queryChanged(state, m_query.get());
+}
+
+MediaQueryMatcher::MediaQueryMatcher(Document* document)
+    : m_document(document)
+    , m_evaluationRound(1)
+{
+    ASSERT(m_document);
+}
+
+MediaQueryMatcher::~MediaQueryMatcher()
+{
+}
+
+void MediaQueryMatcher::documentDestroyed()
+{
+    m_listeners.clear();
+    m_document = 0;
+}
+
+String MediaQueryMatcher::mediaType() const
+{
+    if (!m_document || !m_document->frame() || !m_document->frame()->view())
+        return String();
+
+    return m_document->frame()->view()->mediaType();
+}
+
+PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::prepareEvaluator() const
+{
+    if (!m_document || !m_document->frame())
+        return 0;
+
+    Element* documentElement = m_document->documentElement();
+    if (!documentElement)
+        return 0;
+
+    CSSStyleSelector* styleSelector = m_document->styleSelector();
+    if (!styleSelector)
+        return 0;
+
+    RefPtr<RenderStyle> rootStyle = styleSelector->styleForElement(documentElement, 0 /*defaultParent*/, false /*allowSharing*/, true /*resolveForRootDefault*/);
+
+    return adoptPtr(new MediaQueryEvaluator(mediaType(), m_document->frame(), rootStyle.get()));
+}
+
+bool MediaQueryMatcher::evaluate(MediaList* media)
+{
+    if (!media)
+        return false;
+
+    OwnPtr<MediaQueryEvaluator> evaluator(prepareEvaluator());
+    return evaluator && evaluator->eval(media);
+}
+
+PassRefPtr<MediaQueryList> MediaQueryMatcher::matchMedia(const String& query)
+{
+    if (!m_document)
+        return 0;
+
+    RefPtr<MediaList> media = MediaList::create(query, false);
+    return MediaQueryList::create(this, media, evaluate(media.get()));
+}
+
+void MediaQueryMatcher::addListener(PassRefPtr<MediaQueryListListener> listener, PassRefPtr<MediaQueryList> query)
+{
+    if (!m_document)
+        return;
+
+    for (size_t i = 0; i < m_listeners.size(); ++i) {
+        if (*m_listeners[i]->listener() == *listener && m_listeners[i]->query() == query)
+            return;
+    }
+
+    m_listeners.append(new Listener(listener, query));
+}
+
+void MediaQueryMatcher::removeListener(MediaQueryListListener* listener, MediaQueryList* query)
+{
+    if (!m_document)
+        return;
+
+    for (size_t i = 0; i < m_listeners.size(); ++i) {
+        if (*m_listeners[i]->listener() == *listener && m_listeners[i]->query() == query) {
+            m_listeners.remove(i);
+            return;
+        }
+    }
+}
+
+void MediaQueryMatcher::styleSelectorChanged()
+{
+    ASSERT(m_document);
+
+    ScriptState* scriptState = mainWorldScriptState(m_document->frame());
+    if (!scriptState)
+        return;
+
+    ++m_evaluationRound;
+    OwnPtr<MediaQueryEvaluator> evaluator = prepareEvaluator();
+    if (!evaluator)
+        return;
+
+    for (size_t i = 0; i < m_listeners.size(); ++i)
+        m_listeners[i]->evaluate(scriptState, evaluator.get());
+}
+
+}
diff --git a/WebCore/css/MediaQueryMatcher.h b/WebCore/css/MediaQueryMatcher.h
new file mode 100644 (file)
index 0000000..96bbf83
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef MediaQueryMatcher_h
+#define MediaQueryMatcher_h
+
+#include "ScriptState.h"
+#include <wtf/Forward.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class Document;
+class MediaList;
+class MediaQueryList;
+class MediaQueryListListener;
+class MediaQueryEvaluator;
+
+// MediaQueryMatcher class is responsible for keeping a vector of pairs
+// MediaQueryList x MediaQueryListListener. It is responsible for evaluating the queries
+// whenever it is needed and to call the listeners if the corresponding query has changed.
+// The listeners must be called in the very same order in which they have been added.
+
+class MediaQueryMatcher : public RefCounted<MediaQueryMatcher> {
+public:
+    static PassRefPtr<MediaQueryMatcher> create(Document* document) { return adoptRef(new MediaQueryMatcher(document)); }
+    ~MediaQueryMatcher();
+    void documentDestroyed();
+
+    void addListener(PassRefPtr<MediaQueryListListener>, PassRefPtr<MediaQueryList>);
+    void removeListener(MediaQueryListListener*, MediaQueryList*);
+
+    PassRefPtr<MediaQueryList> matchMedia(const String&);
+
+    unsigned evaluationRound() const { return m_evaluationRound; }
+    void styleSelectorChanged();
+    bool evaluate(MediaList*);
+
+private:
+    class Listener {
+    public:
+        Listener(PassRefPtr<MediaQueryListListener>, PassRefPtr<MediaQueryList>);
+        ~Listener();
+
+        void evaluate(ScriptState*, MediaQueryEvaluator*);
+
+        MediaQueryListListener* listener() { return m_listener.get(); }
+        MediaQueryList* query() { return m_query.get(); }
+
+    private:
+        RefPtr<MediaQueryListListener> m_listener;
+        RefPtr<MediaQueryList> m_query;
+    };
+
+    MediaQueryMatcher(Document*);
+    PassOwnPtr<MediaQueryEvaluator> prepareEvaluator() const;
+    String mediaType() const;
+
+    Document* m_document;
+    Vector<OwnPtr<Listener> > m_listeners;
+
+    // This value is incremented at style selector changes.
+    // It is used to avoid evaluating queries more then once and to make sure
+    // that a media query result change is notified exactly once.
+    unsigned m_evaluationRound;
+};
+
+}
+
+#endif // MediaQueryMatcher_h
index 40f078f..75414f6 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -92,6 +93,8 @@
 #include "InspectorInstrumentation.h"
 #include "KeyboardEvent.h"
 #include "Logging.h"
+#include "MediaQueryList.h"
+#include "MediaQueryMatcher.h"
 #include "MessageEvent.h"
 #include "MouseEvent.h"
 #include "MouseEventWithHitTestResults.h"
@@ -587,6 +590,16 @@ Document::~Document()
     }
 
     m_weakReference->clear();
+
+    if (m_mediaQueryMatcher)
+        m_mediaQueryMatcher->documentDestroyed();
+}
+
+MediaQueryMatcher* Document::mediaQueryMatcher()
+{
+    if (!m_mediaQueryMatcher)
+        m_mediaQueryMatcher = MediaQueryMatcher::create(this);
+    return m_mediaQueryMatcher.get();
 }
 
 #if USE(JSC)
@@ -2906,6 +2919,9 @@ void Document::styleSelectorChanged(StyleSelectorUpdateFlag updateFlag)
         if (view())
             view()->scheduleRelayout();
     }
+
+    if (m_mediaQueryMatcher)
+        m_mediaQueryMatcher->styleSelectorChanged();
 }
 
 void Document::addStyleSheetCandidateNode(Node* node, bool createdByParser)
index 1e89820..476e25b 100644 (file)
@@ -5,6 +5,7 @@
  *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -94,6 +95,8 @@ class IntPoint;
 class DOMWrapperWorld;
 class JSNode;
 class MediaCanStartListener;
+class MediaQueryList;
+class MediaQueryMatcher;
 class MouseEventWithHitTestResults;
 class NodeFilter;
 class NodeIterator;
@@ -203,6 +206,8 @@ public:
     }
     virtual ~Document();
 
+    MediaQueryMatcher* mediaQueryMatcher();
+
     using ContainerNode::ref;
     using ContainerNode::deref;
 
@@ -1373,6 +1378,7 @@ private:
     bool m_writingModeSetOnDocumentElement;
 
     DocumentTiming m_documentTiming;
+    RefPtr<MediaQueryMatcher> m_mediaQueryMatcher;
 };
 
 inline bool Document::DocumentOrderedMap::contains(AtomicStringImpl* id) const
index b5337f9..27f40ec 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -67,7 +68,8 @@
 #include "InspectorInstrumentation.h"
 #include "KURL.h"
 #include "Location.h"
-#include "StyleMedia.h"
+#include "MediaQueryList.h"
+#include "MediaQueryMatcher.h"
 #include "MessageEvent.h"
 #include "Navigator.h"
 #include "NotificationCenter.h"
@@ -83,6 +85,7 @@
 #include "Storage.h"
 #include "StorageArea.h"
 #include "StorageNamespace.h"
+#include "StyleMedia.h"
 #include "SuddenTermination.h"
 #include "WebKitPoint.h"
 #include <algorithm>
@@ -411,6 +414,11 @@ ScriptExecutionContext* DOMWindow::scriptExecutionContext() const
     return document();
 }
 
+PassRefPtr<MediaQueryList> DOMWindow::matchMedia(const String& media)
+{
+    return document() ? document()->mediaQueryMatcher()->matchMedia(media) : 0;
+}
+
 void DOMWindow::disconnectFrame()
 {
     m_frame = 0;
index cb524a0..68b21ff 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006, 2007, 2009 Apple Inc.  All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -58,10 +59,11 @@ namespace WebCore {
     class History;
     class IDBFactory;
     class Location;
-    class StyleMedia;
+    class MediaQueryList;
     class Navigator;
     class Node;
     class NotificationCenter;
+    class StyleMedia;
 
 #if ENABLE(WEB_TIMING)
     class Performance;
@@ -96,6 +98,8 @@ namespace WebCore {
 
         void clear();
 
+        PassRefPtr<MediaQueryList> matchMedia(const String&);
+
 #if ENABLE(ORIENTATION_EVENTS)
         // This is the interface orientation in degrees. Some examples are:
         //  0 is straight up; -90 is when the device is rotated 90 clockwise;
index b93ff55..0b9f5ed 100644 (file)
@@ -140,6 +140,9 @@ module window {
         readonly attribute Document document;
 
         // CSSOM View Module
+        MediaQueryList matchMedia(in DOMString query);
+
+        // styleMedia has been removed from the CSSOM View specification.
         readonly attribute StyleMedia styleMedia;
 
         // DOM Level 2 Style Interface