+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
--- /dev/null
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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>
--- /dev/null
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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>
--- /dev/null
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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>
--- /dev/null
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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>
--- /dev/null
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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
--- /dev/null
+c3a4b15983b538a5247299245f383ea5
\ No newline at end of file
--- /dev/null
+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"
--- /dev/null
+<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>
--- /dev/null
+05a863a321f32f15ca96f0b745ab6823
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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>
--- /dev/null
+13a8a15857868d43e1af1086030f97cf
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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>
--- /dev/null
+4c146be940e196c365414a6205da5a8d
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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>
--- /dev/null
+1c11b6a1285dfb1dad48634108141ce9
\ No newline at end of file
--- /dev/null
+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"
--- /dev/null
+<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
--- /dev/null
+364923683606083e6728dc6edcf76f89
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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
--- /dev/null
+c801be0c86a8d567b3f5be9ffe5e01f4
\ No newline at end of file
--- /dev/null
+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"
--- /dev/null
+<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>
--- /dev/null
+bccd379d30fd3d06b032e0df3728e2b4
\ No newline at end of file
--- /dev/null
+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"
--- /dev/null
+<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>
--- /dev/null
+43a7cd01a8a6327c8980a0357097bab5
\ No newline at end of file
--- /dev/null
+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"
--- /dev/null
+<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>
--- /dev/null
+bdd79ae10c3636b21df9cf919841ba91
\ No newline at end of file
--- /dev/null
+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"
--- /dev/null
+<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>
--- /dev/null
+59693b3b56b343b7a841b54e4d5d41f2
\ No newline at end of file
--- /dev/null
+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
--- /dev/null
+<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>
--- /dev/null
+7499a40172304d162bb6dbf0ac77e8dd
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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>
--- /dev/null
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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
--- /dev/null
+bfd66393358e49a5b1c09f4acb698233
\ No newline at end of file
--- /dev/null
+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"
--- /dev/null
+<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>
--- /dev/null
+bfd66393358e49a5b1c09f4acb698233
\ No newline at end of file
--- /dev/null
+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"
--- /dev/null
+<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>
--- /dev/null
+5f9f2be9db02e8db55395eed16fd5d24
\ No newline at end of file
--- /dev/null
+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)"
--- /dev/null
+<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>
--- /dev/null
+ab6b6fd71e9f104e2db1642352a043d7
\ No newline at end of file
--- /dev/null
+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"
--- /dev/null
+<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>
--- /dev/null
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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>
--- /dev/null
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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>
--- /dev/null
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
--- /dev/null
+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."
--- /dev/null
+<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>
--- /dev/null
+915a9e795ad41ad5998dba4f681f98dc
\ No newline at end of file
--- /dev/null
+<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>
--- /dev/null
+p {
+ color: green;
+}
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.
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;
};
#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"
#define __inline
#include "cssproperties.c"
#include "cssvalues.c"
+#include "cssmediafeatures.c"
#undef __inline
namespace WebCore {
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
char tok;
Value value;
ValueList *valueList;
+
+ int mediaFeatureId;
+ MediaQueryImpl *mediaQuery;
+ MediaQueryExpImpl *mediaQueryExp;
+ MediaQueryExpListImpl *mediaQueryExpList;
+ MediaQueryImpl::Restrictor mediaQueryRestrictor;
}
%{
%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
%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
| khtml_rule maybe_space
| khtml_decls maybe_space
| khtml_value maybe_space
+ | khtml_mediaquery maybe_space
;
khtml_rule:
}
;
+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
| 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();
/* 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() ) {
--- /dev/null
+#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;
+}
--- /dev/null
+#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
--- /dev/null
+#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);
+}
--- /dev/null
+#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
#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"
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;
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);
+}
#include "dom/dom_string.h"
#include "css/css_base.h"
+#include "css/css_mediaqueryimpl.h"
namespace khtml {
class CachedCSSStyleSheet;
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;
};
#include "CachedObjectClient.h"
#include <qvaluelist.h>
-class QPaintDeviceMetrics;
-
namespace khtml {
class RenderStyle;
class CachedImage;
#include "dom/dom_string.h"
-class QPaintDeviceMetrics;
class KHTMLSettings;
namespace DOM
--- /dev/null
+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
#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"
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)
{
#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"
class CSSMutableStyleDeclarationImpl;
class CSSProperty;
class CSSRuleListImpl;
+ class MediaListImpl;
+ class MediaQueryImpl;
struct ParseString {
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; }
int id;
DOM::StyleListImpl *styleElement;
DOM::CSSRuleImpl *rule;
+ DOM::MediaQueryImpl *mediaQuery;
ValueList *valueList;
CSSProperty **parsedProperties;
int numParsedProperties;
#include "csshelper.h"
#include "cssproperties.h"
#include "cssvalues.h"
+#include "css_mediaqueryeval.h"
#include "font.h"
#include "helper.h"
#include "html_documentimpl.h"
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,
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);
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 );
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)
CSSStyleSelector::~CSSStyleSelector()
{
+ delete m_medium;
+ ::delete m_rootDefaultStyle;
delete m_authorStyle;
delete m_userStyle;
delete m_userSheet;
// 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)
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);
}
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
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);
// 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.
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.
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();
}
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);
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
class CSSSelector;
class CSSStyleSheetImpl;
class CSSValueImpl;
+class MediaQueryEvaluator;
class DocumentImpl;
class ElementImpl;
class Frame;
private:
void init();
+ RenderStyle *defaultStyleForRoot(DOM::ElementImpl* e);
void mapBackgroundAttachment(BackgroundLayer* layer, CSSValueImpl* value);
void mapBackgroundClip(BackgroundLayer* layer, CSSValueImpl* value);
CSSRuleListImpl* m_ruleList;
bool m_collectRulesOnly;
- QString m_medium;
-
+ DOM::MediaQueryEvaluator* m_medium;
+ RenderStyle* m_rootDefaultStyle;
+ bool m_resolvingForRootDefaultStyle;
+
RenderStyle::PseudoId dynamicPseudo;
RenderStyle *style;
--- /dev/null
+# 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
print;
}
+# media query, tokenizer state support
+while (<>) {
+ last if /yytext/;
+}
+while (<>) {
+ last if not (/define/ || /line/) ;
+ print;
+}
+
while (<>) {
last if /^YY_DECL/;
}
%option case-insensitive
%option noyywrap
%option 8bit
+%option stack
+%s mediaquery
h [0-9a-fA-F]
nonascii [\200-\377]
"^=" {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;}
"#"{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;}
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;}
%%
#include "css/cssstyleselector.h"
#include "css/css_stylesheetimpl.h"
#include "css/csshelper.h"
+#include "css/css_mediaqueryeval.h"
#include "htmlnames.h"
#include <kurl.h>
// 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
m_cachedSheet = getDocument()->docLoader()->requestStyleSheet(m_url, chset);
if (m_cachedSheet)
m_cachedSheet->ref(this);
+ } else {
+ delete media;
}
}
else if (m_sheet) {
m_sheet = new CSSStyleSheetImpl(this, url);
m_sheet->parseString(sheetStr, !getDocument()->inCompatMode());
- MediaListImpl *media = new MediaListImpl(m_sheet.get(), m_media);
+ MediaListImpl* media = new MediaListImpl(m_sheet.get(), m_media);
m_sheet->setMedia( media );
-
+
m_loading = false;
// Tell the doc about the sheet.
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)
class IntRect;
int screenDepth(QWidget*);
+ int screenDepthPerComponent(QWidget*);
+ bool screenIsMonochrome(QWidget*);
IntRect screenRect(QWidget*);
IntRect usableScreenRect(QWidget*);
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]));