2010-10-21 Luiz Agostini <luiz.agostini@openbossa.org>
Reviewed by Darin Adler.
Implement CSSOM View matchMedia interface
https://bugs.webkit.org/show_bug.cgi?id=37205
New property matchMedia was added to window.
* fast/dom/Window/window-properties-expected.txt:
* fast/dom/Window/window-property-descriptors-expected.txt:
window.matchMedia and MediaQueryList tests.
* fast/media/media-query-list-01-expected.txt: Added.
* fast/media/media-query-list-01.html: Added.
The following tests depend on LayoutTestController::setViewModeMediaFeature() to work.
As it is only implemented by Qt and Gtk the tests needed to be skipped in all other platforms.
* fast/media/media-query-list-02-expected.txt: Added.
* fast/media/media-query-list-02.html: Added.
* fast/media/media-query-list-03-expected.txt: Added.
* fast/media/media-query-list-03.html: Added.
* fast/media/media-query-list-04-expected.txt: Added.
* fast/media/media-query-list-04.html: Added.
* fast/media/media-query-list-05-expected.txt: Added.
* fast/media/media-query-list-05.html: Added.
* fast/media/media-query-list-06-expected.txt: Added.
* fast/media/media-query-list-06.html: Added.
* fast/media/media-query-list-07-expected.txt: Added.
* fast/media/media-query-list-07.html: Added.
* platform/chromium/test_expectations.txt:
* platform/mac/Skipped:
* platform/win/Skipped:
2010-10-21 Luiz Agostini <luiz.agostini@openbossa.org>
Reviewed by Darin Adler.
Implement CSSOM View matchMedia interface
https://bugs.webkit.org/show_bug.cgi?id=37205
New interfaces may be used to evaluate media queries and to associate listeners
to media queries. Those listeners are called whenever the associated query changes.
Specification may be found at http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface
operator== added to JS version of ScriptValue.
Method isFunction added to JS and V8 versions of ScriptValue.
* bindings/js/ScriptValue.cpp:
(WebCore::ScriptValue::isFunction):
* bindings/js/ScriptValue.h:
(WebCore::ScriptValue::operator==):
* bindings/v8/ScriptValue.h:
(WebCore::ScriptValue::isFunction):
Some changes were needed to the code generators to handle type MediaQueryListListener.
* bindings/scripts/CodeGeneratorGObject.pm:
* bindings/scripts/CodeGeneratorJS.pm:
* bindings/scripts/CodeGeneratorV8.pm:
Some changes to the bindings test results that were previously added.
* bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp:
* bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h:
* bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
(WebCore::jsTestMediaQueryListListenerPrototypeFunctionMethod):
* bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
(WebCore::TestMediaQueryListListenerInternal::methodCallback):
(WebCore::ConfigureV8TestMediaQueryListListenerTemplate):
New interfaces:
* css/MediaQueryList.cpp: Added.
* css/MediaQueryList.h: Added.
* css/MediaQueryList.idl: Added.
* css/MediaQueryListListener.cpp: Added.
* css/MediaQueryListListener.h: Added.
* css/MediaQueryListListener.idl: Added.
To avoid adding code to classes DOMWindow and Document a new class MediaQueryMatcher was created.
* css/MediaQueryMatcher.cpp: Added.
* css/MediaQueryMatcher.h: Added.
Document and DOMWindow have changed to support new features. DOMWindow is the class that
publishes methods matchMedia but for page cache to work properly the reference to the
MediaQueryMatcher must be in Document.
* dom/Document.cpp:
(WebCore::Document::~Document):
(WebCore::Document::mediaQueryMatcher):
(WebCore::Document::styleSelectorChanged):
* dom/Document.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::matchMedia):
* page/DOMWindow.h:
* page/DOMWindow.idl:
Build systems
* CMakeLists.txt:
* DerivedSources.make:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pri:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/gobject/GNUmakefile.am:
Tests: fast/media/media-query-list-01.html
fast/media/media-query-list-02.html
fast/media/media-query-list-03.html
fast/media/media-query-list-04.html
fast/media/media-query-list-05.html
fast/media/media-query-list-06.html
fast/media/media-query-list-07.html
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72552 268f45cc-cd09-0410-ab3c-d52691b4dbfc
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>