LayoutTests:
authorthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Feb 2006 02:01:56 +0000 (02:01 +0000)
committerthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Feb 2006 02:01:56 +0000 (02:01 +0000)
        Reviewed by Dave Hyatt, Tim H.

        Layout tests for:
        Bug 4127: WebCore doesn't support Media Queries (CSS3 module)
        http://bugzilla.opendarwin.org/show_bug.cgi?id=4127

        * ChangeLog:
        * fast/media: Added.
        * fast/media/001-expected.checksum: Added.
        * fast/media/001-expected.png: Added.
        * fast/media/001-expected.txt: Added.
        * fast/media/001.html: Added.
        * fast/media/002-expected.checksum: Added.
        * fast/media/002-expected.png: Added.
        * fast/media/002-expected.txt: Added.
        * fast/media/002.html: Added.
        * fast/media/003-expected.checksum: Added.
        * fast/media/003-expected.png: Added.
        * fast/media/003-expected.txt: Added.
        * fast/media/003.html: Added.
        * fast/media/004-expected.checksum: Added.
        * fast/media/004-expected.png: Added.
        * fast/media/004-expected.txt: Added.
        * fast/media/004.html: Added.
        * fast/media/005-expected.checksum: Added.
        * fast/media/005-expected.png: Added.
        * fast/media/005-expected.txt: Added.
        * fast/media/005.html: Added.
        * fast/media/006-expected.checksum: Added.
        * fast/media/006-expected.png: Added.
        * fast/media/006-expected.txt: Added.
        * fast/media/006.html: Added.
        * fast/media/007-expected.checksum: Added.
        * fast/media/007-expected.png: Added.
        * fast/media/007-expected.txt: Added.
        * fast/media/007.html: Added.
        * fast/media/008-expected.checksum: Added.
        * fast/media/008-expected.png: Added.
        * fast/media/008-expected.txt: Added.
        * fast/media/008.html: Added.
        * fast/media/009-expected.checksum: Added.
        * fast/media/009-expected.png: Added.
        * fast/media/009-expected.txt: Added.
        * fast/media/009.html: Added.
        * fast/media/010-expected.checksum: Added.
        * fast/media/010-expected.png: Added.
        * fast/media/010-expected.txt: Added.
        * fast/media/010.html: Added.
        * fast/media/011-expected.checksum: Added.
        * fast/media/011-expected.png: Added.
        * fast/media/011-expected.txt: Added.
        * fast/media/011.html: Added.
        * fast/media/012-expected.checksum: Added.
        * fast/media/012-expected.png: Added.
        * fast/media/012-expected.txt: Added.
        * fast/media/012.html: Added.
        * fast/media/013-expected.checksum: Added.
        * fast/media/013-expected.png: Added.
        * fast/media/013-expected.txt: Added.
        * fast/media/013.html: Added.
        * fast/media/014-expected.checksum: Added.
        * fast/media/014-expected.png: Added.
        * fast/media/014-expected.txt: Added.
        * fast/media/014.html: Added.
        * fast/media/015-expected.checksum: Added.
        * fast/media/015-expected.png: Added.
        * fast/media/015-expected.txt: Added.
        * fast/media/015.html: Added.
        * fast/media/016-expected.checksum: Added.
        * fast/media/016-expected.png: Added.
        * fast/media/016-expected.txt: Added.
        * fast/media/016.html: Added.
        * fast/media/017-expected.checksum: Added.
        * fast/media/017-expected.png: Added.
        * fast/media/017-expected.txt: Added.
        * fast/media/017.html: Added.
        * fast/media/018-expected.checksum: Added.
        * fast/media/018-expected.png: Added.
        * fast/media/018-expected.txt: Added.
        * fast/media/018.html: Added.
        * fast/media/019-expected.checksum: Added.
        * fast/media/019-expected.png: Added.
        * fast/media/019-expected.txt: Added.
        * fast/media/019.html: Added.
        * fast/media/020-expected.checksum: Added.
        * fast/media/020-expected.png: Added.
        * fast/media/020-expected.txt: Added.
        * fast/media/020.html: Added.
        * fast/media/021-expected.checksum: Added.
        * fast/media/021-expected.png: Added.
        * fast/media/021-expected.txt: Added.
        * fast/media/021.html: Added.
        * fast/media/022-expected.checksum: Added.
        * fast/media/022-expected.png: Added.
        * fast/media/022-expected.txt: Added.
        * fast/media/022.html: Added.
        * fast/media/023-expected.checksum: Added.
        * fast/media/023-expected.png: Added.
        * fast/media/023-expected.txt: Added.
        * fast/media/023.html: Added.
        * fast/media/024-expected.checksum: Added.
        * fast/media/024-expected.png: Added.
        * fast/media/024-expected.txt: Added.
        * fast/media/024.html: Added.
        * fast/media/025-expected.checksum: Added.
        * fast/media/025-expected.png: Added.
        * fast/media/025-expected.txt: Added.
        * fast/media/025.html: Added.
        * fast/media/026-expected.checksum: Added.
        * fast/media/026-expected.png: Added.
        * fast/media/026.html: Added.
        * fast/media/import-p-green.css: Added.

WebCore:

        Reviewed by Dave Hyatt and Tim H.

        Bug 4127: WebCore doesn't support Media Queries (CSS3 module)
        http://bugzilla.opendarwin.org/show_bug.cgi?id=4127

        http://www.w3.org/TR/css3-mediaqueries/

        * WebCore.xcodeproj/project.pbxproj:
        * css/css_grammar.y:
        * css/css_mediaqueryeval.cpp: Added.
        (MediaQueryEvaluator):
        (MediaQueryEvaluator::~MediaQueryEvaluator):
        (MediaQueryEvaluator::mediaTypeMatch):
        (applyRestrictor):
        (MediaQueryEvaluator::eval):
        (parseAspectRatio):
        * css/css_mediaqueryeval.h: Added.
        * css/css_mediaqueryimpl.cpp: Added.
        (MediaQueryExpImpl::MediaQueryExpImpl):
        (MediaQueryExpImpl::~MediaQueryExpImpl):
        (MediaQueryExpImpl::mediaFeature):
        (MediaQueryExpImpl::value):
        (MediaQueryImpl::MediaQueryImpl):
        (MediaQueryImpl::~MediaQueryImpl):
        (MediaQueryImpl::restrictor):
        (MediaQueryImpl::expressions):
        (MediaQueryImpl::mediaType):
        (MediaQueryImpl::operator==):
        * css/css_mediaqueryimpl.h: Added.
        (DOM::MediaQueryExpImpl::operator==):
        (DOM::MediaQueryExpListImpl::MediaQueryExpListImpl):
        (DOM::MediaQueryExpListImpl::append):
        (DOM::MediaQueryExpListImpl::list):
        (DOM::MediaQueryImpl::):
        * css/css_stylesheetimpl.cpp:
        (MediaListImpl::MediaListImpl):
        (MediaListImpl::deleteMedium):
        (mediaQueryAsDOMString):
        (MediaListImpl::mediaText):
        (MediaListImpl::setMediaText):
        (MediaListImpl::item):
        (MediaListImpl::appendMedium):
        (MediaListImpl::appendMediaQuery):
        * css/css_stylesheetimpl.h:
        (DOM::MediaListImpl::length):
        (DOM::MediaListImpl::mediaQueries):
        * css/css_valueimpl.h:
        * css/csshelper.h:
        * css/cssmediafeatures.in: Added.
        * css/cssparser.cpp:
        (CSSParser::parseMediaQuery):
        * css/cssparser.h:
        * css/cssstyleselector.cpp:
        (WebCore::CSSStyleSelector::CSSStyleSelector):
        (WebCore::CSSStyleSelector::init):
        (WebCore::CSSStyleSelector::~CSSStyleSelector):
        (WebCore::CSSStyleSelector::loadDefaultStyle):
        (WebCore::CSSStyleSelector::styleForElement):
        (WebCore::CSSStyleSelector::styleRulesForElement):
        (WebCore::CSSRuleSet::addRulesFromSheet):
        (WebCore::CSSStyleSelector::defaultStyleForRoot):
        * css/cssstyleselector.h:
        * css/makemediafeatures: Added.
        * css/maketokenizer:
        * css/tokenizer.flex:
        * khtml/html/html_headimpl.cpp:
        (WebCore::HTMLLinkElementImpl::process):
        (WebCore::HTMLLinkElementImpl::setStyleSheet):
        (WebCore::HTMLStyleElementImpl::childrenChanged):
        * platform/Screen.h:
        * platform/mac/Screen.mm:
        (WebCore::screenDepthPerComponent):
        (WebCore::screenIsMonochrome):

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

127 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/media/001-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/001-expected.png [new file with mode: 0644]
LayoutTests/fast/media/001-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/001.html [new file with mode: 0644]
LayoutTests/fast/media/002-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/002-expected.png [new file with mode: 0644]
LayoutTests/fast/media/002-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/002.html [new file with mode: 0644]
LayoutTests/fast/media/003-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/003-expected.png [new file with mode: 0644]
LayoutTests/fast/media/003-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/003.html [new file with mode: 0644]
LayoutTests/fast/media/004-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/004-expected.png [new file with mode: 0644]
LayoutTests/fast/media/004-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/004.html [new file with mode: 0644]
LayoutTests/fast/media/005-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/005-expected.png [new file with mode: 0644]
LayoutTests/fast/media/005-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/005.html [new file with mode: 0644]
LayoutTests/fast/media/006-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/006-expected.png [new file with mode: 0644]
LayoutTests/fast/media/006-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/006.html [new file with mode: 0644]
LayoutTests/fast/media/007-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/007-expected.png [new file with mode: 0644]
LayoutTests/fast/media/007-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/007.html [new file with mode: 0644]
LayoutTests/fast/media/008-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/008-expected.png [new file with mode: 0644]
LayoutTests/fast/media/008-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/008.html [new file with mode: 0644]
LayoutTests/fast/media/009-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/009-expected.png [new file with mode: 0644]
LayoutTests/fast/media/009-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/009.html [new file with mode: 0644]
LayoutTests/fast/media/010-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/010-expected.png [new file with mode: 0644]
LayoutTests/fast/media/010-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/010.html [new file with mode: 0644]
LayoutTests/fast/media/011-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/011-expected.png [new file with mode: 0644]
LayoutTests/fast/media/011-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/011.html [new file with mode: 0644]
LayoutTests/fast/media/012-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/012-expected.png [new file with mode: 0644]
LayoutTests/fast/media/012-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/012.html [new file with mode: 0644]
LayoutTests/fast/media/013-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/013-expected.png [new file with mode: 0644]
LayoutTests/fast/media/013-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/013.html [new file with mode: 0644]
LayoutTests/fast/media/014-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/014-expected.png [new file with mode: 0644]
LayoutTests/fast/media/014-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/014.html [new file with mode: 0644]
LayoutTests/fast/media/015-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/015-expected.png [new file with mode: 0644]
LayoutTests/fast/media/015-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/015.html [new file with mode: 0644]
LayoutTests/fast/media/016-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/016-expected.png [new file with mode: 0644]
LayoutTests/fast/media/016-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/016.html [new file with mode: 0644]
LayoutTests/fast/media/017-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/017-expected.png [new file with mode: 0644]
LayoutTests/fast/media/017-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/017.html [new file with mode: 0644]
LayoutTests/fast/media/018-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/018-expected.png [new file with mode: 0644]
LayoutTests/fast/media/018-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/018.html [new file with mode: 0644]
LayoutTests/fast/media/019-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/019-expected.png [new file with mode: 0644]
LayoutTests/fast/media/019-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/019.html [new file with mode: 0644]
LayoutTests/fast/media/020-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/020-expected.png [new file with mode: 0644]
LayoutTests/fast/media/020-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/020.html [new file with mode: 0644]
LayoutTests/fast/media/021-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/021-expected.png [new file with mode: 0644]
LayoutTests/fast/media/021-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/021.html [new file with mode: 0644]
LayoutTests/fast/media/022-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/022-expected.png [new file with mode: 0644]
LayoutTests/fast/media/022-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/022.html [new file with mode: 0644]
LayoutTests/fast/media/023-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/023-expected.png [new file with mode: 0644]
LayoutTests/fast/media/023-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/023.html [new file with mode: 0644]
LayoutTests/fast/media/024-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/024-expected.png [new file with mode: 0644]
LayoutTests/fast/media/024-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/024.html [new file with mode: 0644]
LayoutTests/fast/media/025-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/025-expected.png [new file with mode: 0644]
LayoutTests/fast/media/025-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/025.html [new file with mode: 0644]
LayoutTests/fast/media/026-expected.checksum [new file with mode: 0644]
LayoutTests/fast/media/026-expected.png [new file with mode: 0644]
LayoutTests/fast/media/026.html [new file with mode: 0644]
LayoutTests/fast/media/import-p-green.css [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/css/css_grammar.y
WebCore/css/css_mediaqueryeval.cpp [new file with mode: 0644]
WebCore/css/css_mediaqueryeval.h [new file with mode: 0644]
WebCore/css/css_mediaqueryimpl.cpp [new file with mode: 0644]
WebCore/css/css_mediaqueryimpl.h [new file with mode: 0644]
WebCore/css/css_stylesheetimpl.cpp
WebCore/css/css_stylesheetimpl.h
WebCore/css/css_valueimpl.h
WebCore/css/csshelper.h
WebCore/css/cssmediafeatures.in [new file with mode: 0644]
WebCore/css/cssparser.cpp
WebCore/css/cssparser.h
WebCore/css/cssstyleselector.cpp
WebCore/css/cssstyleselector.h
WebCore/css/makemediafeatures [new file with mode: 0644]
WebCore/css/maketokenizer
WebCore/css/tokenizer.flex
WebCore/khtml/html/html_headimpl.cpp
WebCore/platform/Screen.h
WebCore/platform/mac/Screen.mm

index 09e15d3..4a325a9 100644 (file)
@@ -1,3 +1,118 @@
+2006-02-03  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Dave Hyatt, Tim H.
+
+        Layout tests for:
+        Bug 4127: WebCore doesn't support Media Queries (CSS3 module)
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=4127
+
+        * ChangeLog:
+        * fast/media: Added.
+        * fast/media/001-expected.checksum: Added.
+        * fast/media/001-expected.png: Added.
+        * fast/media/001-expected.txt: Added.
+        * fast/media/001.html: Added.
+        * fast/media/002-expected.checksum: Added.
+        * fast/media/002-expected.png: Added.
+        * fast/media/002-expected.txt: Added.
+        * fast/media/002.html: Added.
+        * fast/media/003-expected.checksum: Added.
+        * fast/media/003-expected.png: Added.
+        * fast/media/003-expected.txt: Added.
+        * fast/media/003.html: Added.
+        * fast/media/004-expected.checksum: Added.
+        * fast/media/004-expected.png: Added.
+        * fast/media/004-expected.txt: Added.
+        * fast/media/004.html: Added.
+        * fast/media/005-expected.checksum: Added.
+        * fast/media/005-expected.png: Added.
+        * fast/media/005-expected.txt: Added.
+        * fast/media/005.html: Added.
+        * fast/media/006-expected.checksum: Added.
+        * fast/media/006-expected.png: Added.
+        * fast/media/006-expected.txt: Added.
+        * fast/media/006.html: Added.
+        * fast/media/007-expected.checksum: Added.
+        * fast/media/007-expected.png: Added.
+        * fast/media/007-expected.txt: Added.
+        * fast/media/007.html: Added.
+        * fast/media/008-expected.checksum: Added.
+        * fast/media/008-expected.png: Added.
+        * fast/media/008-expected.txt: Added.
+        * fast/media/008.html: Added.
+        * fast/media/009-expected.checksum: Added.
+        * fast/media/009-expected.png: Added.
+        * fast/media/009-expected.txt: Added.
+        * fast/media/009.html: Added.
+        * fast/media/010-expected.checksum: Added.
+        * fast/media/010-expected.png: Added.
+        * fast/media/010-expected.txt: Added.
+        * fast/media/010.html: Added.
+        * fast/media/011-expected.checksum: Added.
+        * fast/media/011-expected.png: Added.
+        * fast/media/011-expected.txt: Added.
+        * fast/media/011.html: Added.
+        * fast/media/012-expected.checksum: Added.
+        * fast/media/012-expected.png: Added.
+        * fast/media/012-expected.txt: Added.
+        * fast/media/012.html: Added.
+        * fast/media/013-expected.checksum: Added.
+        * fast/media/013-expected.png: Added.
+        * fast/media/013-expected.txt: Added.
+        * fast/media/013.html: Added.
+        * fast/media/014-expected.checksum: Added.
+        * fast/media/014-expected.png: Added.
+        * fast/media/014-expected.txt: Added.
+        * fast/media/014.html: Added.
+        * fast/media/015-expected.checksum: Added.
+        * fast/media/015-expected.png: Added.
+        * fast/media/015-expected.txt: Added.
+        * fast/media/015.html: Added.
+        * fast/media/016-expected.checksum: Added.
+        * fast/media/016-expected.png: Added.
+        * fast/media/016-expected.txt: Added.
+        * fast/media/016.html: Added.
+        * fast/media/017-expected.checksum: Added.
+        * fast/media/017-expected.png: Added.
+        * fast/media/017-expected.txt: Added.
+        * fast/media/017.html: Added.
+        * fast/media/018-expected.checksum: Added.
+        * fast/media/018-expected.png: Added.
+        * fast/media/018-expected.txt: Added.
+        * fast/media/018.html: Added.
+        * fast/media/019-expected.checksum: Added.
+        * fast/media/019-expected.png: Added.
+        * fast/media/019-expected.txt: Added.
+        * fast/media/019.html: Added.
+        * fast/media/020-expected.checksum: Added.
+        * fast/media/020-expected.png: Added.
+        * fast/media/020-expected.txt: Added.
+        * fast/media/020.html: Added.
+        * fast/media/021-expected.checksum: Added.
+        * fast/media/021-expected.png: Added.
+        * fast/media/021-expected.txt: Added.
+        * fast/media/021.html: Added.
+        * fast/media/022-expected.checksum: Added.
+        * fast/media/022-expected.png: Added.
+        * fast/media/022-expected.txt: Added.
+        * fast/media/022.html: Added.
+        * fast/media/023-expected.checksum: Added.
+        * fast/media/023-expected.png: Added.
+        * fast/media/023-expected.txt: Added.
+        * fast/media/023.html: Added.
+        * fast/media/024-expected.checksum: Added.
+        * fast/media/024-expected.png: Added.
+        * fast/media/024-expected.txt: Added.
+        * fast/media/024.html: Added.
+        * fast/media/025-expected.checksum: Added.
+        * fast/media/025-expected.png: Added.
+        * fast/media/025-expected.txt: Added.
+        * fast/media/025.html: Added.
+        * fast/media/026-expected.checksum: Added.
+        * fast/media/026-expected.png: Added.
+        * fast/media/026.html: Added.
+        * fast/media/import-p-green.css: Added.
+
 2006-02-02  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by harrison
diff --git a/LayoutTests/fast/media/001-expected.checksum b/LayoutTests/fast/media/001-expected.checksum
new file mode 100644 (file)
index 0000000..b861cda
--- /dev/null
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/001-expected.png b/LayoutTests/fast/media/001-expected.png
new file mode 100644 (file)
index 0000000..57bc6ac
Binary files /dev/null and b/LayoutTests/fast/media/001-expected.png differ
diff --git a/LayoutTests/fast/media/001-expected.txt b/LayoutTests/fast/media/001-expected.txt
new file mode 100644 (file)
index 0000000..b8e584f
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/001.html b/LayoutTests/fast/media/001.html
new file mode 100644 (file)
index 0000000..b538102
--- /dev/null
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title> HTML4 media descriptions parsing style element media= content</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/002-expected.checksum b/LayoutTests/fast/media/002-expected.checksum
new file mode 100644 (file)
index 0000000..b861cda
--- /dev/null
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/002-expected.png b/LayoutTests/fast/media/002-expected.png
new file mode 100644 (file)
index 0000000..57bc6ac
Binary files /dev/null and b/LayoutTests/fast/media/002-expected.png differ
diff --git a/LayoutTests/fast/media/002-expected.txt b/LayoutTests/fast/media/002-expected.txt
new file mode 100644 (file)
index 0000000..b8e584f
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/002.html b/LayoutTests/fast/media/002.html
new file mode 100644 (file)
index 0000000..2a91bca
--- /dev/null
@@ -0,0 +1,14 @@
+<html>
+<head>
+<title> HTML4 media descriptions parsing style element media= content</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/003-expected.checksum b/LayoutTests/fast/media/003-expected.checksum
new file mode 100644 (file)
index 0000000..b861cda
--- /dev/null
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/003-expected.png b/LayoutTests/fast/media/003-expected.png
new file mode 100644 (file)
index 0000000..57bc6ac
Binary files /dev/null and b/LayoutTests/fast/media/003-expected.png differ
diff --git a/LayoutTests/fast/media/003-expected.txt b/LayoutTests/fast/media/003-expected.txt
new file mode 100644 (file)
index 0000000..b8e584f
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/003.html b/LayoutTests/fast/media/003.html
new file mode 100644 (file)
index 0000000..c00ffbf
--- /dev/null
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title> HTML4 media descriptions parsing style element media= content</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/004-expected.checksum b/LayoutTests/fast/media/004-expected.checksum
new file mode 100644 (file)
index 0000000..b861cda
--- /dev/null
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/004-expected.png b/LayoutTests/fast/media/004-expected.png
new file mode 100644 (file)
index 0000000..57bc6ac
Binary files /dev/null and b/LayoutTests/fast/media/004-expected.png differ
diff --git a/LayoutTests/fast/media/004-expected.txt b/LayoutTests/fast/media/004-expected.txt
new file mode 100644 (file)
index 0000000..b8e584f
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/004.html b/LayoutTests/fast/media/004.html
new file mode 100644 (file)
index 0000000..f07fdfe
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title> CSS3 media query test:  media only all</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/005-expected.checksum b/LayoutTests/fast/media/005-expected.checksum
new file mode 100644 (file)
index 0000000..b861cda
--- /dev/null
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/005-expected.png b/LayoutTests/fast/media/005-expected.png
new file mode 100644 (file)
index 0000000..57bc6ac
Binary files /dev/null and b/LayoutTests/fast/media/005-expected.png differ
diff --git a/LayoutTests/fast/media/005-expected.txt b/LayoutTests/fast/media/005-expected.txt
new file mode 100644 (file)
index 0000000..b8e584f
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/005.html b/LayoutTests/fast/media/005.html
new file mode 100644 (file)
index 0000000..cb2edb6
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title> CSS3 media query test: not braille, screen</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>
\ No newline at end of file
diff --git a/LayoutTests/fast/media/006-expected.checksum b/LayoutTests/fast/media/006-expected.checksum
new file mode 100644 (file)
index 0000000..2638c66
--- /dev/null
@@ -0,0 +1 @@
+c3a4b15983b538a5247299245f383ea5
\ No newline at end of file
diff --git a/LayoutTests/fast/media/006-expected.png b/LayoutTests/fast/media/006-expected.png
new file mode 100644 (file)
index 0000000..f81a569
Binary files /dev/null and b/LayoutTests/fast/media/006-expected.png differ
diff --git a/LayoutTests/fast/media/006-expected.txt b/LayoutTests/fast/media/006-expected.txt
new file mode 100644 (file)
index 0000000..aebbec7
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 808x600
+  RenderCanvas 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/006.html b/LayoutTests/fast/media/006.html
new file mode 100644 (file)
index 0000000..c84810d
--- /dev/null
@@ -0,0 +1,21 @@
+<html>
+<head>
+<title> CSS3 media query test: screen and (max-width: 800px)</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: 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/007-expected.checksum b/LayoutTests/fast/media/007-expected.checksum
new file mode 100644 (file)
index 0000000..54d2303
--- /dev/null
@@ -0,0 +1 @@
+05a863a321f32f15ca96f0b745ab6823
\ No newline at end of file
diff --git a/LayoutTests/fast/media/007-expected.png b/LayoutTests/fast/media/007-expected.png
new file mode 100644 (file)
index 0000000..821360d
Binary files /dev/null and b/LayoutTests/fast/media/007-expected.png differ
diff --git a/LayoutTests/fast/media/007-expected.txt b/LayoutTests/fast/media/007-expected.txt
new file mode 100644 (file)
index 0000000..c02113d
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/007.html b/LayoutTests/fast/media/007.html
new file mode 100644 (file)
index 0000000..23e66ac
--- /dev/null
@@ -0,0 +1,20 @@
+<html>
+<head>
+<title> CSS3 media query test: screen and (max-width: 800px) and (max-height:600px)</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: 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/008-expected.checksum b/LayoutTests/fast/media/008-expected.checksum
new file mode 100644 (file)
index 0000000..9dfbfbd
--- /dev/null
@@ -0,0 +1 @@
+13a8a15857868d43e1af1086030f97cf
\ No newline at end of file
diff --git a/LayoutTests/fast/media/008-expected.png b/LayoutTests/fast/media/008-expected.png
new file mode 100644 (file)
index 0000000..32b1021
Binary files /dev/null and b/LayoutTests/fast/media/008-expected.png differ
diff --git a/LayoutTests/fast/media/008-expected.txt b/LayoutTests/fast/media/008-expected.txt
new file mode 100644 (file)
index 0000000..8225550
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/008.html b/LayoutTests/fast/media/008.html
new file mode 100644 (file)
index 0000000..8257949
--- /dev/null
@@ -0,0 +1,20 @@
+<html>
+<head>
+<title> CSS3 media query test: screen and (color)</title>  
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#color" />
+
+<style type="text/css">
+p {
+  color: red;
+}
+@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/009-expected.checksum b/LayoutTests/fast/media/009-expected.checksum
new file mode 100644 (file)
index 0000000..49da6cb
--- /dev/null
@@ -0,0 +1 @@
+4c146be940e196c365414a6205da5a8d
\ No newline at end of file
diff --git a/LayoutTests/fast/media/009-expected.png b/LayoutTests/fast/media/009-expected.png
new file mode 100644 (file)
index 0000000..09d1e86
Binary files /dev/null and b/LayoutTests/fast/media/009-expected.png differ
diff --git a/LayoutTests/fast/media/009-expected.txt b/LayoutTests/fast/media/009-expected.txt
new file mode 100644 (file)
index 0000000..1bc6635
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/009.html b/LayoutTests/fast/media/009.html
new file mode 100644 (file)
index 0000000..ee03317
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title> CSS3 media query test: import with screen and (min-width: 600px) </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/010-expected.checksum b/LayoutTests/fast/media/010-expected.checksum
new file mode 100644 (file)
index 0000000..710b1d2
--- /dev/null
@@ -0,0 +1 @@
+1c11b6a1285dfb1dad48634108141ce9
\ No newline at end of file
diff --git a/LayoutTests/fast/media/010-expected.png b/LayoutTests/fast/media/010-expected.png
new file mode 100644 (file)
index 0000000..8ae8bb2
Binary files /dev/null and b/LayoutTests/fast/media/010-expected.png differ
diff --git a/LayoutTests/fast/media/010-expected.txt b/LayoutTests/fast/media/010-expected.txt
new file mode 100644 (file)
index 0000000..53d1cf6
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/010.html b/LayoutTests/fast/media/010.html
new file mode 100644 (file)
index 0000000..0257f8a
--- /dev/null
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title> CSS3 media query test: import with screen and (grid: 0) </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>
\ No newline at end of file
diff --git a/LayoutTests/fast/media/011-expected.checksum b/LayoutTests/fast/media/011-expected.checksum
new file mode 100644 (file)
index 0000000..66c0eb6
--- /dev/null
@@ -0,0 +1 @@
+364923683606083e6728dc6edcf76f89
\ No newline at end of file
diff --git a/LayoutTests/fast/media/011-expected.png b/LayoutTests/fast/media/011-expected.png
new file mode 100644 (file)
index 0000000..ffef682
Binary files /dev/null and b/LayoutTests/fast/media/011-expected.png differ
diff --git a/LayoutTests/fast/media/011-expected.txt b/LayoutTests/fast/media/011-expected.txt
new file mode 100644 (file)
index 0000000..945bc17
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/011.html b/LayoutTests/fast/media/011.html
new file mode 100644 (file)
index 0000000..c05d3ae
--- /dev/null
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title> CSS3 media query test: import with not screen and (grid) </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>
\ No newline at end of file
diff --git a/LayoutTests/fast/media/012-expected.checksum b/LayoutTests/fast/media/012-expected.checksum
new file mode 100644 (file)
index 0000000..b2c2964
--- /dev/null
@@ -0,0 +1 @@
+c801be0c86a8d567b3f5be9ffe5e01f4
\ No newline at end of file
diff --git a/LayoutTests/fast/media/012-expected.png b/LayoutTests/fast/media/012-expected.png
new file mode 100644 (file)
index 0000000..c345e8c
Binary files /dev/null and b/LayoutTests/fast/media/012-expected.png differ
diff --git a/LayoutTests/fast/media/012-expected.txt b/LayoutTests/fast/media/012-expected.txt
new file mode 100644 (file)
index 0000000..8092a01
--- /dev/null
@@ -0,0 +1,14 @@
+layer at (0,0) size 968x600
+  RenderCanvas 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/012.html b/LayoutTests/fast/media/012.html
new file mode 100644 (file)
index 0000000..3608c70
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<head>
+<title> CSS3 media query test: relative constraints test using screen and (max-width: 60em)</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/013-expected.checksum b/LayoutTests/fast/media/013-expected.checksum
new file mode 100644 (file)
index 0000000..679e47a
--- /dev/null
@@ -0,0 +1 @@
+bccd379d30fd3d06b032e0df3728e2b4
\ No newline at end of file
diff --git a/LayoutTests/fast/media/013-expected.png b/LayoutTests/fast/media/013-expected.png
new file mode 100644 (file)
index 0000000..ca39f15
Binary files /dev/null and b/LayoutTests/fast/media/013-expected.png differ
diff --git a/LayoutTests/fast/media/013-expected.txt b/LayoutTests/fast/media/013-expected.txt
new file mode 100644 (file)
index 0000000..bbb63b1
--- /dev/null
@@ -0,0 +1,14 @@
+layer at (0,0) size 808x600
+  RenderCanvas 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/013.html b/LayoutTests/fast/media/013.html
new file mode 100644 (file)
index 0000000..9050394
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<head>
+<title> CSS3 media query test: relative constraints test using screen and (min-width: 30em)</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/014-expected.checksum b/LayoutTests/fast/media/014-expected.checksum
new file mode 100644 (file)
index 0000000..ca5ca38
--- /dev/null
@@ -0,0 +1 @@
+43a7cd01a8a6327c8980a0357097bab5
\ No newline at end of file
diff --git a/LayoutTests/fast/media/014-expected.png b/LayoutTests/fast/media/014-expected.png
new file mode 100644 (file)
index 0000000..61977f8
Binary files /dev/null and b/LayoutTests/fast/media/014-expected.png differ
diff --git a/LayoutTests/fast/media/014-expected.txt b/LayoutTests/fast/media/014-expected.txt
new file mode 100644 (file)
index 0000000..568aeea
--- /dev/null
@@ -0,0 +1,14 @@
+layer at (0,0) size 968x600
+  RenderCanvas 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/014.html b/LayoutTests/fast/media/014.html
new file mode 100644 (file)
index 0000000..b4eb207
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<head>
+<title> CSS3 media query test: relative constraints test using screen and (min-width: 60em)</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/015-expected.checksum b/LayoutTests/fast/media/015-expected.checksum
new file mode 100644 (file)
index 0000000..4b24c01
--- /dev/null
@@ -0,0 +1 @@
+bdd79ae10c3636b21df9cf919841ba91
\ No newline at end of file
diff --git a/LayoutTests/fast/media/015-expected.png b/LayoutTests/fast/media/015-expected.png
new file mode 100644 (file)
index 0000000..0aeee3d
Binary files /dev/null and b/LayoutTests/fast/media/015-expected.png differ
diff --git a/LayoutTests/fast/media/015-expected.txt b/LayoutTests/fast/media/015-expected.txt
new file mode 100644 (file)
index 0000000..84d0848
--- /dev/null
@@ -0,0 +1,14 @@
+layer at (0,0) size 808x600
+  RenderCanvas 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/015.html b/LayoutTests/fast/media/015.html
new file mode 100644 (file)
index 0000000..b09c166
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<head>
+<title> CSS3 media query test: relative constraints test using screen and (max-width: 30em)</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/016-expected.checksum b/LayoutTests/fast/media/016-expected.checksum
new file mode 100644 (file)
index 0000000..c488e8b
--- /dev/null
@@ -0,0 +1 @@
+59693b3b56b343b7a841b54e4d5d41f2
\ No newline at end of file
diff --git a/LayoutTests/fast/media/016-expected.png b/LayoutTests/fast/media/016-expected.png
new file mode 100644 (file)
index 0000000..65a9c61
Binary files /dev/null and b/LayoutTests/fast/media/016-expected.png differ
diff --git a/LayoutTests/fast/media/016-expected.txt b/LayoutTests/fast/media/016-expected.txt
new file mode 100644 (file)
index 0000000..78f1c87
--- /dev/null
@@ -0,0 +1,19 @@
+layer at (0,0) size 785x608
+  RenderCanvas at (0,0) size 785x600
+layer at (0,0) size 785x600
+  RenderBlock {HTML} at (0,0) size 785x600
+    RenderBody {BODY} at (8,8) size 769x584
+      RenderInline {SPAN} at (0,0) size 315x18 [color=#008000]
+        RenderText {TEXT} at (239,0) size 315x18
+          text run at (239,0) width 315: "This text should be green if height is atleast 30ex ."
+      RenderText {TEXT} at (0,0) size 0x0
+      RenderBlock (floating) {DIV} at (0,0) size 115x229 [bgcolor=#ADD8E6]
+        RenderText {TEXT} at (0,0) size 115x18
+          text run at (0,0) width 115: "div of height 30ex"
+      RenderText {TEXT} at (0,0) size 0x0
+      RenderBlock (floating) {DIV} at (115,0) size 124x600 [bgcolor=#ADD8E6]
+        RenderText {TEXT} at (0,0) size 124x18
+          text run at (0,0) width 124: "div of height 600px"
+      RenderText {TEXT} at (0,0) size 0x0
+      RenderText {TEXT} at (0,0) size 0x0
+      RenderText {TEXT} at (0,0) size 0x0
diff --git a/LayoutTests/fast/media/016.html b/LayoutTests/fast/media/016.html
new file mode 100644 (file)
index 0000000..9616069
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<head>
+<title> CSS3 media query test: relative constraints test using screen and (min-height: 30ex)</title>  
+<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/#width" />
+
+<style type="text/css">
+span {
+  color: red;
+}
+@media screen and (min-height: 30ex) {
+   span {
+     color: green;
+  }
+}
+</style>
+</head>
+<body>
+
+<span> This text should be green if height is atleast 30ex .</span>
+
+<div style="block:inline; float:left; height: 30ex; background-color: lightblue;"> div of height 30ex </div>
+<div style="block:inline; float:left; height: 600px; background-color: lightblue;"> div of height 600px </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/017-expected.checksum b/LayoutTests/fast/media/017-expected.checksum
new file mode 100644 (file)
index 0000000..551aced
--- /dev/null
@@ -0,0 +1 @@
+7499a40172304d162bb6dbf0ac77e8dd
\ No newline at end of file
diff --git a/LayoutTests/fast/media/017-expected.png b/LayoutTests/fast/media/017-expected.png
new file mode 100644 (file)
index 0000000..15d3031
Binary files /dev/null and b/LayoutTests/fast/media/017-expected.png differ
diff --git a/LayoutTests/fast/media/017-expected.txt b/LayoutTests/fast/media/017-expected.txt
new file mode 100644 (file)
index 0000000..abf8b8c
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/017.html b/LayoutTests/fast/media/017.html
new file mode 100644 (file)
index 0000000..b7a7827
--- /dev/null
@@ -0,0 +1,16 @@
+<html>
+<head>
+<title> CSS3 media query test: screen and (color) and (grid:0) should evaluate true</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/018-expected.checksum b/LayoutTests/fast/media/018-expected.checksum
new file mode 100644 (file)
index 0000000..b861cda
--- /dev/null
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/018-expected.png b/LayoutTests/fast/media/018-expected.png
new file mode 100644 (file)
index 0000000..57bc6ac
Binary files /dev/null and b/LayoutTests/fast/media/018-expected.png differ
diff --git a/LayoutTests/fast/media/018-expected.txt b/LayoutTests/fast/media/018-expected.txt
new file mode 100644 (file)
index 0000000..b8e584f
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/018.html b/LayoutTests/fast/media/018.html
new file mode 100644 (file)
index 0000000..81b9be7
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title> CSS3 media query test: not braille</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>
\ No newline at end of file
diff --git a/LayoutTests/fast/media/019-expected.checksum b/LayoutTests/fast/media/019-expected.checksum
new file mode 100644 (file)
index 0000000..0dc845a
--- /dev/null
@@ -0,0 +1 @@
+bfd66393358e49a5b1c09f4acb698233
\ No newline at end of file
diff --git a/LayoutTests/fast/media/019-expected.png b/LayoutTests/fast/media/019-expected.png
new file mode 100644 (file)
index 0000000..30393f9
Binary files /dev/null and b/LayoutTests/fast/media/019-expected.png differ
diff --git a/LayoutTests/fast/media/019-expected.txt b/LayoutTests/fast/media/019-expected.txt
new file mode 100644 (file)
index 0000000..fe0af81
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/019.html b/LayoutTests/fast/media/019.html
new file mode 100644 (file)
index 0000000..50c88bf
--- /dev/null
@@ -0,0 +1,25 @@
+<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">test not run</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/020-expected.checksum b/LayoutTests/fast/media/020-expected.checksum
new file mode 100644 (file)
index 0000000..0dc845a
--- /dev/null
@@ -0,0 +1 @@
+bfd66393358e49a5b1c09f4acb698233
\ No newline at end of file
diff --git a/LayoutTests/fast/media/020-expected.png b/LayoutTests/fast/media/020-expected.png
new file mode 100644 (file)
index 0000000..30393f9
Binary files /dev/null and b/LayoutTests/fast/media/020-expected.png differ
diff --git a/LayoutTests/fast/media/020-expected.txt b/LayoutTests/fast/media/020-expected.txt
new file mode 100644 (file)
index 0000000..fe0af81
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/020.html b/LayoutTests/fast/media/020.html
new file mode 100644 (file)
index 0000000..be2d988
--- /dev/null
@@ -0,0 +1,29 @@
+<html>
+<head>
+<title> CSS3 media query test: stylesheet media.mediaText property inspection should work</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">test not run</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/021-expected.checksum b/LayoutTests/fast/media/021-expected.checksum
new file mode 100644 (file)
index 0000000..24f456d
--- /dev/null
@@ -0,0 +1 @@
+5f9f2be9db02e8db55395eed16fd5d24
\ No newline at end of file
diff --git a/LayoutTests/fast/media/021-expected.png b/LayoutTests/fast/media/021-expected.png
new file mode 100644 (file)
index 0000000..50e330d
Binary files /dev/null and b/LayoutTests/fast/media/021-expected.png differ
diff --git a/LayoutTests/fast/media/021-expected.txt b/LayoutTests/fast/media/021-expected.txt
new file mode 100644 (file)
index 0000000..9066d32
--- /dev/null
@@ -0,0 +1,14 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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 232x18
+          text run at (0,0) width 232: "braille, not screen, screen and (color)"
+      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/021.html b/LayoutTests/fast/media/021.html
new file mode 100644 (file)
index 0000000..67882c7
--- /dev/null
@@ -0,0 +1,36 @@
+<html>
+<head>
+<title> CSS3 media query test: stylesheet media appendMedium should work</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)");
+    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()">
+<!-- XXX: 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">test not run</p>
+<p> expected to fail (24.07.2005)</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/022-expected.checksum b/LayoutTests/fast/media/022-expected.checksum
new file mode 100644 (file)
index 0000000..c8a51f6
--- /dev/null
@@ -0,0 +1 @@
+ab6b6fd71e9f104e2db1642352a043d7
\ No newline at end of file
diff --git a/LayoutTests/fast/media/022-expected.png b/LayoutTests/fast/media/022-expected.png
new file mode 100644 (file)
index 0000000..5bcd010
Binary files /dev/null and b/LayoutTests/fast/media/022-expected.png differ
diff --git a/LayoutTests/fast/media/022-expected.txt b/LayoutTests/fast/media/022-expected.txt
new file mode 100644 (file)
index 0000000..7987d34
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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"
diff --git a/LayoutTests/fast/media/022.html b/LayoutTests/fast/media/022.html
new file mode 100644 (file)
index 0000000..b86bdfe
--- /dev/null
@@ -0,0 +1,38 @@
+<html>
+<head>
+<title> CSS3 media query test: stylesheet media deleteMedium should work</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()">
+<!-- XXX: 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">test not run</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/023-expected.checksum b/LayoutTests/fast/media/023-expected.checksum
new file mode 100644 (file)
index 0000000..b861cda
--- /dev/null
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/023-expected.png b/LayoutTests/fast/media/023-expected.png
new file mode 100644 (file)
index 0000000..57bc6ac
Binary files /dev/null and b/LayoutTests/fast/media/023-expected.png differ
diff --git a/LayoutTests/fast/media/023-expected.txt b/LayoutTests/fast/media/023-expected.txt
new file mode 100644 (file)
index 0000000..b8e584f
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/023.html b/LayoutTests/fast/media/023.html
new file mode 100644 (file)
index 0000000..0da63fb
--- /dev/null
@@ -0,0 +1,16 @@
+<html>
+<head>
+<title> CSS3 media query test: media not braille should eval true</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/024-expected.checksum b/LayoutTests/fast/media/024-expected.checksum
new file mode 100644 (file)
index 0000000..b861cda
--- /dev/null
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/024-expected.png b/LayoutTests/fast/media/024-expected.png
new file mode 100644 (file)
index 0000000..57bc6ac
Binary files /dev/null and b/LayoutTests/fast/media/024-expected.png differ
diff --git a/LayoutTests/fast/media/024-expected.txt b/LayoutTests/fast/media/024-expected.txt
new file mode 100644 (file)
index 0000000..b8e584f
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/024.html b/LayoutTests/fast/media/024.html
new file mode 100644 (file)
index 0000000..99b22e0
--- /dev/null
@@ -0,0 +1,22 @@
+<html>
+<head>
+<title> CSS3 media query test: media not screen should eval false </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="not screen">
+p {
+    color: red;
+}
+</style>
+
+</head>
+<body>
+<p> This text should be green.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/media/025-expected.checksum b/LayoutTests/fast/media/025-expected.checksum
new file mode 100644 (file)
index 0000000..b861cda
--- /dev/null
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/025-expected.png b/LayoutTests/fast/media/025-expected.png
new file mode 100644 (file)
index 0000000..57bc6ac
Binary files /dev/null and b/LayoutTests/fast/media/025-expected.png differ
diff --git a/LayoutTests/fast/media/025-expected.txt b/LayoutTests/fast/media/025-expected.txt
new file mode 100644 (file)
index 0000000..b8e584f
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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/025.html b/LayoutTests/fast/media/025.html
new file mode 100644 (file)
index 0000000..60a79eb
--- /dev/null
@@ -0,0 +1,23 @@
+<html>
+<head>
+<title> CSS3 media query test: media all and invalid should eval false </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/026-expected.checksum b/LayoutTests/fast/media/026-expected.checksum
new file mode 100644 (file)
index 0000000..b861cda
--- /dev/null
@@ -0,0 +1 @@
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
diff --git a/LayoutTests/fast/media/026-expected.png b/LayoutTests/fast/media/026-expected.png
new file mode 100644 (file)
index 0000000..57bc6ac
Binary files /dev/null and b/LayoutTests/fast/media/026-expected.png differ
diff --git a/LayoutTests/fast/media/026.html b/LayoutTests/fast/media/026.html
new file mode 100644 (file)
index 0000000..90d0a32
--- /dev/null
@@ -0,0 +1,27 @@
+<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/import-p-green.css b/LayoutTests/fast/media/import-p-green.css
new file mode 100644 (file)
index 0000000..37d1e04
--- /dev/null
@@ -0,0 +1,3 @@
+p {
+ color: green;
+}
index 940ba7f..b8a779d 100644 (file)
@@ -1,5 +1,81 @@
 2006-02-03  Timothy Hatcher  <timothy@apple.com>
 
+        Reviewed by Dave Hyatt and Tim H.
+
+        Bug 4127: WebCore doesn't support Media Queries (CSS3 module)
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=4127
+
+        http://www.w3.org/TR/css3-mediaqueries/
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/css_grammar.y:
+        * css/css_mediaqueryeval.cpp: Added.
+        (MediaQueryEvaluator):
+        (MediaQueryEvaluator::~MediaQueryEvaluator):
+        (MediaQueryEvaluator::mediaTypeMatch):
+        (applyRestrictor):
+        (MediaQueryEvaluator::eval):
+        (parseAspectRatio):
+        * css/css_mediaqueryeval.h: Added.
+        * css/css_mediaqueryimpl.cpp: Added.
+        (MediaQueryExpImpl::MediaQueryExpImpl):
+        (MediaQueryExpImpl::~MediaQueryExpImpl):
+        (MediaQueryExpImpl::mediaFeature):
+        (MediaQueryExpImpl::value):
+        (MediaQueryImpl::MediaQueryImpl):
+        (MediaQueryImpl::~MediaQueryImpl):
+        (MediaQueryImpl::restrictor):
+        (MediaQueryImpl::expressions):
+        (MediaQueryImpl::mediaType):
+        (MediaQueryImpl::operator==):
+        * css/css_mediaqueryimpl.h: Added.
+        (DOM::MediaQueryExpImpl::operator==):
+        (DOM::MediaQueryExpListImpl::MediaQueryExpListImpl):
+        (DOM::MediaQueryExpListImpl::append):
+        (DOM::MediaQueryExpListImpl::list):
+        (DOM::MediaQueryImpl::):
+        * css/css_stylesheetimpl.cpp:
+        (MediaListImpl::MediaListImpl):
+        (MediaListImpl::deleteMedium):
+        (mediaQueryAsDOMString):
+        (MediaListImpl::mediaText):
+        (MediaListImpl::setMediaText):
+        (MediaListImpl::item):
+        (MediaListImpl::appendMedium):
+        (MediaListImpl::appendMediaQuery):
+        * css/css_stylesheetimpl.h:
+        (DOM::MediaListImpl::length):
+        (DOM::MediaListImpl::mediaQueries):
+        * css/css_valueimpl.h:
+        * css/csshelper.h:
+        * css/cssmediafeatures.in: Added.
+        * css/cssparser.cpp:
+        (CSSParser::parseMediaQuery):
+        * css/cssparser.h:
+        * css/cssstyleselector.cpp:
+        (WebCore::CSSStyleSelector::CSSStyleSelector):
+        (WebCore::CSSStyleSelector::init):
+        (WebCore::CSSStyleSelector::~CSSStyleSelector):
+        (WebCore::CSSStyleSelector::loadDefaultStyle):
+        (WebCore::CSSStyleSelector::styleForElement):
+        (WebCore::CSSStyleSelector::styleRulesForElement):
+        (WebCore::CSSRuleSet::addRulesFromSheet):
+        (WebCore::CSSStyleSelector::defaultStyleForRoot):
+        * css/cssstyleselector.h:
+        * css/makemediafeatures: Added.
+        * css/maketokenizer:
+        * css/tokenizer.flex:
+        * khtml/html/html_headimpl.cpp:
+        (WebCore::HTMLLinkElementImpl::process):
+        (WebCore::HTMLLinkElementImpl::setStyleSheet):
+        (WebCore::HTMLStyleElementImpl::childrenChanged):
+        * platform/Screen.h:
+        * platform/mac/Screen.mm:
+        (WebCore::screenDepthPerComponent):
+        (WebCore::screenIsMonochrome):
+
+2006-02-03  Timothy Hatcher  <timothy@apple.com>
+
         Reviewed by Justin.
 
         Renamed configuration names to Debug, Release and Production.
index 3cc4186..528f665 100644 (file)
                1A69D381085627410009880D /* domparser.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A69D37F085627410009880D /* domparser.h */; };
                1A69D382085627410009880D /* domparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A69D380085627410009880D /* domparser.cpp */; };
                1ADB5699098827AD0032EEE2 /* JSEvents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ADB5698098827AD0032EEE2 /* JSEvents.cpp */; };
+               47E4D99E09937047006A96C7 /* css_mediaqueryeval.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 47E4D99A09937047006A96C7 /* css_mediaqueryeval.cpp */; };
+               47E4D99F09937047006A96C7 /* css_mediaqueryeval.h in Headers */ = {isa = PBXBuildFile; fileRef = 47E4D99B09937047006A96C7 /* css_mediaqueryeval.h */; };
+               47E4D9A009937047006A96C7 /* css_mediaqueryimpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 47E4D99C09937047006A96C7 /* css_mediaqueryimpl.cpp */; };
+               47E4D9A109937047006A96C7 /* css_mediaqueryimpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 47E4D99D09937047006A96C7 /* css_mediaqueryimpl.h */; };
                550A0BC9085F6039007353D6 /* dom_qname.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* dom_qname.cpp */; };
                550A0BCA085F6039007353D6 /* dom_qname.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* dom_qname.h */; };
                550A0BCD085F604D007353D6 /* htmlnames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BCB085F604D007353D6 /* htmlnames.cpp */; };
                2D90660B0665D937006B6F1A /* KWQClipboard.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KWQClipboard.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                2D90660C0665D937006B6F1A /* KWQClipboard.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQClipboard.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; };
+               47E4D99A09937047006A96C7 /* css_mediaqueryeval.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = css_mediaqueryeval.cpp; sourceTree = "<group>"; };
+               47E4D99B09937047006A96C7 /* css_mediaqueryeval.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = css_mediaqueryeval.h; sourceTree = "<group>"; };
+               47E4D99C09937047006A96C7 /* css_mediaqueryimpl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = css_mediaqueryimpl.cpp; sourceTree = "<group>"; };
+               47E4D99D09937047006A96C7 /* css_mediaqueryimpl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = css_mediaqueryimpl.h; sourceTree = "<group>"; };
                5150C2A10702629000AF642C /* WebDashboardRegion.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDashboardRegion.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                5150C2A50702629800AF642C /* WebDashboardRegion.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebDashboardRegion.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                51F6A3D50663BF04004D2919 /* html_canvasimpl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = html_canvasimpl.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                F523D18402DE42E8018635CA /* css */ = {
                        isa = PBXGroup;
                        children = (
+                               47E4D99A09937047006A96C7 /* css_mediaqueryeval.cpp */,
+                               47E4D99B09937047006A96C7 /* css_mediaqueryeval.h */,
+                               47E4D99C09937047006A96C7 /* css_mediaqueryimpl.cpp */,
+                               47E4D99D09937047006A96C7 /* css_mediaqueryimpl.h */,
                                BCEA477A097CAAC80094C9E4 /* css_base.cpp */,
                                BCEA477B097CAAC80094C9E4 /* css_base.h */,
                                BCEA477C097CAAC80094C9E4 /* css_computedstyle.cpp */,
                                BC6B7A9809933F2E0052867B /* ImageDecoder.h in Headers */,
                                BC6B7B3C099355460052867B /* ImageData.h in Headers */,
                                BC6B7BBC0993611A0052867B /* PDFDocumentImage.h in Headers */,
+                               47E4D99F09937047006A96C7 /* css_mediaqueryeval.h in Headers */,
+                               47E4D9A109937047006A96C7 /* css_mediaqueryimpl.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        buildConfigurationList = 149C283908902B11008A9EFC /* Build configuration list for PBXNativeTarget "WebCore" */;
                        buildPhases = (
                                932FC2C70824B485005B3C75 /* cssproperties.c/h */,
+                               47E4D99809936F1B006A96C7 /* cssmediafeatures.c/h */,
                                932FC2BC0824B422005B3C75 /* cssvalues.c/h */,
                                932FC0B70824A175005B3C75 /* doctypes.cpp */,
                                93EA686C08249AF400687F56 /* kentities.c */,
                        shellPath = /bin/sh;
                        shellScript = "/usr/bin/perl -I\"$SRCROOT/bindings/scripts\" \"$SRCROOT/bindings/scripts/generate-bindings.pl\" --generator JS --idldir \"$SRCROOT/khtml/xml\" --outputdir \"$DERIVED_FILE_DIR\"\n";
                };
+               47E4D99809936F1B006A96C7 /* cssmediafeatures.c/h */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputPaths = (
+                               css/cssmediafeatures.in,
+                               css/makemediafeatures,
+                       );
+                       name = cssmediafeatures.c/h;
+                       outputPaths = (
+                               "$(DERIVED_FILE_DIR)/cssmediafeatures.h",
+                               "$(DERIVED_FILE_DIR)/cssmediafeatures.c",
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "cat css/cssmediafeatures.in > \"$DERIVED_FILE_DIR/cssmediafeatures.in\"\ncd \"$DERIVED_FILE_DIR\"\nsh \"$SRCROOT/css/makemediafeatures\"";
+               };
                932FC0B70824A175005B3C75 /* doctypes.cpp */ = {
                        isa = PBXShellScriptBuildPhase;
                        buildActionMask = 2147483647;
                                BC6B7B4E0993578B0052867B /* ImageData.mm in Sources */,
                                BC6B7BAF0993603C0052867B /* Image.cpp in Sources */,
                                BC6B7BC3099361560052867B /* PDFDocumentImage.mm in Sources */,
+                               47E4D99E09937047006A96C7 /* css_mediaqueryeval.cpp in Sources */,
+                               47E4D9A009937047006A96C7 /* css_mediaqueryimpl.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index b872e28..54eb5c3 100644 (file)
@@ -27,6 +27,7 @@
 #include "css_ruleimpl.h"
 #include "css_stylesheetimpl.h"
 #include "css_valueimpl.h"
+#include "css_mediaqueryimpl.h"
 #include "cssparser.h"
 #include "dom_string.h"
 #include "htmlnames.h"
@@ -54,6 +55,7 @@ using namespace HTMLNames;
 #define __inline
 #include "cssproperties.c"
 #include "cssvalues.c"
+#include "cssmediafeatures.c"
 #undef __inline
 
 namespace WebCore {
@@ -112,6 +114,14 @@ static inline int getValueID(const char *tagStr, int len)
     return val->id;
 }
 
+static inline int getMediaFeatureID(const char *tagStr, int len)
+{
+    const struct css_media_feature_pair *feat = findMediaFeature(tagStr, len);
+    if (!feat)
+        return 0;
+
+    return feat->id;
+}
 
 #define YYDEBUG 0
 #define YYPARSE_PARAM parser
@@ -136,6 +146,12 @@ static inline int getValueID(const char *tagStr, int len)
     char tok;
     Value value;
     ValueList *valueList;
+
+    int mediaFeatureId;
+    MediaQueryImpl *mediaQuery;
+    MediaQueryExpImpl *mediaQueryExp;
+    MediaQueryExpListImpl *mediaQueryExpList;
+    MediaQueryImpl::Restrictor mediaQueryRestrictor;
 }
 
 %{
@@ -175,9 +191,14 @@ static int cssyylex(YYSTYPE *yylval) { return CSSParser::current()->lex(yylval);
 %token KHTML_RULE_SYM
 %token KHTML_DECLS_SYM
 %token KHTML_VALUE_SYM
+%token KHTML_MEDIAQUERY_SYM
 
 %token IMPORTANT_SYM
 
+%token MEDIA_ONLY
+%token MEDIA_NOT
+%token MEDIA_AND
+
 %token <val> QEMS
 %token <val> EMS
 %token <val> EXS
@@ -224,9 +245,15 @@ static int cssyylex(YYSTYPE *yylval) { return CSSParser::current()->lex(yylval);
 %type <string> medium
 %type <string> hexcolor
 
+%type <mediaFeatureId> 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
 
 %type <prop_id> property
@@ -265,6 +292,7 @@ stylesheet:
   | khtml_rule maybe_space
   | khtml_decls maybe_space
   | khtml_value maybe_space
+  | khtml_mediaquery maybe_space
   ;
 
 khtml_rule:
@@ -292,6 +320,18 @@ khtml_value:
     }
 ;
 
+khtml_mediaquery:
+    KHTML_MEDIAQUERY_SYM WHITESPACE maybe_space media_query '}' {
+        CSSParser *p = static_cast<CSSParser *>(parser);
+        p->mediaQuery = $4;
+    }
+    | KHTML_MEDIAQUERY_SYM WHITESPACE maybe_space media_query error '}'{
+        CSSParser *p = static_cast<CSSParser *>(parser);
+        p->mediaQuery = $4;
+    }
+
+;
+
 maybe_space:
     /* empty */
   | maybe_space WHITESPACE
@@ -387,6 +427,86 @@ STRING
 | URI
 ;
 
+media_feature:
+    IDENT maybe_space {
+        QString str = qString($1);
+        $$ = getMediaFeatureID( str.lower().latin1(), str.length() );
+    }
+;
+
+maybe_media_value:
+    /*empty*/ {
+        $$ = 0;
+    }
+    | ':' maybe_space expr maybe_space {
+        $$ = $3;
+    }
+;
+
+media_query_exp:
+    '(' maybe_space media_feature maybe_space maybe_media_value ')' maybe_space {
+        $$ = new MediaQueryExpImpl($3, $5);
+    }
+;
+
+media_query_exp_list:
+    media_query_exp {
+        $$ = new MediaQueryExpListImpl;
+        $$->append($1);
+    }
+    | media_query_exp_list MEDIA_AND maybe_space media_query_exp {
+        $$ = $1;
+        if ($$)
+            $$->append($4);
+        else
+            delete ($4);
+    }
+    | media_query_exp_list error {
+        // Error while parsing media feature list. Delete the list and return 0, which means
+        // that we should handle the media query as css 2.1 media type (or HTML4 media description)
+        delete ($1);
+        $$=0;
+    }
+   ;
+
+maybe_media_query_exp_list:
+    /*empty*/ {
+        $$ = new MediaQueryExpListImpl;
+    }
+    | MEDIA_AND maybe_space media_query_exp_list {
+        $$ = $3;
+    }
+    | MEDIA_AND error {
+        $$ = 0;
+    }
+;
+
+maybe_media_restrictor:
+    /*empty*/{
+        $$ = MediaQueryImpl::None;
+    }
+    | MEDIA_ONLY {
+        $$ = MediaQueryImpl::Only;
+    }
+    | MEDIA_NOT {
+        $$ = MediaQueryImpl::Not;
+    }
+;
+
+media_query:
+    maybe_media_restrictor maybe_space medium maybe_media_query_exp_list {
+        if ($4) {
+            $$ = new MediaQueryImpl($1, domString($3), $4);
+        } else if ($1 == MediaQueryImpl::Only) {
+            $$ = new MediaQueryImpl(MediaQueryImpl::None, "only", new MediaQueryExpListImpl);
+        } else  if ($1 == MediaQueryImpl::Not) {
+            $$ = new MediaQueryImpl(MediaQueryImpl::None, "not", new MediaQueryExpListImpl);
+        } else {
+            $$ = new MediaQueryImpl(MediaQueryImpl::None, domString($3), new MediaQueryExpListImpl);
+        }
+    }
+;
+
 maybe_media_list:
      /* empty */ {
         $$ = new MediaListImpl();
@@ -399,23 +519,25 @@ media_list:
     /* empty */ {
         $$ = 0;
     }
-    | medium {
+    | media_query {
         $$ = new MediaListImpl();
-        $$->appendMedium( domString($1).lower() );
+        $$->appendMediaQuery($1);
     }
-    | media_list ',' maybe_space medium {
+    | media_list ',' maybe_space media_query {
         $$ = $1;
         if ($$)
-            $$->appendMedium( domString($4) );
+            $$->appendMediaQuery($4);
+        else
+            delete $4
     }
     | media_list error {
         delete $1;
         $$ = 0;
     }
-    ;
+;
 
 media:
-    MEDIA_SYM maybe_space media_list '{' maybe_space ruleset_list '}' {
+    MEDIA_SYM maybe_space maybe_media_list '{' maybe_space ruleset_list '}' {
         CSSParser *p = static_cast<CSSParser *>(parser);
         if ( $3 && $6 &&
              p->styleElement && p->styleElement->isCSSStyleSheet() ) {
diff --git a/WebCore/css/css_mediaqueryeval.cpp b/WebCore/css/css_mediaqueryeval.cpp
new file mode 100644 (file)
index 0000000..effe94e
--- /dev/null
@@ -0,0 +1,340 @@
+#include "config.h"
+#include "css_mediaqueryeval.h"
+#include "css_stylesheetimpl.h"
+#include "cssmediafeatures.h"
+#include "css_valueimpl.h"
+#include "rendering/render_style.h"
+#include "page/FrameView.h"
+#include "Screen.h"
+
+
+using namespace WebCore;
+using namespace DOM;
+
+MediaQueryEvaluator:: MediaQueryEvaluator(bool mediaFeatureResult)
+    : m_view(0)
+    , m_style(0)
+    , m_expResult(mediaFeatureResult)
+{
+}
+
+MediaQueryEvaluator:: MediaQueryEvaluator(const QString& acceptedMediaType, bool mediaFeatureResult)
+    : m_mediaType(acceptedMediaType)
+    , m_view(0)
+    , m_style(0)
+    , m_expResult(mediaFeatureResult)
+{
+}
+
+MediaQueryEvaluator:: MediaQueryEvaluator(const QString& acceptedMediaType, FrameView* view, RenderStyle* style)
+    : m_mediaType(acceptedMediaType.lower())
+    , m_view(view)
+    , m_style(style)
+    , m_expResult(false) // doesn't matter
+{
+}
+
+MediaQueryEvaluator::~MediaQueryEvaluator()
+{
+}
+
+bool MediaQueryEvaluator::mediaTypeMatch(const QString& mediaTypeToMatch) const
+{
+    return mediaTypeToMatch.isNull()
+        || mediaTypeToMatch.isEmpty()
+        || (mediaTypeToMatch.startsWith("all", false) && mediaTypeToMatch.length() == 3)
+        || mediaTypeToMatch.lower() == m_mediaType;
+}
+
+static bool applyRestrictor(MediaQueryImpl::Restrictor r, bool value)
+{
+    return r == MediaQueryImpl::Not ? !value : value;
+}
+
+bool MediaQueryEvaluator::eval(const MediaListImpl* mediaList) const
+{
+    if (!mediaList)
+        return true;
+
+    QPtrListIterator<MediaQueryImpl> it(*mediaList->mediaQueries());
+    if (!it.current())
+        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 (MediaQueryImpl* query = it.current(); query && (result==false); query = ++it) {
+
+        if (mediaTypeMatch(query->mediaType())) {
+            QPtrListIterator<MediaQueryExpImpl> exp_it(*query->expressions()->list());
+            // iterate through expressions, stop if any of them eval to false (AND semantics)
+            MediaQueryExpImpl* exp = 0;
+            for (exp = exp_it.current(); exp && eval(exp); exp = ++exp_it) /* empty*/;
+
+            // assume true if we are at the end of the list, otherwise assume false
+            result = applyRestrictor(query->restrictor(), !exp);
+        } else {
+            result = applyRestrictor(query->restrictor(), false);
+        }
+    }
+    return result;
+}
+
+static bool parseAspectRatio(CSSValueImpl* value, int* a, int* b)
+{
+    if (value->isValueList() ){
+        CSSValueListImpl* valueList = static_cast<CSSValueListImpl*>(value);
+        if (valueList->length() == 3 ) {
+            CSSValueImpl* i0 = valueList->item(0);
+            CSSValueImpl* i1 = valueList->item(1);
+            CSSValueImpl* i2 = valueList->item(2);
+            if (i0->isPrimitiveValue() && static_cast<CSSPrimitiveValueImpl*>(i0)->primitiveType() == CSSPrimitiveValue::CSS_NUMBER
+                && i1->isPrimitiveValue() && static_cast<CSSPrimitiveValueImpl*>(i1)->primitiveType() == CSSPrimitiveValue::CSS_STRING
+                && i2->isPrimitiveValue() && static_cast<CSSPrimitiveValueImpl*>(i2)->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
+                DOMString str = static_cast<CSSPrimitiveValueImpl*>(i1)->getStringValue();
+                if (!str.isNull() && str.length() == 1 && str[0] == QChar('/')) {
+                    *a = (int) static_cast<CSSPrimitiveValueImpl*>(i0)->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+                    *b = (int) static_cast<CSSPrimitiveValueImpl*>(i2)->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+                    return true;
+                }
+            }
+        }
+    }
+    return false;
+}
+
+bool MediaQueryEvaluator::eval(const MediaQueryExpImpl* expr) const
+{
+    if (!m_view || !m_style)
+        return m_expResult;
+    CSSValueImpl* value = expr->value();
+    CSSPrimitiveValueImpl* primitive = 0;
+
+    bool isNumberValue = false;
+    double numberValue = -1;
+    int primitiveLength = -1;
+
+    if (value && value->isPrimitiveValue()) {
+        primitive = static_cast<CSSPrimitiveValueImpl*>(value);
+        primitiveLength = primitive->computeLength(m_style);
+        if (primitive->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
+            isNumberValue = true;
+            numberValue = primitive->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+        }
+    }
+
+    switch (expr->mediaFeature()) {
+
+        case CSS_MEDIA_FEAT_MONOCHROME:
+            if (!screenIsMonochrome(m_view))
+                return false;
+            /* fall through*/
+        case CSS_MEDIA_FEAT_COLOR: {
+            int bitsPerComponent = screenDepthPerComponent(m_view);
+            if (value)
+                return (isNumberValue && bitsPerComponent == (int)numberValue);
+            else
+                return bitsPerComponent != 0;
+        }
+
+        case CSS_MEDIA_FEAT_MIN_MONOCHROME: 
+            if (!screenIsMonochrome(m_view))
+                return false;
+            /* fall through */
+        case CSS_MEDIA_FEAT_MIN_COLOR: {
+            int bitsPerComponent = screenDepthPerComponent(m_view);
+            if (value)
+                return (isNumberValue && bitsPerComponent >= (int)numberValue);
+            else
+                return bitsPerComponent != 0;
+        }
+
+        case CSS_MEDIA_FEAT_MAX_MONOCHROME: 
+            if (!screenIsMonochrome(m_view))
+                return false;
+            /* fall through */
+        case CSS_MEDIA_FEAT_MAX_COLOR: {
+            int bitsPerComponent = screenDepthPerComponent(m_view);
+            if (value)
+                return (isNumberValue && bitsPerComponent <= (int)numberValue);
+            else
+                return bitsPerComponent != 0;
+        }
+
+        case CSS_MEDIA_FEAT_COLOR_INDEX:
+        case CSS_MEDIA_FEAT_MIN_COLOR_INDEX:
+        case CSS_MEDIA_FEAT_MAX_COLOR_INDEX:
+            /// XXX: how to get display mode from KWQ?
+            break;
+
+        case CSS_MEDIA_FEAT_DEVICE_ASPECT_RATIO: {
+            if (value) {
+                IntRect sg = screenRect(m_view);
+                int a;
+                int b;
+                if (parseAspectRatio(value, &a, &b))
+                    return (b!=0) && (a*sg.height() == b*sg.width());
+                else
+                    return false;
+            } else {
+                // (device-aspect-ratio), assume if we have a device, its aspect ratio is non-zero
+                return true;
+            }
+        }
+
+        case CSS_MEDIA_FEAT_MIN_DEVICE_ASPECT_RATIO: {
+            if (value) {
+                IntRect sg = screenRect(m_view);
+                int a;
+                int b;
+                if (parseAspectRatio(value, &a, &b))
+                    return (b!=0) && (((double)sg.width()/sg.height()) >= ((double)a/b));
+                else
+                    return false;
+            } else {
+                // (min-device-aspect-ratio), assume if we have a device, its aspect ratio is non-zero
+                return true;
+            }
+        }
+
+        case CSS_MEDIA_FEAT_MAX_DEVICE_ASPECT_RATIO: {
+            if (value) {
+                IntRect sg = screenRect(m_view);
+                int a;
+                int b;
+                if (parseAspectRatio(value, &a, &b))
+                    return (b!=0) && (((double)sg.width()/sg.height()) <= ((double)a/b));
+                else
+                    return false;
+            } else {
+                // (max-device-aspect-ratio), assume if we have a device, its aspect ratio is non-zero
+                return true;
+            }
+        }
+
+        case CSS_MEDIA_FEAT_DEVICE_HEIGHT: {
+            if (value) {
+                IntRect sg = screenRect(m_view);
+                return (primitive && sg.height() == primitiveLength);
+            } else {
+                // (device-height), assume if we have a device, assume non-zero
+                return true;
+            }
+        }
+
+        case CSS_MEDIA_FEAT_MIN_DEVICE_HEIGHT: {
+            if (value) {
+                IntRect sg = screenRect(m_view);
+                return (primitive && sg.height() >= primitiveLength);
+            } else {
+                // (min-device-height), assume if we have a device, assume non-zero
+                return true;
+            }
+        }
+
+        case CSS_MEDIA_FEAT_MAX_DEVICE_HEIGHT: {
+            if (value) {
+                IntRect sg = screenRect(m_view);
+                return (primitive && sg.height() <= primitiveLength);
+            } else {
+                // (max-device-height), assume if we have a device, assume non-zero
+                return true;
+            }
+        }
+
+        case CSS_MEDIA_FEAT_DEVICE_WIDTH: {
+            if (value) {
+                IntRect sg = screenRect(m_view);
+                return (primitive && sg.width() == primitiveLength);
+            } else {
+                // (device-width), assume if we have a device, assume non-zero
+                return true;
+            }
+        }
+
+        case CSS_MEDIA_FEAT_MIN_DEVICE_WIDTH: {
+            if (value) {
+                IntRect sg = screenRect(m_view);
+                return (primitive && sg.width() >= primitiveLength);
+            } else {
+                // (min-device-width), assume if we have a device, assume non-zero
+                return true;
+            }
+        }
+
+        case CSS_MEDIA_FEAT_MAX_DEVICE_WIDTH: {
+            if (value) {
+                IntRect sg = screenRect(m_view);
+                return (primitive && sg.width() <= primitiveLength);
+            } else {
+                // (max-device-width), assume if we have a device, assume non-zero
+                return true;
+            }
+        }
+
+        case CSS_MEDIA_FEAT_GRID: {
+            // if output device is bitmap, grid: 0 == true
+            if (value)
+                return (isNumberValue &&  (int)numberValue == 0 );
+            else
+                return false;
+        }
+
+        case CSS_MEDIA_FEAT_HEIGHT: {
+            if (value)
+                return primitive && m_view->visibleHeight() == primitiveLength;
+            else
+                return m_view->visibleHeight() != 0;
+        }
+
+        case CSS_MEDIA_FEAT_MIN_HEIGHT: {
+            if (value)
+                return primitive && m_view->visibleHeight() >= primitiveLength;
+            else
+                return m_view->visibleHeight() != 0;
+        }
+
+        case CSS_MEDIA_FEAT_MAX_HEIGHT: {
+            if (value)
+                return (primitive && m_view->visibleHeight() <= primitiveLength);
+            else
+                return (m_view->visibleHeight() != 0);
+        }
+
+        case CSS_MEDIA_FEAT_WIDTH: {
+            if (value)
+                return primitive && m_view->visibleWidth() == primitiveLength;
+            else
+                return m_view->visibleWidth() != 0;
+        }
+
+        case CSS_MEDIA_FEAT_MIN_WIDTH: {
+            if (value)
+                return primitive && m_view->visibleWidth() >= primitiveLength;
+            else
+                return m_view->visibleWidth() != 0;
+        }
+
+        case CSS_MEDIA_FEAT_MAX_WIDTH:{
+            if (value)
+                return primitive && m_view->visibleWidth() <= primitiveLength;
+            else
+                return m_view->visibleWidth() != 0;
+        }
+
+        case CSS_MEDIA_FEAT_RESOLUTION:
+        case CSS_MEDIA_FEAT_MIN_RESOLUTION:
+        case CSS_MEDIA_FEAT_MAX_RESOLUTION:
+            //XXX: CSS_DIMENSION doesn't seem to be supported by KHTML
+            break;
+
+        case CSS_MEDIA_FEAT_SCAN:
+            // scan applies to tv media types
+            return false;
+
+        case CSS_MEDIA_FEAT_INVALID:
+        default:
+            break;
+    }
+
+    return false;
+}
diff --git a/WebCore/css/css_mediaqueryeval.h b/WebCore/css/css_mediaqueryeval.h
new file mode 100644 (file)
index 0000000..d2b4b12
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef CSS_css_mediaqueryeval_h
+#define CSS_css_mediaqueryeval_h
+
+#include <qstring.h>
+#include <qvaluelist.h>
+
+#include "css/css_mediaqueryimpl.h"
+
+namespace WebCore {
+  class FrameView;
+  class RenderStyle;
+}
+
+namespace DOM {
+  class MediaListImpl;
+
+/**
+ * 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, but not any media features
+     */
+    MediaQueryEvaluator(const QString& acceptedMediaType, bool mediaFeatureResult = false);
+
+    /** Creates evaluator which evaluates full media queries
+     */
+    MediaQueryEvaluator(const QString& acceptedMediaType, FrameView* view,
+                        khtml::RenderStyle* style);
+
+    ~MediaQueryEvaluator();
+
+    bool mediaTypeMatch(const QString& mediaTypeToMatch) const;
+
+    /** Evaluates a list of media queries */
+    bool eval(const DOM::MediaListImpl* query) const;
+
+    /** Evaluates media query subexpression, ie "and (media-feature: value)" part */
+    bool eval(const DOM::MediaQueryExpImpl* expr) const;
+
+private:
+
+    QString m_mediaType;
+    WebCore::FrameView* m_view; // not owned
+    WebCore::RenderStyle* m_style; // not owned
+    bool m_expResult;
+};
+
+} // namespace
+#endif
diff --git a/WebCore/css/css_mediaqueryimpl.cpp b/WebCore/css/css_mediaqueryimpl.cpp
new file mode 100644 (file)
index 0000000..74f4d64
--- /dev/null
@@ -0,0 +1,115 @@
+#include "config.h"
+#include "css_mediaqueryimpl.h"
+#include "cssparser.h"
+#include "css_base.h"
+#include "css_valueimpl.h"
+
+using namespace DOM;
+using namespace khtml;
+
+MediaQueryExpImpl::MediaQueryExpImpl(int mediaFeatureId, DOM::ValueList* valueList)
+    : m_mediaFeatureId(mediaFeatureId)
+    , m_value(0)
+{   
+    if (valueList) {
+
+        if ( valueList->numValues == 1 ) {
+            DOM::Value* value = valueList->current();
+
+            if ( value->id != 0 ) {
+                m_value = new CSSPrimitiveValueImpl( value->id );
+            } else if ( value->unit == CSSPrimitiveValue::CSS_STRING )
+                m_value = new CSSPrimitiveValueImpl( domString( value->string ),
+                                                     (CSSPrimitiveValue::UnitTypes) value->unit );
+            else if ( value->unit >= CSSPrimitiveValue::CSS_NUMBER &&
+                      value->unit <= CSSPrimitiveValue::CSS_KHZ ) {
+                m_value = new CSSPrimitiveValueImpl( value->fValue,
+                                                     (CSSPrimitiveValue::UnitTypes) value->unit );
+            }
+            valueList->next();
+        } else if ( valueList->numValues > 1) {
+            // create list of values
+            // currently accepts only <integer>/<integer>
+
+            CSSValueListImpl* list = new CSSValueListImpl();
+            Value* value = 0;
+            bool isValid = true;
+
+            while ((value = valueList->current()) && isValid) {
+                if ( value->unit == Value::Operator && value->iValue == '/' ) {
+                    list->append(new CSSPrimitiveValueImpl("/", CSSPrimitiveValue::CSS_STRING));
+                } else if (value->unit == CSSPrimitiveValue::CSS_NUMBER) {
+                    list->append(new CSSPrimitiveValueImpl(value->fValue, CSSPrimitiveValue::CSS_NUMBER));
+                } else {
+                    isValid = false;
+                }
+                value = valueList->next();
+            }
+            if (isValid)
+                m_value = list;
+            else
+                delete(list);
+
+        }
+    }
+}
+
+MediaQueryExpImpl::~MediaQueryExpImpl()
+{
+    delete (m_value);
+}
+
+int MediaQueryExpImpl::mediaFeature() const
+{
+    return m_mediaFeatureId;
+}
+
+CSSValueImpl* MediaQueryExpImpl::value() const
+{
+    return m_value;
+}
+
+MediaQueryImpl::MediaQueryImpl(Restrictor r, const DOM::DOMString &mediaType, MediaQueryExpListImpl* exprs)
+    : m_restrictor(r)
+    , m_mediaType(mediaType)
+    , m_expressions(exprs)
+{
+}
+
+MediaQueryImpl::~MediaQueryImpl()
+{
+    delete(m_expressions);
+}
+
+MediaQueryImpl::Restrictor MediaQueryImpl::restrictor() const
+{
+    return m_restrictor;
+}
+
+MediaQueryExpListImpl* MediaQueryImpl::expressions() const
+{
+    return m_expressions;
+}
+
+QString MediaQueryImpl::mediaType() const
+{
+    return m_mediaType.qstring();
+}
+
+bool MediaQueryImpl::operator==(const MediaQueryImpl& other) const
+{
+    // XXX: case sensitiveness?
+    if (m_restrictor != other.m_restrictor || m_mediaType != other.m_mediaType)
+        return false;
+
+    QPtrListIterator<MediaQueryExpImpl> exp_it(*m_expressions->list());
+    QPtrListIterator<MediaQueryExpImpl> oexp_it(*other.m_expressions->list());
+    MediaQueryExpImpl* exp = 0;
+    MediaQueryExpImpl* oexp = 0;
+    for (exp = exp_it.current(), oexp = oexp_it.current(); exp && oexp; exp = ++exp_it, oexp = ++oexp_it) {
+        if (!(*exp == *oexp) )
+            return false;
+    }
+
+    return (!exp && !oexp);
+}
diff --git a/WebCore/css/css_mediaqueryimpl.h b/WebCore/css/css_mediaqueryimpl.h
new file mode 100644 (file)
index 0000000..12b42de
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef CSS_css_mediaqueryimpl_h
+#define CSS_css_mediaqueryimpl_h
+
+#include <qvaluelist.h>
+#include <qptrlist.h>
+
+#include "dom/dom_string.h"
+#include "css/css_base.h"
+#include "css/css_valueimpl.h"
+namespace DOM {
+class ValueList;
+class CSSPrimitiveValue;
+
+class MediaQueryExpImpl {
+public:
+    MediaQueryExpImpl(int mediaFeatureId, ValueList* values);
+    ~MediaQueryExpImpl();
+
+    int mediaFeature() const;
+    CSSValueImpl* value() const;
+
+    bool operator==(const MediaQueryExpImpl& other) const  {
+        return (other.m_mediaFeatureId == m_mediaFeatureId)
+            && ((!other.m_value && !m_value)
+                || (other.m_value && m_value && other.m_value->cssText() == m_value->cssText()));
+    }
+
+private:
+    int m_mediaFeatureId;
+    CSSValueImpl* m_value;
+};
+
+class MediaQueryExpListImpl
+{
+public:
+    MediaQueryExpListImpl() { exps.setAutoDelete(true); }
+
+    void append(MediaQueryExpImpl* newExp) { exps.append(newExp); }
+    const QPtrList<MediaQueryExpImpl>* list() const { return &exps; }
+
+private:
+    QPtrList<MediaQueryExpImpl> exps;
+};
+
+
+class MediaQueryImpl {
+public:
+    enum Restrictor{
+        Only, Not, None
+    };
+
+    MediaQueryImpl(Restrictor r, const DOMString &mediaType, MediaQueryExpListImpl* exprs);
+    ~MediaQueryImpl();
+
+    Restrictor restrictor() const;
+    MediaQueryExpListImpl* expressions() const;
+    QString mediaType() const;
+
+    bool operator==(const MediaQueryImpl& other) const;
+
+ private:
+    Restrictor m_restrictor;
+    DOMString m_mediaType;
+    MediaQueryExpListImpl* m_expressions;
+};
+
+} // namespace
+
+#endif
index 655b662..507cbc0 100644 (file)
@@ -34,6 +34,8 @@
 #include "css/css_valueimpl.h"
 #include "css/cssparser.h"
 #include "css/css_stylesheetimpl.h"
+#include "css/css_mediaqueryeval.h"
+#include "cssmediafeatures.h"
 
 #include "html/html_documentimpl.h"
 #include "loader.h"
@@ -332,21 +334,17 @@ MediaListImpl::MediaListImpl( CSSStyleSheetImpl *parentSheet,
                               const DOMString &media )
     : StyleBaseImpl( parentSheet )
 {
+    m_lstQueries.setAutoDelete(true);
     setMediaText( media );
 }
 
 MediaListImpl::MediaListImpl( CSSRuleImpl *parentRule, const DOMString &media )
     : StyleBaseImpl(parentRule)
 {
+    m_lstQueries.setAutoDelete(true);
     setMediaText( media );
 }
 
-bool MediaListImpl::contains( const DOMString &medium ) const
-{
-    return m_lstMedia.count() == 0 || m_lstMedia.contains( medium ) ||
-            m_lstMedia.contains( "all" );
-}
-
 CSSStyleSheetImpl *MediaListImpl::parentStyleSheet() const
 {
     return parent()->isCSSStyleSheet() ? static_cast<CSSStyleSheetImpl *>(parent()) : 0;
@@ -359,33 +357,103 @@ CSSRuleImpl *MediaListImpl::parentRule() const
 
 void MediaListImpl::deleteMedium( const DOMString &oldMedium )
 {
-    for ( QValueList<DOMString>::Iterator it = m_lstMedia.begin(); it != m_lstMedia.end(); ++it ) {
-        if ((*it) == oldMedium) {
-            m_lstMedia.remove( it );
-            return;
+    MediaListImpl tempMediaList;
+    CSSParser p(true);
+
+    if (p.parseMediaQuery(&tempMediaList, oldMedium)) {
+        const MediaQueryImpl* oldQuery = QPtrListIterator<MediaQueryImpl>(*tempMediaList.mediaQueries()).current();
+
+        QPtrListIterator<MediaQueryImpl> q_it(m_lstQueries);
+        for(MediaQueryImpl* query = q_it.current(); query; query = ++q_it) {
+            if (*query == *oldQuery) {
+                m_lstQueries.remove(query);
+                break;
+            }
+        }
+    } else {
+        // XXX: throw DOM exception
+    }
+}
+
+static DOM::DOMString mediaQueryAsDOMString(const MediaQueryImpl* query)
+{
+    DOM::DOMString text;
+    switch (query->restrictor()) {
+        case MediaQueryImpl::Only:
+            text += "only ";
+            break;
+        case MediaQueryImpl::Not:
+            text += "not ";
+            break;
+        default:
+            break;
+    }
+    text += query->mediaType();
+    QPtrListIterator<MediaQueryExpImpl> exp_it(*query->expressions()->list());
+    for (MediaQueryExpImpl* exp = exp_it.current(); exp; exp = ++exp_it) {
+        text += " and (";
+        text += getMediaFeatureName(exp->mediaFeature());
+        if (exp->value()) {
+            text += ": ";
+            text += exp->value()->cssText();
         }
+        text += ")";
     }
+    return text;
 }
 
 DOM::DOMString MediaListImpl::mediaText() const
 {
-    DOMString text = "";
-    for (QValueList<DOMString>::ConstIterator it = m_lstMedia.begin(); it != m_lstMedia.end(); ++it) {
-        if (text.length() > 0)
+    DOMString text;
+    QPtrListIterator<MediaQueryImpl> q_it(m_lstQueries);
+    bool first = true;
+    for (MediaQueryImpl* query = q_it.current(); query; query = ++q_it) {
+        if (!first)
             text += ", ";
-        text += *it;
+        else
+            first = false;
+        text += mediaQueryAsDOMString(query);
     }
     return text;
 }
 
 void MediaListImpl::setMediaText(const DOM::DOMString &value)
 {
-    m_lstMedia.clear();
-    QStringList list = QStringList::split( ',', value.qstring() );
-    for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
-    {
+    CSSParser p(true);
+    m_lstQueries.clear();
+
+    QStringList list = QStringList::split(',', value.qstring());
+    for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
         DOMString medium = (*it).stripWhiteSpace();
-        if (!medium.isEmpty())
-            m_lstMedia.append( medium );
+        if (medium != "") {
+            if (!p.parseMediaQuery( this, medium )) {
+                // FAIL
+                // XXX: throw DOM exception
+            }
+        }
     }
 }
+
+DOM::DOMString MediaListImpl::item(unsigned long index) const
+{
+    // XXX: inefficient and ugly! QPtrList doesn't have at() const
+    QPtrListIterator<MediaQueryImpl> q_it(m_lstQueries);
+    MediaQueryImpl* query = q_it.current();
+    for (; query && index; query = ++q_it) --index;
+    if (query)
+        return mediaQueryAsDOMString(query);
+    return DOM::DOMString();
+}
+
+void MediaListImpl::appendMedium(const DOM::DOMString &newMedium)
+{
+    CSSParser p(true);
+    if (!p.parseMediaQuery(this, newMedium)) {
+        // XXX: throw dom exception
+    }
+}
+
+void MediaListImpl::appendMediaQuery(MediaQueryImpl* mediaQuery)
+{
+    m_lstQueries.append(mediaQuery);
+}
index 86bcdd4..3c2076c 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "dom/dom_string.h"
 #include "css/css_base.h"
+#include "css/css_mediaqueryimpl.h"
 
 namespace khtml {
     class CachedCSSStyleSheet;
@@ -161,26 +162,23 @@ public:
 
     CSSStyleSheetImpl *parentStyleSheet() const;
     CSSRuleImpl *parentRule() const;
-    unsigned length() const { return m_lstMedia.count(); }
-    DOM::DOMString item ( unsigned index ) const { return m_lstMedia[index]; }
+    unsigned long length() const { return m_lstQueries.count(); }
+    DOM::DOMString item ( unsigned long index ) const;
     void deleteMedium ( const DOM::DOMString &oldMedium );
-    void appendMedium ( const DOM::DOMString &newMedium ) { m_lstMedia.append(newMedium); }
+    void appendMedium ( const DOM::DOMString &newMedium );
 
     DOM::DOMString mediaText() const;
     void setMediaText(const DOM::DOMString &value);
 
     /**
-     * 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 DOM::DOMString &medium ) const;
+    void appendMediaQuery(MediaQueryImpl* mediaQuery);
+    const QPtrList<MediaQueryImpl>* mediaQueries() const { return &m_lstQueries; }
 
 protected:
-    QValueList<DOM::DOMString> m_lstMedia;
+    QPtrList<MediaQueryImpl> m_lstQueries;
+    DOM::DOMString m_mediaText;    
 };
 
 
index 0a603c7..217ec38 100644 (file)
@@ -28,8 +28,6 @@
 #include "CachedObjectClient.h"
 #include <qvaluelist.h>
 
-class QPaintDeviceMetrics;
-
 namespace khtml {
     class RenderStyle;
     class CachedImage;
index ddf4239..72d47f0 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "dom/dom_string.h"
 
-class QPaintDeviceMetrics;
 class KHTMLSettings;
 
 namespace DOM
diff --git a/WebCore/css/cssmediafeatures.in b/WebCore/css/cssmediafeatures.in
new file mode 100644 (file)
index 0000000..2b16339
--- /dev/null
@@ -0,0 +1,29 @@
+color
+color-index
+device-aspect-ratio
+device-height
+device-width
+grid
+height
+max-color
+max-color-index
+max-device-aspect-ratio
+max-device-height
+max-device-width
+max-height
+max-monochrome
+max-resolution
+max-width
+min-color
+min-color-index
+min-device-aspect-ratio
+min-device-height
+min-device-width
+min-height
+min-monochrome
+min-resolution
+min-width
+monochrome
+resolution
+scan
+width
index 237138a..f740311 100644 (file)
@@ -33,6 +33,7 @@
 #include "css_valueimpl.h"
 #include "css_ruleimpl.h"
 #include "css_stylesheetimpl.h"
+#include "css_mediaqueryimpl.h"
 #include "cssproperties.h"
 #include "cssvalues.h"
 #include "helper.h"
@@ -298,6 +299,30 @@ bool CSSParser::parseDeclaration( CSSMutableStyleDeclarationImpl *declaration, c
     return ok;
 }
 
+bool CSSParser::parseMediaQuery( DOM::MediaListImpl *queries, const DOM::DOMString &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 parser.y)
+    setupParser ("@-khtml-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, CSSValueImpl *value, bool important)
 {
@@ -2837,6 +2862,7 @@ typedef unsigned int YY_CHAR;
 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
 #define yyterminate() yyTok = END_TOKEN; return yyTok
 #define YY_FATAL_ERROR(a)
+#define BEGIN yy_start = 1 + 2 *
 
 #include "tokenizer.cpp"
 
index 82bbbc9..9dcf8f8 100644 (file)
@@ -40,6 +40,8 @@ namespace DOM {
     class CSSMutableStyleDeclarationImpl;
     class CSSProperty;
     class CSSRuleListImpl;
+    class MediaListImpl;
+    class MediaQueryImpl;
 
 
     struct ParseString {
@@ -113,6 +115,7 @@ namespace DOM {
         static RGBA32 CSSParser::parseColor( const DOM::DOMString &string );
        bool parseColor( DOM::CSSMutableStyleDeclarationImpl *declaration, const DOM::DOMString &string );
        bool parseDeclaration( DOM::CSSMutableStyleDeclarationImpl *decls, const DOM::DOMString &string );
+    bool parseMediaQuery( DOM::MediaListImpl *queries, const DOM::DOMString &string );
 
        static CSSParser *current() { return currentParser; }
 
@@ -169,6 +172,7 @@ namespace DOM {
        int id;
        DOM::StyleListImpl *styleElement;
        DOM::CSSRuleImpl *rule;
+    DOM::MediaQueryImpl *mediaQuery;
        ValueList *valueList;
        CSSProperty **parsedProperties;
        int numParsedProperties;
index 9dcb7e7..4d5ec44 100644 (file)
@@ -38,6 +38,7 @@
 #include "csshelper.h"
 #include "cssproperties.h"
 #include "cssvalues.h"
+#include "css_mediaqueryeval.h"
 #include "font.h"
 #include "helper.h"
 #include "html_documentimpl.h"
@@ -169,7 +170,7 @@ public:
     
     typedef HashMap<AtomicStringImpl*, CSSRuleDataList*> AtomRuleMap;
     
-    void addRulesFromSheet(CSSStyleSheetImpl* sheet, const DOMString &medium = "screen");
+    void addRulesFromSheet(DOM::CSSStyleSheetImpl* sheet, DOM::MediaQueryEvaluator* medium);
     
     void addRule(CSSStyleRuleImpl* rule, CSSSelector* sel);
     void addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map,
@@ -212,11 +213,31 @@ CSSStyleSelector::CSSStyleSelector( DocumentImpl* doc, QString userStyleSheet, S
     settings = view ? view->frame()->settings() : 0;
     if (!defaultStyle)
         loadDefaultStyle();
-    m_medium = view ? view->mediaType() : QString("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
+    // XXX: this assumes that element that gets passed to styleForElement -call 
+    // is from the document that owns the style selector        
+    if (view) {
+        m_medium = new MediaQueryEvaluator(view->mediaType());
+    } else {        
+        m_medium = new MediaQueryEvaluator("all");
+    }
+    ElementImpl *root = doc->documentElement();
+    if (root) {         
+        m_rootDefaultStyle = defaultStyleForRoot(root);
+        // 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 CSSStyleSheetImpl(doc);
@@ -244,7 +265,20 @@ CSSStyleSelector::CSSStyleSelector( CSSStyleSheetImpl *sheet )
 
     if(!defaultStyle) loadDefaultStyle();
     FrameView *view = sheet->doc()->view();
-    m_medium =  view ? view->mediaType() : QString("all");
+
+    if (view) {
+        m_medium = new MediaQueryEvaluator(view->mediaType());
+    } else {        
+        m_medium = new MediaQueryEvaluator("all");
+    }
+    ElementImpl *root = sheet->doc()->documentElement();
+    if (root) {         
+        m_rootDefaultStyle = defaultStyleForRoot(root);
+    }
+    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_medium );
@@ -255,6 +289,9 @@ void CSSStyleSelector::init()
     element = 0;
     settings = 0;
     m_matchedRuleCount = m_matchedDeclCount = m_tmpRuleCount = 0;
+    m_rootDefaultStyle = 0;
+    m_medium = 0;
+    m_resolvingForRootDefaultStyle = false;
 }
 
 void CSSStyleSelector::setEncodedURL(const KURL& url)
@@ -276,6 +313,8 @@ void CSSStyleSelector::setEncodedURL(const KURL& url)
 
 CSSStyleSelector::~CSSStyleSelector()
 {
+    delete m_medium;    
+    ::delete m_rootDefaultStyle;
     delete m_authorStyle;
     delete m_userStyle;
     delete m_userSheet;
@@ -316,19 +355,23 @@ void CSSStyleSelector::loadDefaultStyle()
 
     // Strict-mode rules.
     defaultSheet = parseUASheet(html4UserAgentStyleSheet);
-    defaultStyle->addRulesFromSheet(defaultSheet, "screen");
-    defaultPrintStyle->addRulesFromSheet(defaultSheet, "print");
+
+    MediaQueryEvaluator screenEval("screen");
+    defaultStyle->addRulesFromSheet(defaultSheet, &screenEval);
+
+    MediaQueryEvaluator printEval("print");
+    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)
@@ -710,7 +753,7 @@ RenderStyle* CSSStyleSelector::locateSharedStyle()
 
 RenderStyle* CSSStyleSelector::styleForElement(ElementImpl* e, RenderStyle* defaultParent, bool allowSharing)
 {
-    if (!e->getDocument()->haveStylesheetsLoaded()) {
+    if (!m_resolvingForRootDefaultStyle && !e->getDocument()->haveStylesheetsLoaded()) {
         if (!styleNotYetAvailable) {
             styleNotYetAvailable = ::new RenderStyle();
             styleNotYetAvailable->setDisplay(NONE);
@@ -732,7 +775,11 @@ RenderStyle* CSSStyleSelector::styleForElement(ElementImpl* e, RenderStyle* defa
     }
     initForStyleResolve(e, defaultParent);
 
-    style = new (e->getDocument()->renderArena()) RenderStyle();
+    if (m_resolvingForRootDefaultStyle) {
+        style = ::new RenderStyle();
+    } else {
+        style = new (e->getDocument()->renderArena()) RenderStyle();
+    }
     if (parentStyle)
         style->inheritFrom(parentStyle);
     else
@@ -747,61 +794,65 @@ RenderStyle* CSSStyleSelector::styleForElement(ElementImpl* e, RenderStyle* defa
         matchRules(defaultQuirksStyle, firstUARule, lastUARule);
     
     // 3. If our medium is print, then we match rules from the print sheet.
-    if (m_medium == "print")
+    if (m_medium->mediaTypeMatch("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 NamedMappedAttrMapImpl* map = styledElement->mappedAttributes();
-            for (uint i = 0; i < map->length(); i++) {
-                MappedAttributeImpl* attr = map->attributeItem(i);
-                if (attr->decl()) {
-                    if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
-                    lastAuthorRule = m_matchedDeclCount;
-                    addMatchedDeclaration(attr->decl());
+    if (!m_resolvingForRootDefaultStyle) {
+        // 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 NamedMappedAttrMapImpl* map = styledElement->mappedAttributes();
+                for (uint i = 0; i < map->length(); i++) {
+                    MappedAttributeImpl* 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.
-        CSSMutableStyleDeclarationImpl* 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.
+            CSSMutableStyleDeclarationImpl* 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) {
-        CSSMutableStyleDeclarationImpl* 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) {
+            CSSMutableStyleDeclarationImpl* 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);
+    if (!m_resolvingForRootDefaultStyle) {
+        applyDeclarations(true, false, 0, m_matchedDeclCount-1);
+        applyDeclarations(true, true, firstAuthorRule, lastAuthorRule);
+    }
     applyDeclarations(true, true, firstUserRule, lastUserRule);
     applyDeclarations(true, true, firstUARule, lastUARule);
     
@@ -827,8 +878,10 @@ RenderStyle* CSSStyleSelector::styleForElement(ElementImpl* e, RenderStyle* defa
     // 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);
-    applyDeclarations(false, true, firstUARule, lastUARule);
+    if (!m_resolvingForRootDefaultStyle) {
+        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.
@@ -1054,7 +1107,7 @@ RefPtr<CSSRuleListImpl> CSSStyleSelector::styleRulesForElement(ElementImpl* e, b
             matchRules(defaultQuirksStyle, firstUARule, lastUARule);
         
         // If our medium is print, then we match rules from the print sheet.
-        if (m_medium == "print")
+        if (m_medium->mediaTypeMatch("print"))
             matchRules(defaultPrintStyle, firstUARule, lastUARule);
 
         // Now we check user sheet rules.
@@ -1578,14 +1631,14 @@ void CSSRuleSet::addRule(CSSStyleRuleImpl* rule, CSSSelector* sel)
         m_universalRules->append(m_ruleCount++, rule, sel);
 }
 
-void CSSRuleSet::addRulesFromSheet(CSSStyleSheetImpl *sheet, const DOMString &medium)
+void CSSRuleSet::addRulesFromSheet(CSSStyleSheetImpl *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();
@@ -1599,14 +1652,14 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheetImpl *sheet, const DOMString &me
         }
         else if(item->isImportRule()) {
             CSSImportRuleImpl *import = static_cast<CSSImportRuleImpl *>(item);
-            if (!import->media() || import->media()->contains(medium))
+            if (!import->media() || medium->eval(import->media()))
                 addRulesFromSheet(import->styleSheet(), medium);
         }
         else if(item->isMediaRule()) {
             CSSMediaRuleImpl *r = static_cast<CSSMediaRuleImpl*>(item);
             CSSRuleListImpl *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++) {
                     CSSRuleImpl *childItem = rules->item(j);
@@ -4286,5 +4339,15 @@ Color CSSStyleSelector::getColorFromPrimitiveValue(CSSPrimitiveValueImpl* primit
         col.setRgb(primitiveValue->getRGBColorValue());
     return col;    
 }
+    
+RenderStyle* CSSStyleSelector::defaultStyleForRoot(ElementImpl* e)
+{
+    // XXX: Not a nice way to make the allocation of new style from global heap 
+    // (and not from RenderArena), and to prevent selector to match author stylesheet rules 
+    m_resolvingForRootDefaultStyle = true;
+    RenderStyle* result = styleForElement(e, 0, false);
+    m_resolvingForRootDefaultStyle = false;
+    return result;
+}
 
 } // namespace WebCore
index 0f482aa..909b07f 100644 (file)
@@ -40,6 +40,7 @@ class CSSRuleSet;
 class CSSSelector;
 class CSSStyleSheetImpl;
 class CSSValueImpl;
+class MediaQueryEvaluator;
 class DocumentImpl;
 class ElementImpl;
 class Frame;
@@ -174,6 +175,7 @@ public:
  
     private:
         void init();
+        RenderStyle *defaultStyleForRoot(DOM::ElementImpl* e);
         
         void mapBackgroundAttachment(BackgroundLayer* layer, CSSValueImpl* value);
         void mapBackgroundClip(BackgroundLayer* layer, CSSValueImpl* value);
@@ -199,8 +201,10 @@ public:
         CSSRuleListImpl* m_ruleList;
         bool m_collectRulesOnly;
 
-        QString m_medium;
-
+        DOM::MediaQueryEvaluator* m_medium;
+        RenderStyle* m_rootDefaultStyle;
+        bool m_resolvingForRootDefaultStyle;
+        
         RenderStyle::PseudoId dynamicPseudo;
         
         RenderStyle *style;
diff --git a/WebCore/css/makemediafeatures b/WebCore/css/makemediafeatures
new file mode 100644 (file)
index 0000000..cbf7ea6
--- /dev/null
@@ -0,0 +1,57 @@
+#   This file is part of the KDE libraries
+#
+#   Copyright (C) 1999 Waldo Bastian (bastian@kde.org)
+#
+#   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.
+#
+#----------------------------------------------------------------------------
+#
+#  KDE HTML Widget -- Script to generate cssmediafeatures.c and cssmediafeatures.h
+#
+grep "^[^\#]" cssmediafeatures.in > cssmediafeatures.strip
+
+echo -e '%{\n/* This file is automatically generated from cssmediafeatures.in by makeprop, do not edit */\n/* Copyright 1999 W. Bastian */\n#include "cssmediafeatures.h"\n%}\nstruct css_media_feature_pair {\n    const char *name;\n    int id;\n};\n%%' > cssmediafeatures.gperf
+cat cssmediafeatures.strip | awk '{ do { prop = $0; gsub("-", "_"); print prop ", CSS_MEDIA_FEAT_" toupper($0) } while (getline) }' >> cssmediafeatures.gperf
+echo '%%' >> cssmediafeatures.gperf
+echo -e '/* This file is automatically generated from cssmediafeatures.in by makeprop, do not edit */\n/* Copyright 1998 W. Bastian */\n\n#ifndef CSSMEDIAFEATURES_H\n#define CSSMEDIAFEATURES_H\n\nDOM::DOMString getMediaFeatureName(unsigned short id);\n' > cssmediafeatures.h
+cat cssmediafeatures.strip | awk '{ \
+i=1; \
+print "#define CSS_MEDIA_FEAT_INVALID 0"; \
+print "#define CSS_MEDIA_FEAT_MIN 1"; \
+do { gsub("-", "_"); print "#define CSS_MEDIA_FEAT_" toupper($0) " " i; i = i + 1 } while (getline); \
+print ""; \
+print "#define CSS_MEDIA_FEAT_MAX CSS_MEDIA_FEAT_WIDTH"; \
+print "#define CSS_MEDIA_FEAT_TOTAL " i \
+}' >> cssmediafeatures.h
+gperf -a -L 'ANSI-C' -E -C -c -o -t -k '*' -NfindMediaFeature -Hhash_media_feat -Wwordlist_media_feat -D -s 2 cssmediafeatures.gperf > cssmediafeatures.c || exit 1
+echo -e '#endif\n' >> cssmediafeatures.h
+
+cat cssmediafeatures.strip | awk '{ \
+i=1; \
+print "static const char * const mediaFeatureList[] = {"; \
+print "\"\","; \
+do { print "\"" $0 "\", "; i = i + 1 } while (getline); \
+print "    0"; \
+print "};"; \
+print "DOMString getMediaFeatureName(unsigned short id)"; \
+print "{"; \
+print "    if(id >= CSS_MEDIA_FEAT_TOTAL || id == 0)"; \
+print "      return DOMString();";\
+print "    else";\
+print "      return DOMString(mediaFeatureList[id]);"; \
+print "};"; \
+print ""; \
+}' >> cssmediafeatures.c
index 7a39e21..daa70c8 100644 (file)
@@ -53,6 +53,15 @@ while (<>) {
     print;
 }
 
+# media query, tokenizer state support
+while (<>) {
+  last if /yytext/;
+}
+while (<>) {
+  last if not (/define/ || /line/) ;
+  print;
+}
+
 while (<>) {
     last if /^YY_DECL/;
 }
index b051784..84abb09 100644 (file)
@@ -1,6 +1,8 @@
 %option case-insensitive
 %option noyywrap
 %option 8bit
+%option stack
+%s mediaquery
 
 h               [0-9a-fA-F]
 nonascii        [\200-\377]
@@ -33,6 +35,9 @@ range           \?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|
 "^="                    {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;}
 
@@ -40,15 +45,16 @@ range           \?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|
 
 "#"{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; }
 "@-khtml-rule"    {yyTok = KHTML_RULE_SYM; return yyTok; }
 "@-khtml-decls"   {yyTok = KHTML_DECLS_SYM; return yyTok; }
 "@-khtml-value"   {yyTok = KHTML_VALUE_SYM; return yyTok; }
+"@-khtml-mediaquery"   {BEGIN(mediaquery); yyTok = KHTML_MEDIAQUERY_SYM; return yyTok; }
 
 "!"{w}"important"         {yyTok = IMPORTANT_SYM; return yyTok;}
 
@@ -79,6 +85,8 @@ range           \?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|
 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;}
 
 %%
index 0e9fcf4..10a0aea 100644 (file)
@@ -43,6 +43,7 @@
 #include "css/cssstyleselector.h"
 #include "css/css_stylesheetimpl.h"
 #include "css/csshelper.h"
+#include "css/css_mediaqueryeval.h"
 #include "htmlnames.h"
 
 #include <kurl.h>
@@ -236,7 +237,10 @@ void HTMLLinkElementImpl::process()
         // 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), screenEval("screen", true), printEval("print", true);
+        MediaListImpl* media = new MediaListImpl();
+        media->setMediaText( m_media );
+        if (allEval.eval(media) || screenEval.eval(media) || printEval.eval(media)) {
             m_loading = true;
 
             // Add ourselves as a pending sheet, but only if we aren't an alternate 
@@ -250,6 +254,8 @@ void HTMLLinkElementImpl::process()
             m_cachedSheet = getDocument()->docLoader()->requestStyleSheet(m_url, chset);
             if (m_cachedSheet)
                 m_cachedSheet->ref(this);
+        } else {
+            delete media;
         }
     }
     else if (m_sheet) {
@@ -276,9 +282,9 @@ void HTMLLinkElementImpl::setStyleSheet(const DOM::DOMString &url, const DOM::DO
     m_sheet = new CSSStyleSheetImpl(this, url);
     m_sheet->parseString(sheetStr, !getDocument()->inCompatMode());
 
-    MediaListImpl *media = new MediaListImpl(m_sheet.get(), m_media);
+    MediaListImplmedia = new MediaListImpl(m_sheet.get(), m_media);
     m_sheet->setMedia( media );
-
+    
     m_loading = false;
 
     // Tell the doc about the sheet.
@@ -750,16 +756,23 @@ void HTMLStyleElementImpl::childrenChanged()
         m_sheet = 0;
     }
 
-    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"))) {
-        getDocument()->addPendingSheet();
-        m_loading = true;
-        m_sheet = new CSSStyleSheetImpl(this);
-        m_sheet->parseString(text, !getDocument()->inCompatMode());
-        MediaListImpl *media = new MediaListImpl(m_sheet.get(), m_media);
-        m_sheet->setMedia(media);
-        m_loading = false;
+    m_loading = false;    
+    if ((m_type.isEmpty() || m_type == "text/css")) {// Type must be empty or CSS
+        MediaListImpl* media = new MediaListImpl();
+        media->setMediaText(m_media);
+        MediaQueryEvaluator allEval(true), screenEval("screen", true),  printEval("print", true);
+        if (allEval.eval(media) || screenEval.eval(media) || printEval.eval(media)) {
+            getDocument()->addPendingSheet();
+            m_loading = true;
+            m_sheet = new CSSStyleSheetImpl(this);
+            m_sheet->ref();
+            m_sheet->parseString(text, !getDocument()->inCompatMode());
+            media->setParent(m_sheet.get());
+            m_sheet->setMedia(media);
+            m_loading = false;
+        } else {
+            delete media;
+        }
     }
 
     if (!isLoading() && m_sheet)
index 4f2e9fd..8caa16e 100644 (file)
@@ -33,6 +33,8 @@ namespace WebCore {
     class IntRect;
 
     int screenDepth(QWidget*);
+    int screenDepthPerComponent(QWidget*);
+    bool screenIsMonochrome(QWidget*);
     IntRect screenRect(QWidget*);
     IntRect usableScreenRect(QWidget*);
 
index 9004d4b..f4ae806 100644 (file)
@@ -50,6 +50,22 @@ int screenDepth(QWidget* widget)
     return [screen(widget) depth];
 }
 
+int screenDepthPerComponent(QWidget* widget)
+{
+   return NSBitsPerSampleFromDepth([screen(widget) depth]);
+}
+
+bool screenIsMonochrome(QWidget* widget)
+{
+    NSScreen* s = screen(widget);
+    NSDictionary* dd = [s deviceDescription];
+    NSString* colorSpaceName = [dd objectForKey:NSDeviceColorSpaceName];
+    // XXX: can named colorspace or custom colorspace be monochrome?
+    // XXX: will NS*BlackColorSpace or NS*WhiteColorSpace be always monochrome?
+    return colorSpaceName == NSCalibratedWhiteColorSpace || colorSpaceName == NSCalibratedBlackColorSpace || 
+        colorSpaceName == NSDeviceWhiteColorSpace || colorSpaceName == NSDeviceBlackColorSpace;
+}
+
 IntRect screenRect(QWidget* widget)
 {
     return enclosingIntRect(flipGlobalRect([screen(widget) frame]));