[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

luiz at webkit.org luiz at webkit.org
Wed Dec 22 16:22:28 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit db0dd4315350940409e21a6f94fe596aa95e1390
Author: luiz at webkit.org <luiz at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 22 21:02:27 2010 +0000

    2010-10-21  Luiz Agostini  <luiz.agostini at 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-10-21  Luiz Agostini  <luiz.agostini at 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: http://svn.webkit.org/repository/webkit/trunk@72552 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6197949..2d122fe 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,39 @@
+2010-10-21  Luiz Agostini  <luiz.agostini at 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 at webkit.org>
 
         Unreviewed update of Windows Skipped list.
diff --git a/LayoutTests/fast/dom/Window/window-properties-expected.txt b/LayoutTests/fast/dom/Window/window-properties-expected.txt
index 5cab84b..c7b099a 100644
--- a/LayoutTests/fast/dom/Window/window-properties-expected.txt
+++ b/LayoutTests/fast/dom/Window/window-properties-expected.txt
@@ -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]
diff --git a/LayoutTests/fast/dom/Window/window-property-descriptors-expected.txt b/LayoutTests/fast/dom/Window/window-property-descriptors-expected.txt
index 1d9c4df..68315ad 100644
--- a/LayoutTests/fast/dom/Window/window-property-descriptors-expected.txt
+++ b/LayoutTests/fast/dom/Window/window-property-descriptors-expected.txt
@@ -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
index 0000000..4eba3f5
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-01-expected.txt
@@ -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
index 0000000..33dcc67
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-01.html
@@ -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
index 0000000..63643d8
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-02-expected.txt
@@ -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
index 0000000..7093ca1
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-02.html
@@ -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
index 0000000..f24e206
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-03-expected.txt
@@ -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
index 0000000..833bdde
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-03.html
@@ -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
index 0000000..3a6d0db
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-04-expected.txt
@@ -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
index 0000000..a877a5a
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-04.html
@@ -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
index 0000000..047e106
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-05-expected.txt
@@ -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
index 0000000..6b66b0a
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-05.html
@@ -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
index 0000000..1c65465
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-06-expected.txt
@@ -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
index 0000000..5913e56
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-06.html
@@ -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
index 0000000..8b0e7f9
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-07-expected.txt
@@ -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
index 0000000..0344263
--- /dev/null
+++ b/LayoutTests/fast/media/media-query-list-07.html
@@ -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>
diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt
index 218ed1c..cab652a 100644
--- a/LayoutTests/platform/chromium/test_expectations.txt
+++ b/LayoutTests/platform/chromium/test_expectations.txt
@@ -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
diff --git a/LayoutTests/platform/mac/Skipped b/LayoutTests/platform/mac/Skipped
index 5a72d3b..fe9d7ee 100644
--- a/LayoutTests/platform/mac/Skipped
+++ b/LayoutTests/platform/mac/Skipped
@@ -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
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index 25cce52..a341908 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -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
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 3fbc7b5..f39556d 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -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
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index dbdb1b7..f107d92 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,89 @@
+2010-10-21  Luiz Agostini  <luiz.agostini at 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 at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/DerivedSources.make b/WebCore/DerivedSources.make
index 793e155..5b0fb09 100644
--- a/WebCore/DerivedSources.make
+++ b/WebCore/DerivedSources.make
@@ -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)
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index e5fe2a7..ec2c5c1 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -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 \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index af782a6..0011516 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -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',
@@ -1058,11 +1059,17 @@
             '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',
diff --git a/WebCore/WebCore.pri b/WebCore/WebCore.pri
index ec213d6..fa73ca4 100644
--- a/WebCore/WebCore.pri
+++ b/WebCore/WebCore.pri
@@ -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 \
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 6714893..8648650 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -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 \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
old mode 100644
new mode 100755
index 9cce6bb..519e336
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -9851,6 +9851,62 @@
 				>
 			</File>
 			<File
+				RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSMediaQueryList.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug_Internal|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug_Cairo|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release_Cairo|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug_All|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSMediaQueryList.h"
+				>
+			</File>
+			<File
 				RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSKeyboardEvent.cpp"
 				>
 				<FileConfiguration
@@ -30551,6 +30607,30 @@
 				>
 			</File>
 			<File
+				RelativePath="..\css\MediaQueryList.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\css\MediaQueryList.h"
+				>
+			</File>
+			<File
+				RelativePath="..\css\MediaQueryListListener.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\css\MediaQueryListListener.h"
+				>
+			</File>
+			<File
+				RelativePath="..\css\MediaQueryMatcher.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\css\MediaQueryMatcher.h"
+				>
+			</File>
+			<File
 				RelativePath="..\css\Pair.h"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index c3266a1..8531d74 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -5313,8 +5313,16 @@
 		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 */; };
@@ -11363,8 +11371,18 @@
 		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>"; };
@@ -15774,6 +15792,8 @@
 				A8D05FA90A23B30F005E7203 /* JSCSSValueList.cpp */,
 				A8D05FAA0A23B30F005E7203 /* JSCSSValueList.h */,
 				BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */,
+				D3A94A42122DC40F00A37BBC /* JSMediaQueryList.cpp */,
+				D3A94A43122DC40F00A37BBC /* JSMediaQueryList.h */,
 				BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */,
 				BCFE2F0F0C1B58370020235F /* JSRect.cpp */,
 				BCFE2F100C1B58370020235F /* JSRect.h */,
@@ -17763,6 +17783,14 @@
 				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 */,
@@ -21291,6 +21319,10 @@
 				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;
 		};
@@ -23848,6 +23880,10 @@
 				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;
 		};
diff --git a/WebCore/bindings/gobject/GNUmakefile.am b/WebCore/bindings/gobject/GNUmakefile.am
index 338d7f9..bf896bd 100644
--- a/WebCore/bindings/gobject/GNUmakefile.am
+++ b/WebCore/bindings/gobject/GNUmakefile.am
@@ -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 \
diff --git a/WebCore/bindings/js/ScriptValue.cpp b/WebCore/bindings/js/ScriptValue.cpp
index a58e0c7..a2a72b6 100644
--- a/WebCore/bindings/js/ScriptValue.cpp
+++ b/WebCore/bindings/js/ScriptValue.cpp
@@ -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());
diff --git a/WebCore/bindings/js/ScriptValue.h b/WebCore/bindings/js/ScriptValue.h
index b170fcf..5746c3f 100644
--- a/WebCore/bindings/js/ScriptValue.h
+++ b/WebCore/bindings/js/ScriptValue.h
@@ -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*);
 
diff --git a/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/WebCore/bindings/scripts/CodeGeneratorGObject.pm
index ca2bd9c..dd5c05c 100644
--- a/WebCore/bindings/scripts/CodeGeneratorGObject.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorGObject.pm
@@ -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;
         }
         
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index b4b03bb..95cdf30 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -6,6 +6,7 @@
 # Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
 # Copyright (C) 2009 Cameron McCormack <cam at 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)";
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 049f765..7ea4c63 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -7,6 +7,7 @@
 # Copyright (C) 2007, 2008, 2009 Google Inc.
 # Copyright (C) 2009 Cameron McCormack <cam at 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
 );
 
 
diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp
index 7956e30..f5ded79 100644
--- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp
+++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp
@@ -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)
 
diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h
index 94e825e..612439b 100644
--- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h
+++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h
@@ -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 */
diff --git a/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp b/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp
index cde9672..e505ed2 100644
--- a/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp
+++ b/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp
@@ -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());
 
diff --git a/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp b/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp
index 1f78f39..f1c4e2b 100644
--- a/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp
+++ b/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp
@@ -22,13 +22,13 @@
 #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;
diff --git a/WebCore/bindings/v8/ScriptValue.h b/WebCore/bindings/v8/ScriptValue.h
index 1743da0..d412901 100644
--- a/WebCore/bindings/v8/ScriptValue.h
+++ b/WebCore/bindings/v8/ScriptValue.h
@@ -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
index 0000000..aa3ef60
--- /dev/null
+++ b/WebCore/css/MediaQueryList.cpp
@@ -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
index 0000000..8ff4988
--- /dev/null
+++ b/WebCore/css/MediaQueryList.h
@@ -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
index 0000000..e775db8
--- /dev/null
+++ b/WebCore/css/MediaQueryList.idl
@@ -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
index 0000000..ab73b1d
--- /dev/null
+++ b/WebCore/css/MediaQueryListListener.cpp
@@ -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
index 0000000..de62683
--- /dev/null
+++ b/WebCore/css/MediaQueryListListener.h
@@ -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
index 0000000..7031557
--- /dev/null
+++ b/WebCore/css/MediaQueryListListener.idl
@@ -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
index 0000000..e076837
--- /dev/null
+++ b/WebCore/css/MediaQueryMatcher.cpp
@@ -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
index 0000000..96bbf83
--- /dev/null
+++ b/WebCore/css/MediaQueryMatcher.h
@@ -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
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 40f078f..75414f6 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -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)
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 1e89820..476e25b 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -5,6 +5,7 @@
  *           (C) 2006 Alexey Proskuryakov (ap at 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
diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp
index b5337f9..27f40ec 100644
--- a/WebCore/page/DOMWindow.cpp
+++ b/WebCore/page/DOMWindow.cpp
@@ -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;
diff --git a/WebCore/page/DOMWindow.h b/WebCore/page/DOMWindow.h
index cb524a0..68b21ff 100644
--- a/WebCore/page/DOMWindow.h
+++ b/WebCore/page/DOMWindow.h
@@ -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;
diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl
index b93ff55..0b9f5ed 100644
--- a/WebCore/page/DOMWindow.idl
+++ b/WebCore/page/DOMWindow.idl
@@ -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

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list