Reviewed by Hyatt. Tweaked by Maciej. Tweaks reviewed by Beth.
Landed by Beth.
CSS3 Media Queries implementation.
<http://bugzilla.opendarwin.org/show_bug.cgi?id=4127>
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/kjs_css.cpp:
(KJS::DOMMediaList::put):
(KJS::KJS::DOMMediaListProtoFunc::callAsFunction):
* bindings/objc/DOMCSS.mm:
(-[DOMMediaList setMediaText:]):
(-[DOMMediaList deleteMedium:]):
(-[DOMMediaList appendMedium:]):
* css/CSSGrammar.y:
* css/MediaFeatureNames.cpp: Added.
(WebCore::MediaFeatureNames::init):
* css/MediaFeatureNames.h: Added.
* css/MediaList.cpp:
(WebCore::MediaList::MediaList):
(WebCore::MediaList::~MediaList):
(WebCore::parseMediaDescriptor):
(WebCore::MediaList::deleteMedium):
(WebCore::MediaList::mediaText):
(WebCore::MediaList::setMediaText):
(WebCore::MediaList::item):
(WebCore::MediaList::appendMedium):
(WebCore::MediaList::appendMediaQuery):
* css/MediaList.h:
(WebCore::MediaList::MediaList):
(WebCore::MediaList::length):
(WebCore::MediaList::mediaQueries):
* css/MediaQuery.cpp: Added.
(WebCore::MediaQuery::MediaQuery):
(WebCore::MediaQuery::~MediaQuery):
(WebCore::MediaQuery::operator==):
(WebCore::MediaQuery::cssText):
* css/MediaQuery.h: Added.
(WebCore::MediaQuery::):
(WebCore::MediaQuery::restrictor):
(WebCore::MediaQuery::expressions):
(WebCore::MediaQuery::mediaType):
(WebCore::MediaQuery::append):
* css/MediaQueryEvaluator.cpp: Added.
(WebCore::):
(WebCore::MediaQueryEvaluator):
(WebCore::MediaQueryEvaluator::~MediaQueryEvaluator):
(WebCore::MediaQueryEvaluator::mediaTypeMatch):
(WebCore::applyRestrictor):
(WebCore::MediaQueryEvaluator::eval):
(WebCore::parseAspectRatio):
(WebCore::cmpvalue):
(WebCore::numberValue):
(WebCore::colorMediaFeatureEval):
(WebCore::monochromeMediaFeatureEval):
(WebCore::device_aspect_ratioMediaFeatureEval):
(WebCore::gridMediaFeatureEval):
(WebCore::device_heightMediaFeatureEval):
(WebCore::device_widthMediaFeatureEval):
(WebCore::heightMediaFeatureEval):
(WebCore::widthMediaFeatureEval):
(WebCore::min_colorMediaFeatureEval):
(WebCore::max_colorMediaFeatureEval):
(WebCore::min_monochromeMediaFeatureEval):
(WebCore::max_monochromeMediaFeatureEval):
(WebCore::min_device_aspect_ratioMediaFeatureEval):
(WebCore::max_device_aspect_ratioMediaFeatureEval):
(WebCore::min_heightMediaFeatureEval):
(WebCore::max_heightMediaFeatureEval):
(WebCore::min_widthMediaFeatureEval):
(WebCore::max_widthMediaFeatureEval):
(WebCore::min_device_heightMediaFeatureEval):
(WebCore::max_device_heightMediaFeatureEval):
(WebCore::min_device_widthMediaFeatureEval):
(WebCore::max_device_widthMediaFeatureEval):
(WebCore::createFunctionMap):
* css/MediaQueryEvaluator.h: Added.
* css/MediaQueryExp.cpp: Added.
(WebCore::MediaQueryExp::MediaQueryExp):
(WebCore::MediaQueryExp::~MediaQueryExp):
* css/MediaQueryExp.h: Added.
(WebCore::MediaQueryExp::mediaFeature):
(WebCore::MediaQueryExp::value):
(WebCore::MediaQueryExp::operator==):
* css/StyleSheet.cpp:
(WebCore::StyleSheet::setMedia):
* css/cssparser.cpp:
(WebCore::CSSParser::CSSParser):
(WebCore::CSSParser::~CSSParser):
(WebCore::CSSParser::setupParser):
(WebCore::CSSParser::parseMediaQuery):
(WebCore::CSSParser::createFloatingMediaQueryExp):
(WebCore::CSSParser::sinkFloatingMediaQueryExp):
(WebCore::CSSParser::createFloatingMediaQueryExpList):
(WebCore::CSSParser::sinkFloatingMediaQueryExpList):
(WebCore::CSSParser::createFloatingMediaQuery):
(WebCore::CSSParser::sinkFloatingMediaQuery):
* css/cssparser.h:
* css/cssstyleselector.cpp:
(WebCore::CSSStyleSelector::CSSStyleSelector):
(WebCore::CSSStyleSelector::init):
(WebCore::CSSStyleSelector::~CSSStyleSelector):
(WebCore::CSSStyleSelector::loadDefaultStyle):
(WebCore::CSSStyleSelector::matchUARules):
(WebCore::CSSStyleSelector::styleForElement):
(WebCore::CSSStyleSelector::pseudoStyleForElement):
(WebCore::CSSStyleSelector::updateFont):
(WebCore::CSSStyleSelector::cacheBorderAndBackground):
(WebCore::CSSStyleSelector::styleRulesForElement):
(WebCore::CSSRuleSet::addRulesFromSheet):
* css/cssstyleselector.h:
* css/maketokenizer:
* css/tokenizer.flex:
* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createCSSStyleSheet):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
(WebCore::HTMLLinkElement::setStyleSheet):
* html/HTMLStyleElement.cpp:
(WebCore::HTMLStyleElement::childrenChanged):
* ksvg2/svg/SVGDOMImplementation.cpp:
(SVGDOMImplementation::createCSSStyleSheet):
* ksvg2/svg/SVGStyleElement.cpp:
(WebCore::SVGStyleElement::childrenChanged):
* page/Frame.cpp:
(WebCore::Frame::Frame):
* platform/Screen.h:
* platform/mac/ScreenMac.mm:
(WebCore::screenDepthPerComponent):
(WebCore::screenIsMonochrome):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@14779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 163ab2c..9f7e75b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,237 @@
+2006-06-09 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>
+
+ Reviewed by Hyatt.
+
+ Test cases for CSS3 Media Queries implementation.
+ <http://bugzilla.opendarwin.org/show_bug.cgi?id=4127>
+
+ * fast/media/import-p-green.css: Added.
+ * fast/media/import-p-red.css: Added.
+ * fast/media/media-descriptor-syntax-01-expected.checksum: Added.
+ * fast/media/media-descriptor-syntax-01-expected.png: Added.
+ * fast/media/media-descriptor-syntax-01-expected.txt: Added.
+ * fast/media/media-descriptor-syntax-01.html: Added.
+ * fast/media/media-descriptor-syntax-02-expected.checksum: Added.
+ * fast/media/media-descriptor-syntax-02-expected.png: Added.
+ * fast/media/media-descriptor-syntax-02-expected.txt: Added.
+ * fast/media/media-descriptor-syntax-02.html: Added.
+ * fast/media/media-descriptor-syntax-03-expected.checksum: Added.
+ * fast/media/media-descriptor-syntax-03-expected.png: Added.
+ * fast/media/media-descriptor-syntax-03-expected.txt: Added.
+ * fast/media/media-descriptor-syntax-03.html: Added.
+ * fast/media/media-descriptor-syntax-04-expected.checksum: Added.
+ * fast/media/media-descriptor-syntax-04-expected.png: Added.
+ * fast/media/media-descriptor-syntax-04-expected.txt: Added.
+ * fast/media/media-descriptor-syntax-04.html: Added.
+ * fast/media/media-descriptor-syntax-05-expected.checksum: Added.
+ * fast/media/media-descriptor-syntax-05-expected.png: Added.
+ * fast/media/media-descriptor-syntax-05-expected.txt: Added.
+ * fast/media/media-descriptor-syntax-05.html: Added.
+ * fast/media/media-descriptor-syntax-06-expected.checksum: Added.
+ * fast/media/media-descriptor-syntax-06-expected.png: Added.
+ * fast/media/media-descriptor-syntax-06-expected.txt: Added.
+ * fast/media/media-descriptor-syntax-06.html: Added.
+ * fast/media/media-type-syntax-01-expected.checksum: Added.
+ * fast/media/media-type-syntax-01-expected.png: Added.
+ * fast/media/media-type-syntax-01-expected.txt: Added.
+ * fast/media/media-type-syntax-01.html: Added.
+ * fast/media/media-type-syntax-02-expected.checksum: Added.
+ * fast/media/media-type-syntax-02-expected.png: Added.
+ * fast/media/media-type-syntax-02-expected.txt: Added.
+ * fast/media/media-type-syntax-02.html: Added.
+ * fast/media/mq-compound-query-01-expected.checksum: Added.
+ * fast/media/mq-compound-query-01-expected.png: Added.
+ * fast/media/mq-compound-query-01-expected.txt: Added.
+ * fast/media/mq-compound-query-01.html: Added.
+ * fast/media/mq-compound-query-02-expected.checksum: Added.
+ * fast/media/mq-compound-query-02-expected.png: Added.
+ * fast/media/mq-compound-query-02-expected.txt: Added.
+ * fast/media/mq-compound-query-02.html: Added.
+ * fast/media/mq-compound-query-03-expected.checksum: Added.
+ * fast/media/mq-compound-query-03-expected.png: Added.
+ * fast/media/mq-compound-query-03-expected.txt: Added.
+ * fast/media/mq-compound-query-03.html: Added.
+ * fast/media/mq-compound-query-04-expected.checksum: Added.
+ * fast/media/mq-compound-query-04-expected.png: Added.
+ * fast/media/mq-compound-query-04-expected.txt: Added.
+ * fast/media/mq-compound-query-04.html: Added.
+ * fast/media/mq-compound-query-05-expected.checksum: Added.
+ * fast/media/mq-compound-query-05-expected.png: Added.
+ * fast/media/mq-compound-query-05-expected.txt: Added.
+ * fast/media/mq-compound-query-05.html: Added.
+ * fast/media/mq-grid-01-expected.checksum: Added.
+ * fast/media/mq-grid-01-expected.png: Added.
+ * fast/media/mq-grid-01-expected.txt: Added.
+ * fast/media/mq-grid-01.html: Added.
+ * fast/media/mq-grid-02-expected.checksum: Added.
+ * fast/media/mq-grid-02-expected.png: Added.
+ * fast/media/mq-grid-02-expected.txt: Added.
+ * fast/media/mq-grid-02.html: Added.
+ * fast/media/mq-invalid-media-feature-01-expected.checksum: Added.
+ * fast/media/mq-invalid-media-feature-01-expected.png: Added.
+ * fast/media/mq-invalid-media-feature-01-expected.txt: Added.
+ * fast/media/mq-invalid-media-feature-01.html: Added.
+ * fast/media/mq-invalid-media-feature-02-expected.checksum: Added.
+ * fast/media/mq-invalid-media-feature-02-expected.png: Added.
+ * fast/media/mq-invalid-media-feature-02-expected.txt: Added.
+ * fast/media/mq-invalid-media-feature-02.html: Added.
+ * fast/media/mq-invalid-media-feature-03-expected.checksum: Added.
+ * fast/media/mq-invalid-media-feature-03-expected.png: Added.
+ * fast/media/mq-invalid-media-feature-03-expected.txt: Added.
+ * fast/media/mq-invalid-media-feature-03.html: Added.
+ * fast/media/mq-invalid-media-feature-04-expected.checksum: Added.
+ * fast/media/mq-invalid-media-feature-04-expected.png: Added.
+ * fast/media/mq-invalid-media-feature-04-expected.txt: Added.
+ * fast/media/mq-invalid-media-feature-04.html: Added.
+ * fast/media/mq-invalid-syntax-01-expected.checksum: Added.
+ * fast/media/mq-invalid-syntax-01-expected.png: Added.
+ * fast/media/mq-invalid-syntax-01-expected.txt: Added.
+ * fast/media/mq-invalid-syntax-01.html: Added.
+ * fast/media/mq-invalid-syntax-02-expected.checksum: Added.
+ * fast/media/mq-invalid-syntax-02-expected.png: Added.
+ * fast/media/mq-invalid-syntax-02-expected.txt: Added.
+ * fast/media/mq-invalid-syntax-02.html: Added.
+ * fast/media/mq-invalid-syntax-03-expected.checksum: Added.
+ * fast/media/mq-invalid-syntax-03-expected.png: Added.
+ * fast/media/mq-invalid-syntax-03-expected.txt: Added.
+ * fast/media/mq-invalid-syntax-03.html: Added.
+ * fast/media/mq-invalid-syntax-04-expected.checksum: Added.
+ * fast/media/mq-invalid-syntax-04-expected.png: Added.
+ * fast/media/mq-invalid-syntax-04-expected.txt: Added.
+ * fast/media/mq-invalid-syntax-04.html: Added.
+ * fast/media/mq-invalid-syntax-05-expected.checksum: Added.
+ * fast/media/mq-invalid-syntax-05-expected.png: Added.
+ * fast/media/mq-invalid-syntax-05-expected.txt: Added.
+ * fast/media/mq-invalid-syntax-05.html: Added.
+ * fast/media/mq-js-media-except-01-expected.checksum: Added.
+ * fast/media/mq-js-media-except-01-expected.png: Added.
+ * fast/media/mq-js-media-except-01-expected.txt: Added.
+ * fast/media/mq-js-media-except-01.html: Added.
+ * fast/media/mq-js-media-except-02-expected.checksum: Added.
+ * fast/media/mq-js-media-except-02-expected.png: Added.
+ * fast/media/mq-js-media-except-02-expected.txt: Added.
+ * fast/media/mq-js-media-except-02.html: Added.
+ * fast/media/mq-js-media-except-03-expected.checksum: Added.
+ * fast/media/mq-js-media-except-03-expected.png: Added.
+ * fast/media/mq-js-media-except-03-expected.txt: Added.
+ * fast/media/mq-js-media-except-03.html: Added.
+ * fast/media/mq-js-media-forward-syntax-expected.checksum: Added.
+ * fast/media/mq-js-media-forward-syntax-expected.png: Added.
+ * fast/media/mq-js-media-forward-syntax-expected.txt: Added.
+ * fast/media/mq-js-media-forward-syntax.html: Added.
+ * fast/media/mq-js-stylesheet-media-01-expected.checksum: Added.
+ * fast/media/mq-js-stylesheet-media-01-expected.png: Added.
+ * fast/media/mq-js-stylesheet-media-01-expected.txt: Added.
+ * fast/media/mq-js-stylesheet-media-01.html: Added.
+ * fast/media/mq-js-stylesheet-media-02-expected.checksum: Added.
+ * fast/media/mq-js-stylesheet-media-02-expected.png: Added.
+ * fast/media/mq-js-stylesheet-media-02-expected.txt: Added.
+ * fast/media/mq-js-stylesheet-media-02.html: Added.
+ * fast/media/mq-js-stylesheet-media-03-expected.checksum: Added.
+ * fast/media/mq-js-stylesheet-media-03-expected.png: Added.
+ * fast/media/mq-js-stylesheet-media-03-expected.txt: Added.
+ * fast/media/mq-js-stylesheet-media-03.html: Added.
+ * fast/media/mq-js-stylesheet-media-04-expected.checksum: Added.
+ * fast/media/mq-js-stylesheet-media-04-expected.png: Added.
+ * fast/media/mq-js-stylesheet-media-04-expected.txt: Added.
+ * fast/media/mq-js-stylesheet-media-04.html: Added.
+ * fast/media/mq-min-constraint-expected.checksum: Added.
+ * fast/media/mq-min-constraint-expected.png: Added.
+ * fast/media/mq-min-constraint-expected.txt: Added.
+ * fast/media/mq-min-constraint.html: Added.
+ * fast/media/mq-relative-constraints-02-expected.checksum: Added.
+ * fast/media/mq-relative-constraints-02-expected.png: Added.
+ * fast/media/mq-relative-constraints-02-expected.txt: Added.
+ * fast/media/mq-relative-constraints-02.html: Added.
+ * fast/media/mq-relative-constraints-03-expected.checksum: Added.
+ * fast/media/mq-relative-constraints-03-expected.png: Added.
+ * fast/media/mq-relative-constraints-03-expected.txt: Added.
+ * fast/media/mq-relative-constraints-03.html: Added.
+ * fast/media/mq-relative-constraints-04-expected.checksum: Added.
+ * fast/media/mq-relative-constraints-04-expected.png: Added.
+ * fast/media/mq-relative-constraints-04-expected.txt: Added.
+ * fast/media/mq-relative-constraints-04.html: Added.
+ * fast/media/mq-relative-constraints-05-expected.checksum: Added.
+ * fast/media/mq-relative-constraints-05-expected.png: Added.
+ * fast/media/mq-relative-constraints-05-expected.txt: Added.
+ * fast/media/mq-relative-constraints-05.html: Added.
+ * fast/media/mq-relative-constraints-06-expected.checksum: Added.
+ * fast/media/mq-relative-constraints-06-expected.png: Added.
+ * fast/media/mq-relative-constraints-06-expected.txt: Added.
+ * fast/media/mq-relative-constraints-06.html: Added.
+ * fast/media/mq-relative-constraints-07-expected.checksum: Added.
+ * fast/media/mq-relative-constraints-07-expected.png: Added.
+ * fast/media/mq-relative-constraints-07-expected.txt: Added.
+ * fast/media/mq-relative-constraints-07.html: Added.
+ * fast/media/mq-relative-constraints-08-expected.checksum: Added.
+ * fast/media/mq-relative-constraints-08-expected.png: Added.
+ * fast/media/mq-relative-constraints-08-expected.txt: Added.
+ * fast/media/mq-relative-constraints-08.html: Added.
+ * fast/media/mq-relative-constraints-09-expected.checksum: Added.
+ * fast/media/mq-relative-constraints-09-expected.png: Added.
+ * fast/media/mq-relative-constraints-09-expected.txt: Added.
+ * fast/media/mq-relative-constraints-09.html: Added.
+ * fast/media/mq-simple-neg-query-01-expected.checksum: Added.
+ * fast/media/mq-simple-neg-query-01-expected.png: Added.
+ * fast/media/mq-simple-neg-query-01-expected.txt: Added.
+ * fast/media/mq-simple-neg-query-01.html: Added.
+ * fast/media/mq-simple-neg-query-02-expected.checksum: Added.
+ * fast/media/mq-simple-neg-query-02-expected.png: Added.
+ * fast/media/mq-simple-neg-query-02-expected.txt: Added.
+ * fast/media/mq-simple-neg-query-02.html: Added.
+ * fast/media/mq-simple-neg-query-03-expected.checksum: Added.
+ * fast/media/mq-simple-neg-query-03-expected.png: Added.
+ * fast/media/mq-simple-neg-query-03-expected.txt: Added.
+ * fast/media/mq-simple-neg-query-03.html: Added.
+ * fast/media/mq-simple-neg-query-04-expected.checksum: Added.
+ * fast/media/mq-simple-neg-query-04-expected.png: Added.
+ * fast/media/mq-simple-neg-query-04-expected.txt: Added.
+ * fast/media/mq-simple-neg-query-04.html: Added.
+ * fast/media/mq-simple-neg-query-05-expected.checksum: Added.
+ * fast/media/mq-simple-neg-query-05-expected.png: Added.
+ * fast/media/mq-simple-neg-query-05-expected.txt: Added.
+ * fast/media/mq-simple-neg-query-05.html: Added.
+ * fast/media/mq-simple-query-01-expected.checksum: Added.
+ * fast/media/mq-simple-query-01-expected.png: Added.
+ * fast/media/mq-simple-query-01-expected.txt: Added.
+ * fast/media/mq-simple-query-01.html: Added.
+ * fast/media/mq-simple-query-02-expected.checksum: Added.
+ * fast/media/mq-simple-query-02-expected.png: Added.
+ * fast/media/mq-simple-query-02-expected.txt: Added.
+ * fast/media/mq-simple-query-02.html: Added.
+ * fast/media/mq-simple-query-03-expected.checksum: Added.
+ * fast/media/mq-simple-query-03-expected.png: Added.
+ * fast/media/mq-simple-query-03-expected.txt: Added.
+ * fast/media/mq-simple-query-03.html: Added.
+ * fast/media/mq-simple-query-04-expected.checksum: Added.
+ * fast/media/mq-simple-query-04-expected.png: Added.
+ * fast/media/mq-simple-query-04-expected.txt: Added.
+ * fast/media/mq-simple-query-04.html: Added.
+ * fast/media/mq-simple-query-05-expected.checksum: Added.
+ * fast/media/mq-simple-query-05-expected.png: Added.
+ * fast/media/mq-simple-query-05-expected.txt: Added.
+ * fast/media/mq-simple-query-05.html: Added.
+ * fast/media/mq-valueless-expected.checksum: Added.
+ * fast/media/mq-valueless-expected.png: Added.
+ * fast/media/mq-valueless-expected.txt: Added.
+ * fast/media/mq-valueless.html: Added.
+ * fast/media/mq-width-absolute-01-expected.checksum: Added.
+ * fast/media/mq-width-absolute-01-expected.png: Added.
+ * fast/media/mq-width-absolute-01-expected.txt: Added.
+ * fast/media/mq-width-absolute-01.html: Added.
+ * fast/media/mq-width-absolute-02-expected.checksum: Added.
+ * fast/media/mq-width-absolute-02-expected.png: Added.
+ * fast/media/mq-width-absolute-02-expected.txt: Added.
+ * fast/media/mq-width-absolute-02.html: Added.
+ * fast/media/mq-width-absolute-03-expected.checksum: Added.
+ * fast/media/mq-width-absolute-03-expected.png: Added.
+ * fast/media/mq-width-absolute-03-expected.txt: Added.
+ * fast/media/mq-width-absolute-03.html: Added.
+ * fast/media/mq-width-absolute-04-expected.checksum: Added.
+ * fast/media/mq-width-absolute-04-expected.png: Added.
+ * fast/media/mq-width-absolute-04-expected.txt: Added.
+ * fast/media/mq-width-absolute-04.html: Added.
+
2006-06-08 Justin Garcia <justin.garcia@apple.com>
Reviewed by levi
diff --git a/LayoutTests/fast/media/import-p-green.css b/LayoutTests/fast/media/import-p-green.css
new file mode 100644
index 0000000..131ad93
--- /dev/null
+++ b/LayoutTests/fast/media/import-p-green.css
@@ -0,0 +1 @@
+p { color: green }
diff --git a/LayoutTests/fast/media/import-p-red.css b/LayoutTests/fast/media/import-p-red.css
new file mode 100644
index 0000000..e8b0e11
--- /dev/null
+++ b/LayoutTests/fast/media/import-p-red.css
@@ -0,0 +1,2 @@
+p { color: red }
+\ No newline at end of file
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-01-expected.checksum b/LayoutTests/fast/media/media-descriptor-syntax-01-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-01-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-01-expected.png b/LayoutTests/fast/media/media-descriptor-syntax-01-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-01-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-01-expected.txt b/LayoutTests/fast/media/media-descriptor-syntax-01-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-01-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-01.html b/LayoutTests/fast/media/media-descriptor-syntax-01.html
new file mode 100644
index 0000000..3c5ca9f
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-01.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title>HTML4 media descriptors test: parsing style element media attribute, forward-compatible syntax</title>
+<link rel="help" href="http://www.w3.org/TR/REC-html40/types.html#h-6.13" />
+
+<style type="text/css" media="3d-glasses, screen and resolution > 40dpi, braille">
+p { color: green }
+</style>
+
+</head>
+<body>
+</body>
+<p> This text should be green. </p>
+</html>
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-02-expected.checksum b/LayoutTests/fast/media/media-descriptor-syntax-02-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-02-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-02-expected.png b/LayoutTests/fast/media/media-descriptor-syntax-02-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-02-expected.txt b/LayoutTests/fast/media/media-descriptor-syntax-02-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-02-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-02.html b/LayoutTests/fast/media/media-descriptor-syntax-02.html
new file mode 100644
index 0000000..d3cb208
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-02.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>HTML4 media descriptor test: parsing style element media attribute, forward-compatible syntax</title>
+<link rel="help" href="http://www.w3.org/TR/REC-html40/types.html#h-6.13" />
+<!-- actual testcase from http://www.hixie.ch/tests/evil/css/import/extra/styleexoticmedia.html -->
+
+<style type="text/css" media="screen;braille">
+p { color: green }
+</style>
+
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-03-expected.checksum b/LayoutTests/fast/media/media-descriptor-syntax-03-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-03-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-03-expected.png b/LayoutTests/fast/media/media-descriptor-syntax-03-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-03-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-03-expected.txt b/LayoutTests/fast/media/media-descriptor-syntax-03-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-03-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-03.html b/LayoutTests/fast/media/media-descriptor-syntax-03.html
new file mode 100644
index 0000000..c503521
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-03.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title>HTML4 media descriptor test: parsing style element media attribute, forward-compatible syntax</title>
+<link rel="help" href="http://www.w3.org/TR/REC-html40/types.html#h-6.13" />
+<!-- actual testcase from http://www.hixie.ch/tests/evil/css/import/extra/styleexoticmedia.html -->
+<style type="text/css" media="braille, all with print">
+p { color: green }
+</style>
+
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-04-expected.checksum b/LayoutTests/fast/media/media-descriptor-syntax-04-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-04-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-04-expected.png b/LayoutTests/fast/media/media-descriptor-syntax-04-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-04-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-04-expected.txt b/LayoutTests/fast/media/media-descriptor-syntax-04-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-04-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-04.html b/LayoutTests/fast/media/media-descriptor-syntax-04.html
new file mode 100644
index 0000000..bd22795
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-04.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<title>HTML4 media descriptor test: parsing style element media attribute, forward-compatible syntax</title>
+<link rel="help" href="http://www.w3.org/TR/REC-html40/types.html#h-6.13" />
+<style type="text/css" media=",,,,">
+p { color: green }
+</style>
+
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-05-expected.checksum b/LayoutTests/fast/media/media-descriptor-syntax-05-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-05-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-05-expected.png b/LayoutTests/fast/media/media-descriptor-syntax-05-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-05-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-05-expected.txt b/LayoutTests/fast/media/media-descriptor-syntax-05-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-05-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-05.html b/LayoutTests/fast/media/media-descriptor-syntax-05.html
new file mode 100644
index 0000000..805fa23
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-05.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<title>HTML4 media descriptor test: parsing style element media attribute, forward-compatible syntax</title>
+<link rel="help" href="http://www.w3.org/TR/REC-html40/types.html#h-6.13" />
+<style type="text/css" media="*****|{}- |[|">
+p { color: green }
+</style>
+
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-06-expected.checksum b/LayoutTests/fast/media/media-descriptor-syntax-06-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-06-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-06-expected.png b/LayoutTests/fast/media/media-descriptor-syntax-06-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-06-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-06-expected.txt b/LayoutTests/fast/media/media-descriptor-syntax-06-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-06-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/media-descriptor-syntax-06.html b/LayoutTests/fast/media/media-descriptor-syntax-06.html
new file mode 100644
index 0000000..ffcc4bc
--- /dev/null
+++ b/LayoutTests/fast/media/media-descriptor-syntax-06.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<title>HTML4 media descriptor test: parsing style element media attribute, forward-compatible syntax</title>
+<link rel="help" href="http://www.w3.org/TR/REC-html40/types.html#h-6.13" />
+<style type="text/css" media=" ">
+p { color: green }
+</style>
+
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/media-type-syntax-01-expected.checksum b/LayoutTests/fast/media/media-type-syntax-01-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/media-type-syntax-01-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/media-type-syntax-01-expected.png b/LayoutTests/fast/media/media-type-syntax-01-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/media-type-syntax-01-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/media-type-syntax-01-expected.txt b/LayoutTests/fast/media/media-type-syntax-01-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/media-type-syntax-01-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/media-type-syntax-01.html b/LayoutTests/fast/media/media-type-syntax-01.html
new file mode 100644
index 0000000..940cffb
--- /dev/null
+++ b/LayoutTests/fast/media/media-type-syntax-01.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title>CSS2.1 media type test: parsing simple @media css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/REC-html40/types.html#h-6.13" />
+
+<style type="text/css">
+@media all { p { color: green } }
+</style>
+
+</head>
+<body>
+</body>
+<p> This text should be green. </p>
+</html>
diff --git a/LayoutTests/fast/media/media-type-syntax-02-expected.checksum b/LayoutTests/fast/media/media-type-syntax-02-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/media-type-syntax-02-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/media-type-syntax-02-expected.png b/LayoutTests/fast/media/media-type-syntax-02-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/media-type-syntax-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/media-type-syntax-02-expected.txt b/LayoutTests/fast/media/media-type-syntax-02-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/media-type-syntax-02-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/media-type-syntax-02.html b/LayoutTests/fast/media/media-type-syntax-02.html
new file mode 100644
index 0000000..6d81bb4
--- /dev/null
+++ b/LayoutTests/fast/media/media-type-syntax-02.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>CSS2.1 media type test: parsing simple @media css rule. Media type ,,,, should be considered as invalid syntax</title>
+<link rel="help" href="http://www.w3.org/TR/REC-html40/types.html#h-6.13" />
+
+<style type="text/css">
+p { color: green }
+@media ,,,,, { p { color: red } }
+</style>
+
+</head>
+<body>
+</body>
+<p> This text should be green. </p>
+</html>
diff --git a/LayoutTests/fast/media/mq-compound-query-01-expected.checksum b/LayoutTests/fast/media/mq-compound-query-01-expected.checksum
new file mode 100644
index 0000000..551aced
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-01-expected.checksum
@@ -0,0 +1 @@
+7499a40172304d162bb6dbf0ac77e8dd
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-compound-query-01-expected.png b/LayoutTests/fast/media/mq-compound-query-01-expected.png
new file mode 100644
index 0000000..15d3031
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-01-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-compound-query-01-expected.txt b/LayoutTests/fast/media/mq-compound-query-01-expected.txt
new file mode 100644
index 0000000..0266729
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-01-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 317x18
+ text run at (0,0) width 317: "This text should be green on bitmap color devices."
diff --git a/LayoutTests/fast/media/mq-compound-query-01.html b/LayoutTests/fast/media/mq-compound-query-01.html
new file mode 100644
index 0000000..4867acb
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-01.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<title>CSS3 media query test: media query testing compound queries (screen and (color) and (grid:0)). Using style element, media attribute.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<style type="text/css" media="screen and (color) and (grid:0)">
+p { color: green }
+</style>
+
+</head>
+<body>
+<p> This text should be green on bitmap color devices.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-compound-query-02-expected.checksum b/LayoutTests/fast/media/mq-compound-query-02-expected.checksum
new file mode 100644
index 0000000..551aced
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-02-expected.checksum
@@ -0,0 +1 @@
+7499a40172304d162bb6dbf0ac77e8dd
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-compound-query-02-expected.png b/LayoutTests/fast/media/mq-compound-query-02-expected.png
new file mode 100644
index 0000000..15d3031
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-compound-query-02-expected.txt b/LayoutTests/fast/media/mq-compound-query-02-expected.txt
new file mode 100644
index 0000000..0266729
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-02-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 317x18
+ text run at (0,0) width 317: "This text should be green on bitmap color devices."
diff --git a/LayoutTests/fast/media/mq-compound-query-02.html b/LayoutTests/fast/media/mq-compound-query-02.html
new file mode 100644
index 0000000..9d019dd
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-02.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+<title>CSS3 media query test: media query testing compound queries (screen and (color) and (grid:0)). Using link element, media attribute</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<link rel="stylesheet" type="text/css" media="screen and (color) and (grid:0)" href="import-p-green.css" />
+</head>
+<body>
+<p> This text should be green on bitmap color devices.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-compound-query-03-expected.checksum b/LayoutTests/fast/media/mq-compound-query-03-expected.checksum
new file mode 100644
index 0000000..551aced
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-03-expected.checksum
@@ -0,0 +1 @@
+7499a40172304d162bb6dbf0ac77e8dd
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-compound-query-03-expected.png b/LayoutTests/fast/media/mq-compound-query-03-expected.png
new file mode 100644
index 0000000..15d3031
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-03-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-compound-query-03-expected.txt b/LayoutTests/fast/media/mq-compound-query-03-expected.txt
new file mode 100644
index 0000000..0266729
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-03-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 317x18
+ text run at (0,0) width 317: "This text should be green on bitmap color devices."
diff --git a/LayoutTests/fast/media/mq-compound-query-03.html b/LayoutTests/fast/media/mq-compound-query-03.html
new file mode 100644
index 0000000..83b1734
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-03.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<title>CSS3 media query test: media query testing compound queries (screen and (color) and (grid:0)). Using style element, css @import rule</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<style type="text/css" >
+@import url(import-p-green.css) screen and (color) and (grid:0);
+</style>
+
+</head>
+<body>
+<p> This text should be green on bitmap color devices.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-compound-query-04-expected.checksum b/LayoutTests/fast/media/mq-compound-query-04-expected.checksum
new file mode 100644
index 0000000..551aced
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-04-expected.checksum
@@ -0,0 +1 @@
+7499a40172304d162bb6dbf0ac77e8dd
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-compound-query-04-expected.png b/LayoutTests/fast/media/mq-compound-query-04-expected.png
new file mode 100644
index 0000000..15d3031
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-04-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-compound-query-04-expected.txt b/LayoutTests/fast/media/mq-compound-query-04-expected.txt
new file mode 100644
index 0000000..0266729
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-04-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 317x18
+ text run at (0,0) width 317: "This text should be green on bitmap color devices."
diff --git a/LayoutTests/fast/media/mq-compound-query-04.html b/LayoutTests/fast/media/mq-compound-query-04.html
new file mode 100644
index 0000000..1c6eb62
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-04.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>CSS3 media query test: media query testing compound queries (screen and (color) and (grid:0)). Using style element, css @media rule</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<style type="text/css">
+@media screen and (color) and (grid:0) {
+p { color: green }
+}
+</style>
+
+</head>
+<body>
+<p> This text should be green on bitmap color devices.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-compound-query-05-expected.checksum b/LayoutTests/fast/media/mq-compound-query-05-expected.checksum
new file mode 100644
index 0000000..54d2303
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-05-expected.checksum
@@ -0,0 +1 @@
+05a863a321f32f15ca96f0b745ab6823
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-compound-query-05-expected.png b/LayoutTests/fast/media/mq-compound-query-05-expected.png
new file mode 100644
index 0000000..821360d
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-05-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-compound-query-05-expected.txt b/LayoutTests/fast/media/mq-compound-query-05-expected.txt
new file mode 100644
index 0000000..f4f32bc
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-05-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 399x18
+ text run at (0,0) width 399: "This text should be green if viewport is at most 800px x 600px."
diff --git a/LayoutTests/fast/media/mq-compound-query-05.html b/LayoutTests/fast/media/mq-compound-query-05.html
new file mode 100644
index 0000000..376e7e3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-compound-query-05.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>CSS3 media query test: Compound media query, absolute values (screen and (max-width: 800px) and (max-height:600px)). Using style element, @media css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+
+<style type="text/css">
+@media screen and (max-width: 800px) and (max-height:600px){
+p { color: green }
+}
+</style>
+</head>
+<body>
+<p> This text should be green if viewport is at most 800px x 600px.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-grid-01-expected.checksum b/LayoutTests/fast/media/mq-grid-01-expected.checksum
new file mode 100644
index 0000000..710b1d2
--- /dev/null
+++ b/LayoutTests/fast/media/mq-grid-01-expected.checksum
@@ -0,0 +1 @@
+1c11b6a1285dfb1dad48634108141ce9
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-grid-01-expected.png b/LayoutTests/fast/media/mq-grid-01-expected.png
new file mode 100644
index 0000000..8ae8bb2
--- /dev/null
+++ b/LayoutTests/fast/media/mq-grid-01-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-grid-01-expected.txt b/LayoutTests/fast/media/mq-grid-01-expected.txt
new file mode 100644
index 0000000..fcb7ae3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-grid-01-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 378x18
+ text run at (0,0) width 378: "This text should be green if viewing device is bitmap device"
diff --git a/LayoutTests/fast/media/mq-grid-01.html b/LayoutTests/fast/media/mq-grid-01.html
new file mode 100644
index 0000000..d6a4884
--- /dev/null
+++ b/LayoutTests/fast/media/mq-grid-01.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>CSS3 media query test: Media query testing value of grid (screen and grid:0). Using style attribute, @media css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<style type="text/css">
+@media screen and (grid: 0) {
+p { color: green }
+}
+</style>
+</head>
+<body>
+<p> This text should be green if viewing device is bitmap device</p>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/media/mq-grid-02-expected.checksum b/LayoutTests/fast/media/mq-grid-02-expected.checksum
new file mode 100644
index 0000000..66c0eb6
--- /dev/null
+++ b/LayoutTests/fast/media/mq-grid-02-expected.checksum
@@ -0,0 +1 @@
+364923683606083e6728dc6edcf76f89
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-grid-02-expected.png b/LayoutTests/fast/media/mq-grid-02-expected.png
new file mode 100644
index 0000000..ffef682
--- /dev/null
+++ b/LayoutTests/fast/media/mq-grid-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-grid-02-expected.txt b/LayoutTests/fast/media/mq-grid-02-expected.txt
new file mode 100644
index 0000000..6134912
--- /dev/null
+++ b/LayoutTests/fast/media/mq-grid-02-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 399x18
+ text run at (0,0) width 399: "This text should be green if viewing device is not a grid device."
diff --git a/LayoutTests/fast/media/mq-grid-02.html b/LayoutTests/fast/media/mq-grid-02.html
new file mode 100644
index 0000000..6590b4e
--- /dev/null
+++ b/LayoutTests/fast/media/mq-grid-02.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title>CSS3 media query test: media query testing not and parameterless feature (not screen and (grid)). Using style element, @media css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#grid" />
+<style type="text/css">
+@media not screen and (grid) {
+p { color: green }
+}
+</style>
+</head>
+<body>
+<p> This text should be green if viewing device is not a grid device.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-01-expected.checksum b/LayoutTests/fast/media/mq-invalid-media-feature-01-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-01-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-01-expected.png b/LayoutTests/fast/media/mq-invalid-media-feature-01-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-01-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-01-expected.txt b/LayoutTests/fast/media/mq-invalid-media-feature-01-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-01-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-01.html b/LayoutTests/fast/media/mq-invalid-media-feature-01.html
new file mode 100644
index 0000000..007523c
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-01.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>CSS3 media query test: syntactically correct query with invalid media feature should eval false (all and (invalid)). Using style element, media attribute.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<style type="text/css">
+p { color: green }
+</style>
+<style type="text/css" media="all and (invalid)">
+p { color: red }
+</style>
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-02-expected.checksum b/LayoutTests/fast/media/mq-invalid-media-feature-02-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-02-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-02-expected.png b/LayoutTests/fast/media/mq-invalid-media-feature-02-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-02-expected.txt b/LayoutTests/fast/media/mq-invalid-media-feature-02-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-02-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-02.html b/LayoutTests/fast/media/mq-invalid-media-feature-02.html
new file mode 100644
index 0000000..f8467b8
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-02.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<title>CSS3 media query test: syntactically correct query with invalid media feature should eval false (all and (invalid)). Using link element, media attribute.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<style type="text/css">
+p { color: green }
+</style>
+<link rel="stylesheet" type="text/css" media="all and (invalid)" href="import-p-red.css" />
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-03-expected.checksum b/LayoutTests/fast/media/mq-invalid-media-feature-03-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-03-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-03-expected.png b/LayoutTests/fast/media/mq-invalid-media-feature-03-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-03-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-03-expected.txt b/LayoutTests/fast/media/mq-invalid-media-feature-03-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-03-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-03.html b/LayoutTests/fast/media/mq-invalid-media-feature-03.html
new file mode 100644
index 0000000..4781a05
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-03.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>CSS3 media query test: syntactically correct query with invalid media feature should eval false (all and (invalid)). Using style element, css import rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<style type="text/css">
+p { color: green }
+</style>
+<style type="text/css">
+@import url(import-p-red.css) all and (invalid);
+</style>
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-04-expected.checksum b/LayoutTests/fast/media/mq-invalid-media-feature-04-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-04-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-04-expected.png b/LayoutTests/fast/media/mq-invalid-media-feature-04-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-04-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-04-expected.txt b/LayoutTests/fast/media/mq-invalid-media-feature-04-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-04-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-invalid-media-feature-04.html b/LayoutTests/fast/media/mq-invalid-media-feature-04.html
new file mode 100644
index 0000000..05c9d47
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-media-feature-04.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>CSS3 media query test: syntactically correct query with invalid media feature should eval false (all and (invalid)). Using style element, css media rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<style type="text/css">
+p { color: green }
+@media all and (invalid) {
+p { color: red }
+}
+</style>
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-01-expected.checksum b/LayoutTests/fast/media/mq-invalid-syntax-01-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-01-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-01-expected.png b/LayoutTests/fast/media/mq-invalid-syntax-01-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-01-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-01-expected.txt b/LayoutTests/fast/media/mq-invalid-syntax-01-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-01-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-01.html b/LayoutTests/fast/media/mq-invalid-syntax-01.html
new file mode 100644
index 0000000..9baddbf
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-01.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title>CSS3 media query test: syntactically invalid media query inside html element should be treated as html media descriptor. Using style element, media attribute.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+
+<style type="text/css" media="all and invalid">
+p { color: green }
+</style>
+
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-02-expected.checksum b/LayoutTests/fast/media/mq-invalid-syntax-02-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-02-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-02-expected.png b/LayoutTests/fast/media/mq-invalid-syntax-02-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-02-expected.txt b/LayoutTests/fast/media/mq-invalid-syntax-02-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-02-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-02.html b/LayoutTests/fast/media/mq-invalid-syntax-02.html
new file mode 100644
index 0000000..69a9b34
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-02.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+<title>CSS3 media query test: syntactically invalid media query inside html element should be treated as media descriptor. Using link element, media attribute.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+
+<link rel="stylesheet" type="text/css" media="all and invalid" href="import-p-green.css" />
+
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-03-expected.checksum b/LayoutTests/fast/media/mq-invalid-syntax-03-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-03-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-03-expected.png b/LayoutTests/fast/media/mq-invalid-syntax-03-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-03-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-03-expected.txt b/LayoutTests/fast/media/mq-invalid-syntax-03-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-03-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-03.html b/LayoutTests/fast/media/mq-invalid-syntax-03.html
new file mode 100644
index 0000000..0c34d5b
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-03.html
@@ -0,0 +1,16 @@
+<html>
+<head>
+<title>CSS3 media query test: syntactically invalid media query inside css rule should eval to false. Using style element, css import rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<style type="text/css">
+p { color: green }
+</style>
+<style type="text/css">
+@import url(import-p-red.css) all and invalid;
+</style>
+
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-04-expected.checksum b/LayoutTests/fast/media/mq-invalid-syntax-04-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-04-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-04-expected.png b/LayoutTests/fast/media/mq-invalid-syntax-04-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-04-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-04-expected.txt b/LayoutTests/fast/media/mq-invalid-syntax-04-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-04-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-04.html b/LayoutTests/fast/media/mq-invalid-syntax-04.html
new file mode 100644
index 0000000..a5e608c
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-04.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>CSS3 media query test: syntactically invalid media query inside css rule should eval to false. Using style element, css media rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<style type="text/css">
+p { color: green }
+@media all and invalid {
+p { color: red }
+}
+</style>
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-05-expected.checksum b/LayoutTests/fast/media/mq-invalid-syntax-05-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-05-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-05-expected.png b/LayoutTests/fast/media/mq-invalid-syntax-05-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-05-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-05-expected.txt b/LayoutTests/fast/media/mq-invalid-syntax-05-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-05-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-invalid-syntax-05.html b/LayoutTests/fast/media/mq-invalid-syntax-05.html
new file mode 100644
index 0000000..bd5db84
--- /dev/null
+++ b/LayoutTests/fast/media/mq-invalid-syntax-05.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>CSS3 media query test: syntactically invalid media query inside css rule should eval to false (,,,,). Using style element, css import rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<!-- this test shows slight disconnect between css media queries and html4 media descriptors -->
+<style type="text/css" media=",,,,,,">
+p { color: green }
+</styl>
+<style type="text/css">
+@import url(import-p-red.css) all,,,,,,;
+
+</style>
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-js-media-except-01-expected.checksum b/LayoutTests/fast/media/mq-js-media-except-01-expected.checksum
new file mode 100644
index 0000000..7534215
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-01-expected.checksum
@@ -0,0 +1 @@
+9d59e88369e0bb024dff565dca8552d4
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-js-media-except-01-expected.png b/LayoutTests/fast/media/mq-js-media-except-01-expected.png
new file mode 100644
index 0000000..a95b087
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-01-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-js-media-except-01-expected.txt b/LayoutTests/fast/media/mq-js-media-except-01-expected.txt
new file mode 100644
index 0000000..a962b50
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-01-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 244x18
+ text run at (0,0) width 244: "The text below should read \"Success.\""
+ RenderBlock {P} at (0,34) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 54x18
+ text run at (0,0) width 54: "Success."
+ RenderBlock {P} at (0,68) size 784x18
+ RenderText {#text} at (0,0) size 519x18
+ text run at (0,0) width 519: "Following exception was caught: Error: NOT_FOUND_ERR: DOM Exception 8"
diff --git a/LayoutTests/fast/media/mq-js-media-except-01.html b/LayoutTests/fast/media/mq-js-media-except-01.html
new file mode 100644
index 0000000..cf68ec8
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-01.html
@@ -0,0 +1,31 @@
+<html>
+<head>
+<title>CSS3 media query test: deleteMedium throwing exception.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+
+<style type="text/css">
+@media all and (color) {
+p#result { color: green;}
+}
+</style>
+
+<script language="javascript">
+function test() {
+ try {
+ document.styleSheets[0].cssRules[0].media.deleteMedium("all and (");
+ }
+ catch(e) {
+ document.getElementById("result").innerHTML = "Success."
+ document.getElementById("details").innerHTML = "Following exception was caught: " + e;
+ }
+}
+</script>
+
+
+</head>
+<body onload="test()">
+<p>The text below should read "Success." </p>
+<p id="result">Failure: test not run.</p>
+<p id="details"></p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-js-media-except-02-expected.checksum b/LayoutTests/fast/media/mq-js-media-except-02-expected.checksum
new file mode 100644
index 0000000..33f25b9
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-02-expected.checksum
@@ -0,0 +1 @@
+84987ac023fd4ab7ec1021a5298cba0f
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-js-media-except-02-expected.png b/LayoutTests/fast/media/mq-js-media-except-02-expected.png
new file mode 100644
index 0000000..8a07c1d
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-js-media-except-02-expected.txt b/LayoutTests/fast/media/mq-js-media-except-02-expected.txt
new file mode 100644
index 0000000..0762171
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-02-expected.txt
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
+ RenderBlock {P} at (0,34) size 784x18
+ RenderText {#text} at (0,0) size 401x18
+ text run at (0,0) width 401: "Caught exception: Error: SYNTAX_ERR: DOM Exception 12"
diff --git a/LayoutTests/fast/media/mq-js-media-except-02.html b/LayoutTests/fast/media/mq-js-media-except-02.html
new file mode 100644
index 0000000..657c98e
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-02.html
@@ -0,0 +1,38 @@
+<html>
+<head>
+<title>CSS3 media query test: @media css rule media.mediaText property parsing, media query syntax error should be handled correctly.</title>
+<link rel="help" href="http://www.w3.org/TR/CSS21/media.html" />
+
+<style type="text/css">
+p#result {color: green}
+
+@media not screen {
+/* query will be modified from javascript */
+/* the manipulation contains syntax error, and should fail */
+p#result {color: red}
+}
+
+@media screen and resolution > 40dpi {
+/* media query with syntax error should fail */
+/* corresponding DOM manipulation will fail */
+p#result {color: red}
+}
+</style>
+<script language="javascript">
+function test() {
+ try {
+ // this should throw
+ document.styleSheets[0].cssRules[1].media.mediaText = "screen and resolution > 40dpi";
+ } catch (e) {
+ document.getElementById("result").innerHTML = "This text should be green.";
+ document.getElementById("details").innerHTML = "Caught exception: " + e;
+ }
+}
+</script>
+
+</head>
+<body onload="test()">
+<p id="result">Failure: test not run</p>
+<p id="details"></p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-js-media-except-03-expected.checksum b/LayoutTests/fast/media/mq-js-media-except-03-expected.checksum
new file mode 100644
index 0000000..087a29d
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-03-expected.checksum
@@ -0,0 +1 @@
+6b2b09a646db9fc944c4bb148dec6135
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-js-media-except-03-expected.png b/LayoutTests/fast/media/mq-js-media-except-03-expected.png
new file mode 100644
index 0000000..cfcdbd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-03-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-js-media-except-03-expected.txt b/LayoutTests/fast/media/mq-js-media-except-03-expected.txt
new file mode 100644
index 0000000..eabb0c8
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-03-expected.txt
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 221x18
+ text run at (0,0) width 221: "Success. This text should be green."
+ RenderBlock {P} at (0,34) size 784x18
+ RenderText {#text} at (0,0) size 401x18
+ text run at (0,0) width 401: "Caught exception: Error: SYNTAX_ERR: DOM Exception 12"
diff --git a/LayoutTests/fast/media/mq-js-media-except-03.html b/LayoutTests/fast/media/mq-js-media-except-03.html
new file mode 100644
index 0000000..fe3c3dd
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-except-03.html
@@ -0,0 +1,43 @@
+<html>
+<head>
+<title>CSS3 media query test: @media css rule media.mediaText property parsing, media query syntax error should be handled correctly (,,,,).</title>
+<link rel="help" href="http://www.w3.org/TR/CSS21/media.html" />
+<link rel="help" href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSMediaRule" />
+<!-- this test shows slight disconnect between css media queries and html4 media descriptors -->
+<style type="text/css">
+p#result {color: green}
+
+@media braille {
+/* query will be modified from javascript */
+/* the manipulation contains syntax error, and should fail */
+p#result {color: red}
+}
+}
+</style>
+<script language="javascript">
+function test() {
+ try {
+ // this shouldn't throw
+ document.styleSheets[0].media.mediaText = ",,,,";
+ } catch (e) {
+ document.getElementById("result").innerHTML = "Failure. ,,,, should be valid media descriptor.";
+ document.getElementById("details").innerHTML = "Caught exception: " + e;
+ return;
+ }
+ try {
+ // this should throw
+ document.styleSheets[0].cssRules[1].media.mediaText = ",,,,";
+ document.getElementById("result").innerHTML = "Failure. No exception thrown.";
+ } catch (e) {
+ document.getElementById("result").innerHTML = "Success. This text should be green.";
+ document.getElementById("details").innerHTML = "Caught exception: " + e;
+ }
+}
+</script>
+
+</head>
+<body onload="test()">
+<p id="result">Failure: test not run</p>
+<p id="details">aaa</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.checksum b/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.png b/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.txt b/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-forward-syntax-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-js-media-forward-syntax.html b/LayoutTests/fast/media/mq-js-media-forward-syntax.html
new file mode 100644
index 0000000..5e74cdb
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-media-forward-syntax.html
@@ -0,0 +1,33 @@
+<html>
+<head>
+<title>CSS3 media query test: stylesheet media.mediaText = parsing, media descriptor fallback in document.StyleSheet.media.mediaText</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+
+<!-- the media property of stylesheet below will be manipulated, and
+ manipulation should respect html media descriptor forward-compatible syntax.
+ This means the manipulation should succeed. -->
+<style type="text/css">
+
+p#result { color: green;}
+
+@media screen and resolution > 40dpi {
+/* media query with syntax error should fail */
+/* corresponding DOM manipulation to the mediaText of the stylesheet will succeed */
+p#result { color: red;}
+
+}
+</style>
+<script language="javascript">
+function test() {
+ // this should not throw, because StyleSheet should respect Media Description forward-compatible syntax
+ document.styleSheets[0].media.mediaText = "screen and resolution > 40dpi";
+ document.getElementById("result").innerHTML = "This text should be green.";
+}
+</script>
+
+
+</head>
+<body onload="test()">
+<p id="result">Failure: test not run</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.checksum b/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.checksum
new file mode 100644
index 0000000..0dc845a
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.checksum
@@ -0,0 +1 @@
+bfd66393358e49a5b1c09f4acb698233
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.png b/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.png
new file mode 100644
index 0000000..30393f9
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.txt b/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.txt
new file mode 100644
index 0000000..4af0a58
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-01-expected.txt
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 610x18
+ text run at (0,0) width 610: "The text below should be green and contain \"braille, media, screen and (color) and (grid: 0), tty\"."
+ RenderBlock {P} at (0,34) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 312x18
+ text run at (0,0) width 312: "braille, media, screen and (color) and (grid: 0), tty"
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-01.html b/LayoutTests/fast/media/mq-js-stylesheet-media-01.html
new file mode 100644
index 0000000..13b21c4
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-01.html
@@ -0,0 +1,23 @@
+<html>
+<head>
+<title>CSS3 media query test: stylesheet media.mediaText property inspection.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+
+<style type="text/css" media="braille, media with error, screen and (color) and (grid:0), tty resolution > 600px">
+#result { color: green }
+</style>
+
+<script language="javascript">
+function test() {
+ re = document.getElementById("result");
+ re.innerHTML = "started";
+ re.innerHTML = document.styleSheets[0].media.mediaText;
+}
+</script>
+
+</head>
+<body onload="test()">
+<p> The text below should be green and contain "braille, media, screen and (color) and (grid: 0), tty". </p>
+<p id="result">Failure: test not run</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.checksum b/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.checksum
new file mode 100644
index 0000000..0dc845a
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.checksum
@@ -0,0 +1 @@
+bfd66393358e49a5b1c09f4acb698233
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.png b/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.png
new file mode 100644
index 0000000..30393f9
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.txt b/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.txt
new file mode 100644
index 0000000..4af0a58
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-02-expected.txt
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 610x18
+ text run at (0,0) width 610: "The text below should be green and contain \"braille, media, screen and (color) and (grid: 0), tty\"."
+ RenderBlock {P} at (0,34) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 312x18
+ text run at (0,0) width 312: "braille, media, screen and (color) and (grid: 0), tty"
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-02.html b/LayoutTests/fast/media/mq-js-stylesheet-media-02.html
new file mode 100644
index 0000000..bc7ff03
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-02.html
@@ -0,0 +1,27 @@
+<html>
+<head>
+<title>CSS3 media query test: stylesheet media property enumeration.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<link rel="help" href="http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html" />
+
+<style type="text/css" media="braille, media with error, screen and (color) and (grid:0), tty resolution > 600px">
+#result { color: green; }
+</style>
+
+<script language="javascript">
+function test() {
+ re = document.getElementById("result");
+ re.innerHTML = "started";
+ re.innerHTML = document.styleSheets[0].media.item(0)
+ + ", " + document.styleSheets[0].media.item(1)
+ + ", " + document.styleSheets[0].media.item(2)
+ + ", " + document.styleSheets[0].media.item(3) ;
+}
+</script>
+
+</head>
+<body onload="test()">
+<p> The text below should be green and contain "braille, media, screen and (color) and (grid: 0), tty". </p>
+<p id="result">Failure: test not run</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.checksum b/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.checksum
new file mode 100644
index 0000000..259cb2f
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.checksum
@@ -0,0 +1 @@
+e6d84d9dec5b0856a1c30816e87d16aa
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.png b/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.png
new file mode 100644
index 0000000..2062465
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.txt b/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.txt
new file mode 100644
index 0000000..203f9eb
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-03-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 560x18
+ text run at (0,0) width 560: "This text should be green and below should read \"braille, not screen, screen and (color)\"."
+ RenderBlock {P} at (0,34) size 784x18
+ RenderText {#text} at (0,0) size 304x18
+ text run at (0,0) width 304: "braille, not screen, screen and (color), not screen"
+ RenderBlock {P} at (0,68) size 784x18
+ RenderText {#text} at (0,0) size 182x18
+ text run at (0,0) width 182: "expected to fail (24.07.2005)"
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-03.html b/LayoutTests/fast/media/mq-js-stylesheet-media-03.html
new file mode 100644
index 0000000..bdc88b1
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-03.html
@@ -0,0 +1,35 @@
+<html>
+<head>
+<title>CSS3 media query test: stylesheet media.appendMedium</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<link rel="help" href="http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html" />
+<style type="text/css" media="braille, not screen">
+p { color: green }
+</style>
+
+<script language="javascript">
+function test() {
+ var re = document.getElementById("result");
+ var media = document.styleSheets[0].media;
+ media.appendMedium("screen and (color)");
+ media.appendMedium("not screen");
+ var first = true;
+ for (var i = 0; i < media.length; ++i) {
+ if (!first) re.innerHTML += ", " + media.item(i);
+ else re.innerHTML = media.item(i);
+ first = false;
+ }
+
+}
+</script>
+
+</head>
+<body onload="test()">
+<!-- FIXME: NOTE! This will fail until dynamic setting of media property causes style recalculation.
+ This is not the case currently (24.07.2005)
+-->
+<p> This text should be green and below should read "braille, not screen, screen and (color)". </p>
+<p id="result">Failure: test not run</p>
+<p> expected to fail (24.07.2005)</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.checksum b/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.checksum
new file mode 100644
index 0000000..169d8b2
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.checksum
@@ -0,0 +1 @@
+0cf7a9c4a6243d772ea0d5d074bdb442
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.png b/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.png
new file mode 100644
index 0000000..7ed2eb3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.txt b/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.txt
new file mode 100644
index 0000000..d96e002
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-04-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 445x18
+ text run at (0,0) width 445: "This text should be green and below should read \"media list is empty\"."
+ RenderBlock {P} at (0,34) size 784x18
+ RenderText {#text} at (0,0) size 117x18
+ text run at (0,0) width 117: "media list is empty"
+ RenderBlock {P} at (0,68) size 784x18
+ RenderText {#text} at (0,0) size 177x18
+ text run at (0,0) width 177: "Expected to fail (24.7.2005)"
diff --git a/LayoutTests/fast/media/mq-js-stylesheet-media-04.html b/LayoutTests/fast/media/mq-js-stylesheet-media-04.html
new file mode 100644
index 0000000..4464f20
--- /dev/null
+++ b/LayoutTests/fast/media/mq-js-stylesheet-media-04.html
@@ -0,0 +1,37 @@
+<html>
+<head>
+<title>CSS3 media query test: stylesheet media deleteMedium </title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<link rel="help" href="http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html" />
+<style type="text/css" media="braille, not screen">
+p { color: green }
+</style>
+
+<script language="javascript">
+function test() {
+ var re = document.getElementById("result");
+ var media = document.styleSheets[0].media;
+ media.appendMedium("screen and (color)");
+ while (media.length) {
+ media.deleteMedium(media.item(0));
+ }
+ re.innerHTML = "media list is empty"
+ var first = true;
+ for (var i = 0; i < media.length; ++i) {
+ if (!first) re.innerHTML += ", " + media.item(i);
+ else re.innerHTML = media.item(i);
+ first = false;
+ }
+}
+</script>
+
+</head>
+<body onload="test()">
+<!-- FIXME: NOTE! This will fail until dynamic setting of media property causes style recalculation.
+ This is not the case currently (24.07.2005)
+-->
+<p> This text should be green and below should read "media list is empty". </p>
+<p id="result">Failure: test not run</p>
+<p> Expected to fail (24.7.2005) </p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-min-constraint-expected.checksum b/LayoutTests/fast/media/mq-min-constraint-expected.checksum
new file mode 100644
index 0000000..49da6cb
--- /dev/null
+++ b/LayoutTests/fast/media/mq-min-constraint-expected.checksum
@@ -0,0 +1 @@
+4c146be940e196c365414a6205da5a8d
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-min-constraint-expected.png b/LayoutTests/fast/media/mq-min-constraint-expected.png
new file mode 100644
index 0000000..09d1e86
--- /dev/null
+++ b/LayoutTests/fast/media/mq-min-constraint-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-min-constraint-expected.txt b/LayoutTests/fast/media/mq-min-constraint-expected.txt
new file mode 100644
index 0000000..817c25f
--- /dev/null
+++ b/LayoutTests/fast/media/mq-min-constraint-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 381x18
+ text run at (0,0) width 381: "This text should be green if viewport width is at least 600px."
diff --git a/LayoutTests/fast/media/mq-min-constraint.html b/LayoutTests/fast/media/mq-min-constraint.html
new file mode 100644
index 0000000..25d536d
--- /dev/null
+++ b/LayoutTests/fast/media/mq-min-constraint.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>CSS3 media query test: Media query with min- constraint (screen and (min-width: 600px)). Using style attribute, @import css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<link rel="help" href="http://www.w3.org/TR/CSS21/cascade.html#at-import" />
+
+<style type="text/css">
+p { color: red }
+</style>
+<style type="text/css">
+@import url(import-p-green.css) screen and (min-width: 600px);
+</style>
+</head>
+<body>
+<p> This text should be green if viewport width is at least 600px.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-relative-constraints-02-expected.checksum b/LayoutTests/fast/media/mq-relative-constraints-02-expected.checksum
new file mode 100644
index 0000000..04a3866
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-02-expected.checksum
@@ -0,0 +1 @@
+a10b78e692cedb6b2ed9fbd56b383c5e
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-relative-constraints-02-expected.png b/LayoutTests/fast/media/mq-relative-constraints-02-expected.png
new file mode 100644
index 0000000..dcdb17e
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-relative-constraints-02-expected.txt b/LayoutTests/fast/media/mq-relative-constraints-02-expected.txt
new file mode 100644
index 0000000..d1ec510
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-02-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 808x600
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 808x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x584
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 360x18
+ text run at (0,0) width 360: "This text should be green if viewport is wider than 30em."
+ RenderBlock {DIV} at (0,34) size 480x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 123x18
+ text run at (0,0) width 123: "div of length 30 em"
+ RenderBlock {DIV} at (0,52) size 800x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 124x18
+ text run at (0,0) width 124: "div of length 800px"
diff --git a/LayoutTests/fast/media/mq-relative-constraints-02.html b/LayoutTests/fast/media/mq-relative-constraints-02.html
new file mode 100644
index 0000000..7006316
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-02.html
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title>CSS3 media query test: relative constraints test using screen and (min-width: 30em). Using style element, media attribute </title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+<style type="text/css" media="screen and (min-width: 30em)">
+p {
+ color: green;
+}
+</style>
+</head>
+<body>
+
+<p> This text should be green if viewport is wider than 30em. </p>
+
+<div style="width: 30em; background-color: lightblue;"> div of length 30 em </div>
+<div style="width: 800px; background-color: lightblue;"> div of length 800px </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-relative-constraints-03-expected.checksum b/LayoutTests/fast/media/mq-relative-constraints-03-expected.checksum
new file mode 100644
index 0000000..04a3866
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-03-expected.checksum
@@ -0,0 +1 @@
+a10b78e692cedb6b2ed9fbd56b383c5e
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-relative-constraints-03-expected.png b/LayoutTests/fast/media/mq-relative-constraints-03-expected.png
new file mode 100644
index 0000000..dcdb17e
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-03-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-relative-constraints-03-expected.txt b/LayoutTests/fast/media/mq-relative-constraints-03-expected.txt
new file mode 100644
index 0000000..d1ec510
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-03-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 808x600
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 808x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x584
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 360x18
+ text run at (0,0) width 360: "This text should be green if viewport is wider than 30em."
+ RenderBlock {DIV} at (0,34) size 480x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 123x18
+ text run at (0,0) width 123: "div of length 30 em"
+ RenderBlock {DIV} at (0,52) size 800x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 124x18
+ text run at (0,0) width 124: "div of length 800px"
diff --git a/LayoutTests/fast/media/mq-relative-constraints-03.html b/LayoutTests/fast/media/mq-relative-constraints-03.html
new file mode 100644
index 0000000..70a2473
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-03.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title>CSS3 media query test: relative constraints test using screen and (min-width: 30em). Using link element, media attribute </title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+<link rel="stylesheet" type="text/css" media="screen and (min-width: 30em)" href="import-p-green.css" />
+</head>
+<body>
+
+<p> This text should be green if viewport is wider than 30em. </p>
+
+<div style="width: 30em; background-color: lightblue;"> div of length 30 em </div>
+<div style="width: 800px; background-color: lightblue;"> div of length 800px </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-relative-constraints-04-expected.checksum b/LayoutTests/fast/media/mq-relative-constraints-04-expected.checksum
new file mode 100644
index 0000000..04a3866
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-04-expected.checksum
@@ -0,0 +1 @@
+a10b78e692cedb6b2ed9fbd56b383c5e
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-relative-constraints-04-expected.png b/LayoutTests/fast/media/mq-relative-constraints-04-expected.png
new file mode 100644
index 0000000..dcdb17e
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-04-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-relative-constraints-04-expected.txt b/LayoutTests/fast/media/mq-relative-constraints-04-expected.txt
new file mode 100644
index 0000000..d1ec510
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-04-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 808x600
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 808x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x584
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 360x18
+ text run at (0,0) width 360: "This text should be green if viewport is wider than 30em."
+ RenderBlock {DIV} at (0,34) size 480x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 123x18
+ text run at (0,0) width 123: "div of length 30 em"
+ RenderBlock {DIV} at (0,52) size 800x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 124x18
+ text run at (0,0) width 124: "div of length 800px"
diff --git a/LayoutTests/fast/media/mq-relative-constraints-04.html b/LayoutTests/fast/media/mq-relative-constraints-04.html
new file mode 100644
index 0000000..ce889cb
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-04.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>CSS3 media query test: relative constraints test using screen and (min-width: 30em). Using style element, css @import rule </title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+
+<style type="text/css">
+@import url(import-p-green.css) screen and (min-width: 30em);
+</style>
+</head>
+<body>
+
+<p> This text should be green if viewport is wider than 30em. </p>
+
+<div style="width: 30em; background-color: lightblue;"> div of length 30 em </div>
+<div style="width: 800px; background-color: lightblue;"> div of length 800px </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-relative-constraints-05-expected.checksum b/LayoutTests/fast/media/mq-relative-constraints-05-expected.checksum
new file mode 100644
index 0000000..04a3866
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-05-expected.checksum
@@ -0,0 +1 @@
+a10b78e692cedb6b2ed9fbd56b383c5e
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-relative-constraints-05-expected.png b/LayoutTests/fast/media/mq-relative-constraints-05-expected.png
new file mode 100644
index 0000000..dcdb17e
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-05-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-relative-constraints-05-expected.txt b/LayoutTests/fast/media/mq-relative-constraints-05-expected.txt
new file mode 100644
index 0000000..d1ec510
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-05-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 808x600
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 808x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x584
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 360x18
+ text run at (0,0) width 360: "This text should be green if viewport is wider than 30em."
+ RenderBlock {DIV} at (0,34) size 480x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 123x18
+ text run at (0,0) width 123: "div of length 30 em"
+ RenderBlock {DIV} at (0,52) size 800x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 124x18
+ text run at (0,0) width 124: "div of length 800px"
diff --git a/LayoutTests/fast/media/mq-relative-constraints-05.html b/LayoutTests/fast/media/mq-relative-constraints-05.html
new file mode 100644
index 0000000..c04bd3c
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-05.html
@@ -0,0 +1,24 @@
+<html>
+<head>
+<title>CSS3 media query test: relative constraints test using screen and (min-width: 30em). Using style element, css @media rule </title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+
+<style type="text/css">
+p {
+ color: red;
+}
+@media screen and (min-width: 30em) {
+ p {
+ color: green;
+ }
+}
+</style>
+</head>
+<body>
+
+<p> This text should be green if viewport is wider than 30em. </p>
+
+<div style="width: 30em; background-color: lightblue;"> div of length 30 em </div>
+<div style="width: 800px; background-color: lightblue;"> div of length 800px </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-relative-constraints-06-expected.checksum b/LayoutTests/fast/media/mq-relative-constraints-06-expected.checksum
new file mode 100644
index 0000000..eba6089
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-06-expected.checksum
@@ -0,0 +1 @@
+d1770e1876ba95b0f2b7c39264bf54e8
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-relative-constraints-06-expected.png b/LayoutTests/fast/media/mq-relative-constraints-06-expected.png
new file mode 100644
index 0000000..f963b87
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-06-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-relative-constraints-06-expected.txt b/LayoutTests/fast/media/mq-relative-constraints-06-expected.txt
new file mode 100644
index 0000000..0255af2
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-06-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 968x600
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 968x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x584
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 728x18
+ text run at (0,0) width 728: "This text should be green if viewport is narrower than 60em. This tests that (min-width: 60em) can evaluate to false."
+ RenderBlock {DIV} at (0,34) size 960x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 123x18
+ text run at (0,0) width 123: "div of length 60 em"
+ RenderBlock {DIV} at (0,52) size 800x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 124x18
+ text run at (0,0) width 124: "div of length 800px"
diff --git a/LayoutTests/fast/media/mq-relative-constraints-06.html b/LayoutTests/fast/media/mq-relative-constraints-06.html
new file mode 100644
index 0000000..da71b0d
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-06.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>CSS3 media query test: media query testing constraints with relative values evaluating false (screen and (min-width: 60em)). Using style element, @media css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+<style type="text/css">
+p { color: green }
+@media screen and (min-width: 60em) {
+p { color: red }
+}
+</style>
+</head>
+<body>
+<p> This text should be green if viewport is narrower than 60em. This tests that (min-width: 60em) can evaluate to false.</p>
+<div style="width: 60em; background-color: lightblue;"> div of length 60 em </div>
+<div style="width: 800px; background-color: lightblue;"> div of length 800px </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-relative-constraints-07-expected.checksum b/LayoutTests/fast/media/mq-relative-constraints-07-expected.checksum
new file mode 100644
index 0000000..bc19618
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-07-expected.checksum
@@ -0,0 +1 @@
+5d142d526aa81c82a34e953c5d235a4b
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-relative-constraints-07-expected.png b/LayoutTests/fast/media/mq-relative-constraints-07-expected.png
new file mode 100644
index 0000000..6ba126d
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-07-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-relative-constraints-07-expected.txt b/LayoutTests/fast/media/mq-relative-constraints-07-expected.txt
new file mode 100644
index 0000000..cccd799
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-07-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 808x600
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 808x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x584
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 710x18
+ text run at (0,0) width 710: "This text should be green if viewport is wider than 30em. This tests that (max-width: 30em) can evaluate to false."
+ RenderBlock {DIV} at (0,34) size 480x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 123x18
+ text run at (0,0) width 123: "div of length 30 em"
+ RenderBlock {DIV} at (0,52) size 800x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 124x18
+ text run at (0,0) width 124: "div of length 800px"
diff --git a/LayoutTests/fast/media/mq-relative-constraints-07.html b/LayoutTests/fast/media/mq-relative-constraints-07.html
new file mode 100644
index 0000000..402825d
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-07.html
@@ -0,0 +1,19 @@
+<html>
+<head>
+<title>CSS3 media query test: media query testing constraints with relative values evaluating false (screen and (max-width: 30em)). Using style element, @media css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+<style type="text/css">
+p { color: green }
+@media screen and (max-width: 30em) {
+p { color: red }
+}
+</style>
+</head>
+<body>
+
+<p> This text should be green if viewport is wider than 30em. This tests that (max-width: 30em) can evaluate to false. </p>
+
+<div style="width: 30em; background-color: lightblue;"> div of length 30 em </div>
+<div style="width: 800px; background-color: lightblue;"> div of length 800px </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-relative-constraints-08-expected.checksum b/LayoutTests/fast/media/mq-relative-constraints-08-expected.checksum
new file mode 100644
index 0000000..933547c
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-08-expected.checksum
@@ -0,0 +1 @@
+9b06fcede219853f1c30a7f2e80c37ff
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-relative-constraints-08-expected.png b/LayoutTests/fast/media/mq-relative-constraints-08-expected.png
new file mode 100644
index 0000000..41ce35d
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-08-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-relative-constraints-08-expected.txt b/LayoutTests/fast/media/mq-relative-constraints-08-expected.txt
new file mode 100644
index 0000000..7b0793d
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-08-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 785x642
+ RenderView at (0,0) size 785x600
+layer at (0,0) size 785x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x576
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 319x18
+ text run at (0,0) width 319: "This text should be green if height is at least 30ex ."
+ RenderBlock (floating) {DIV} at (0,34) size 115x229 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 115x18
+ text run at (0,0) width 115: "div of height 30ex"
+ RenderBlock (floating) {DIV} at (115,34) size 124x600 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 124x18
+ text run at (0,0) width 124: "div of height 600px"
diff --git a/LayoutTests/fast/media/mq-relative-constraints-08.html b/LayoutTests/fast/media/mq-relative-constraints-08.html
new file mode 100644
index 0000000..797f3c7
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-08.html
@@ -0,0 +1,20 @@
+<html>
+<head>
+<title>CSS3 media query test: media query testing constraints with relative values (screen and (min-height: 30ex)). Using style element, @media css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+
+<style type="text/css">
+p { color: red }
+@media screen and (min-height: 30ex) {
+p { color: green }
+}
+</style>
+</head>
+<body>
+
+<p> This text should be green if height is at least 30ex .</p>
+
+<div style="display:inline; float:left; height: 30ex; background-color: lightblue;"> div of height 30ex </div>
+<div style="display:inline; float:left; height: 600px; background-color: lightblue;"> div of height 600px </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-relative-constraints-09-expected.checksum b/LayoutTests/fast/media/mq-relative-constraints-09-expected.checksum
new file mode 100644
index 0000000..a39b5c6
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-09-expected.checksum
@@ -0,0 +1 @@
+c8038806895a2d04f217d5d4f83be565
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-relative-constraints-09-expected.png b/LayoutTests/fast/media/mq-relative-constraints-09-expected.png
new file mode 100644
index 0000000..9154105
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-09-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-relative-constraints-09-expected.txt b/LayoutTests/fast/media/mq-relative-constraints-09-expected.txt
new file mode 100644
index 0000000..862018a
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-09-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 968x600
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 968x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x584
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 381x18
+ text run at (0,0) width 381: "This text should be green if viewport is narrower than 60em."
+ RenderBlock {DIV} at (0,34) size 960x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 123x18
+ text run at (0,0) width 123: "div of length 60 em"
+ RenderBlock {DIV} at (0,52) size 800x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 124x18
+ text run at (0,0) width 124: "div of length 800px"
diff --git a/LayoutTests/fast/media/mq-relative-constraints-09.html b/LayoutTests/fast/media/mq-relative-constraints-09.html
new file mode 100644
index 0000000..725cd71
--- /dev/null
+++ b/LayoutTests/fast/media/mq-relative-constraints-09.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>CSS3 media query test: media query testing constraints with relative values (screen and (max-width: 60em)). Using style element, @media css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+<style type="text/css">
+p { color: red }
+@media screen and (max-width: 60em) {
+p { color: green }
+}
+</style>
+</head>
+<body>
+<p> This text should be green if viewport is narrower than 60em. </p>
+<div style="width: 60em; background-color: lightblue;"> div of length 60 em </div>
+<div style="width: 800px; background-color: lightblue;"> div of length 800px </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-01-expected.checksum b/LayoutTests/fast/media/mq-simple-neg-query-01-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-01-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-01-expected.png b/LayoutTests/fast/media/mq-simple-neg-query-01-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-01-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-01-expected.txt b/LayoutTests/fast/media/mq-simple-neg-query-01-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-01-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-01.html b/LayoutTests/fast/media/mq-simple-neg-query-01.html
new file mode 100644
index 0000000..18560e3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-01.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+<title>CSS3 media query test: simple media query (not braille, screen). Using style element, media attribute.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<style type="text/css" media="not braille, screen">
+p { color: green }
+</style>
+</head>
+<body>
+<p> This text should be green. </p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-02-expected.checksum b/LayoutTests/fast/media/mq-simple-neg-query-02-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-02-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-02-expected.png b/LayoutTests/fast/media/mq-simple-neg-query-02-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-02-expected.txt b/LayoutTests/fast/media/mq-simple-neg-query-02-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-02-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-02.html b/LayoutTests/fast/media/mq-simple-neg-query-02.html
new file mode 100644
index 0000000..137b03f
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-02.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+<title>CSS3 media query test: simple media quer (not braille, screen). Using link element, media attribute.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<link rel="stylesheet" type="text/css" media="not braille, screen" href="import-p-green.css" />
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-03-expected.checksum b/LayoutTests/fast/media/mq-simple-neg-query-03-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-03-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-03-expected.png b/LayoutTests/fast/media/mq-simple-neg-query-03-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-03-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-03-expected.txt b/LayoutTests/fast/media/mq-simple-neg-query-03-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-03-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-03.html b/LayoutTests/fast/media/mq-simple-neg-query-03.html
new file mode 100644
index 0000000..a641a52
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-03.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+<title>CSS3 media query test: simple media query (not braille, screen). Using style element, css @import rule</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<style type="text/css">
+@import url(import-p-green.css) not braille, screen;
+</style>
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-04-expected.checksum b/LayoutTests/fast/media/mq-simple-neg-query-04-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-04-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-04-expected.png b/LayoutTests/fast/media/mq-simple-neg-query-04-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-04-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-04-expected.txt b/LayoutTests/fast/media/mq-simple-neg-query-04-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-04-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-04.html b/LayoutTests/fast/media/mq-simple-neg-query-04.html
new file mode 100644
index 0000000..fc075b2
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-04.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title> CSS3 media query test: simple media query (not braille, screen). Using style element, css @media rule</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<style type="text/css">
+@media not braille, screen {
+p { color: green }
+}
+</style>
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-05-expected.checksum b/LayoutTests/fast/media/mq-simple-neg-query-05-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-05-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-05-expected.png b/LayoutTests/fast/media/mq-simple-neg-query-05-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-05-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-05-expected.txt b/LayoutTests/fast/media/mq-simple-neg-query-05-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-05-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-simple-neg-query-05.html b/LayoutTests/fast/media/mq-simple-neg-query-05.html
new file mode 100644
index 0000000..60bb04c
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-neg-query-05.html
@@ -0,0 +1,16 @@
+<html>
+<head>
+<title>CSS3 media query test: media query testing not and feature braille (not braille). Using style element, @media css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<style type="text/css">
+@media not braille {
+p { color: green }
+}
+</style>
+
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/media/mq-simple-query-01-expected.checksum b/LayoutTests/fast/media/mq-simple-query-01-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-01-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-simple-query-01-expected.png b/LayoutTests/fast/media/mq-simple-query-01-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-01-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-simple-query-01-expected.txt b/LayoutTests/fast/media/mq-simple-query-01-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-01-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-simple-query-01.html b/LayoutTests/fast/media/mq-simple-query-01.html
new file mode 100644
index 0000000..7571d63
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-01.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title>CSS3 media query test: simple media query. Using style element, media attribute</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+
+<style type="text/css" media="only all">
+p { color: green }
+</style>
+
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-simple-query-02-expected.checksum b/LayoutTests/fast/media/mq-simple-query-02-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-02-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-simple-query-02-expected.png b/LayoutTests/fast/media/mq-simple-query-02-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-simple-query-02-expected.txt b/LayoutTests/fast/media/mq-simple-query-02-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-02-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-simple-query-02.html b/LayoutTests/fast/media/mq-simple-query-02.html
new file mode 100644
index 0000000..44bdc70
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-02.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+<title>CSS3 media query test: simple media query. Using link element, media attribute</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+
+<link type="text/css" media="only all" href="import-p-green.css" />
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-simple-query-03-expected.checksum b/LayoutTests/fast/media/mq-simple-query-03-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-03-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-simple-query-03-expected.png b/LayoutTests/fast/media/mq-simple-query-03-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-03-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-simple-query-03-expected.txt b/LayoutTests/fast/media/mq-simple-query-03-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-03-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-simple-query-03.html b/LayoutTests/fast/media/mq-simple-query-03.html
new file mode 100644
index 0000000..13024d6
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-03.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+<title>CSS3 media query test: simple media query. Using style element, css @import rule</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<style type="text/css">
+@import url(import-p-green.css) only all;
+</style>
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-simple-query-04-expected.checksum b/LayoutTests/fast/media/mq-simple-query-04-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-04-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-simple-query-04-expected.png b/LayoutTests/fast/media/mq-simple-query-04-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-04-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-simple-query-04-expected.txt b/LayoutTests/fast/media/mq-simple-query-04-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-04-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-simple-query-04.html b/LayoutTests/fast/media/mq-simple-query-04.html
new file mode 100644
index 0000000..6506d1b
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-04.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title>CSS3 media query test: simple media query. Using style element, css @media rule</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#syntax" />
+<style type="text/css">
+@media only all {
+p { color: green }
+}
+</style>
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-simple-query-05-expected.checksum b/LayoutTests/fast/media/mq-simple-query-05-expected.checksum
new file mode 100644
index 0000000..b861cda
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-05-expected.checksum
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-simple-query-05-expected.png b/LayoutTests/fast/media/mq-simple-query-05-expected.png
new file mode 100644
index 0000000..57bc6ac
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-05-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-simple-query-05-expected.txt b/LayoutTests/fast/media/mq-simple-query-05-expected.txt
new file mode 100644
index 0000000..7442bd3
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-05-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 163x18
+ text run at (0,0) width 163: "This text should be green."
diff --git a/LayoutTests/fast/media/mq-simple-query-05.html b/LayoutTests/fast/media/mq-simple-query-05.html
new file mode 100644
index 0000000..6d63879
--- /dev/null
+++ b/LayoutTests/fast/media/mq-simple-query-05.html
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title> CSS3 media query test: matches color or monochrome screens </title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />
+<style type="text/css">
+p { color: red }
+@media all and (color) {
+p { color: green }
+}
+@media all and (monochrome) {
+p { color: green;}
+}
+</style>
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-valueless-expected.checksum b/LayoutTests/fast/media/mq-valueless-expected.checksum
new file mode 100644
index 0000000..9dfbfbd
--- /dev/null
+++ b/LayoutTests/fast/media/mq-valueless-expected.checksum
@@ -0,0 +1 @@
+13a8a15857868d43e1af1086030f97cf
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-valueless-expected.png b/LayoutTests/fast/media/mq-valueless-expected.png
new file mode 100644
index 0000000..32b1021
--- /dev/null
+++ b/LayoutTests/fast/media/mq-valueless-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-valueless-expected.txt b/LayoutTests/fast/media/mq-valueless-expected.txt
new file mode 100644
index 0000000..a1d8e98
--- /dev/null
+++ b/LayoutTests/fast/media/mq-valueless-expected.txt
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x576
+ RenderBlock {P} at (0,0) size 784x18 [color=#008000]
+ RenderText {#text} at (0,0) size 308x18
+ text run at (0,0) width 308: "This text should be green if color display is used."
diff --git a/LayoutTests/fast/media/mq-valueless.html b/LayoutTests/fast/media/mq-valueless.html
new file mode 100644
index 0000000..68a2ac9
--- /dev/null
+++ b/LayoutTests/fast/media/mq-valueless.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>CSS3 media query test: media query without values (screen and (color)). Using style element, @media css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#color" />
+
+<style type="text/css">
+@media screen and (color) {
+p { color: green }
+}
+</style>
+</head>
+<body>
+<p> This text should be green if color display is used.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-width-absolute-01-expected.checksum b/LayoutTests/fast/media/mq-width-absolute-01-expected.checksum
new file mode 100644
index 0000000..9b12f86
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-01-expected.checksum
@@ -0,0 +1 @@
+2c542eb1435d62f934f9256b8a0694d8
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-width-absolute-01-expected.png b/LayoutTests/fast/media/mq-width-absolute-01-expected.png
new file mode 100644
index 0000000..3fd64ba
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-01-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-width-absolute-01-expected.txt b/LayoutTests/fast/media/mq-width-absolute-01-expected.txt
new file mode 100644
index 0000000..1f9e5cc
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-01-expected.txt
@@ -0,0 +1,11 @@
+layer at (0,0) size 808x600
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 808x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x584
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 378x18
+ text run at (0,0) width 378: "This text should be green if viewport is at most 800px wide."
+ RenderBlock {DIV} at (0,34) size 800x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 121x18
+ text run at (0,0) width 121: "div of width 800px"
diff --git a/LayoutTests/fast/media/mq-width-absolute-01.html b/LayoutTests/fast/media/mq-width-absolute-01.html
new file mode 100644
index 0000000..5a3aa00
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-01.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<title>CSS3 media query test: Absolute width query (screen and (max-width: 800px)). Using style element, media attribute.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+<style type="text/css" media="screen and (max-width: 800px)">
+p { color: green }
+</style>
+</head>
+<body>
+<p> This text should be green if viewport is at most 800px wide.</p>
+<div style="width: 800px; background-color:lightblue;">div of width 800px</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-width-absolute-02-expected.checksum b/LayoutTests/fast/media/mq-width-absolute-02-expected.checksum
new file mode 100644
index 0000000..9b12f86
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-02-expected.checksum
@@ -0,0 +1 @@
+2c542eb1435d62f934f9256b8a0694d8
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-width-absolute-02-expected.png b/LayoutTests/fast/media/mq-width-absolute-02-expected.png
new file mode 100644
index 0000000..3fd64ba
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-02-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-width-absolute-02-expected.txt b/LayoutTests/fast/media/mq-width-absolute-02-expected.txt
new file mode 100644
index 0000000..1f9e5cc
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-02-expected.txt
@@ -0,0 +1,11 @@
+layer at (0,0) size 808x600
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 808x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x584
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 378x18
+ text run at (0,0) width 378: "This text should be green if viewport is at most 800px wide."
+ RenderBlock {DIV} at (0,34) size 800x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 121x18
+ text run at (0,0) width 121: "div of width 800px"
diff --git a/LayoutTests/fast/media/mq-width-absolute-02.html b/LayoutTests/fast/media/mq-width-absolute-02.html
new file mode 100644
index 0000000..e1c5bc0
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-02.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+<title>CSS3 media query test: Absolute width query (screen and (max-width: 800px)). Using link element, media attribute.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+<link type="text/css" media="screen and (max-width: 800px)" href="import-p-green.css" />
+</head>
+<body>
+<p> This text should be green if viewport is at most 800px wide.</p>
+<div style="width: 800px; background-color:lightblue;">div of width 800px</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-width-absolute-03-expected.checksum b/LayoutTests/fast/media/mq-width-absolute-03-expected.checksum
new file mode 100644
index 0000000..9b12f86
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-03-expected.checksum
@@ -0,0 +1 @@
+2c542eb1435d62f934f9256b8a0694d8
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-width-absolute-03-expected.png b/LayoutTests/fast/media/mq-width-absolute-03-expected.png
new file mode 100644
index 0000000..3fd64ba
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-03-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-width-absolute-03-expected.txt b/LayoutTests/fast/media/mq-width-absolute-03-expected.txt
new file mode 100644
index 0000000..1f9e5cc
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-03-expected.txt
@@ -0,0 +1,11 @@
+layer at (0,0) size 808x600
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 808x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x584
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 378x18
+ text run at (0,0) width 378: "This text should be green if viewport is at most 800px wide."
+ RenderBlock {DIV} at (0,34) size 800x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 121x18
+ text run at (0,0) width 121: "div of width 800px"
diff --git a/LayoutTests/fast/media/mq-width-absolute-03.html b/LayoutTests/fast/media/mq-width-absolute-03.html
new file mode 100644
index 0000000..196f2f4
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-03.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<title>CSS3 media query test: Absolute width query (screen and (max-width: 800px)). Using style element, @import css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+<style type="text/css">
+@import url(import-p-green.css) screen and (max-width: 800px);
+</style>
+</head>
+<body>
+<p> This text should be green if viewport is at most 800px wide.</p>
+<div style="width: 800px; background-color:lightblue;">div of width 800px</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/mq-width-absolute-04-expected.checksum b/LayoutTests/fast/media/mq-width-absolute-04-expected.checksum
new file mode 100644
index 0000000..9b12f86
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-04-expected.checksum
@@ -0,0 +1 @@
+2c542eb1435d62f934f9256b8a0694d8
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-width-absolute-04-expected.png b/LayoutTests/fast/media/mq-width-absolute-04-expected.png
new file mode 100644
index 0000000..3fd64ba
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-04-expected.png
Binary files differ
diff --git a/LayoutTests/fast/media/mq-width-absolute-04-expected.txt b/LayoutTests/fast/media/mq-width-absolute-04-expected.txt
new file mode 100644
index 0000000..1f9e5cc
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-04-expected.txt
@@ -0,0 +1,11 @@
+layer at (0,0) size 808x600
+ RenderView at (0,0) size 785x585
+layer at (0,0) size 808x600
+ RenderBlock {HTML} at (0,0) size 785x600
+ RenderBody {BODY} at (8,8) size 769x584
+ RenderBlock {P} at (0,0) size 769x18 [color=#008000]
+ RenderText {#text} at (0,0) size 378x18
+ text run at (0,0) width 378: "This text should be green if viewport is at most 800px wide."
+ RenderBlock {DIV} at (0,34) size 800x18 [bgcolor=#ADD8E6]
+ RenderText {#text} at (0,0) size 121x18
+ text run at (0,0) width 121: "div of width 800px"
diff --git a/LayoutTests/fast/media/mq-width-absolute-04.html b/LayoutTests/fast/media/mq-width-absolute-04.html
new file mode 100644
index 0000000..13b0db4
--- /dev/null
+++ b/LayoutTests/fast/media/mq-width-absolute-04.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>CSS3 media query test: Absolute width query (screen and (max-width: 800px)). Using style element, @media css rule.</title>
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+<style type="text/css">
+@media screen and (max-width: 800px) {
+p { color: green }
+}
+</style>
+</head>
+<body>
+<p> This text should be green if viewport is at most 800px wide.</p>
+<div style="width: 800px; background-color:lightblue;">div of width 800px</div>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 0e1544a..eff1527 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,136 @@
+2006-06-09 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>
+
+ Reviewed by Hyatt. Tweaked by Maciej. Tweaks reviewed by Beth.
+ Landed by Beth.
+
+ CSS3 Media Queries implementation.
+ <http://bugzilla.opendarwin.org/show_bug.cgi?id=4127>
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/kjs_css.cpp:
+ (KJS::DOMMediaList::put):
+ (KJS::KJS::DOMMediaListProtoFunc::callAsFunction):
+ * bindings/objc/DOMCSS.mm:
+ (-[DOMMediaList setMediaText:]):
+ (-[DOMMediaList deleteMedium:]):
+ (-[DOMMediaList appendMedium:]):
+ * css/CSSGrammar.y:
+ * css/MediaFeatureNames.cpp: Added.
+ (WebCore::MediaFeatureNames::init):
+ * css/MediaFeatureNames.h: Added.
+ * css/MediaList.cpp:
+ (WebCore::MediaList::MediaList):
+ (WebCore::MediaList::~MediaList):
+ (WebCore::parseMediaDescriptor):
+ (WebCore::MediaList::deleteMedium):
+ (WebCore::MediaList::mediaText):
+ (WebCore::MediaList::setMediaText):
+ (WebCore::MediaList::item):
+ (WebCore::MediaList::appendMedium):
+ (WebCore::MediaList::appendMediaQuery):
+ * css/MediaList.h:
+ (WebCore::MediaList::MediaList):
+ (WebCore::MediaList::length):
+ (WebCore::MediaList::mediaQueries):
+ * css/MediaQuery.cpp: Added.
+ (WebCore::MediaQuery::MediaQuery):
+ (WebCore::MediaQuery::~MediaQuery):
+ (WebCore::MediaQuery::operator==):
+ (WebCore::MediaQuery::cssText):
+ * css/MediaQuery.h: Added.
+ (WebCore::MediaQuery::):
+ (WebCore::MediaQuery::restrictor):
+ (WebCore::MediaQuery::expressions):
+ (WebCore::MediaQuery::mediaType):
+ (WebCore::MediaQuery::append):
+ * css/MediaQueryEvaluator.cpp: Added.
+ (WebCore::):
+ (WebCore::MediaQueryEvaluator):
+ (WebCore::MediaQueryEvaluator::~MediaQueryEvaluator):
+ (WebCore::MediaQueryEvaluator::mediaTypeMatch):
+ (WebCore::applyRestrictor):
+ (WebCore::MediaQueryEvaluator::eval):
+ (WebCore::parseAspectRatio):
+ (WebCore::cmpvalue):
+ (WebCore::numberValue):
+ (WebCore::colorMediaFeatureEval):
+ (WebCore::monochromeMediaFeatureEval):
+ (WebCore::device_aspect_ratioMediaFeatureEval):
+ (WebCore::gridMediaFeatureEval):
+ (WebCore::device_heightMediaFeatureEval):
+ (WebCore::device_widthMediaFeatureEval):
+ (WebCore::heightMediaFeatureEval):
+ (WebCore::widthMediaFeatureEval):
+ (WebCore::min_colorMediaFeatureEval):
+ (WebCore::max_colorMediaFeatureEval):
+ (WebCore::min_monochromeMediaFeatureEval):
+ (WebCore::max_monochromeMediaFeatureEval):
+ (WebCore::min_device_aspect_ratioMediaFeatureEval):
+ (WebCore::max_device_aspect_ratioMediaFeatureEval):
+ (WebCore::min_heightMediaFeatureEval):
+ (WebCore::max_heightMediaFeatureEval):
+ (WebCore::min_widthMediaFeatureEval):
+ (WebCore::max_widthMediaFeatureEval):
+ (WebCore::min_device_heightMediaFeatureEval):
+ (WebCore::max_device_heightMediaFeatureEval):
+ (WebCore::min_device_widthMediaFeatureEval):
+ (WebCore::max_device_widthMediaFeatureEval):
+ (WebCore::createFunctionMap):
+ * css/MediaQueryEvaluator.h: Added.
+ * css/MediaQueryExp.cpp: Added.
+ (WebCore::MediaQueryExp::MediaQueryExp):
+ (WebCore::MediaQueryExp::~MediaQueryExp):
+ * css/MediaQueryExp.h: Added.
+ (WebCore::MediaQueryExp::mediaFeature):
+ (WebCore::MediaQueryExp::value):
+ (WebCore::MediaQueryExp::operator==):
+ * css/StyleSheet.cpp:
+ (WebCore::StyleSheet::setMedia):
+ * css/cssparser.cpp:
+ (WebCore::CSSParser::CSSParser):
+ (WebCore::CSSParser::~CSSParser):
+ (WebCore::CSSParser::setupParser):
+ (WebCore::CSSParser::parseMediaQuery):
+ (WebCore::CSSParser::createFloatingMediaQueryExp):
+ (WebCore::CSSParser::sinkFloatingMediaQueryExp):
+ (WebCore::CSSParser::createFloatingMediaQueryExpList):
+ (WebCore::CSSParser::sinkFloatingMediaQueryExpList):
+ (WebCore::CSSParser::createFloatingMediaQuery):
+ (WebCore::CSSParser::sinkFloatingMediaQuery):
+ * css/cssparser.h:
+ * css/cssstyleselector.cpp:
+ (WebCore::CSSStyleSelector::CSSStyleSelector):
+ (WebCore::CSSStyleSelector::init):
+ (WebCore::CSSStyleSelector::~CSSStyleSelector):
+ (WebCore::CSSStyleSelector::loadDefaultStyle):
+ (WebCore::CSSStyleSelector::matchUARules):
+ (WebCore::CSSStyleSelector::styleForElement):
+ (WebCore::CSSStyleSelector::pseudoStyleForElement):
+ (WebCore::CSSStyleSelector::updateFont):
+ (WebCore::CSSStyleSelector::cacheBorderAndBackground):
+ (WebCore::CSSStyleSelector::styleRulesForElement):
+ (WebCore::CSSRuleSet::addRulesFromSheet):
+ * css/cssstyleselector.h:
+ * css/maketokenizer:
+ * css/tokenizer.flex:
+ * dom/DOMImplementation.cpp:
+ (WebCore::DOMImplementation::createCSSStyleSheet):
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::process):
+ (WebCore::HTMLLinkElement::setStyleSheet):
+ * html/HTMLStyleElement.cpp:
+ (WebCore::HTMLStyleElement::childrenChanged):
+ * ksvg2/svg/SVGDOMImplementation.cpp:
+ (SVGDOMImplementation::createCSSStyleSheet):
+ * ksvg2/svg/SVGStyleElement.cpp:
+ (WebCore::SVGStyleElement::childrenChanged):
+ * page/Frame.cpp:
+ (WebCore::Frame::Frame):
+ * platform/Screen.h:
+ * platform/mac/ScreenMac.mm:
+ (WebCore::screenDepthPerComponent):
+ (WebCore::screenIsMonochrome):
+
2006-06-08 Justin Garcia <justin.garcia@apple.com>
Reviewed by levi
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index da119cd..3b3179a 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -150,6 +150,14 @@
1AE2AEC80A1D297B00B42B25 /* JSHTMLQuoteElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE2AEC40A1D297B00B42B25 /* JSHTMLQuoteElement.h */; };
1AE2AEE60A1D2A7500B42B25 /* JSHTMLBlockquoteElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE2AEE40A1D2A7500B42B25 /* JSHTMLBlockquoteElement.cpp */; };
1AE2AEE70A1D2A7500B42B25 /* JSHTMLBlockquoteElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE2AEE50A1D2A7500B42B25 /* JSHTMLBlockquoteElement.h */; };
+ 4E1959210A39DABA00220FE5 /* MediaFeatureNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */; };
+ 4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */; };
+ 4E1959290A39DACC00220FE5 /* MediaQuery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4E1959230A39DACC00220FE5 /* MediaQuery.cpp */; };
+ 4E19592A0A39DACC00220FE5 /* MediaQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959240A39DACC00220FE5 /* MediaQuery.h */; };
+ 4E19592B0A39DACC00220FE5 /* MediaQueryEvaluator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4E1959250A39DACC00220FE5 /* MediaQueryEvaluator.cpp */; };
+ 4E19592C0A39DACC00220FE5 /* MediaQueryEvaluator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959260A39DACC00220FE5 /* MediaQueryEvaluator.h */; };
+ 4E19592D0A39DACC00220FE5 /* MediaQueryExp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4E1959270A39DACC00220FE5 /* MediaQueryExp.cpp */; };
+ 4E19592E0A39DACC00220FE5 /* MediaQueryExp.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959280A39DACC00220FE5 /* MediaQueryExp.h */; };
5126E6BB0A2E3B12005C29FA /* IconDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5126E6B90A2E3B12005C29FA /* IconDatabase.cpp */; };
5126E6BC0A2E3B12005C29FA /* IconDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 5126E6BA0A2E3B12005C29FA /* IconDatabase.h */; settings = {ATTRIBUTES = (Private, ); }; };
5126E6BF0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 5126E6BD0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -1735,6 +1743,14 @@
2D90660B0665D937006B6F1A /* ClipboardMac.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ClipboardMac.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
2D90660C0665D937006B6F1A /* ClipboardMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ClipboardMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
4758C44308C5F217009BAF05 /* KCanvasPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasPath.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+ 4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaFeatureNames.cpp; sourceTree = "<group>"; };
+ 4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaFeatureNames.h; sourceTree = "<group>"; };
+ 4E1959230A39DACC00220FE5 /* MediaQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQuery.cpp; sourceTree = "<group>"; };
+ 4E1959240A39DACC00220FE5 /* MediaQuery.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaQuery.h; sourceTree = "<group>"; };
+ 4E1959250A39DACC00220FE5 /* MediaQueryEvaluator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryEvaluator.cpp; sourceTree = "<group>"; };
+ 4E1959260A39DACC00220FE5 /* MediaQueryEvaluator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaQueryEvaluator.h; sourceTree = "<group>"; };
+ 4E1959270A39DACC00220FE5 /* MediaQueryExp.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryExp.cpp; sourceTree = "<group>"; };
+ 4E1959280A39DACC00220FE5 /* MediaQueryExp.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaQueryExp.h; sourceTree = "<group>"; };
5126E6B90A2E3B12005C29FA /* IconDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IconDatabase.cpp; sourceTree = "<group>"; };
5126E6BA0A2E3B12005C29FA /* IconDatabase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IconDatabase.h; sourceTree = "<group>"; };
5126E6BD0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreIconDatabaseBridge.h; sourceTree = "<group>"; };
@@ -5057,6 +5073,14 @@
F523D18402DE42E8018635CA /* css */ = {
isa = PBXGroup;
children = (
+ 4E1959230A39DACC00220FE5 /* MediaQuery.cpp */,
+ 4E1959240A39DACC00220FE5 /* MediaQuery.h */,
+ 4E1959250A39DACC00220FE5 /* MediaQueryEvaluator.cpp */,
+ 4E1959260A39DACC00220FE5 /* MediaQueryEvaluator.h */,
+ 4E1959270A39DACC00220FE5 /* MediaQueryExp.cpp */,
+ 4E1959280A39DACC00220FE5 /* MediaQueryExp.h */,
+ 4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */,
+ 4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */,
A80E6CDA0A1989CA007FB8C5 /* Counter.h */,
930705C709E0C95F00B17FE4 /* Counter.idl */,
A80E6CBB0A1989CA007FB8C5 /* CSSBorderImageValue.cpp */,
@@ -6207,6 +6231,10 @@
5126E6BC0A2E3B12005C29FA /* IconDatabase.h in Headers */,
5126E6BF0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h in Headers */,
D07DEABA0A36554A00CA30F8 /* InsertListCommand.h in Headers */,
+ 4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */,
+ 4E19592A0A39DACC00220FE5 /* MediaQuery.h in Headers */,
+ 4E19592C0A39DACC00220FE5 /* MediaQueryEvaluator.h in Headers */,
+ 4E19592E0A39DACC00220FE5 /* MediaQueryExp.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -7044,6 +7072,10 @@
5126E6BB0A2E3B12005C29FA /* IconDatabase.cpp in Sources */,
5126E6C00A2E3B29005C29FA /* WebCoreIconDatabaseBridge.mm in Sources */,
D07DEAB90A36554A00CA30F8 /* InsertListCommand.cpp in Sources */,
+ 4E1959210A39DABA00220FE5 /* MediaFeatureNames.cpp in Sources */,
+ 4E1959290A39DACC00220FE5 /* MediaQuery.cpp in Sources */,
+ 4E19592B0A39DACC00220FE5 /* MediaQueryEvaluator.cpp in Sources */,
+ 4E19592D0A39DACC00220FE5 /* MediaQueryExp.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/WebCore/bindings/js/kjs_css.cpp b/WebCore/bindings/js/kjs_css.cpp
index 28dd557..95929c3 100644
--- a/WebCore/bindings/js/kjs_css.cpp
+++ b/WebCore/bindings/js/kjs_css.cpp
@@ -530,9 +530,10 @@
void DOMMediaList::put(ExecState* exec, const Identifier &propertyName, JSValue* value, int attr)
{
+ DOMExceptionTranslator exception(exec);
MediaList &mediaList = *m_impl;
if (propertyName == "mediaText")
- mediaList.setMediaText(value->toString(exec));
+ mediaList.setMediaText(value->toString(exec), exception);
else
DOMObject::put(exec, propertyName, value, attr);
}
@@ -546,15 +547,16 @@
{
if (!thisObj->inherits(&KJS::DOMMediaList::info))
return throwError(exec, TypeError);
- MediaList &mediaList = *static_cast<DOMMediaList*>(thisObj)->impl();
+ DOMExceptionTranslator exception(exec);
+ MediaList& mediaList = *static_cast<DOMMediaList *>(thisObj)->impl();
switch (id) {
case DOMMediaList::Item:
return jsStringOrNull(mediaList.item(args[0]->toInt32(exec)));
case DOMMediaList::DeleteMedium:
- mediaList.deleteMedium(args[0]->toString(exec));
+ mediaList.deleteMedium(args[0]->toString(exec), exception);
return jsUndefined();
case DOMMediaList::AppendMedium:
- mediaList.appendMedium(args[0]->toString(exec));
+ mediaList.appendMedium(args[0]->toString(exec), exception);
return jsUndefined();
default:
return jsUndefined();
diff --git a/WebCore/bindings/objc/DOMCSS.mm b/WebCore/bindings/objc/DOMCSS.mm
index 0c5dd6b..bd46156 100644
--- a/WebCore/bindings/objc/DOMCSS.mm
+++ b/WebCore/bindings/objc/DOMCSS.mm
@@ -333,7 +333,9 @@
- (void)setMediaText:(NSString *)mediaText
{
- [self _mediaList]->setMediaText(mediaText);
+ ExceptionCode ec = 0;
+ [self _mediaList]->setMediaText(mediaText, ec);
+ raiseOnDOMError(ec);
}
- (unsigned)length
@@ -348,12 +350,16 @@
- (void)deleteMedium:(NSString *)oldMedium
{
- [self _mediaList]->deleteMedium(oldMedium);
+ ExceptionCode ec = 0;
+ [self _mediaList]->deleteMedium(oldMedium, ec);
+ raiseOnDOMError(ec);
}
- (void)appendMedium:(NSString *)newMedium
{
- [self _mediaList]->appendMedium(newMedium);
+ ExceptionCode ec = 0;
+ [self _mediaList]->appendMedium(newMedium, ec);
+ raiseOnDOMError(ec);
}
@end
diff --git a/WebCore/css/CSSGrammar.y b/WebCore/css/CSSGrammar.y
index 5e2462b..a93d375 100644
--- a/WebCore/css/CSSGrammar.y
+++ b/WebCore/css/CSSGrammar.y
@@ -38,6 +38,8 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
+#include "MediaQuery.h"
+#include "MediaQueryExp.h"
#if SVG_SUPPORT
#include "ksvgcssproperties.h"
@@ -139,6 +141,11 @@
char tok;
Value value;
ValueList* valueList;
+
+ MediaQuery* mediaQuery;
+ MediaQueryExp* mediaQueryExp;
+ Vector<MediaQueryExp*>* mediaQueryExpList;
+ MediaQuery::Restrictor mediaQueryRestrictor;
}
%{
@@ -181,8 +188,12 @@
%token WEBKIT_RULE_SYM
%token WEBKIT_DECLS_SYM
%token WEBKIT_VALUE_SYM
+%token WEBKIT_MEDIAQUERY_SYM
%token IMPORTANT_SYM
+%token MEDIA_ONLY
+%token MEDIA_NOT
+%token MEDIA_AND
%token <val> QEMS
%token <val> EMS
@@ -231,8 +242,15 @@
%type <string> medium
%type <string> hexcolor
+%type <string> media_feature
%type <mediaList> media_list
%type <mediaList> maybe_media_list
+%type <mediaQuery> media_query
+%type <mediaQueryRestrictor> maybe_media_restrictor
+%type <valueList> maybe_media_value
+%type <mediaQueryExp> media_query_exp
+%type <mediaQueryExpList> media_query_exp_list
+%type <mediaQueryExpList> maybe_media_query_exp_list
%type <ruleList> ruleset_list
@@ -272,6 +290,7 @@
| webkit_rule maybe_space
| webkit_decls maybe_space
| webkit_value maybe_space
+ | webkit_mediaquery maybe_space
;
webkit_rule:
@@ -300,6 +319,13 @@
}
;
+webkit_mediaquery:
+ WEBKIT_MEDIAQUERY_SYM WHITESPACE maybe_space media_query '}' {
+ CSSParser* p = static_cast<CSSParser*>(parser);
+ p->mediaQuery = p->sinkFloatingMediaQuery($4);
+ }
+;
+
maybe_space:
/* empty */ %prec UNIMPORTANT_TOK
| maybe_space WHITESPACE
@@ -383,23 +409,84 @@
| URI
;
+media_feature:
+ IDENT maybe_space {
+ $$ = $1;
+ }
+ ;
+
+maybe_media_value:
+ /*empty*/ {
+ $$ = 0;
+ }
+ | ':' maybe_space expr maybe_space {
+ $$ = $3;
+ }
+ ;
+
+media_query_exp:
+ MEDIA_AND maybe_space '(' maybe_space media_feature maybe_space maybe_media_value ')' maybe_space {
+ $5.lower();
+ $$ = static_cast<CSSParser*>(parser)->createFloatingMediaQueryExp(atomicString($5), $7);
+ }
+ ;
+
+media_query_exp_list:
+ media_query_exp {
+ CSSParser* p = static_cast<CSSParser*>(parser);
+ $$ = p->createFloatingMediaQueryExpList();
+ $$->append(p->sinkFloatingMediaQueryExp($1));
+ }
+ | media_query_exp_list media_query_exp {
+ $$ = $1;
+ $$->append(static_cast<CSSParser*>(parser)->sinkFloatingMediaQueryExp($2));
+ }
+ ;
+
+maybe_media_query_exp_list:
+ /*empty*/ {
+ $$ = static_cast<CSSParser*>(parser)->createFloatingMediaQueryExpList();
+ }
+ | media_query_exp_list
+ ;
+
+maybe_media_restrictor:
+ /*empty*/ {
+ $$ = MediaQuery::None;
+ }
+ | MEDIA_ONLY {
+ $$ = MediaQuery::Only;
+ }
+ | MEDIA_NOT {
+ $$ = MediaQuery::Not;
+ }
+ ;
+
+media_query:
+ maybe_media_restrictor maybe_space medium maybe_media_query_exp_list {
+ CSSParser* p = static_cast<CSSParser*>(parser);
+ $3.lower();
+ $$ = p->createFloatingMediaQuery($1, domString($3), p->sinkFloatingMediaQueryExpList($4));
+ }
+ ;
+
maybe_media_list:
/* empty */ {
$$ = static_cast<CSSParser*>(parser)->createMediaList();
}
| media_list
-;
-
+ ;
media_list:
- medium {
- $$ = static_cast<CSSParser*>(parser)->createMediaList();
- $$->appendMedium(domString($1).lower());
+ media_query {
+ CSSParser* p = static_cast<CSSParser*>(parser);
+ $$ = p->createMediaList();
+ $$->appendMediaQuery(p->sinkFloatingMediaQuery($1));
}
- | media_list ',' maybe_space medium {
+ | media_list ',' maybe_space media_query {
$$ = $1;
if ($$)
- $$->appendMedium(domString($4).lower());
+ $$->appendMediaQuery(static_cast<CSSParser*>(parser)->sinkFloatingMediaQuery($4));
}
| media_list error {
$$ = 0;
diff --git a/WebCore/css/MediaFeatureNames.cpp b/WebCore/css/MediaFeatureNames.cpp
new file mode 100644
index 0000000..e015d7d
--- /dev/null
+++ b/WebCore/css/MediaFeatureNames.cpp
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 2005 Apple Computer, Inc.
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#if AVOID_STATIC_CONSTRUCTORS
+#define CSS_MEDIAQUERY_NAMES_HIDE_GLOBALS 1
+#endif
+
+#include "MediaFeatureNames.h"
+#include "StaticConstructors.h"
+
+namespace WebCore { namespace MediaFeatureNames {
+
+#define DEFINE_MEDIAFEATURE_GLOBAL(name, str) \
+ DEFINE_GLOBAL(AtomicString, name##MediaFeature, str)
+CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(DEFINE_MEDIAFEATURE_GLOBAL)
+#undef DEFINE_MEDIAFEATURE_GLOBAL
+
+void init()
+{
+ static bool initialized;
+ if (!initialized) {
+ // Use placement new to initialize the globals.
+
+ AtomicString::init();
+ #define INITIALIZE_GLOBAL(name, str) new ((void*)&name##MediaFeature) AtomicString(str);
+ CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(INITIALIZE_GLOBAL)
+ #undef INITIALIZE_GLOBAL
+ initialized = true;
+ }
+}
+
+} }
diff --git a/WebCore/css/MediaFeatureNames.h b/WebCore/css/MediaFeatureNames.h
new file mode 100644
index 0000000..7530165
--- /dev/null
+++ b/WebCore/css/MediaFeatureNames.h
@@ -0,0 +1,65 @@
+/*
+ * This file is part of the CSS implementation for KDE.
+ *
+ * Copyright (C) 2005 Apple Computer, Inc.
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+#ifndef MEDIAFEATURENAMES_H
+#define MEDIAFEATURENAMES_H
+
+#include "AtomicString.h"
+
+namespace WebCore { namespace MediaFeatureNames {
+
+#define CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(macro) \
+ macro(color, "color") \
+ macro(grid, "grid") \
+ macro(monochrome, "monochrome") \
+ macro(height, "height") \
+ macro(width, "width") \
+ macro(device_aspect_ratio, "device-aspect-ratio") \
+ macro(device_height, "device-height") \
+ macro(device_width, "device-width") \
+ macro(max_color, "max-color") \
+ macro(max_device_aspect_ratio, "max-device-aspect-ratio") \
+ macro(max_device_height, "max-device-height") \
+ macro(max_device_width, "max-device-width") \
+ macro(max_height, "max-height") \
+ macro(max_monochrome, "max-monochrome") \
+ macro(max_width, "max-width") \
+ macro(min_color, "min-color") \
+ macro(min_device_aspect_ratio, "min-device-aspect-ratio") \
+ macro(min_device_height, "min-device-height") \
+ macro(min_device_width, "min-device-width") \
+ macro(min_height, "min-height") \
+ macro(min_monochrome, "min-monochrome") \
+ macro(min_width, "min-width") \
+// end of macro
+
+#if !CSS_MEDIAQUERY_NAMES_HIDE_GLOBALS
+ #define CSS_MEDIAQUERY_NAMES_DECLARE(name, str) extern const AtomicString name##MediaFeature;
+ CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(CSS_MEDIAQUERY_NAMES_DECLARE)
+ #undef CSS_MEDIAQUERY_NAMES_DECLARE
+#endif
+
+ void init();
+} }
+
+#endif
+
+
diff --git a/WebCore/css/MediaList.cpp b/WebCore/css/MediaList.cpp
index 675e595..a0184b8 100644
--- a/WebCore/css/MediaList.cpp
+++ b/WebCore/css/MediaList.cpp
@@ -25,29 +25,79 @@
#include "CSSRule.h"
#include "CSSStyleSheet.h"
#include "DeprecatedStringList.h"
+#include "ExceptionCode.h"
+#include "MediaQuery.h"
+#include "cssparser.h"
+
namespace WebCore {
-MediaList::MediaList(CSSStyleSheet* parentSheet)
+/* MediaList is used to store 3 types of media related entities which mean the same:
+ * Media Queries, Media Types and Media Descriptors.
+ * Currently MediaList always tries to parse media queries and if parsing fails,
+ * tries to fallback to Media Descriptors if m_fallback flag is set.
+ * Slight problem with syntax error handling:
+ * CSS 2.1 Spec (http://www.w3.org/TR/CSS21/media.html)
+ * specifies that failing media type parsing is a syntax error
+ * CSS 3 Media Queries Spec (http://www.w3.org/TR/css3-mediaqueries/)
+ * specifies that failing media query is a syntax error
+ * HTML 4.01 spec (http://www.w3.org/TR/REC-html40/present/styles.html#adef-media)
+ * specifies that Media Descriptors should be parsed with forward-compatible syntax
+ * DOM Level 2 Style Sheet spec (http://www.w3.org/TR/DOM-Level-2-Style/)
+ * talks about MediaList.mediaText and refers
+ * - to Media Descriptors of HTML 4.0 in context of StyleSheet
+ * - to Media Types of CSS 2.0 in context of CSSMediaRule and CSSImportRule
+ *
+ * These facts create situation where same (illegal) media specification may result in
+ * different parses depending on whether it is media attr of style element or part of
+ * css @media rule.
+ * <style media="screen and resolution > 40dpi"> ..</style> will be enabled on screen devices where as
+ * @media screen and resolution > 40dpi {..} will not.
+ * This gets more counter-intuitive in JavaScript:
+ * document.styleSheets[0].media.mediaText = "screen and resolution > 40dpi" will be ok and
+ * enabled, while
+ * document.styleSheets[0].cssRules[0].media.mediaText = "screen and resolution > 40dpi" will
+ * throw SYNTAX_ERR exception.
+ */
+
+MediaList::MediaList(CSSStyleSheet* parentSheet, bool fallbackToDescriptor)
: StyleBase(parentSheet)
+ , m_fallback(fallbackToDescriptor)
{
}
-MediaList::MediaList(CSSStyleSheet* parentSheet, const String& media)
+MediaList::MediaList(CSSStyleSheet* parentSheet, const String& media, bool fallbackToDescriptor)
: StyleBase(parentSheet)
+ , m_fallback(fallbackToDescriptor)
{
- setMediaText(media);
+ ExceptionCode ec = 0;
+ setMediaText(media, ec);
+ // FIXME: parsing can fail. The problem with failing constructor is that
+ // we would need additional flag saying MediaList is not valid
+ // Parse can fail only when fallbackToDescriptor == false, i.e when HTML4 media descriptor
+ // forward-compatible syntax is not in use.
+ // DOMImplementationCSS seems to mandate that media descriptors are used
+ // for both html and svg, even though svg:style doesn't use media descriptors
+ // Currently the only places where parsing can fail are
+ // creating <svg:style>, creating css media / import rules from js
+ if (ec)
+ setMediaText("invalid", ec);
}
-MediaList::MediaList(CSSRule* parentRule, const String& media)
+MediaList::MediaList(CSSRule* parentRule, const String& media, bool fallbackToDescriptor)
: StyleBase(parentRule)
+ , m_fallback(fallbackToDescriptor)
{
- setMediaText(media);
+ ExceptionCode ec = 0;
+ setMediaText(media, ec);
+ //FIXME: parsing can fail.
+ if (ec)
+ setMediaText("invalid", ec);
}
-bool MediaList::contains(const String& medium) const
+MediaList::~MediaList()
{
- return m_lstMedia.count() == 0 || m_lstMedia.contains(medium) || m_lstMedia.contains("all");
+ deleteAllValues(m_queries);
}
CSSStyleSheet *MediaList::parentStyleSheet() const
@@ -60,36 +110,147 @@
return parent()->isRule() ? static_cast<CSSRule*>(parent()) : 0;
}
-void MediaList::deleteMedium(const String& oldMedium)
+static String parseMediaDescriptor(const String& s)
{
- for (DeprecatedValueList<String>::Iterator it = m_lstMedia.begin(); it != m_lstMedia.end(); ++it) {
- if ((*it) == oldMedium) {
- m_lstMedia.remove(it);
- return;
+ int len = s.length();
+
+ // http://www.w3.org/TR/REC-html40/types.html#type-media-descriptors
+ // "Each entry is truncated just before the first character that isn't a
+ // US ASCII letter [a-zA-Z] (ISO 10646 hex 41-5a, 61-7a), digit [0-9] (hex 30-39),
+ // or hyphen (hex 2d)."
+ int i;
+ unsigned short c;
+ for (i = 0; i < len; ++i) {
+ c = s[i];
+ if (! ((c >= 'a' && c <= 'z')
+ || (c >= 'A' && c <= 'Z')
+ || (c >= '1' && c <= '9')
+ || (c == '-')))
+ break;
+ }
+ return s.left(i);
+}
+
+void MediaList::deleteMedium(const String& oldMedium, ExceptionCode& ec)
+{
+ MediaList tempMediaList;
+ CSSParser p(true);
+
+ MediaQuery* oldQuery = 0;
+ bool deleteOldQuery = false;
+
+ if (p.parseMediaQuery(&tempMediaList, oldMedium)) {
+ if (tempMediaList.m_queries.size() > 0)
+ oldQuery = tempMediaList.m_queries[0];
+ } else if (m_fallback) {
+ String medium = parseMediaDescriptor(oldMedium);
+ if (!medium.isNull()) {
+ oldQuery = new MediaQuery(MediaQuery::None, medium, 0);
+ deleteOldQuery = true;
}
}
+
+ // DOM Style Sheets spec doesn't allow SYNTAX_ERR to be thrown in deleteMedium
+ ec = NOT_FOUND_ERR;
+
+ if (oldQuery) {
+ for(size_t i = 0; i < m_queries.size(); ++i) {
+ MediaQuery* a = m_queries[i];
+ if (*a == *oldQuery) {
+ m_queries.remove(i);
+ delete a;
+ ec = 0;
+ break;
+ }
+ }
+ if (deleteOldQuery)
+ delete oldQuery;
+ }
}
WebCore::String MediaList::mediaText() const
{
- String text = "";
- for (DeprecatedValueList<String>::ConstIterator it = m_lstMedia.begin(); it != m_lstMedia.end(); ++it) {
- if (text.length() > 0)
+ String text("");
+
+ bool first = true;
+ for (size_t i = 0; i < m_queries.size(); ++i) {
+ if (!first)
text += ", ";
- text += *it;
+ else
+ first = false;
+ text += m_queries[i]->cssText();
}
+
return text;
}
-void MediaList::setMediaText(const WebCore::String& value)
+void MediaList::setMediaText(const WebCore::String& value, ExceptionCode& ec)
{
- m_lstMedia.clear();
+ MediaList tempMediaList;
+ CSSParser p(true);
+
DeprecatedStringList list = DeprecatedStringList::split(',', value.deprecatedString());
for (DeprecatedStringList::Iterator it = list.begin(); it != list.end(); ++it) {
String medium = (*it).stripWhiteSpace();
- if (!medium.isEmpty())
- m_lstMedia.append(medium);
+ if (!medium.isEmpty()) {
+ if (!p.parseMediaQuery(&tempMediaList, medium)) {
+ if (m_fallback) {
+ String mediaDescriptor = parseMediaDescriptor(medium);
+ if (!mediaDescriptor.isNull())
+ tempMediaList.m_queries.append(new MediaQuery(MediaQuery::None, mediaDescriptor, 0));
+ } else {
+ ec = SYNTAX_ERR;
+ return;
+ }
+ }
+ } else if (!m_fallback) {
+ ec = SYNTAX_ERR;
+ return;
+ }
}
+ // ",,,," falls straight through, but is not valid unless fallback
+ if (!m_fallback && list.begin() == list.end()) {
+ String s = value.deprecatedString().stripWhiteSpace();
+ if (!s.isEmpty()) {
+ ec = SYNTAX_ERR;
+ return;
+ }
+ }
+
+ ec = 0;
+ deleteAllValues(m_queries);
+ m_queries = tempMediaList.m_queries;
+ tempMediaList.m_queries.clear();
+}
+
+String MediaList::item(unsigned index) const
+{
+ if (index < m_queries.size()) {
+ MediaQuery* query = m_queries[index];
+ return query->cssText();
+ }
+
+ return String();
+}
+
+void MediaList::appendMedium(const String& newMedium, ExceptionCode& ec)
+{
+ ec = INVALID_CHARACTER_ERR;
+ CSSParser p(true);
+ if (p.parseMediaQuery(this, newMedium)) {
+ ec = 0;
+ } else if (m_fallback) {
+ String medium = parseMediaDescriptor(newMedium);
+ if (!medium.isNull()) {
+ m_queries.append(new MediaQuery(MediaQuery::None, medium, 0));
+ ec = 0;
+ }
+ }
+}
+
+void MediaList::appendMediaQuery(MediaQuery* mediaQuery)
+{
+ m_queries.append(mediaQuery);
}
}
diff --git a/WebCore/css/MediaList.h b/WebCore/css/MediaList.h
index 3691e21..8a5b201 100644
--- a/WebCore/css/MediaList.h
+++ b/WebCore/css/MediaList.h
@@ -24,46 +24,42 @@
#define MediaList_H
#include "StyleBase.h"
-#include "DeprecatedValueList.h"
+#include <wtf/Vector.h>
#include "PlatformString.h"
namespace WebCore {
-
+typedef int ExceptionCode;
class CSSStyleSheet;
+class MediaQuery;
class CSSRule;
class MediaList : public StyleBase
{
public:
- MediaList() : StyleBase(0) {}
- MediaList(CSSStyleSheet* parentSheet);
- MediaList(CSSStyleSheet* parentSheet, const String& media);
- MediaList(CSSRule* parentRule, const String& media);
+ MediaList(bool fallbackToDescription = false) : StyleBase(0), m_fallback(fallbackToDescription) {}
+ MediaList(CSSStyleSheet* parentSheet, bool fallbackToDescription = false);
+ MediaList(CSSStyleSheet* parentSheet, const String& media, bool fallbackToDescription = false);
+ MediaList(CSSRule* parentRule, const String& media, bool fallbackToDescription = false);
+ ~MediaList();
virtual bool isMediaList() { return true; }
CSSStyleSheet* parentStyleSheet() const;
CSSRule* parentRule() const;
- unsigned length() const { return m_lstMedia.count(); }
- String item(unsigned index) const { return m_lstMedia[index]; }
- void deleteMedium(const String& oldMedium);
- void appendMedium(const String& newMedium) { m_lstMedia.append(newMedium); }
+ unsigned length() const { return (unsigned) m_queries.size(); }
+ String item(unsigned index) const;
+ void deleteMedium(const String& oldMedium, ExceptionCode&);
+ void appendMedium(const String& newMedium, ExceptionCode&);
String mediaText() const;
- void setMediaText(const String&);
+ void setMediaText(const String&, ExceptionCode&xo);
- /**
- * Check if the list contains either the requested medium, or the
- * catch-all "all" media type. Returns true when found, false otherwise.
- * Since not specifying media types should be treated as "all" according
- * to DOM specs, an empty list always returns true.
- *
- * _NOT_ part of the DOM!
- */
- bool contains(const String& medium) const;
+ void appendMediaQuery(MediaQuery* mediaQuery);
+ const Vector<MediaQuery*>* mediaQueries() const { return &m_queries; }
protected:
- DeprecatedValueList<String> m_lstMedia;
+ Vector<MediaQuery*> m_queries;
+ bool m_fallback; // true if failed media query parsing should fallback to media description parsing
};
} // namespace
diff --git a/WebCore/css/MediaQuery.cpp b/WebCore/css/MediaQuery.cpp
new file mode 100644
index 0000000..ff57372
--- /dev/null
+++ b/WebCore/css/MediaQuery.cpp
@@ -0,0 +1,97 @@
+/*
+ * CSS Media Query
+ *
+ * Copyright (C) 2005, 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MediaQuery.h"
+
+#include "MediaQueryExp.h"
+
+namespace WebCore {
+
+MediaQuery::MediaQuery(Restrictor r, const String& mediaType, Vector<MediaQueryExp*>* exprs)
+ : m_restrictor(r)
+ , m_mediaType(mediaType)
+ , m_expressions(exprs)
+{
+ if (!m_expressions)
+ m_expressions = new Vector<MediaQueryExp*>;
+}
+
+MediaQuery::~MediaQuery()
+{
+ if (m_expressions) {
+ deleteAllValues(*m_expressions);
+ delete m_expressions;
+ }
+}
+
+bool MediaQuery::operator==(const MediaQuery& other) const
+{
+ if (m_restrictor != other.m_restrictor
+ || m_mediaType != other.m_mediaType
+ || m_expressions->size() != other.m_expressions->size())
+ return false;
+
+ for (size_t i = 0; i < m_expressions->size(); ++i) {
+ MediaQueryExp* exp = m_expressions->at(i);
+ MediaQueryExp* oexp = other.m_expressions->at(i);
+ if (!(*exp == *oexp))
+ return false;
+ }
+
+ return true;
+}
+
+String MediaQuery::cssText() const
+{
+ String text;
+ switch (m_restrictor) {
+ case MediaQuery::Only:
+ text += "only ";
+ break;
+ case MediaQuery::Not:
+ text += "not ";
+ break;
+ case MediaQuery::None:
+ default:
+ break;
+ }
+ text += m_mediaType;
+ for (size_t i = 0; i < m_expressions->size(); ++i) {
+ MediaQueryExp* exp = m_expressions->at(i);
+ text += " and (";
+ text += exp->mediaFeature();
+ if (exp->value()) {
+ text += ": ";
+ text += exp->value()->cssText();
+ }
+ text += ")";
+ }
+ return text;
+}
+
+} //namespace
diff --git a/WebCore/css/MediaQuery.h b/WebCore/css/MediaQuery.h
new file mode 100644
index 0000000..0aa0da1
--- /dev/null
+++ b/WebCore/css/MediaQuery.h
@@ -0,0 +1,62 @@
+/*
+ * CSS Media Query
+ *
+ * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MediaQuery_h
+#define MediaQuery_h
+
+#include "PlatformString.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+class MediaQueryExp;
+
+class MediaQuery
+{
+public:
+ enum Restrictor {
+ Only, Not, None
+ };
+
+ MediaQuery(Restrictor r, const String& mediaType, Vector<MediaQueryExp*>* exprs);
+ ~MediaQuery();
+
+ Restrictor restrictor() const { return m_restrictor; }
+ const Vector<MediaQueryExp*>* expressions() const { return m_expressions; }
+ String mediaType() const { return m_mediaType; }
+ bool operator==(const MediaQuery& other) const;
+ void append(MediaQueryExp* newExp) { m_expressions->append(newExp); }
+ String cssText() const;
+
+ private:
+ Restrictor m_restrictor;
+ String m_mediaType;
+ Vector<MediaQueryExp*>* m_expressions;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/MediaQueryEvaluator.cpp b/WebCore/css/MediaQueryEvaluator.cpp
new file mode 100644
index 0000000..e4ea439
--- /dev/null
+++ b/WebCore/css/MediaQueryEvaluator.cpp
@@ -0,0 +1,366 @@
+/*
+ * CSS Media Query Evaluator
+ *
+ * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MediaQueryEvaluator.h"
+
+#include "CSSPrimitiveValue.h"
+#include "CSSValueList.h"
+#include "FloatRect.h"
+#include "IntRect.h"
+#include "MediaFeatureNames.h"
+#include "MediaList.h"
+#include "MediaQuery.h"
+#include "MediaQueryExp.h"
+#include "rendering/render_style.h"
+#include "page/FrameView.h"
+#include "Screen.h"
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+using namespace MediaFeatureNames;
+
+enum MediaFeaturePrefix
+{
+ MinPrefix, MaxPrefix, NoPrefix
+};
+
+typedef bool (*EvalFunc)(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix op);
+typedef HashMap<AtomicStringImpl*, EvalFunc> FunctionMap;
+static FunctionMap* gFunctionMap;
+
+/*
+ * FIXME: following media features are not implemented: color_index, scan, resolution
+ *
+ * color_index, min-color-index, max_color_index: It's unknown how to retrieve
+ * the information if the display mode is indexed
+ * scan: The "scan" media feature describes the scanning process of
+ * tv output devices. It's unknown how to retrieve this information from
+ * the platform
+ * resolution, min-resolution, max-resolution: css parser doesn't seem to
+ * support CSS_DIMENSION
+ */
+
+MediaQueryEvaluator:: MediaQueryEvaluator(bool mediaFeatureResult)
+ : m_view(0)
+ , m_style(0)
+ , m_expResult(mediaFeatureResult)
+{
+}
+
+MediaQueryEvaluator:: MediaQueryEvaluator(const String& acceptedMediaType, bool mediaFeatureResult)
+ : m_mediaType(acceptedMediaType)
+ , m_view(0)
+ , m_style(0)
+ , m_expResult(mediaFeatureResult)
+{
+}
+
+MediaQueryEvaluator:: MediaQueryEvaluator(const String& acceptedMediaType, FrameView* view, RenderStyle* style)
+ : m_mediaType(acceptedMediaType.lower())
+ , m_view(view)
+ , m_style(style)
+ , m_expResult(false) // doesn't matter when we have m_view and m_style
+{
+}
+
+MediaQueryEvaluator::~MediaQueryEvaluator()
+{
+}
+
+bool MediaQueryEvaluator::mediaTypeMatch(const String& mediaTypeToMatch) const
+{
+ return mediaTypeToMatch.isEmpty()
+ || equalIgnoringCase(mediaTypeToMatch, "all")
+ || equalIgnoringCase(mediaTypeToMatch, m_mediaType);
+}
+
+static bool applyRestrictor(MediaQuery::Restrictor r, bool value)
+{
+ return r == MediaQuery::Not ? !value : value;
+}
+
+bool MediaQueryEvaluator::eval(const MediaList* mediaList) const
+{
+ if (!mediaList)
+ return true;
+
+ const Vector<MediaQuery*>* queries = mediaList->mediaQueries();
+ if (!queries->size())
+ return true; // empty query list evaluates to true
+
+ // iterate over queries, stop if any of them eval to true (OR semantics)
+ bool result = false;
+ for (size_t i = 0; i < queries->size() && !result; ++i) {
+ MediaQuery* query = queries->at(i);
+
+ if (mediaTypeMatch(query->mediaType())) {
+ const Vector<MediaQueryExp*>* exps = query->expressions();
+ // iterate through expressions, stop if any of them eval to false
+ // (AND semantics)
+ size_t j = 0;
+ for (; j < exps->size() && eval(exps->at(j)); ++j) /* empty*/;
+
+ // assume true if we are at the end of the list,
+ // otherwise assume false
+ result = applyRestrictor(query->restrictor(), exps->size() == j);
+ } else
+ result = applyRestrictor(query->restrictor(), false);
+ }
+
+ return result;
+}
+
+static bool parseAspectRatio(CSSValue* value, int& a, int& b)
+{
+ if (value->isValueList()){
+ CSSValueList* valueList = static_cast<CSSValueList*>(value);
+ if (valueList->length() == 3) {
+ CSSValue* i0 = valueList->item(0);
+ CSSValue* i1 = valueList->item(1);
+ CSSValue* i2 = valueList->item(2);
+ if (i0->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(i0)->primitiveType() == CSSPrimitiveValue::CSS_NUMBER
+ && i1->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(i1)->primitiveType() == CSSPrimitiveValue::CSS_STRING
+ && i2->isPrimitiveValue() && static_cast<CSSPrimitiveValue*>(i2)->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
+ String str = static_cast<CSSPrimitiveValue*>(i1)->getStringValue();
+ if (!str.isNull() && str.length() == 1 && str[0] == QChar('/')) {
+ a = (int) static_cast<CSSPrimitiveValue*>(i0)->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+ b = (int) static_cast<CSSPrimitiveValue*>(i2)->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+inline bool cmpvalue(int a, int b, MediaFeaturePrefix op)
+{
+ switch (op) {
+ case MinPrefix:
+ return a >= b;
+ case MaxPrefix:
+ return a <= b;
+ case NoPrefix:
+ return a == b;
+ }
+ return false;
+}
+
+static bool numberValue(CSSValue* value, float& result)
+{
+ if (value->isPrimitiveValue()
+ && static_cast<CSSPrimitiveValue*>(value)->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
+ result = static_cast<CSSPrimitiveValue*>(value)->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+ return true;
+ }
+ return false;
+}
+
+static bool colorMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix op)
+{
+ int bitsPerComponent = screenDepthPerComponent(view);
+ float number;
+ if (value)
+ return numberValue(value, number) && cmpvalue(bitsPerComponent, (int)number, op);
+
+ return bitsPerComponent != 0;
+}
+
+static bool monochromeMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix op)
+{
+ if (!screenIsMonochrome(view))
+ return false;
+
+ return colorMediaFeatureEval(value, style, view, op);
+}
+
+static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix op)
+{
+ if (value) {
+ FloatRect sg = screenRect(view);
+ int a = 0;
+ int b = 0;
+ if (parseAspectRatio(value, a, b))
+ return b != 0 && cmpvalue(a * (int)sg.height(), b * (int)sg.width(), op);
+ return false;
+ }
+
+ // ({,min-,max-}device-aspect-ratio)
+ // assume if we have a device, its aspect ratio is non-zero
+ return true;
+}
+
+static bool gridMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix op)
+{
+ // if output device is bitmap, grid: 0 == true
+ // assume we have bitmap device
+ float number;
+ if (value && numberValue(value, number))
+ return cmpvalue((int)number, 0, op);
+ return false;
+}
+
+static bool device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix op)
+{
+ if (value) {
+ FloatRect sg = screenRect(view);
+ return value->isPrimitiveValue() && cmpvalue((int)sg.height(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
+ }
+ // ({,min-,max-}device-height)
+ // assume if we have a device, assume non-zero
+ return true;
+}
+
+static bool device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix op)
+{
+ if (value) {
+ FloatRect sg = screenRect(view);
+ return value->isPrimitiveValue() && cmpvalue((int)sg.width(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
+ }
+ // ({,min-,max-}device-width)
+ // assume if we have a device, assume non-zero
+ return true;
+}
+
+static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix op)
+{
+ if (value)
+ return value->isPrimitiveValue() && cmpvalue(view->visibleHeight(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
+
+ return view->visibleHeight() != 0;
+}
+
+static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix op)
+{
+ if (value)
+ return value->isPrimitiveValue() && cmpvalue(view->visibleWidth(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
+
+ return view->visibleWidth() != 0;
+}
+
+// rest of the functions are trampolines which set the prefix according to the media feature expression used
+
+static bool min_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return colorMediaFeatureEval(value, style, view, MinPrefix);
+}
+
+static bool max_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return colorMediaFeatureEval(value, style, view, MaxPrefix);
+}
+
+static bool min_monochromeMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return monochromeMediaFeatureEval(value, style, view, MinPrefix);
+}
+
+static bool max_monochromeMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return monochromeMediaFeatureEval(value, style, view, MaxPrefix);
+}
+
+static bool min_device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return device_aspect_ratioMediaFeatureEval(value, style, view, MinPrefix);
+}
+
+static bool max_device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return device_aspect_ratioMediaFeatureEval(value, style, view, MaxPrefix);
+}
+
+static bool min_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return heightMediaFeatureEval(value, style, view, MinPrefix);
+}
+
+static bool max_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return heightMediaFeatureEval(value, style, view, MaxPrefix);
+}
+
+static bool min_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return widthMediaFeatureEval(value, style, view, MinPrefix);
+}
+
+static bool max_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return widthMediaFeatureEval(value, style, view, MaxPrefix);
+}
+
+static bool min_device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return device_heightMediaFeatureEval(value, style, view, MinPrefix);
+}
+
+static bool max_device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return device_heightMediaFeatureEval(value, style, view, MaxPrefix);
+}
+
+static bool min_device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return device_widthMediaFeatureEval(value, style, view, MinPrefix);
+}
+
+static bool max_device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, FrameView* view, MediaFeaturePrefix /*op*/)
+{
+ return device_widthMediaFeatureEval(value, style, view, MaxPrefix);
+}
+
+static void createFunctionMap()
+{
+ // Create the table.
+ gFunctionMap = new FunctionMap;
+#define ADD_TO_FUNCTIONMAP(name, str) \
+ gFunctionMap->set(name##MediaFeature.impl(), name##MediaFeatureEval);
+ CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP);
+#undef ADD_TO_FUNCTIONMAP
+}
+
+bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const
+{
+ if (!m_view || !m_style)
+ return m_expResult;
+
+ if (!gFunctionMap)
+ createFunctionMap();
+
+ // call the media feature evaluation function. Assume no prefix
+ // and let trampoline functions override the prefix if prefix is
+ // used
+ EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl());
+ if (func)
+ return func(expr->value(), m_style, m_view, NoPrefix);
+
+ return false;
+}
+
+} // namespace
diff --git a/WebCore/css/MediaQueryEvaluator.h b/WebCore/css/MediaQueryEvaluator.h
new file mode 100644
index 0000000..f33cec7
--- /dev/null
+++ b/WebCore/css/MediaQueryEvaluator.h
@@ -0,0 +1,88 @@
+/*
+ * CSS Media Query Evaluator
+ *
+ * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MediaQueryEvaluator_h
+#define MediaQueryEvaluator_h
+
+#include "PlatformString.h"
+
+namespace WebCore {
+class FrameView;
+class RenderStyle;
+class MediaList;
+class MediaQueryExp;
+
+/**
+ * Class that evaluates css media queries as defined in
+ * CSS3 Module "Media Queries" (http://www.w3.org/TR/css3-mediaqueries/)
+ * Special constructors are needed, if simple media queries are to be
+ * evaluated without knowledge of the medium features. This can happen
+ * for example when parsing UA stylesheets, if evaluation is done
+ * right after parsing.
+ *
+ * the boolean parameter is used to approximate results of evaluation, if
+ * the device characteristics are not known. This can be used to prune the loading
+ * of stylesheets to only those which are probable to match.
+ */
+class MediaQueryEvaluator
+{
+public:
+ /** Creates evaluator which evaluates only simple media queries
+ * Evaluator returns true for "all", and returns value of \mediaFeatureResult
+ * for any media features
+ */
+ MediaQueryEvaluator(bool mediaFeatureResult = false);
+
+ /** Creates evaluator which evaluates only simple media queries
+ * Evaluator returns true for acceptedMediaType and returns value of \mediafeatureResult
+ * for any media features
+ */
+ MediaQueryEvaluator(const String& acceptedMediaType, bool mediaFeatureResult = false);
+
+ /** Creates evaluator which evaluates full media queries
+ */
+ MediaQueryEvaluator(const String& acceptedMediaType, FrameView* view, RenderStyle* style);
+
+ ~MediaQueryEvaluator();
+
+ bool mediaTypeMatch(const String& mediaTypeToMatch) const;
+
+ /** Evaluates a list of media queries */
+ bool eval(const MediaList* query) const;
+
+ /** Evaluates media query subexpression, ie "and (media-feature: value)" part */
+ bool eval(const MediaQueryExp* expr) const;
+
+private:
+ String m_mediaType;
+ FrameView* m_view; // not owned
+ RenderStyle* m_style; // not owned
+ bool m_expResult;
+};
+
+} // namespace
+#endif
diff --git a/WebCore/css/MediaQueryExp.cpp b/WebCore/css/MediaQueryExp.cpp
new file mode 100644
index 0000000..bbab37f
--- /dev/null
+++ b/WebCore/css/MediaQueryExp.cpp
@@ -0,0 +1,86 @@
+/*
+ * CSS Media Query
+ *
+ * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MediaQueryExp.h"
+
+#include "cssparser.h"
+#include "CSSPrimitiveValue.h"
+#include "CSSValueList.h"
+
+namespace WebCore {
+
+MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, ValueList* valueList)
+ : m_mediaFeature(mediaFeature)
+ , m_value(0)
+{
+ if (valueList) {
+ if (valueList->size() == 1) {
+ Value* value = valueList->current();
+
+ if (value->id != 0)
+ m_value = new CSSPrimitiveValue(value->id);
+ else if (value->unit == CSSPrimitiveValue::CSS_STRING)
+ m_value = new CSSPrimitiveValue(domString(value->string), (CSSPrimitiveValue::UnitTypes) value->unit);
+ else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER &&
+ value->unit <= CSSPrimitiveValue::CSS_KHZ)
+ m_value = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
+
+ valueList->next();
+ } else if (valueList->size() > 1) {
+ // create list of values
+ // currently accepts only <integer>/<integer>
+
+ CSSValueList* list = new CSSValueList();
+ Value* value = 0;
+ bool isValid = true;
+
+ while ((value = valueList->current()) && isValid) {
+ if (value->unit == Value::Operator && value->iValue == '/')
+ list->append(new CSSPrimitiveValue("/", CSSPrimitiveValue::CSS_STRING));
+ else if (value->unit == CSSPrimitiveValue::CSS_NUMBER)
+ list->append(new CSSPrimitiveValue(value->fValue, CSSPrimitiveValue::CSS_NUMBER));
+ else
+ isValid = false;
+
+ value = valueList->next();
+ }
+
+ if (isValid)
+ m_value = list;
+ else
+ delete list;
+ }
+ }
+}
+
+MediaQueryExp::~MediaQueryExp()
+{
+ delete m_value;
+}
+
+} // namespace
diff --git a/WebCore/css/MediaQueryExp.h b/WebCore/css/MediaQueryExp.h
new file mode 100644
index 0000000..25d5c86
--- /dev/null
+++ b/WebCore/css/MediaQueryExp.h
@@ -0,0 +1,60 @@
+/*
+ * CSS Media Query
+ *
+ * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MediaQueryExp_h
+#define MediaQueryExp_h
+
+#include "AtomicString.h"
+#include "CSSValue.h"
+
+namespace WebCore {
+class ValueList;
+
+class MediaQueryExp
+{
+public:
+ MediaQueryExp(const AtomicString& mediaFeature, ValueList* values);
+ ~MediaQueryExp();
+
+ AtomicString mediaFeature() const { return m_mediaFeature; }
+
+ CSSValue* value() const { return m_value; }
+
+ bool operator==(const MediaQueryExp& other) const {
+ return (other.m_mediaFeature == m_mediaFeature)
+ && ((!other.m_value && !m_value)
+ || (other.m_value && m_value && other.m_value->cssText() == m_value->cssText()));
+ }
+
+private:
+ AtomicString m_mediaFeature;
+ CSSValue* m_value;
+};
+
+} // namespace
+
+#endif
diff --git a/WebCore/css/StyleSheet.cpp b/WebCore/css/StyleSheet.cpp
index 699121c..0aafe64 100644
--- a/WebCore/css/StyleSheet.cpp
+++ b/WebCore/css/StyleSheet.cpp
@@ -64,7 +64,11 @@
void StyleSheet::setMedia(MediaList* media)
{
+ if (m_media)
+ m_media->setParent(0);
+
m_media = media;
+ m_media->setParent(this);
}
}
diff --git a/WebCore/css/cssparser.cpp b/WebCore/css/cssparser.cpp
index ba6e286..f22e69d 100644
--- a/WebCore/css/cssparser.cpp
+++ b/WebCore/css/cssparser.cpp
@@ -50,6 +50,7 @@
#include "Pair.h"
#include "ShadowValue.h"
#include "csshelper.h"
+#include "MediaQueryExp.h"
#define YYDEBUG 0
@@ -93,6 +94,9 @@
CSSParser* CSSParser::currentParser = 0;
CSSParser::CSSParser(bool strictParsing)
+ : m_floatingMediaQuery(0)
+ , m_floatingMediaQueryExp(0)
+ , m_floatingMediaQueryExpList(0)
{
#ifdef CSS_DEBUG
kdDebug(6080) << "CSSParser::CSSParser this=" << this << endl;
@@ -129,6 +133,12 @@
fastFree(data);
+ if (m_floatingMediaQueryExpList) {
+ deleteAllValues(*m_floatingMediaQueryExpList);
+ delete m_floatingMediaQueryExpList;
+ }
+ delete m_floatingMediaQueryExp;
+ delete m_floatingMediaQuery;
deleteAllValues(m_floatingSelectors);
deleteAllValues(m_floatingValueLists);
deleteAllValues(m_floatingFunctions);
@@ -151,6 +161,9 @@
void CSSParser::setupParser(const char* prefix, const String& string, const char* suffix)
{
int length = string.length() + strlen(prefix) + strlen(suffix) + 2;
+
+ if (data)
+ fastFree(data);
data = static_cast<UChar*>(fastMalloc(length * sizeof(UChar)));
for (unsigned i = 0; i < strlen(prefix); i++)
@@ -293,6 +306,32 @@
return ok;
}
+bool CSSParser::parseMediaQuery(MediaList* queries, const String& string)
+{
+ if (string.isEmpty() || string.isNull()) {
+ return true;
+ }
+
+ mediaQuery = 0;
+ // can't use { because tokenizer state switches from mediaquery to initial state when it sees { token.
+ // instead insert one " " (which is WHITESPACE in CSSGrammar.y)
+ setupParser ("@-webkit-mediaquery ", string, "} ");
+
+ CSSParser* old = currentParser;
+ currentParser = this;
+ cssyyparse(this);
+ currentParser = old;
+
+ bool ok = false;
+ if (mediaQuery) {
+ ok = true;
+ queries->appendMediaQuery(mediaQuery);
+ mediaQuery = 0;
+ }
+
+ return ok;
+}
+
void CSSParser::addProperty(int propId, CSSValue *value, bool important)
{
@@ -2868,6 +2907,51 @@
return value;
}
+MediaQueryExp* CSSParser::createFloatingMediaQueryExp(const AtomicString& mediaFeature, ValueList* values)
+{
+ delete m_floatingMediaQueryExp;
+ m_floatingMediaQueryExp = new MediaQueryExp(mediaFeature, values);
+ return m_floatingMediaQueryExp;
+}
+
+MediaQueryExp* CSSParser::sinkFloatingMediaQueryExp(MediaQueryExp* e)
+{
+ ASSERT(e == m_floatingMediaQueryExp);
+ m_floatingMediaQueryExp = 0;
+ return e;
+}
+
+Vector<MediaQueryExp*>* CSSParser::createFloatingMediaQueryExpList()
+{
+ if (m_floatingMediaQueryExpList) {
+ deleteAllValues(*m_floatingMediaQueryExpList);
+ delete m_floatingMediaQueryExpList;
+ }
+ m_floatingMediaQueryExpList = new Vector<MediaQueryExp*>;
+ return m_floatingMediaQueryExpList;
+}
+
+Vector<MediaQueryExp*>* CSSParser::sinkFloatingMediaQueryExpList(Vector<MediaQueryExp*>* l)
+{
+ ASSERT(l == m_floatingMediaQueryExpList);
+ m_floatingMediaQueryExpList = 0;
+ return l;
+}
+
+MediaQuery* CSSParser::createFloatingMediaQuery(MediaQuery::Restrictor r, const String& mediaType, Vector<MediaQueryExp*>* exprs)
+{
+ delete m_floatingMediaQuery;
+ m_floatingMediaQuery = new MediaQuery(r, mediaType, exprs);
+ return m_floatingMediaQuery;
+}
+
+MediaQuery* CSSParser::sinkFloatingMediaQuery(MediaQuery* mq)
+{
+ ASSERT(mq == m_floatingMediaQuery);
+ m_floatingMediaQuery = 0;
+ return mq;
+}
+
MediaList* CSSParser::createMediaList()
{
MediaList* list = new MediaList;
@@ -2947,6 +3031,13 @@
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
#define yyterminate() yyTok = END_TOKEN; return yyTok
#define YY_FATAL_ERROR(a)
+// The line below is needed to build the tokenizer with conditon stack.
+// The macro is used in the tokenizer grammar with lines containing
+// BEGIN(mediaqueries) and BEGIN(initial). yy_start acts as index to
+// tokenizer transition table, and 'mediaqueries' and 'initial' are
+// offset multipliers that specify which transitions are active
+// in the tokenizer during in each condition (tokenizer state)
+#define BEGIN yy_start = 1 + 2 *
#include "tokenizer.cpp"
diff --git a/WebCore/css/cssparser.h b/WebCore/css/cssparser.h
index d68a7e2..bf3dc5e 100644
--- a/WebCore/css/cssparser.h
+++ b/WebCore/css/cssparser.h
@@ -27,6 +27,7 @@
#include "Color.h"
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
+#include "MediaQuery.h"
namespace WebCore {
@@ -43,6 +44,9 @@
class MediaList;
class StyleBase;
class StyleList;
+ class MediaList;
+ class MediaQueryExp;
+
struct ParseString {
UChar* characters;
@@ -110,6 +114,7 @@
static RGBA32 parseColor(const String&);
bool parseColor(CSSMutableStyleDeclaration*, const String&);
bool parseDeclaration(CSSMutableStyleDeclaration*, const String&);
+ bool parseMediaQuery(MediaList*, const String&);
static CSSParser* current() { return currentParser; }
@@ -177,12 +182,20 @@
CSSRuleList* createRuleList();
CSSRule* createStyleRule(CSSSelector*);
+ MediaQueryExp* createFloatingMediaQueryExp(const AtomicString&, ValueList*);
+ MediaQueryExp* sinkFloatingMediaQueryExp(MediaQueryExp*);
+ Vector<MediaQueryExp*>* createFloatingMediaQueryExpList();
+ Vector<MediaQueryExp*>* sinkFloatingMediaQueryExpList(Vector<MediaQueryExp*>*);
+ MediaQuery* createFloatingMediaQuery(MediaQuery::Restrictor, const String&, Vector<MediaQueryExp*>*);
+ MediaQuery* sinkFloatingMediaQuery(MediaQuery*);
+
public:
bool strict;
bool important;
int id;
StyleList* styleElement;
RefPtr<CSSRule> rule;
+ MediaQuery* mediaQuery;
ValueList* valueList;
CSSProperty** parsedProperties;
int numParsedProperties;
@@ -226,6 +239,10 @@
HashSet<ValueList*> m_floatingValueLists;
HashSet<Function*> m_floatingFunctions;
+ MediaQuery* m_floatingMediaQuery;
+ MediaQueryExp* m_floatingMediaQueryExp;
+ Vector<MediaQueryExp*>* m_floatingMediaQueryExpList;
+
// defines units allowed for a certain property, used in parseUnit
enum Units {
FUnknown = 0x0000,
diff --git a/WebCore/css/cssstyleselector.cpp b/WebCore/css/cssstyleselector.cpp
index 0596460..19cef2f 100644
--- a/WebCore/css/cssstyleselector.cpp
+++ b/WebCore/css/cssstyleselector.cpp
@@ -48,6 +48,7 @@
#include "History.h"
#include "KWQKHTMLSettings.h"
#include "MediaList.h"
+#include "MediaQueryEvaluator.h"
#include "Pair.h"
#include "RectImpl.h"
#include "RenderTheme.h"
@@ -172,7 +173,7 @@
typedef HashMap<AtomicStringImpl*, CSSRuleDataList*> AtomRuleMap;
- void addRulesFromSheet(CSSStyleSheet* sheet, const String &medium = "screen");
+ void addRulesFromSheet(CSSStyleSheet* sheet, MediaQueryEvaluator* medium);
void addRule(CSSStyleRule* rule, CSSSelector* sel);
void addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map,
@@ -214,18 +215,39 @@
settings = view ? view->frame()->settings() : 0;
if (!defaultStyle)
loadDefaultStyle();
- m_mediaType = view ? view->mediaType() : String("all");
m_userStyle = 0;
m_userSheet = 0;
+ // construct document root element default style. this is needed
+ // to evaluate media queries that contain relative constraints, like "screen and (max-width: 10em)"
+ // This is here instead of constructor, because when constructor is run,
+ // document doesn't have documentElement
+ // NOTE: this assumes that element that gets passed to styleForElement -call
+ // is always from the document that owns the style selector
+ if (view)
+ m_medium = new MediaQueryEvaluator(view->mediaType());
+ else
+ m_medium = new MediaQueryEvaluator("all");
+
+ Element* root = doc->documentElement();
+
+ if (root)
+ m_rootDefaultStyle = styleForElement(root, 0, false, true); // dont ref, because the RenderStyle is allocated from global heap
+
+ if (m_rootDefaultStyle && view) {
+ delete m_medium;
+ m_medium = new MediaQueryEvaluator(view->mediaType(), view, m_rootDefaultStyle);
+ }
+
+
// FIXME: This sucks! The user sheet is reparsed every time!
if (!userStyleSheet.isEmpty()) {
m_userSheet = new CSSStyleSheet(doc);
m_userSheet->parseString(userStyleSheet, strictParsing);
m_userStyle = new CSSRuleSet();
- m_userStyle->addRulesFromSheet(m_userSheet, m_mediaType);
+ m_userStyle->addRulesFromSheet(m_userSheet, m_medium);
}
// add stylesheets from document
@@ -234,10 +256,8 @@
DeprecatedPtrListIterator<StyleSheet> it(styleSheets->styleSheets);
for (; it.current(); ++it)
if (it.current()->isCSSStyleSheet() && !it.current()->disabled())
- m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(it.current()), m_mediaType);
+ m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(it.current()), m_medium);
- m_ruleList = 0;
- m_collectRulesOnly = false;
}
CSSStyleSelector::CSSStyleSelector(CSSStyleSheet *sheet)
@@ -247,10 +267,23 @@
if (!defaultStyle)
loadDefaultStyle();
FrameView *view = sheet->doc()->view();
- m_mediaType = view ? view->mediaType() : String("all");
+
+ if (view)
+ m_medium = new MediaQueryEvaluator(view->mediaType());
+ else
+ m_medium = new MediaQueryEvaluator("all");
+
+ Element* root = sheet->doc()->documentElement();
+ if (root)
+ m_rootDefaultStyle = styleForElement(root, 0, false, true);
+
+ if (m_rootDefaultStyle && view) {
+ delete m_medium;
+ m_medium = new MediaQueryEvaluator(view->mediaType(), view, m_rootDefaultStyle);
+ }
m_authorStyle = new CSSRuleSet();
- m_authorStyle->addRulesFromSheet(sheet, m_mediaType);
+ m_authorStyle->addRulesFromSheet(sheet, m_medium);
}
void CSSStyleSelector::init()
@@ -258,6 +291,10 @@
element = 0;
settings = 0;
m_matchedRuleCount = m_matchedDeclCount = m_tmpRuleCount = 0;
+ m_ruleList = 0;
+ m_collectRulesOnly = false;
+ m_rootDefaultStyle = 0;
+ m_medium = 0;
}
void CSSStyleSelector::setEncodedURL(const KURL& url)
@@ -279,6 +316,9 @@
CSSStyleSelector::~CSSStyleSelector()
{
+ delete m_medium;
+ ::delete m_rootDefaultStyle;
+
delete m_authorStyle;
delete m_userStyle;
delete m_userSheet;
@@ -307,21 +347,24 @@
defaultPrintStyle = new CSSRuleSet;
defaultQuirksStyle = new CSSRuleSet;
+ MediaQueryEvaluator screenEval("screen");
+ MediaQueryEvaluator printEval("print");
+
// Strict-mode rules.
defaultSheet = parseUASheet(html4UserAgentStyleSheet);
- defaultStyle->addRulesFromSheet(defaultSheet, "screen");
- defaultPrintStyle->addRulesFromSheet(defaultSheet, "print");
+ defaultStyle->addRulesFromSheet(defaultSheet, &screenEval);
+ defaultPrintStyle->addRulesFromSheet(defaultSheet, &printEval);
#if SVG_SUPPORT
// SVG rules.
svgSheet = parseUASheet(svgUserAgentStyleSheet);
- defaultStyle->addRulesFromSheet(svgSheet, "screen");
- defaultPrintStyle->addRulesFromSheet(svgSheet, "print");
+ defaultStyle->addRulesFromSheet(svgSheet, &screenEval);
+ defaultPrintStyle->addRulesFromSheet(svgSheet, &printEval);
#endif
// Quirks-mode rules.
quirksSheet = parseUASheet(quirksUserAgentStyleSheet);
- defaultQuirksStyle->addRulesFromSheet(quirksSheet, "screen");
+ defaultQuirksStyle->addRulesFromSheet(quirksSheet, &screenEval);
}
void CSSStyleSelector::addMatchedRule(CSSRuleData* rule)
@@ -700,8 +743,24 @@
return 0;
}
+void CSSStyleSelector::matchUARules(int& firstUARule, int& lastUARule)
+{
+ // 1. First we match rules from the user agent sheet.
+ matchRules(defaultStyle, firstUARule, lastUARule);
-RenderStyle* CSSStyleSelector::styleForElement(Element* e, RenderStyle* defaultParent, bool allowSharing)
+ // 2. In quirks mode, we match rules from the quirks user agent sheet.
+ if (!strictParsing)
+ matchRules(defaultQuirksStyle, firstUARule, lastUARule);
+
+ // 3. If our medium is print, then we match rules from the print sheet.
+ if (m_medium->mediaTypeMatch("print"))
+ matchRules(defaultPrintStyle, firstUARule, lastUARule);
+}
+
+// If resolveForRootDefault is true, style based on user agent style sheet only. This is used in media queries, where
+// relative units are interpreted according to document root element style, styled only with UA stylesheet
+
+RenderStyle* CSSStyleSelector::styleForElement(Element* e, RenderStyle* defaultParent, bool allowSharing, bool resolveForRootDefault)
{
if (allowSharing && !e->document()->haveStylesheetsLoaded()) {
if (!styleNotYetAvailable) {
@@ -728,113 +787,102 @@
}
initForStyleResolve(e, defaultParent);
- style = new (e->document()->renderArena()) RenderStyle();
- style->ref();
+ if (resolveForRootDefault) {
+ style = ::new RenderStyle();
+ // don't ref, because we want to delete this, but we cannot unref it
+ } else {
+ style = new (e->document()->renderArena()) RenderStyle();
+ style->ref();
+ }
if (parentStyle)
style->inheritFrom(parentStyle);
else
parentStyle = style;
-
- // 1. First we match rules from the user agent sheet.
+
int firstUARule = -1, lastUARule = -1;
- matchRules(defaultStyle, firstUARule, lastUARule);
-
- // 2. In quirks mode, we match rules from the quirks user agent sheet.
- if (!strictParsing)
- matchRules(defaultQuirksStyle, firstUARule, lastUARule);
-
- // 3. If our medium is print, then we match rules from the print sheet.
- if (m_mediaType == "print")
- matchRules(defaultPrintStyle, firstUARule, lastUARule);
-
- // 4. Now we check user sheet rules.
int firstUserRule = -1, lastUserRule = -1;
- matchRules(m_userStyle, firstUserRule, lastUserRule);
-
- // 5. Now check author rules, beginning first with presentational attributes
- // mapped from HTML.
int firstAuthorRule = -1, lastAuthorRule = -1;
- if (styledElement) {
- // Ask if the HTML element has mapped attributes.
- if (styledElement->hasMappedAttributes()) {
- // Walk our attribute list and add in each decl.
- const NamedMappedAttrMap* map = styledElement->mappedAttributes();
- for (unsigned i = 0; i < map->length(); i++) {
- MappedAttribute* attr = map->attributeItem(i);
- if (attr->decl()) {
- if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
- lastAuthorRule = m_matchedDeclCount;
- addMatchedDeclaration(attr->decl());
+ matchUARules(firstUARule, lastUARule);
+
+ if (!resolveForRootDefault) {
+ // 4. Now we check user sheet rules.
+ matchRules(m_userStyle, firstUserRule, lastUserRule);
+
+ // 5. Now check author rules, beginning first with presentational attributes
+ // mapped from HTML.
+ if (styledElement) {
+ // Ask if the HTML element has mapped attributes.
+ if (styledElement->hasMappedAttributes()) {
+ // Walk our attribute list and add in each decl.
+ const NamedMappedAttrMap* map = styledElement->mappedAttributes();
+ for (unsigned i = 0; i < map->length(); i++) {
+ MappedAttribute* attr = map->attributeItem(i);
+ if (attr->decl()) {
+ if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
+ lastAuthorRule = m_matchedDeclCount;
+ addMatchedDeclaration(attr->decl());
+ }
}
}
- }
- // Now we check additional mapped declarations.
- // Tables and table cells share an additional mapped rule that must be applied
- // after all attributes, since their mapped style depends on the values of multiple attributes.
- CSSMutableStyleDeclaration* attributeDecl = styledElement->additionalAttributeStyleDecl();
- if (attributeDecl) {
- if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
- lastAuthorRule = m_matchedDeclCount;
- addMatchedDeclaration(attributeDecl);
+ // Now we check additional mapped declarations.
+ // Tables and table cells share an additional mapped rule that must be applied
+ // after all attributes, since their mapped style depends on the values of multiple attributes.
+ CSSMutableStyleDeclaration* attributeDecl = styledElement->additionalAttributeStyleDecl();
+ if (attributeDecl) {
+ if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
+ lastAuthorRule = m_matchedDeclCount;
+ addMatchedDeclaration(attributeDecl);
+ }
+ }
+
+ // 6. Check the rules in author sheets next.
+ matchRules(m_authorStyle, firstAuthorRule, lastAuthorRule);
+
+ // 7. Now check our inline style attribute.
+ if (styledElement) {
+ CSSMutableStyleDeclaration* inlineDecl = styledElement->inlineStyleDecl();
+ if (inlineDecl) {
+ if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
+ lastAuthorRule = m_matchedDeclCount;
+ addMatchedDeclaration(inlineDecl);
+ }
}
}
-
- // 6. Check the rules in author sheets next.
- matchRules(m_authorStyle, firstAuthorRule, lastAuthorRule);
-
- // 7. Now check our inline style attribute.
- if (styledElement) {
- CSSMutableStyleDeclaration* inlineDecl = styledElement->inlineStyleDecl();
- if (inlineDecl) {
- if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
- lastAuthorRule = m_matchedDeclCount;
- addMatchedDeclaration(inlineDecl);
- }
- }
-
+
// Now we have all of the matched rules in the appropriate order. Walk the rules and apply
// high-priority properties first, i.e., those properties that other properties depend on.
// The order is (1) high-priority not important, (2) high-priority important, (3) normal not important
// and (4) normal important.
applyDeclarations(true, false, 0, m_matchedDeclCount-1);
- applyDeclarations(true, true, firstAuthorRule, lastAuthorRule);
- applyDeclarations(true, true, firstUserRule, lastUserRule);
+ if (!resolveForRootDefault) {
+ applyDeclarations(true, true, firstAuthorRule, lastAuthorRule);
+ applyDeclarations(true, true, firstUserRule, lastUserRule);
+ }
applyDeclarations(true, true, firstUARule, lastUARule);
// If our font got dirtied, go ahead and update it now.
- if (fontDirty) {
- checkForTextSizeAdjust();
- checkForGenericFamilyChange(style, parentStyle);
- style->font().update();
- fontDirty = false;
- }
+ if (fontDirty)
+ updateFont();
// Now do the normal priority UA properties.
applyDeclarations(false, false, firstUARule, lastUARule);
// Cache our border and background so that we can examine them later.
- m_hasUAAppearance = style->hasAppearance();
- if (m_hasUAAppearance) {
- m_borderData = style->border();
- m_backgroundData = *style->backgroundLayers();
- m_backgroundColor = style->backgroundColor();
- }
+ cacheBorderAndBackground();
// Now do the author and user normal priority properties and all the !important properties.
- applyDeclarations(false, false, lastUARule+1, m_matchedDeclCount-1);
- applyDeclarations(false, true, firstAuthorRule, lastAuthorRule);
- applyDeclarations(false, true, firstUserRule, lastUserRule);
+ if (!resolveForRootDefault) {
+ applyDeclarations(false, false, lastUARule+1, m_matchedDeclCount-1);
+ applyDeclarations(false, true, firstAuthorRule, lastAuthorRule);
+ applyDeclarations(false, true, firstUserRule, lastUserRule);
+ }
applyDeclarations(false, true, firstUARule, lastUARule);
// If our font got dirtied by one of the non-essential font props,
// go ahead and update it a second time.
- if (fontDirty) {
- checkForTextSizeAdjust();
- checkForGenericFamilyChange(style, parentStyle);
- style->font().update();
- fontDirty = false;
- }
+ if (fontDirty)
+ updateFont();
// Clean up our style object's display and text decorations (among other fixups).
adjustRenderStyle(style, e);
@@ -883,23 +931,14 @@
applyDeclarations(true, true, firstUARule, lastUARule);
// If our font got dirtied, go ahead and update it now.
- if (fontDirty) {
- checkForTextSizeAdjust();
- checkForGenericFamilyChange(style, parentStyle);
- style->font().update();
- fontDirty = false;
- }
+ if (fontDirty)
+ updateFont();
// Now do the normal priority properties.
applyDeclarations(false, false, firstUARule, lastUARule);
// Cache our border and background so that we can examine them later.
- m_hasUAAppearance = style->hasAppearance();
- if (m_hasUAAppearance) {
- m_borderData = style->border();
- m_backgroundData = *style->backgroundLayers();
- m_backgroundColor = style->backgroundColor();
- }
+ cacheBorderAndBackground();
applyDeclarations(false, false, lastUARule+1, m_matchedDeclCount-1);
applyDeclarations(false, true, firstAuthorRule, lastAuthorRule);
@@ -908,13 +947,8 @@
// If our font got dirtied by one of the non-essential font props,
// go ahead and update it a second time.
- if (fontDirty) {
- checkForTextSizeAdjust();
- checkForGenericFamilyChange(style, parentStyle);
- style->font().update();
- fontDirty = false;
- }
-
+ if (fontDirty)
+ updateFont();
// Clean up our style object's display and text decorations (among other fixups).
adjustRenderStyle(style, 0);
@@ -1038,6 +1072,24 @@
view->useSlowRepaints();
}
+void CSSStyleSelector::updateFont()
+{
+ checkForTextSizeAdjust();
+ checkForGenericFamilyChange(style, parentStyle);
+ style->font().update();
+ fontDirty = false;
+}
+
+void CSSStyleSelector::cacheBorderAndBackground()
+{
+ m_hasUAAppearance = style->hasAppearance();
+ if (m_hasUAAppearance) {
+ m_borderData = style->border();
+ m_backgroundData = *style->backgroundLayers();
+ m_backgroundColor = style->backgroundColor();
+ }
+}
+
RefPtr<CSSRuleList> CSSStyleSelector::styleRulesForElement(Element* e, bool authorOnly)
{
if (!e->document()->haveStylesheetsLoaded())
@@ -1049,17 +1101,9 @@
initForStyleResolve(e, 0);
if (!authorOnly) {
- // First we match rules from the user agent sheet.
int firstUARule = -1, lastUARule = -1;
- matchRules(defaultStyle, firstUARule, lastUARule);
-
- // In quirks mode, we match rules from the quirks user agent sheet.
- if (!strictParsing)
- matchRules(defaultQuirksStyle, firstUARule, lastUARule);
-
- // If our medium is print, then we match rules from the print sheet.
- if (m_mediaType == "print")
- matchRules(defaultPrintStyle, firstUARule, lastUARule);
+ // First we match rules from the user agent sheet.
+ matchUARules(firstUARule, lastUARule);
// Now we check user sheet rules.
int firstUserRule = -1, lastUserRule = -1;
@@ -1588,14 +1632,14 @@
m_universalRules->append(m_ruleCount++, rule, sel);
}
-void CSSRuleSet::addRulesFromSheet(CSSStyleSheet *sheet, const String &medium)
+void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, MediaQueryEvaluator* medium)
{
if (!sheet || !sheet->isCSSStyleSheet())
return;
// No media implies "all", but if a media list exists it must
// contain our current medium
- if (sheet->media() && !sheet->media()->contains(medium))
+ if (sheet->media() && !medium->eval(sheet->media()))
return; // the style sheet doesn't apply
int len = sheet->length();
@@ -1609,14 +1653,14 @@
}
else if(item->isImportRule()) {
CSSImportRule* import = static_cast<CSSImportRule*>(item);
- if (!import->media() || import->media()->contains(medium))
+ if (!import->media() || medium->eval(import->media()))
addRulesFromSheet(import->styleSheet(), medium);
}
else if(item->isMediaRule()) {
CSSMediaRule* r = static_cast<CSSMediaRule*>(item);
CSSRuleList* rules = r->cssRules();
- if ((!r->media() || r->media()->contains(medium)) && rules) {
+ if ((!r->media() || medium->eval(r->media())) && rules) {
// Traverse child elements of the @media rule.
for (unsigned j = 0; j < rules->length(); j++) {
CSSRule *childItem = rules->item(j);
diff --git a/WebCore/css/cssstyleselector.h b/WebCore/css/cssstyleselector.h
index 3df939e..d46b3ac 100644
--- a/WebCore/css/cssstyleselector.h
+++ b/WebCore/css/cssstyleselector.h
@@ -44,6 +44,7 @@
class CSSStyleRule;
class CSSStyleSheet;
class CSSValue;
+class MediaQueryEvaluator;
class Document;
class Element;
class Frame;
@@ -93,7 +94,7 @@
void initElementAndPseudoState(Element* e);
void initForStyleResolve(Element* e, RenderStyle* parentStyle);
- RenderStyle *styleForElement(Element*, RenderStyle* parentStyle=0, bool allowSharing=true);
+ RenderStyle *styleForElement(Element*, RenderStyle* parentStyle=0, bool allowSharing=true, bool resolveForRootDefault=false);
RenderStyle* pseudoStyleForElement(RenderStyle::PseudoId, Element*, RenderStyle* parentStyle=0);
RenderStyle* locateSharedStyle();
@@ -177,7 +178,11 @@
private:
void init();
-
+
+ void matchUARules(int& firstUARule, int& lastUARule);
+ void updateFont();
+ void cacheBorderAndBackground();
+
void mapBackgroundAttachment(BackgroundLayer* layer, CSSValue* value);
void mapBackgroundClip(BackgroundLayer* layer, CSSValue* value);
void mapBackgroundOrigin(BackgroundLayer* layer, CSSValue* value);
@@ -203,7 +208,8 @@
CSSRuleList* m_ruleList;
bool m_collectRulesOnly;
- String m_mediaType;
+ MediaQueryEvaluator* m_medium;
+ RenderStyle* m_rootDefaultStyle;
RenderStyle::PseudoId dynamicPseudo;
diff --git a/WebCore/css/maketokenizer b/WebCore/css/maketokenizer
index 0657d3e..af09587 100644
--- a/WebCore/css/maketokenizer
+++ b/WebCore/css/maketokenizer
@@ -53,6 +53,15 @@
print;
}
+# media query, tokenizer state support
+while (<>) {
+ last if /yytext/;
+}
+while (<>) {
+ last if not (/define/ || /line/) ;
+ print;
+}
+
while (<>) {
last if /^YY_DECL/;
}
diff --git a/WebCore/css/tokenizer.flex b/WebCore/css/tokenizer.flex
index c61e80a..c0691b8 100644
--- a/WebCore/css/tokenizer.flex
+++ b/WebCore/css/tokenizer.flex
@@ -1,6 +1,8 @@
%option case-insensitive
%option noyywrap
%option 8bit
+%option stack
+%s mediaquery
h [0-9a-fA-F]
nonascii [\200-\377]
@@ -34,6 +36,9 @@
"^=" {yyTok = BEGINSWITH; return yyTok;}
"$=" {yyTok = ENDSWITH; return yyTok;}
"*=" {yyTok = CONTAINS; return yyTok;}
+<mediaquery>"not" {yyTok = MEDIA_NOT; return yyTok;}
+<mediaquery>"only" {yyTok = MEDIA_ONLY; return yyTok;}
+<mediaquery>"and" {yyTok = MEDIA_AND; return yyTok;}
{string} {yyTok = STRING; return yyTok;}
@@ -41,15 +46,16 @@
"#"{name} {yyTok = HASH; return yyTok;}
-"@import" {yyTok = IMPORT_SYM; return yyTok;}
+"@import" {BEGIN(mediaquery); yyTok = IMPORT_SYM; return yyTok;}
"@page" {yyTok = PAGE_SYM; return yyTok;}
-"@media" {yyTok = MEDIA_SYM; return yyTok;}
+"@media" {BEGIN(mediaquery); yyTok = MEDIA_SYM; return yyTok;}
"@font-face" {yyTok = FONT_FACE_SYM; return yyTok;}
"@charset" {yyTok = CHARSET_SYM; return yyTok;}
"@namespace" {yyTok = NAMESPACE_SYM; return yyTok; }
"@-webkit-rule" {yyTok = WEBKIT_RULE_SYM; return yyTok; }
"@-webkit-decls" {yyTok = WEBKIT_DECLS_SYM; return yyTok; }
"@-webkit-value" {yyTok = WEBKIT_VALUE_SYM; return yyTok; }
+"@-webkit-mediaquery" {BEGIN(mediaquery); yyTok = WEBKIT_MEDIAQUERY_SYM; return yyTok; }
"!"{w}"important" {yyTok = IMPORTANT_SYM; return yyTok;}
@@ -81,6 +87,8 @@
U\+{range} {yyTok = UNICODERANGE; return yyTok;}
U\+{h}{1,6}-{h}{1,6} {yyTok = UNICODERANGE; return yyTok;}
+<mediaquery>"{" |
+<mediaquery>";" {BEGIN(INITIAL); yyTok = *yytext; return yyTok; }
. {yyTok = *yytext; return yyTok;}
%%
diff --git a/WebCore/dom/DOMImplementation.cpp b/WebCore/dom/DOMImplementation.cpp
index bb1006a..17cfbd3 100644
--- a/WebCore/dom/DOMImplementation.cpp
+++ b/WebCore/dom/DOMImplementation.cpp
@@ -166,7 +166,7 @@
ec = 0;
CSSStyleSheet* const nullSheet = 0;
RefPtr<CSSStyleSheet> sheet = new CSSStyleSheet(nullSheet);
- sheet->setMedia(new MediaList(sheet.get(), media));
+ sheet->setMedia(new MediaList(sheet.get(), media, true));
return sheet.release();
}
diff --git a/WebCore/html/HTMLLinkElement.cpp b/WebCore/html/HTMLLinkElement.cpp
index 051ea0b..c3fe9c6 100644
--- a/WebCore/html/HTMLLinkElement.cpp
+++ b/WebCore/html/HTMLLinkElement.cpp
@@ -32,6 +32,7 @@
#include "HTMLNames.h"
#include "MediaList.h"
#include "csshelper.h"
+#include "MediaQueryEvaluator.h"
namespace WebCore {
@@ -168,7 +169,11 @@
// no need to load style sheets which aren't for the screen output
// ### there may be in some situations e.g. for an editor or script to manipulate
// also, don't load style sheets for standalone documents
- if (m_media.isNull() || m_media.contains("screen") || m_media.contains("all") || m_media.contains("print")) {
+ MediaQueryEvaluator allEval(true);
+ MediaQueryEvaluator screenEval("screen", true);
+ MediaQueryEvaluator printEval("print", true);
+ RefPtr<MediaList> media = new MediaList((CSSStyleSheet*)0, m_media, true);
+ if (allEval.eval(media.get()) || screenEval.eval(media.get()) || printEval.eval(media.get())) {
// Add ourselves as a pending sheet, but only if we aren't an alternate
// stylesheet. Alternate stylesheets don't hold up render tree construction.
@@ -211,8 +216,8 @@
m_sheet = new CSSStyleSheet(this, url);
m_sheet->parseString(sheetStr, !document()->inCompatMode());
- MediaList* media = new MediaList(m_sheet.get(), m_media);
- m_sheet->setMedia(media);
+ RefPtr<MediaList> media = new MediaList((CSSStyleSheet*)0, m_media, true);
+ m_sheet->setMedia(media.get());
m_loading = false;
diff --git a/WebCore/html/HTMLStyleElement.cpp b/WebCore/html/HTMLStyleElement.cpp
index 92a4e0c..fee08d5 100644
--- a/WebCore/html/HTMLStyleElement.cpp
+++ b/WebCore/html/HTMLStyleElement.cpp
@@ -27,6 +27,7 @@
#include "Document.h"
#include "HTMLNames.h"
#include "MediaList.h"
+#include "MediaQueryEvaluator.h"
namespace WebCore {
@@ -83,15 +84,18 @@
}
m_loading = false;
- if ((m_type.isEmpty() || m_type == "text/css") // Type must be empty or CSS
- && (m_media.isNull() || m_media.contains("screen") || m_media.contains("all") || m_media.contains("print"))) {
- document()->addPendingSheet();
- m_loading = true;
- m_sheet = new CSSStyleSheet(this);
- m_sheet->parseString(text, !document()->inCompatMode());
- MediaList* media = new MediaList(m_sheet.get(), m_media);
- m_sheet->setMedia(media);
- m_loading = false;
+ if (m_type.isEmpty() || m_type == "text/css") { // Type must be empty or CSS
+ RefPtr<MediaList> media = new MediaList((CSSStyleSheet*)0, m_media, true);
+ MediaQueryEvaluator screenEval("screen", true);
+ MediaQueryEvaluator printEval("print", true);
+ if (screenEval.eval(media.get()) || printEval.eval(media.get())) {
+ document()->addPendingSheet();
+ m_loading = true;
+ m_sheet = new CSSStyleSheet(this);
+ m_sheet->parseString(text, !document()->inCompatMode());
+ m_sheet->setMedia(media.get());
+ m_loading = false;
+ }
}
if (!isLoading() && m_sheet)
diff --git a/WebCore/ksvg2/svg/SVGDOMImplementation.cpp b/WebCore/ksvg2/svg/SVGDOMImplementation.cpp
index fdbe818..5e92c6a 100644
--- a/WebCore/ksvg2/svg/SVGDOMImplementation.cpp
+++ b/WebCore/ksvg2/svg/SVGDOMImplementation.cpp
@@ -191,7 +191,10 @@
CSSStyleSheet *parent = 0;
RefPtr<CSSStyleSheet> sheet = new CSSStyleSheet(parent);
//sheet->setTitle(title);
- sheet->setMedia(new MediaList(sheet.get(), media));
+ // http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-DOMImplementationCSS says
+ // that media descriptors should be used, even though svg:style has only
+ // css media types. Hence the third parameter (true).
+ sheet->setMedia(new MediaList(sheet.get(), media, true));
return sheet.release();
}
diff --git a/WebCore/ksvg2/svg/SVGStyleElement.cpp b/WebCore/ksvg2/svg/SVGStyleElement.cpp
index a4a7f00..7d134d9 100644
--- a/WebCore/ksvg2/svg/SVGStyleElement.cpp
+++ b/WebCore/ksvg2/svg/SVGStyleElement.cpp
@@ -30,6 +30,7 @@
#include "Document.h"
#include "ExceptionCode.h"
#include "MediaList.h"
+#include "MediaQueryEvaluator.h"
#include "PlatformString.h"
namespace WebCore {
@@ -96,17 +97,18 @@
m_sheet = 0;
m_loading = false;
- const AtomicString& _media = media();
- if ((type().isEmpty() || type() == "text/css") && (_media.isNull() || _media.contains("screen") || _media.contains("all") || _media.contains("print"))) {
+ MediaQueryEvaluator screenEval("screen", true);
+ MediaQueryEvaluator printEval("print", true);
+ RefPtr<MediaList> mediaList = new MediaList((CSSStyleSheet*)0, media());
+ if ((type().isEmpty() || type() == "text/css") && (screenEval.eval(mediaList.get()) || printEval.eval(mediaList.get()))) {
ownerDocument()->addPendingSheet();
m_loading = true;
m_sheet = new CSSStyleSheet(this);
m_sheet->parseString(textContent()); // SVG css is always parsed in strict mode
-
- MediaList* mediaList = new MediaList(m_sheet.get(), _media);
- m_sheet->setMedia(mediaList);
+
+ m_sheet->setMedia(mediaList.get());
m_loading = false;
}
diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp
index b7b169d..aa13323 100644
--- a/WebCore/page/Frame.cpp
+++ b/WebCore/page/Frame.cpp
@@ -50,6 +50,7 @@
#include "HTMLFrameElement.h"
#include "HTMLGenericFormElement.h"
#include "HTMLNames.h"
+#include "MediaFeatureNames.h"
#include "HTMLObjectElement.h"
#include "ImageDocument.h"
#include "MouseEventWithHitTestResults.h"
@@ -151,6 +152,7 @@
EventNames::init();
HTMLNames::init();
QualifiedName::init();
+ MediaFeatureNames::init();
#if SVG_SUPPORT
SVGNames::init();
diff --git a/WebCore/platform/Screen.h b/WebCore/platform/Screen.h
index 3adb800..e9d1433 100644
--- a/WebCore/platform/Screen.h
+++ b/WebCore/platform/Screen.h
@@ -32,6 +32,8 @@
class Widget;
int screenDepth(Widget*);
+ int screenDepthPerComponent(Widget*);
+ bool screenIsMonochrome(Widget*);
FloatRect screenRect(Widget*);
FloatRect usableScreenRect(Widget*);
diff --git a/WebCore/platform/mac/ScreenMac.mm b/WebCore/platform/mac/ScreenMac.mm
index 35dd382..4cdeca6 100644
--- a/WebCore/platform/mac/ScreenMac.mm
+++ b/WebCore/platform/mac/ScreenMac.mm
@@ -86,6 +86,22 @@
return NSBitsPerPixelFromDepth([screen(widget) depth]);
}
+int screenDepthPerComponent(Widget* widget)
+{
+ return NSBitsPerSampleFromDepth([screen(widget) depth]);
+}
+
+bool screenIsMonochrome(Widget* widget)
+{
+ NSScreen* s = screen(widget);
+ NSDictionary* dd = [s deviceDescription];
+ NSString* colorSpaceName = [dd objectForKey:NSDeviceColorSpaceName];
+ return colorSpaceName == NSCalibratedWhiteColorSpace
+ || colorSpaceName == NSCalibratedBlackColorSpace
+ || colorSpaceName == NSDeviceWhiteColorSpace
+ || colorSpaceName == NSDeviceBlackColorSpace;
+}
+
// These methods scale between window and WebView coordinates because JavaScript/DOM operations
// assume that the WebView and the window share the same coordinate system.