Reviewed by Hyatt.
authorbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Apr 2006 22:06:33 +0000 (22:06 +0000)
committerbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Apr 2006 22:06:33 +0000 (22:06 +0000)
        Implementation of CSS3 background-size property. See
        http://bugzilla.opendarwin.org/show_bug.cgi?id=8353 for details.

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

84 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/backgroundSize01-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize01-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize01-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize01.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize02-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize02-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize02-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize02.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize03-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize03-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize03-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize03.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize04-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize04-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize04-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize04.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize05-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize05-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize05-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize05.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize06-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize06-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize06-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize06.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize07-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize07-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize07-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize07.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize08-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize08-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize08-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize08.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize09-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize09-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize09-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize09.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize10-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize10-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize10-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize10.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize11-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize11-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize11-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize11.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize12-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize12-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize12-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize12.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize13-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize13-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize13-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize13.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize14-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize14-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize14-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize14.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize15-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize15-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize15-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize15.html [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize16-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize16-expected.png [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize16-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/backgroundSize16.html [new file with mode: 0644]
LayoutTests/fast/css/resources/bikes.bmp [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.vcproj/Image Viewer/ImageView.cpp
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/css/CSSPropertyNames.in
WebCore/css/css_valueimpl.h
WebCore/css/cssparser.cpp
WebCore/css/cssparser.h
WebCore/css/cssstyleselector.cpp
WebCore/css/cssstyleselector.h
WebCore/platform/GraphicsContext.h
WebCore/platform/Image.h
WebCore/platform/cairo/GraphicsContextCairo.cpp
WebCore/platform/cairo/ImageCairo.cpp
WebCore/platform/mac/GraphicsContextMac.mm
WebCore/platform/mac/ImageMac.mm
WebCore/rendering/RenderBox.cpp
WebCore/rendering/render_style.cpp
WebCore/rendering/render_style.h

index 66be8b638eb43d0bfed2bf91a322312ce2bf3b1c..a596b85dbe29f2c9ad8254aa26441fa604c6753b 100644 (file)
@@ -1,3 +1,76 @@
+2006-04-18  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Hyatt
+
+        Layout tests for http://bugzilla.opendarwin.org/show_bug.cgi?
+        id=8353 CSS3: Implement background-size property
+
+        * fast/css/backgroundSize01-expected.checksum: Added.
+        * fast/css/backgroundSize01-expected.png: Added.
+        * fast/css/backgroundSize01-expected.txt: Added.
+        * fast/css/backgroundSize01.html: Added.
+        * fast/css/backgroundSize02-expected.checksum: Added.
+        * fast/css/backgroundSize02-expected.png: Added.
+        * fast/css/backgroundSize02-expected.txt: Added.
+        * fast/css/backgroundSize02.html: Added.
+        * fast/css/backgroundSize03-expected.checksum: Added.
+        * fast/css/backgroundSize03-expected.png: Added.
+        * fast/css/backgroundSize03-expected.txt: Added.
+        * fast/css/backgroundSize03.html: Added.
+        * fast/css/backgroundSize04-expected.checksum: Added.
+        * fast/css/backgroundSize04-expected.png: Added.
+        * fast/css/backgroundSize04-expected.txt: Added.
+        * fast/css/backgroundSize04.html: Added.
+        * fast/css/backgroundSize05-expected.checksum: Added.
+        * fast/css/backgroundSize05-expected.png: Added.
+        * fast/css/backgroundSize05-expected.txt: Added.
+        * fast/css/backgroundSize05.html: Added.
+        * fast/css/backgroundSize06-expected.checksum: Added.
+        * fast/css/backgroundSize06-expected.png: Added.
+        * fast/css/backgroundSize06-expected.txt: Added.
+        * fast/css/backgroundSize06.html: Added.
+        * fast/css/backgroundSize07-expected.checksum: Added.
+        * fast/css/backgroundSize07-expected.png: Added.
+        * fast/css/backgroundSize07-expected.txt: Added.
+        * fast/css/backgroundSize07.html: Added.
+        * fast/css/backgroundSize08-expected.checksum: Added.
+        * fast/css/backgroundSize08-expected.png: Added.
+        * fast/css/backgroundSize08-expected.txt: Added.
+        * fast/css/backgroundSize08.html: Added.
+        * fast/css/backgroundSize09-expected.checksum: Added.
+        * fast/css/backgroundSize09-expected.png: Added.
+        * fast/css/backgroundSize09-expected.txt: Added.
+        * fast/css/backgroundSize09.html: Added.
+        * fast/css/backgroundSize10-expected.checksum: Added.
+        * fast/css/backgroundSize10-expected.png: Added.
+        * fast/css/backgroundSize10-expected.txt: Added.
+        * fast/css/backgroundSize10.html: Added.
+        * fast/css/backgroundSize11-expected.checksum: Added.
+        * fast/css/backgroundSize11-expected.png: Added.
+        * fast/css/backgroundSize11-expected.txt: Added.
+        * fast/css/backgroundSize11.html: Added.
+        * fast/css/backgroundSize12-expected.checksum: Added.
+        * fast/css/backgroundSize12-expected.png: Added.
+        * fast/css/backgroundSize12-expected.txt: Added.
+        * fast/css/backgroundSize12.html: Added.
+        * fast/css/backgroundSize13-expected.checksum: Added.
+        * fast/css/backgroundSize13-expected.png: Added.
+        * fast/css/backgroundSize13-expected.txt: Added.
+        * fast/css/backgroundSize13.html: Added.
+        * fast/css/backgroundSize14-expected.checksum: Added.
+        * fast/css/backgroundSize14-expected.png: Added.
+        * fast/css/backgroundSize14-expected.txt: Added.
+        * fast/css/backgroundSize14.html: Added.
+        * fast/css/backgroundSize15-expected.checksum: Added.
+        * fast/css/backgroundSize15-expected.png: Added.
+        * fast/css/backgroundSize15-expected.txt: Added.
+        * fast/css/backgroundSize15.html: Added.
+        * fast/css/backgroundSize16-expected.checksum: Added.
+        * fast/css/backgroundSize16-expected.png: Added.
+        * fast/css/backgroundSize16-expected.txt: Added.
+        * fast/css/backgroundSize16.html: Added.
+        * fast/css/resources/bikes.bmp: Added.
+
 2006-04-18  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by harrison
diff --git a/LayoutTests/fast/css/backgroundSize01-expected.checksum b/LayoutTests/fast/css/backgroundSize01-expected.checksum
new file mode 100644 (file)
index 0000000..b31e2e8
--- /dev/null
@@ -0,0 +1 @@
+f7d3d0824bd6276f93f382cc8cb76946
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize01-expected.png b/LayoutTests/fast/css/backgroundSize01-expected.png
new file mode 100644 (file)
index 0000000..b6dec85
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize01-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize01-expected.txt b/LayoutTests/fast/css/backgroundSize01-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize01.html b/LayoutTests/fast/css/backgroundSize01.html
new file mode 100644 (file)
index 0000000..6528ec0
--- /dev/null
@@ -0,0 +1,11 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -webkit-background-size: auto 25%;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize02-expected.checksum b/LayoutTests/fast/css/backgroundSize02-expected.checksum
new file mode 100644 (file)
index 0000000..3b853a6
--- /dev/null
@@ -0,0 +1 @@
+addf612c326f06d7459a177119aa470c
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize02-expected.png b/LayoutTests/fast/css/backgroundSize02-expected.png
new file mode 100644 (file)
index 0000000..35162b8
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize02-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize02-expected.txt b/LayoutTests/fast/css/backgroundSize02-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize02.html b/LayoutTests/fast/css/backgroundSize02.html
new file mode 100644 (file)
index 0000000..e3b946b
--- /dev/null
@@ -0,0 +1,11 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -khtml-background-size: 50% auto;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize03-expected.checksum b/LayoutTests/fast/css/backgroundSize03-expected.checksum
new file mode 100644 (file)
index 0000000..0613023
--- /dev/null
@@ -0,0 +1 @@
+ac77417f16bb47afc4997de4b528fdfb
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize03-expected.png b/LayoutTests/fast/css/backgroundSize03-expected.png
new file mode 100644 (file)
index 0000000..02f4ef0
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize03-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize03-expected.txt b/LayoutTests/fast/css/backgroundSize03-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize03.html b/LayoutTests/fast/css/backgroundSize03.html
new file mode 100644 (file)
index 0000000..0cc91c7
--- /dev/null
@@ -0,0 +1,11 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -khtml-background-size: auto;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize04-expected.checksum b/LayoutTests/fast/css/backgroundSize04-expected.checksum
new file mode 100644 (file)
index 0000000..fa2e058
--- /dev/null
@@ -0,0 +1 @@
+88eb9833f5c6beda44d8b07a7d7f146c
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize04-expected.png b/LayoutTests/fast/css/backgroundSize04-expected.png
new file mode 100644 (file)
index 0000000..c945f59
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize04-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize04-expected.txt b/LayoutTests/fast/css/backgroundSize04-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize04.html b/LayoutTests/fast/css/backgroundSize04.html
new file mode 100644 (file)
index 0000000..c326c52
--- /dev/null
@@ -0,0 +1,11 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -khtml-background-size: 100%;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize05-expected.checksum b/LayoutTests/fast/css/backgroundSize05-expected.checksum
new file mode 100644 (file)
index 0000000..fe69237
--- /dev/null
@@ -0,0 +1 @@
+19e13e3fc020bf628e756fd3d36b8e5a
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize05-expected.png b/LayoutTests/fast/css/backgroundSize05-expected.png
new file mode 100644 (file)
index 0000000..952ea0d
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize05-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize05-expected.txt b/LayoutTests/fast/css/backgroundSize05-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize05.html b/LayoutTests/fast/css/backgroundSize05.html
new file mode 100644 (file)
index 0000000..008f7c6
--- /dev/null
@@ -0,0 +1,11 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -khtml-background-size: 100 auto;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize06-expected.checksum b/LayoutTests/fast/css/backgroundSize06-expected.checksum
new file mode 100644 (file)
index 0000000..7f84fe9
--- /dev/null
@@ -0,0 +1 @@
+e11ee31ba2b820c892987271dd0b63f7
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize06-expected.png b/LayoutTests/fast/css/backgroundSize06-expected.png
new file mode 100644 (file)
index 0000000..66d68e5
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize06-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize06-expected.txt b/LayoutTests/fast/css/backgroundSize06-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize06.html b/LayoutTests/fast/css/backgroundSize06.html
new file mode 100644 (file)
index 0000000..f821133
--- /dev/null
@@ -0,0 +1,11 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -khtml-background-size: 33% 50%;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize07-expected.checksum b/LayoutTests/fast/css/backgroundSize07-expected.checksum
new file mode 100644 (file)
index 0000000..584d3bc
--- /dev/null
@@ -0,0 +1 @@
+5c3fa3e80ab59d6aa3e97db22a7b76d7
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize07-expected.png b/LayoutTests/fast/css/backgroundSize07-expected.png
new file mode 100644 (file)
index 0000000..643dbb4
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize07-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize07-expected.txt b/LayoutTests/fast/css/backgroundSize07-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize07.html b/LayoutTests/fast/css/backgroundSize07.html
new file mode 100644 (file)
index 0000000..0fed79b
--- /dev/null
@@ -0,0 +1,12 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -khtml-background-size: 33%;
+        background-repeat: repeat-x;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize08-expected.checksum b/LayoutTests/fast/css/backgroundSize08-expected.checksum
new file mode 100644 (file)
index 0000000..42486de
--- /dev/null
@@ -0,0 +1 @@
+0efb567bc94fe7ed8db5b2df92654f16
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize08-expected.png b/LayoutTests/fast/css/backgroundSize08-expected.png
new file mode 100644 (file)
index 0000000..f7e16b8
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize08-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize08-expected.txt b/LayoutTests/fast/css/backgroundSize08-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize08.html b/LayoutTests/fast/css/backgroundSize08.html
new file mode 100644 (file)
index 0000000..ea78764
--- /dev/null
@@ -0,0 +1,12 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -khtml-background-size: auto 33%;
+        background-repeat: repeat-y;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize09-expected.checksum b/LayoutTests/fast/css/backgroundSize09-expected.checksum
new file mode 100644 (file)
index 0000000..bf3da3d
--- /dev/null
@@ -0,0 +1 @@
+9668f153bbe5847e765ae2d3c80d208c
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize09-expected.png b/LayoutTests/fast/css/backgroundSize09-expected.png
new file mode 100644 (file)
index 0000000..34469d1
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize09-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize09-expected.txt b/LayoutTests/fast/css/backgroundSize09-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize09.html b/LayoutTests/fast/css/backgroundSize09.html
new file mode 100644 (file)
index 0000000..3e0dbee
--- /dev/null
@@ -0,0 +1,12 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -khtml-background-size: 100 auto;
+        background-repeat: no-repeat;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize10-expected.checksum b/LayoutTests/fast/css/backgroundSize10-expected.checksum
new file mode 100644 (file)
index 0000000..46036a7
--- /dev/null
@@ -0,0 +1 @@
+13f0c9a5c5a487bc02e26edcb2ef2549
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize10-expected.png b/LayoutTests/fast/css/backgroundSize10-expected.png
new file mode 100644 (file)
index 0000000..a08e8de
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize10-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize10-expected.txt b/LayoutTests/fast/css/backgroundSize10-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize10.html b/LayoutTests/fast/css/backgroundSize10.html
new file mode 100644 (file)
index 0000000..e432d5e
--- /dev/null
@@ -0,0 +1,13 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -khtml-background-size: 100 auto;
+        background-repeat: no-repeat;
+        background-position: center;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize11-expected.checksum b/LayoutTests/fast/css/backgroundSize11-expected.checksum
new file mode 100644 (file)
index 0000000..6debf92
--- /dev/null
@@ -0,0 +1 @@
+b82a02ebda3c933d6519bdf3fc63b752
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize11-expected.png b/LayoutTests/fast/css/backgroundSize11-expected.png
new file mode 100644 (file)
index 0000000..d4a46f0
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize11-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize11-expected.txt b/LayoutTests/fast/css/backgroundSize11-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize11.html b/LayoutTests/fast/css/backgroundSize11.html
new file mode 100644 (file)
index 0000000..3d740c4
--- /dev/null
@@ -0,0 +1,13 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -khtml-background-size: 100 auto;
+        background-repeat: no-repeat;
+        background-position: right;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize12-expected.checksum b/LayoutTests/fast/css/backgroundSize12-expected.checksum
new file mode 100644 (file)
index 0000000..1bd2676
--- /dev/null
@@ -0,0 +1 @@
+ee2a1ba93b49d3fcddf2cf97a8c70511
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize12-expected.png b/LayoutTests/fast/css/backgroundSize12-expected.png
new file mode 100644 (file)
index 0000000..85d288a
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize12-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize12-expected.txt b/LayoutTests/fast/css/backgroundSize12-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize12.html b/LayoutTests/fast/css/backgroundSize12.html
new file mode 100644 (file)
index 0000000..e7044bd
--- /dev/null
@@ -0,0 +1,12 @@
+<head>
+<style>
+    body {
+        background-image:url(resources/bikes.bmp); 
+        -khtml-background-size: auto 150;
+        background-position: right;
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize13-expected.checksum b/LayoutTests/fast/css/backgroundSize13-expected.checksum
new file mode 100644 (file)
index 0000000..b46e157
--- /dev/null
@@ -0,0 +1 @@
+47a7ac13b200431a77631b810410fb9c
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize13-expected.png b/LayoutTests/fast/css/backgroundSize13-expected.png
new file mode 100644 (file)
index 0000000..98c2a01
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize13-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize13-expected.txt b/LayoutTests/fast/css/backgroundSize13-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize13.html b/LayoutTests/fast/css/backgroundSize13.html
new file mode 100644 (file)
index 0000000..c48e28d
--- /dev/null
@@ -0,0 +1,14 @@
+<head>
+<style>
+    body {
+        background: url(resources/bikes.bmp);
+        -khtml-background-size: 50% auto;
+        background-position: 100% 99%;
+        background-attachment: fixed;
+        background-repeat: no-repeat; 
+    }
+</style>
+</head>
+
+<body>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize14-expected.checksum b/LayoutTests/fast/css/backgroundSize14-expected.checksum
new file mode 100644 (file)
index 0000000..6f615f9
--- /dev/null
@@ -0,0 +1 @@
+86ae57c74e9df5fa2314deed94c23780
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize14-expected.png b/LayoutTests/fast/css/backgroundSize14-expected.png
new file mode 100644 (file)
index 0000000..956d255
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize14-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize14-expected.txt b/LayoutTests/fast/css/backgroundSize14-expected.txt
new file mode 100644 (file)
index 0000000..e670c0c
--- /dev/null
@@ -0,0 +1,5 @@
+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 784x584
diff --git a/LayoutTests/fast/css/backgroundSize14.html b/LayoutTests/fast/css/backgroundSize14.html
new file mode 100644 (file)
index 0000000..a95c493
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<style>
+body
+{ 
+    background-image: url('resources/bikes.bmp');
+    background-position: 33% 33%;
+    -khtml-background-size: 50% auto;
+    background-repeat:no-repeat;
+}
+</style>
+</head>
+
+<body>
+</body>
+
+</html>
+
diff --git a/LayoutTests/fast/css/backgroundSize15-expected.checksum b/LayoutTests/fast/css/backgroundSize15-expected.checksum
new file mode 100644 (file)
index 0000000..8d74fae
--- /dev/null
@@ -0,0 +1 @@
+48b1c9efafb05210f60385edb938e96f
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize15-expected.png b/LayoutTests/fast/css/backgroundSize15-expected.png
new file mode 100644 (file)
index 0000000..0266f0e
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize15-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize15-expected.txt b/LayoutTests/fast/css/backgroundSize15-expected.txt
new file mode 100644 (file)
index 0000000..a46b6c9
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 808x970
+  RenderCanvas at (0,0) size 785x585
+layer at (0,0) size 808x970
+  RenderBlock {HTML} at (0,0) size 785x970
+    RenderBody {BODY} at (8,8) size 769x954
+      RenderBlock {DIV} at (0,0) size 100x100
+      RenderBlock (anonymous) at (0,100) size 769x54
+        RenderBR {BR} at (0,0) size 0x18
+        RenderBR {BR} at (0,18) size 0x18
+        RenderBR {BR} at (0,36) size 0x18
+      RenderBlock {DIV} at (0,154) size 800x800
diff --git a/LayoutTests/fast/css/backgroundSize15.html b/LayoutTests/fast/css/backgroundSize15.html
new file mode 100644 (file)
index 0000000..a92d8ea
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<style>
+div { 
+    background-image:url(resources/bikes.bmp); 
+    -khtml-background-size: 133px 135px;
+    }
+</style>
+
+<body>
+
+<div style="width:100px; height:100px"></div>
+
+<br><br><br>
+
+<div style="width:800px; height:800px"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize16-expected.checksum b/LayoutTests/fast/css/backgroundSize16-expected.checksum
new file mode 100644 (file)
index 0000000..4a0482d
--- /dev/null
@@ -0,0 +1 @@
+c2abd70b5621a4ef3911bde6afabffbb
\ No newline at end of file
diff --git a/LayoutTests/fast/css/backgroundSize16-expected.png b/LayoutTests/fast/css/backgroundSize16-expected.png
new file mode 100644 (file)
index 0000000..bae0419
Binary files /dev/null and b/LayoutTests/fast/css/backgroundSize16-expected.png differ
diff --git a/LayoutTests/fast/css/backgroundSize16-expected.txt b/LayoutTests/fast/css/backgroundSize16-expected.txt
new file mode 100644 (file)
index 0000000..c6b9a63
--- /dev/null
@@ -0,0 +1,25 @@
+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 784x584
+      RenderInline {SPAN} at (0,0) size 782x270
+        RenderText {#text} at (0,0) size 782x270
+          text run at (0,0) width 469: "I am typing a lot of text so that this goes onto many lines. I am still typing. "
+          text run at (469,0) width 283: "I am typing a lot of text so that this goes onto"
+          text run at (0,18) width 771: "many lines. I am still typing. I am typing a lot of text so that this goes onto many lines. I am still typing. I am typing a lot of"
+          text run at (0,36) width 762: "text so that this goes onto many lines. I am still typing. I am typing a lot of text so that this goes onto many lines. I am still"
+          text run at (0,54) width 768: "typing. I am typing a lot of text so that this goes onto many lines. I am still typing. I am typing a lot of text so that this goes"
+          text run at (0,72) width 766: "onto many lines. I am still typing. I am typing a lot of text so that this goes onto many lines. I am still typing. I am typing a"
+          text run at (0,90) width 773: "lot of text so that this goes onto many lines. I am still typing. I am typing a lot of text so that this goes onto many lines. I am"
+          text run at (0,108) width 761: "still typing. I am typing a lot of text so that this goes onto many lines. I am still typing. I am typing a lot of text so that this"
+          text run at (0,126) width 744: "goes onto many lines. I am still typing. I am typing a lot of text so that this goes onto many lines. I am still typing. I am"
+          text run at (0,144) width 759: "typing a lot of text so that this goes onto many lines. I am still typing. I am typing a lot of text so that this goes onto many"
+          text run at (0,162) width 777: "lines. I am still typing. I am typing a lot of text so that this goes onto many lines. I am still typing. I am typing a lot of text so"
+          text run at (0,180) width 774: "that this goes onto many lines. I am still typing. I am typing a lot of text so that this goes onto many lines. I am still typing. I"
+          text run at (0,198) width 782: "am typing a lot of text so that this goes onto many lines. I am still typing. I am typing a lot of text so that this goes onto many"
+          text run at (0,216) width 777: "lines. I am still typing. I am typing a lot of text so that this goes onto many lines. I am still typing. I am typing a lot of text so"
+          text run at (0,234) width 774: "that this goes onto many lines. I am still typing. I am typing a lot of text so that this goes onto many lines. I am still typing. I"
+          text run at (0,252) width 456: "am typing a lot of text so that this goes onto many lines. I am still typing."
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/fast/css/backgroundSize16.html b/LayoutTests/fast/css/backgroundSize16.html
new file mode 100644 (file)
index 0000000..5f45e0c
--- /dev/null
@@ -0,0 +1,37 @@
+<html>
+<style>
+span { 
+    background-image:url(resources/bikes.bmp); 
+    -webkit-background-size: 40px auto;
+    }
+</style>
+
+<body>
+
+<span>I am typing a lot of text so that this goes onto many lines. I am still typing. 
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.
+I am typing a lot of text so that this goes onto many lines. I am still typing.</span>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/resources/bikes.bmp b/LayoutTests/fast/css/resources/bikes.bmp
new file mode 100644 (file)
index 0000000..a60c001
Binary files /dev/null and b/LayoutTests/fast/css/resources/bikes.bmp differ
index 67feb5cf468ddac385db78971e671c2052bfee36..1a6bd8514eaae98f392e325f64e755372d54778f 100644 (file)
@@ -1,3 +1,52 @@
+2006-04-18  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Hyatt.
+
+        Implementation of CSS3 background-size property. See 
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=8353 for details.
+
+        * Viewer/ImageView.cpp: Adjust parameters to drawTiledImage()
+        * css/CSSComputedStyleDeclaration.cpp: Add background-size
+        * css/CSSPropertyNames.in: Same.
+        * css/css_valueimpl.h: Add a constructor for Pair that takes the 
+        two halves of the pair.
+        * css/cssparser.cpp: Parse background-size. Still need to take care 
+        of parsing the shorthand.
+        * css/cssparser.h: Same.
+        * css/cssstyleselector.cpp: Address background-size.
+        * css/cssstyleselector.h: Same.
+        * platform/GraphicsContext.h: drawTiledImage() now takes the 
+        tileSize so that it can appropriately scale.
+        * platform/Image.h: Same as above, but for tileInRect()
+        * platform/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::drawTiledImage):
+        * platform/cairo/ImageCairo.cpp:
+        (WebCore::Image::tileInRect): Take care of scaling image in 
+        necessary in Cairo.
+        * platform/mac/GraphicsContextMac.mm:
+        (WebCore::GraphicsContext::drawTiledImage): 
+        * platform/mac/ImageMac.mm:
+        (WebCore::Image::tileInRect): Take care of scaling image if 
+        necessary in CG.
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::paintBackgroundExtended): Compute appropriate 
+        scale if background-size is set. If no-repeat is set, just call 
+        drawImage() directly.
+        * rendering/render_style.cpp: Add background-size to the style.
+        (WebCore::m_next):
+        (WebCore::BackgroundLayer::BackgroundLayer):
+        (WebCore::BackgroundLayer::operator=):
+        (WebCore::BackgroundLayer::operator==):
+        (WebCore::BackgroundLayer::fillUnsetProperties):
+        (WebCore::BackgroundLayer::cullEmptyLayers):
+        * rendering/render_style.h: Same.
+        (WebCore::BackgroundLayer::backgroundSize):
+        (WebCore::BackgroundLayer::isBackgroundSizeSet):
+        (WebCore::BackgroundLayer::setBackgroundSize):
+        (WebCore::BackgroundLayer::clearBackgroundSize):
+        (WebCore::RenderStyle::backgroundSize):
+        (WebCore::RenderStyle::initialBackgroundSize):
+
 2006-04-17  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by harrison
index 0f9fe8063e26c4ef4ed292f77aeb0b178e954cfc..b449ab92d18c4d495af2569ccecfd91c067e1915 100644 (file)
@@ -109,7 +109,7 @@ void ImageView::OnDraw(CDC* pDC)
     FloatRect dstRect(FloatPoint(left, top), FloatSize(width, height));
     FloatRect imageRect(srcPoint, image->size());
     if (tile)
-        gc.drawTiledImage(image, IntRect(left, top, width, height), srcPoint.x(), srcPoint.y());
+        gc.drawTiledImage(image, IntRect(left, top, width, height), IntPoint(srcPoint.x(), srcPoint.y()), image->size());
     else {
         gc.drawImage(image, dstRect,
             imageRect.x(), imageRect.y(), imageRect.width(), imageRect.height(), Image::CompositeSourceOver);
index 9eee0604c976c25b9ba9bdafa159d5a3d258357d..d54c050e6b6161e06230ad5b44a2e4637d2a72a5 100644 (file)
@@ -38,6 +38,7 @@ namespace WebCore {
 static const int computedProperties[] = {
     CSS_PROP_BACKGROUND_COLOR,
     CSS_PROP_BACKGROUND_IMAGE,
+    CSS_PROP__WEBKIT_BACKGROUND_SIZE,
     CSS_PROP_BACKGROUND_REPEAT,
     CSS_PROP_BACKGROUND_ATTACHMENT,
     CSS_PROP__WEBKIT_BACKGROUND_CLIP,
@@ -303,6 +304,19 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
     return getPropertyCSSValue(propertyID, UpdateLayout);
 }
 
+CSSPrimitiveValue* primitiveValueFromLength(Length length, RenderObject* renderer, RenderStyle* style)
+{
+    String string;
+    if (length.isPercent())
+        string = numberAsString(length.value()) + "%";
+    else if (length.isFixed())
+        string = numberAsString(length.calcMinValue(0));
+    else if (length.isAuto())
+        string += "auto";
+    string += " ";
+    return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING);
+}
+
 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
 {
     Node* node = m_node.get();
@@ -328,6 +342,14 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         if (style->backgroundImage())
             return new CSSPrimitiveValue(style->backgroundImage()->url(), CSSPrimitiveValue::CSS_URI);
         return new CSSPrimitiveValue(CSS_VAL_NONE);
+    case CSS_PROP__WEBKIT_BACKGROUND_SIZE: {
+        Length widthLength = style->backgroundSize().width;
+        Length heightLength = style->backgroundSize().height;
+        CSSPrimitiveValue* bgWidth = primitiveValueFromLength(widthLength, renderer, style);
+        CSSPrimitiveValue* bgHeight = primitiveValueFromLength(heightLength, renderer, style);
+        Pair* pair = new Pair(bgWidth, bgHeight);
+        return new CSSPrimitiveValue(pair);
+    }
     case CSS_PROP_BACKGROUND_REPEAT:
         switch (style->backgroundRepeat()) {
             case REPEAT:
index ce5569ef9d43a5446eaa50e7db3893e90a90f203..ac2439838c48806cb93762426c28cca6c0a0edb0 100644 (file)
@@ -17,6 +17,7 @@ background-position
 background-position-x
 background-position-y
 background-repeat
+-webkit-background-size
 -webkit-binding
 border-collapse
 -webkit-border-image
index 499b554203e987087acfde0d78fa8d63c72d8fe1..53f315d5c6c373c251d6d558419de211d0e8ae1d 100644 (file)
@@ -330,10 +330,13 @@ protected:
 
 // A primitive value representing a pair.  This is useful for properties like border-radius, background-size/position,
 // and border-spacing (all of which are space-separated sets of two values).  At the moment we are only using it for
-// border-radius, but (FIXME) border-spacing and background-position could be converted over to use it
-// (eliminating some extra -webkit- internal properties).
+// border-radius and background-size, but (FIXME) border-spacing and background-position could be converted over to use
+// it (eliminating some extra -webkit- internal properties).
 class Pair : public Shared<Pair> {
 public:
+    Pair() : m_first(0), m_second(0) { }
+    Pair(PassRefPtr<CSSPrimitiveValue> first, PassRefPtr<CSSPrimitiveValue> second)
+        : m_first(first), m_second(second) { }
     virtual ~Pair();
 
     CSSPrimitiveValue* first() const { return m_first.get(); }
index edfa4e6ceb7b73eef1602b45491cad8ff53f9089..d65c157677b1b1ab5bdd845e4f96d967eff99a3b 100644 (file)
@@ -657,6 +657,7 @@ bool CSSParser::parseValue(int propId, bool important)
     case CSS_PROP_BACKGROUND_POSITION:
     case CSS_PROP_BACKGROUND_POSITION_X:
     case CSS_PROP_BACKGROUND_POSITION_Y:
+    case CSS_PROP__WEBKIT_BACKGROUND_SIZE:
     case CSS_PROP_BACKGROUND_REPEAT: {
         CSSValue *val1 = 0, *val2 = 0;
         int propId1, propId2;
@@ -931,9 +932,7 @@ bool CSSParser::parseValue(int propId, bool important)
             parsedValue2 = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
         }
         
-        Pair* pair = new Pair;
-        pair->setFirst(parsedValue1);
-        pair->setSecond(parsedValue2);
+        Pair* pair = new Pair(parsedValue1, parsedValue2);
         CSSPrimitiveValue* val = new CSSPrimitiveValue(pair);
         addProperty(propId, val, important);
         return true;
@@ -1105,7 +1104,7 @@ bool CSSParser::parseValue(int propId, bool important)
 
         /* shorthand properties */
     case CSS_PROP_BACKGROUND:
-        // ['background-color' || 'background-image' ||'background-repeat' ||
+        // ['background-color' || 'background-image' || 'background-size' || 'background-repeat' ||
         // 'background-attachment' || 'background-position'] | inherit
         return parseBackgroundShorthand(important);
     case CSS_PROP_BORDER:
@@ -1249,10 +1248,11 @@ bool CSSParser::parseBackgroundShorthand(bool important)
 {
     // Position must come before color in this array because a plain old "0" is a legal color
     // in quirks mode but it's usually the X coordinate of a position.
-    const int numProperties = 7;
-    const int properties[numProperties] = { CSS_PROP_BACKGROUND_IMAGE, CSS_PROP_BACKGROUND_REPEAT,
+    // FIXME: Add CSS_PROP__KHTML_BACKGROUND_SIZE to the shorthand.
+    const int properties[] = { CSS_PROP_BACKGROUND_IMAGE, CSS_PROP_BACKGROUND_REPEAT, 
         CSS_PROP_BACKGROUND_ATTACHMENT, CSS_PROP_BACKGROUND_POSITION, CSS_PROP__WEBKIT_BACKGROUND_CLIP,
         CSS_PROP__WEBKIT_BACKGROUND_ORIGIN, CSS_PROP_BACKGROUND_COLOR };
+    const int numProperties = sizeof(properties) / sizeof(properties[0]);
     
     ShorthandScope scope(this, CSS_PROP_BACKGROUND);
 
@@ -1584,6 +1584,36 @@ void CSSParser::parseBackgroundPosition(CSSValue*& value1, CSSValue*& value2)
     }
 }
 
+CSSValue* CSSParser::parseBackgroundSize()
+{
+    Value* value = valueList->current();
+    CSSPrimitiveValue* parsedValue1;
+    
+    if (value->id == CSS_VAL_AUTO)
+        parsedValue1 = new CSSPrimitiveValue(0, CSSPrimitiveValue::CSS_UNKNOWN);
+    else {
+        if (!validUnit(value, FLength|FPercent, strict))
+            return 0;
+        parsedValue1 = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
+    }
+    
+    CSSPrimitiveValue* parsedValue2 = parsedValue1;
+    if ((value = valueList->next())) {
+        if (value->id == CSS_VAL_AUTO)
+            parsedValue2 = new CSSPrimitiveValue(0, CSSPrimitiveValue::CSS_UNKNOWN);
+        else {
+            if (!validUnit(value, FLength|FPercent, strict)) {
+                delete parsedValue1;
+                return 0;
+            }
+            parsedValue2 = new CSSPrimitiveValue(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
+        }
+    }
+    
+    Pair* pair = new Pair(parsedValue1, parsedValue2);
+    return new CSSPrimitiveValue(pair);
+}
+
 bool CSSParser::parseBackgroundProperty(int propId, int& propId1, int& propId2, 
                                         CSSValue*& retValue1, CSSValue*& retValue2)
 {
@@ -1657,6 +1687,11 @@ bool CSSParser::parseBackgroundProperty(int propId, int& propId1, int& propId2,
                         valueList->next();
                     }
                     break;
+                case CSS_PROP__WEBKIT_BACKGROUND_SIZE:
+                    currValue = parseBackgroundSize();
+                    if (currValue)
+                        valueList->next();
+                    break;
             }
             
             if (!currValue)
index dcd0abe0b102d3c3cfbf931f8f1960db8bd6b9b6..60910ab09372abb3942b2b31f090bb2031fff83a 100644 (file)
@@ -129,6 +129,7 @@ namespace WebCore {
         CSSValue* parseBackgroundImage();
         CSSValue* parseBackgroundPositionXY(bool& xFound, bool& yFound);
         void parseBackgroundPosition(CSSValue*& value1, CSSValue*& value2);
+        CSSValue* parseBackgroundSize();
         
         bool parseBackgroundProperty(int propId, int& propId1, int& propId2, CSSValue*& retValue1, CSSValue*& retValue2);
         bool parseBackgroundShorthand(bool important);
index 51f62d22b28cc90ba86986c25bd0bc25654c53eb..f6b03c55363b85f418cdc7845fd074ca8d7b0796 100644 (file)
@@ -1709,6 +1709,9 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     case CSS_PROP_BACKGROUND_REPEAT:
         HANDLE_BACKGROUND_VALUE(backgroundRepeat, BackgroundRepeat, value)
         break;
+    case CSS_PROP__WEBKIT_BACKGROUND_SIZE:
+        HANDLE_BACKGROUND_VALUE(backgroundSize, BackgroundSize, value)
+        break;
     case CSS_PROP_BORDER_COLLAPSE:
         HANDLE_INHERIT_AND_INITIAL(borderCollapse, BorderCollapse)
         if(!primitiveValue) break;
@@ -3953,6 +3956,56 @@ void CSSStyleSelector::mapBackgroundRepeat(BackgroundLayer* layer, CSSValue* val
     }
 }
 
+void CSSStyleSelector::mapBackgroundSize(BackgroundLayer* layer, CSSValue* value)
+{
+    LengthSize b = RenderStyle::initialBackgroundSize();
+    
+    if (value->cssValueType() == CSSValue::CSS_INITIAL) {
+        layer->setBackgroundSize(b);
+        return;
+    }
+    
+    if (!value->isPrimitiveValue())
+        return;
+        
+    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+    Pair* pair = primitiveValue->getPairValue();
+    if (!pair)
+        return;
+    
+    CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(pair->first());
+    CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(pair->second());
+    
+    if (!first || !second)
+        return;
+        
+    Length firstLength, secondLength;
+    int firstType = first->primitiveType();
+    int secondType = second->primitiveType();
+    
+    if (firstType == CSSPrimitiveValue::CSS_UNKNOWN)
+        firstLength = Length(Auto);
+    else if (firstType > CSSPrimitiveValue::CSS_PERCENTAGE && firstType < CSSPrimitiveValue::CSS_DEG)
+        firstLength = Length(first->computeLengthIntForLength(style), Fixed);
+    else if (firstType == CSSPrimitiveValue::CSS_PERCENTAGE)
+        firstLength = Length((int)first->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+    else
+        return;
+
+    if (secondType == CSSPrimitiveValue::CSS_UNKNOWN)
+        secondLength = Length(Auto);
+    else if (secondType > CSSPrimitiveValue::CSS_PERCENTAGE && secondType < CSSPrimitiveValue::CSS_DEG)
+        secondLength = Length(second->computeLengthIntForLength(style), Fixed);
+    else if (secondType == CSSPrimitiveValue::CSS_PERCENTAGE)
+        secondLength = Length((int)second->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+    else
+        return;
+    
+    b.width = firstLength;
+    b.height = secondLength;
+    layer->setBackgroundSize(b);
+}
+
 void CSSStyleSelector::mapBackgroundXPosition(BackgroundLayer* layer, CSSValue* value)
 {
     if (value->cssValueType() == CSSValue::CSS_INITIAL) {
index 027a80616b4d358e18f4bbac10586b91013eb4f7..6aaf105e2f06539988be31ba7757e62d0716591d 100644 (file)
@@ -176,6 +176,7 @@ public:
         void mapBackgroundOrigin(BackgroundLayer* layer, CSSValue* value);
         void mapBackgroundImage(BackgroundLayer* layer, CSSValue* value);
         void mapBackgroundRepeat(BackgroundLayer* layer, CSSValue* value);
+        void mapBackgroundSize(BackgroundLayer* layer, CSSValue* value);
         void mapBackgroundXPosition(BackgroundLayer* layer, CSSValue* value);
         void mapBackgroundYPosition(BackgroundLayer* layer, CSSValue* value);
         
index f53c6179629dbcbf1b63ce326bd39b4649c6edbf..432ed090dc52eaa02825435a706a05d82980a2ab 100644 (file)
@@ -115,7 +115,7 @@ namespace WebCore {
             float sx = 0, float sy = 0, float sw = -1, float sh = -1,
             Image::CompositeOperator = Image::CompositeSourceOver, 
             void* nativeData = 0);
-        void drawTiledImage(Image*, const IntRect& dest, int sx = 0, int sy = 0, void* nativeData = 0);
+        void drawTiledImage(Image*, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize, void* nativeData = 0);
         void drawScaledAndTiledImage(Image*, const IntRect&, int, int, int, int, 
             Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
             void* nativeData = 0);
index fa6f904638947a11fe5e900e69dc2635a7b99354..4d5e848f0e4d466daf5240191c0d337253240bf8 100644 (file)
@@ -29,6 +29,7 @@
 #include "DeprecatedArray.h"
 #include "ImageSource.h"
 #include "IntSize.h"
+#include "FloatSize.h"
 #include <kxmlcore/Vector.h>
 
 #if __APPLE__
@@ -161,7 +162,8 @@ public:
     // Drawing routines.
     void drawInRect(const FloatRect& dstRect, const FloatRect& srcRect,
                     CompositeOperator compositeOp, void* context);
-    void tileInRect(const FloatRect& dstRect, const FloatPoint& point, void* context);
+    void tileInRect(const FloatRect& destRect, const FloatPoint& point,
+                    const FloatSize& tileSize, void* context);
     void scaleAndTileInRect(const FloatRect& dstRect, const FloatRect& srcRect,
                             TileRule hRule, TileRule vRule, void* context);
 
index 9821890b1f99796910e6d0d9d2b278ff6630c6bd..f7cd15319772f2700004d7dc55d47646a3c20f56 100644 (file)
@@ -376,7 +376,7 @@ void GraphicsContext::drawImage(Image* image, const FloatRect& destRect,
     image->drawInRect(dest, FloatRect(sx, sy, tsw, tsh), compositeOperator, context);
 }
 
-void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, int sx, int sy, void* context)
+void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, const IntPoint& srcPoint, const IntSize& tileSize, void* context)
 {
     if (!context)
         context = m_data->context;
@@ -384,7 +384,7 @@ void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, int sx,
     if (paintingDisabled())
         return;
     
-    image->tileInRect(dest, FloatPoint(sx, sy), context);
+    image->tileInRect(dest, srcPoint, tileSize, noRepeat, context);
 }
 
 void GraphicsContext::drawScaledAndTiledImage(Image* image, const IntRect& dest, int sx, int sy, int sw, int sh, 
index 58456f36f5f96609ea702c67457fdc9462f4a131..24e372f2bef11f45c9070bb87ad5d210ab958cc2 100644 (file)
@@ -133,7 +133,7 @@ void Image::drawInRect(const FloatRect& dst, const FloatRect& src,
 
 }
 
-void Image::tileInRect(const FloatRect& dstRect, const FloatPoint& srcPoint, void* ctxt)
+void Image::tileInRect(const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, void* ctxt)
 {
     if (!m_source.initialized())
         return;
@@ -142,17 +142,37 @@ void Image::tileInRect(const FloatRect& dstRect, const FloatPoint& srcPoint, voi
     if (!image) // If it's too early we won't have an image yet.
         return;
 
-    IntSize selfSize = size();                       
+    IntSize intrinsicImageSize = size();                       
     FloatRect srcRect(srcPoint, selfSize);
+    FloatPoint point = srcPoint;
 
     // Check and see if a single draw of the image can cover the entire area we are supposed to tile.
     float tileWidth = size().width();
     float tileHeight = size().height();
+    
+    // If the scale is not equal to the intrinsic size of the image, set transform matrix
+    // to the appropriate scalar matrix, scale the source point, and set the size of the
+    // scaled tile. 
+    float scaleX = 1.0;
+    float scaleY = 1.0;
+    cairo_matrix_t* mat;
+    cairo_matrix_init_identity(&mat);
+    if (tileSize.width() != intrinsicImageSize.width() || tileSize.height() != intrinsicImageSize.height()) {
+        scaleX = intrinsicImageSize.width() / tileSize.width();
+        scaleY = intrinsicImageSize.height() / tileSize.height();
+        cairo_matrix_init_scale(&mat, scaleX, scaleY);
+        
+        point.setX(point.x() / scaleX);
+        point.setY(point.y() / scaleY);
+        
+        tileWidth = tileSize.width();
+        tileHeight = tileSize.height();
+    }
    
     // We could get interesting source offsets (negative ones or positive ones.  Deal with both
     // out of bounds cases.
-    float dstTileX = dstRect.x() + fmodf(fmodf(-srcPoint.x(), tileWidth) - tileWidth, tileWidth);
-    float dstTileY = dstRect.y() + fmodf(fmodf(-srcPoint.y(), tileHeight) - tileHeight, tileHeight);
+    float dstTileX = dstRect.x() + fmodf(fmodf(-point.x(), tileWidth) - tileWidth, tileWidth);
+    float dstTileY = dstRect.y() + fmodf(fmodf(-point.y(), tileHeight) - tileHeight, tileHeight);
     FloatRect dstTileRect(dstTileX, dstTileY, tileWidth, tileHeight);
     
     float srcX = dstRect.x() - dstTileRect.x();
@@ -161,7 +181,7 @@ void Image::tileInRect(const FloatRect& dstRect, const FloatPoint& srcPoint, voi
     // If the single image draw covers the whole area, then just draw once.
     if (dstTileRect.contains(dstRect)) {
         drawInRect(dstRect,
-                   FloatRect(srcX, srcY, dstRect.width(), dstRect.height()),
+                   FloatRect(srcX * scaleX, srcY * scaleY, dstRect.width() * scaleX, dstRect.height() * scaleY),
                    Image::CompositeSourceOver,
                    ctxt);
         return;
@@ -178,6 +198,7 @@ void Image::tileInRect(const FloatRect& dstRect, const FloatPoint& srcPoint, voi
 
     cairo_translate(context, dstTileRect.x(), dstTileRect.y());
     cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image);
+    cairo_pattern_set_matrix(pattern, &mat);
     cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
 
     // Draw the image.
index f96f30501062ac852a91fd6b3bebd4d411049f64..51898c1fdd5b469adb8d0d8a8c04713554904c84 100644 (file)
@@ -387,12 +387,12 @@ void GraphicsContext::drawImage(Image* image, const FloatRect& dest,
     image->drawInRect(FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(sx, sy, tsw, tsh), compositeOperator, context);
 }
 
-void GraphicsContext::drawTiledImage(Image* image, const IntRect& rect, int sx, int sy, void* context)
+void GraphicsContext::drawTiledImage(Image* image, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize, void* context)
 {
     if (paintingDisabled())
         return;
     
-    image->tileInRect(rect, FloatPoint(sx, sy), context);
+    image->tileInRect(destRect, srcPoint, tileSize, context);
 }
 
 void GraphicsContext::drawScaledAndTiledImage(Image* image, const IntRect& dest, int sx, int sy, int sw, int sh, 
index fca968c9c18337635403a1ce96471b7cd569a1db..b212ab306ecd6abd1127f45c7ef7a793f1fe6b7d 100644 (file)
@@ -292,7 +292,7 @@ static void drawPattern(void* info, CGContextRef context)
 
 static const CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
 
-void Image::tileInRect(const FloatRect& dstRect, const FloatPoint& srcPoint, void* ctxt)
+void Image::tileInRect(const FloatRect& destRect, const FloatPoint& srcPoint, const FloatSize& tileSize, void* ctxt)
 {    
     CGImageRef image = frameAtIndex(m_currentFrame);
     if (!image)
@@ -301,32 +301,52 @@ void Image::tileInRect(const FloatRect& dstRect, const FloatPoint& srcPoint, voi
     CGContextRef context = graphicsContext(ctxt);
 
     if (m_currentFrame == 0 && m_isSolidColor)
-        return fillSolidColorInRect(m_solidColor, dstRect, Image::CompositeSourceOver, context);
-
-    CGSize tileSize = size();
-    CGRect rect = dstRect;
-    CGPoint point = srcPoint;
+        return fillSolidColorInRect(m_solidColor, destRect, Image::CompositeSourceOver, context);
+
+    CGPoint scaledPoint = srcPoint;
+    CGRect destination = destRect;
+    CGSize intrinsicTileSize = size();
+    CGSize scaledTileSize = intrinsicTileSize;
+
+    // If tileSize is not equal to the intrinsic size of the image, set patternTransform
+    // to the appropriate scalar matrix, scale the source point, and set the size of the
+    // scaled tile. 
+    float scaleX = 1.0;
+    float scaleY = 1.0;
+    CGAffineTransform patternTransform = CGAffineTransformIdentity;
+    if (tileSize.width() != intrinsicTileSize.width || tileSize.height() != intrinsicTileSize.height) {
+        scaleX = tileSize.width() / intrinsicTileSize.width;
+        scaleY = tileSize.height() / intrinsicTileSize.height;
+        patternTransform = CGAffineTransformMakeScale(scaleX, scaleY);
+        
+        scaledPoint = CGPointApplyAffineTransform(scaledPoint, patternTransform);
+        scaledTileSize = tileSize;
+    }
 
     // Check and see if a single draw of the image can cover the entire area we are supposed to tile.
     NSRect oneTileRect;
-    oneTileRect.origin.x = rect.origin.x + fmodf(fmodf(-point.x, tileSize.width) - tileSize.width, tileSize.width);
-    oneTileRect.origin.y = rect.origin.y + fmodf(fmodf(-point.y, tileSize.height) - tileSize.height, tileSize.height);
-    oneTileRect.size.height = tileSize.height;
-    oneTileRect.size.width = tileSize.width;
+    oneTileRect.origin.x = destination.origin.x + fmodf(fmodf(-scaledPoint.x, scaledTileSize.width) - 
+                            scaledTileSize.width, scaledTileSize.width);
+    oneTileRect.origin.y = destination.origin.y + fmodf(fmodf(-scaledPoint.y, scaledTileSize.height) - 
+                            scaledTileSize.height, scaledTileSize.height);
+    oneTileRect.size.width = scaledTileSize.width;
+    oneTileRect.size.height = scaledTileSize.height;
 
     // If the single image draw covers the whole area, then just draw once.
-    if (NSContainsRect(oneTileRect, NSMakeRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height))) {
+    if (NSContainsRect(oneTileRect, NSMakeRect(destination.origin.x, destination.origin.y, 
+                                        destination.size.width, destination.size.height))) {
         CGRect fromRect;
-        fromRect.origin.x = rect.origin.x - oneTileRect.origin.x;
-        fromRect.origin.y = rect.origin.y - oneTileRect.origin.y;
-        fromRect.size = rect.size;
+        fromRect.origin.x = (destination.origin.x - oneTileRect.origin.x) / scaleX;
+        fromRect.origin.y = (destination.origin.y - oneTileRect.origin.y) / scaleY;
+        fromRect.size.width = oneTileRect.size.width / scaleX;
+        fromRect.size.height = oneTileRect.size.height / scaleY;
 
-        drawInRect(dstRect, FloatRect(fromRect), Image::CompositeSourceOver, context);
+        drawInRect(destRect, FloatRect(fromRect), Image::CompositeSourceOver, context);
         return;
     }
 
-    CGPatternRef pattern = CGPatternCreate(this, CGRectMake(0, 0, tileSize.width, tileSize.height),
-                                           CGAffineTransformIdentity, tileSize.width, tileSize.height, 
+    CGPatternRef pattern = CGPatternCreate(this, CGRectMake(0, 0, intrinsicTileSize.width, intrinsicTileSize.height),
+                                           patternTransform, intrinsicTileSize.width, intrinsicTileSize.height, 
                                            kCGPatternTilingConstantSpacing, true, &patternCallbacks);
     
     if (pattern) {
@@ -344,7 +364,7 @@ void Image::tileInRect(const FloatRect& dstRect, const FloatPoint& srcPoint, voi
 
         setCompositingOperation(context, Image::CompositeSourceOver);
 
-        CGContextFillRect(context, rect);
+        CGContextFillRect(context, destination);
 
         CGContextRestoreGState(context);
 
index 59a647993b45256f5d3fd6787f99169a627fc23e..5815030e797299af93906faaa0edd6b560163331 100644 (file)
@@ -446,6 +446,8 @@ void RenderBox::paintBackgroundExtended(GraphicsContext* p, const Color& c, cons
         int sy = 0;
         int cw,ch;
         int cx,cy;
+        int scaledWidth = w;
+        int scaledHeight = h;
         
         // CSS2 chapter 14.2.1
 
@@ -464,14 +466,14 @@ void RenderBox::paintBackgroundExtended(GraphicsContext* p, const Color& c, cons
                     top += paddingTop();
                 }
             }
-
+            
             int pw = w - hpab;
             int ph = h - vpab;
-                        
+
             int pixw = bg->imageSize().width();
             int pixh = bg->imageSize().height();
             EBackgroundRepeat bgr = bgLayer->backgroundRepeat();
-            if( (bgr == NO_REPEAT || bgr == REPEAT_Y) && w > pixw ) {
+            if((bgr == NO_REPEAT || bgr == REPEAT_Y) && w > pixw) {
                 cw = pixw;
                 int xPosition = bgLayer->backgroundXPosition().calcMinValue(pw - pixw);
                 if (xPosition >= 0)
@@ -500,7 +502,7 @@ void RenderBox::paintBackgroundExtended(GraphicsContext* p, const Color& c, cons
                 }
             }
 
-            if( (bgr == NO_REPEAT || bgr == REPEAT_X) && h > pixh ) {
+            if((bgr == NO_REPEAT || bgr == REPEAT_X) && h > pixh) {
                 ch = pixh;
                 int yPosition = bgLayer->backgroundYPosition().calcMinValue(ph - pixh);
                 if (yPosition >= 0)
@@ -530,17 +532,17 @@ void RenderBox::paintBackgroundExtended(GraphicsContext* p, const Color& c, cons
                 }
             }
         }
-        else
-        {
+        else {
             //fixed
             IntRect vr = viewRect();
             int pw = vr.width();
             int ph = vr.height();
-
+            scaledWidth = pw;
+            scaledHeight = ph;
             int pixw = bg->imageSize().width();
             int pixh = bg->imageSize().height();
             EBackgroundRepeat bgr = bgLayer->backgroundRepeat();
-            if( (bgr == NO_REPEAT || bgr == REPEAT_Y) && pw > pixw ) {
+            if((bgr == NO_REPEAT || bgr == REPEAT_Y) && pw > pixw) {
                 cw = pixw;
                 cx = vr.x() + bgLayer->backgroundXPosition().calcMinValue(pw - pixw);
             } else {
@@ -550,7 +552,7 @@ void RenderBox::paintBackgroundExtended(GraphicsContext* p, const Color& c, cons
                     sx = pixw - bgLayer->backgroundXPosition().calcMinValue(pw - pixw) % pixw;
             }
 
-            if( (bgr == NO_REPEAT || bgr == REPEAT_X) && ph > pixh ) {
+            if((bgr == NO_REPEAT || bgr == REPEAT_X) && ph > pixh) {
                 ch = pixh;
                 cy = vr.y() + bgLayer->backgroundYPosition().calcMinValue(ph - pixh);
             } else {
@@ -569,8 +571,69 @@ void RenderBox::paintBackgroundExtended(GraphicsContext* p, const Color& c, cons
             ch = b.height();
         }
 
-        if (cw>0 && ch>0)
-            p->drawTiledImage(bg->image(), IntRect(cx, cy, cw, ch), sx, sy);
+        if (bgLayer->isBackgroundSizeSet()) {
+            Length bgWidth = bgLayer->backgroundSize().width;
+            Length bgHeight = bgLayer->backgroundSize().height;
+            
+            if (bgWidth.isPercent())
+                scaledWidth = scaledWidth * bgWidth.value() / 100;
+            else if (bgWidth.isFixed())
+                scaledWidth = bgWidth.value();
+            else if (bgWidth.isAuto()) {
+                // If the width is auto and the height is not, we have to use the appropriate
+                // scale to maintain our aspect ratio.
+                if (bgHeight.isPercent()) {
+                    int scaledH = scaledHeight * bgHeight.value() / 100;
+                    scaledWidth = bg->imageSize().width() * scaledH / bg->imageSize().height();
+                } else if (bgHeight.isFixed())
+                    scaledWidth = bg->imageSize().width() * bgHeight.value() / bg->imageSize().height();
+            }
+            
+            if (bgHeight.isPercent())
+                scaledHeight = scaledHeight * bgHeight.value() / 100;
+            else if (bgHeight.isFixed())
+                scaledHeight = bgHeight.value();
+            else if (bgHeight.isAuto()) {
+                // If the height is auto and the width is not, we have to use the appropriate
+                // scale to maintain our aspect ratio.
+                if (bgWidth.isPercent())
+                    scaledHeight = bg->imageSize().height() * scaledWidth / bg->imageSize().width();
+                else if (bgWidth.isFixed())
+                    scaledHeight = bg->imageSize().height() * bgWidth.value() / bg->imageSize().width();
+                else if (bgWidth.isAuto()) {
+                    // If both width and height are auto, we just want to use the image's
+                    // intrinsic size.
+                    scaledWidth = bg->imageSize().width();
+                    scaledHeight = bg->imageSize().height();
+                }
+            }
+            
+            // If we are only repeating in one direction, we need to adjust the size and position of our
+            // container to take our new scale into account.
+            EBackgroundRepeat bgr = bgLayer->backgroundRepeat();
+            if ((bgr == REPEAT_X || bgr == NO_REPEAT) && scaledHeight < ch) {
+                ch = scaledHeight;
+                cy -= bgLayer->backgroundYPosition().calcMinValue(scaledHeight - bg->imageSize().height());
+            }
+            if ((bgr == REPEAT_Y || bgr == NO_REPEAT) && scaledWidth < cw) {
+                cw = scaledWidth;
+                cx -= bgLayer->backgroundXPosition().calcMinValue(scaledWidth - bg->imageSize().width());
+            }        
+        } else {
+            scaledWidth = bg->imageSize().width();
+            scaledHeight = bg->imageSize().height();
+        }
+
+        if (cw > 0 && ch > 0) {
+            if (bgLayer->backgroundRepeat() == NO_REPEAT) {
+                int imageSizeX = bg->imageSize().width();
+                int imageSizeY = bg->imageSize().height();
+                int originX = cx + int(fmodf(fmodf(-sx, imageSizeX) - imageSizeX, imageSizeX));
+                int originY = cy + int(fmodf(fmodf(-sy, imageSizeY) - imageSizeY, imageSizeY));
+                p->drawImage(bg->image(), IntRect(cx, cy, cw, ch), originX, originY, imageSizeX, imageSizeY);
+            } else
+                p->drawTiledImage(bg->image(), IntRect(cx, cy, cw, ch), IntPoint(sx, sy), IntSize(scaledWidth, scaledHeight));
+        }
     }
     
     if (bgLayer->backgroundClip() != BGBORDER)
index 6085d59c14b0c4e07a1612dbbe5d5e67b86dc988..6cfa63090e381fd4bb7cf21295dbaf2632e057b8 100644 (file)
@@ -103,9 +103,11 @@ BackgroundLayer::BackgroundLayer()
  m_bgClip(RenderStyle::initialBackgroundClip()),
  m_bgOrigin(RenderStyle::initialBackgroundOrigin()),
  m_bgRepeat(RenderStyle::initialBackgroundRepeat()),
+ m_backgroundSize(RenderStyle::initialBackgroundSize()),
  m_next(0)
 {
-    m_imageSet = m_attachmentSet = m_clipSet = m_originSet = m_repeatSet = m_xPosSet = m_yPosSet = false;     
+    m_imageSet = m_attachmentSet = m_clipSet = m_originSet = 
+            m_repeatSet = m_xPosSet = m_yPosSet = m_backgroundSizeSet = false;     
 }
 
 BackgroundLayer::BackgroundLayer(const BackgroundLayer& o)
@@ -118,6 +120,7 @@ BackgroundLayer::BackgroundLayer(const BackgroundLayer& o)
     m_bgClip = o.m_bgClip;
     m_bgOrigin = o.m_bgOrigin;
     m_bgRepeat = o.m_bgRepeat;
+    m_backgroundSize = o.m_backgroundSize;
     m_imageSet = o.m_imageSet;
     m_attachmentSet = o.m_attachmentSet;
     m_clipSet = o.m_clipSet;
@@ -125,6 +128,7 @@ BackgroundLayer::BackgroundLayer(const BackgroundLayer& o)
     m_repeatSet = o.m_repeatSet;
     m_xPosSet = o.m_xPosSet;
     m_yPosSet = o.m_yPosSet;
+    m_backgroundSizeSet = o.m_backgroundSizeSet;
 }
 
 BackgroundLayer::~BackgroundLayer()
@@ -145,6 +149,7 @@ BackgroundLayer& BackgroundLayer::operator=(const BackgroundLayer& o) {
     m_bgClip = o.m_bgClip;
     m_bgOrigin = o.m_bgOrigin;
     m_bgRepeat = o.m_bgRepeat;
+    m_backgroundSize = o.m_backgroundSize;
     
     m_imageSet = o.m_imageSet;
     m_attachmentSet = o.m_attachmentSet;
@@ -153,15 +158,17 @@ BackgroundLayer& BackgroundLayer::operator=(const BackgroundLayer& o) {
     m_repeatSet = o.m_repeatSet;
     m_xPosSet = o.m_xPosSet;
     m_yPosSet = o.m_yPosSet;
+    m_backgroundSizeSet = o.m_backgroundSizeSet;
     
     return *this;
 }
 
 bool BackgroundLayer::operator==(const BackgroundLayer& o) const {
     return m_image == o.m_image && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition &&
-           m_bgAttachment == o.m_bgAttachment && m_bgClip == o.m_bgClip && m_bgOrigin == o.m_bgOrigin && m_bgRepeat == o.m_bgRepeat && 
-           m_imageSet == o.m_imageSet && m_attachmentSet == o.m_attachmentSet && m_repeatSet == o.m_repeatSet &&
-           m_xPosSet == o.m_xPosSet && m_yPosSet == o.m_yPosSet &&
+           m_bgAttachment == o.m_bgAttachment && m_bgClip == o.m_bgClip && m_bgOrigin == o.m_bgOrigin && m_bgRepeat == o.m_bgRepeat &&
+           m_backgroundSize.width == o.m_backgroundSize.width && m_backgroundSize.height == o.m_backgroundSize.height && 
+           m_imageSet == o.m_imageSet && m_attachmentSet == o.m_attachmentSet && m_repeatSet == o.m_repeatSet && 
+           m_xPosSet == o.m_xPosSet && m_yPosSet == o.m_yPosSet && m_backgroundSizeSet == o.m_backgroundSizeSet && 
            ((m_next && o.m_next) ? *m_next == *o.m_next : m_next == o.m_next);
 }
 
@@ -244,6 +251,17 @@ void BackgroundLayer::fillUnsetProperties()
                 pattern = this;
         }
     }
+    
+    for (curr = this; curr && curr->isBackgroundSizeSet(); curr = curr->next());
+    if (curr && curr != this) {
+        // We need to fill in the remaining values with the pattern specified.
+        for (BackgroundLayer* pattern = this; curr; curr = curr->next()) {
+            curr->m_backgroundSize = pattern->m_backgroundSize;
+            pattern = pattern->next();
+            if (pattern == curr || !pattern)
+                pattern = this;
+        }
+    }
 }
 
 void BackgroundLayer::cullEmptyLayers()
@@ -254,7 +272,8 @@ void BackgroundLayer::cullEmptyLayers()
         if (next && !next->isBackgroundImageSet() &&
             !next->isBackgroundXPositionSet() && !next->isBackgroundYPositionSet() &&
             !next->isBackgroundAttachmentSet() && !next->isBackgroundClipSet() &&
-            !next->isBackgroundOriginSet() && !next->isBackgroundRepeatSet()) {
+            !next->isBackgroundOriginSet() && !next->isBackgroundRepeatSet() &&
+            !next->isBackgroundSizeSet()) {
             delete next;
             p->m_next = 0;
             break;
index eea66685cf19291c3d5917adfe18517a972d09b4..72ba4a64f848bb9caf5b189c74f6787ca50d6afb 100644 (file)
@@ -434,6 +434,11 @@ enum EBackgroundRepeat {
     REPEAT, REPEAT_X, REPEAT_Y, NO_REPEAT
 };
 
+struct LengthSize {
+    Length width;
+    Length height;
+};
+
 struct BackgroundLayer {
 public:
     BackgroundLayer();
@@ -446,6 +451,7 @@ public:
     EBackgroundBox backgroundClip() const { return static_cast<EBackgroundBox>(m_bgClip); }
     EBackgroundBox backgroundOrigin() const { return static_cast<EBackgroundBox>(m_bgOrigin); }
     EBackgroundRepeat backgroundRepeat() const { return static_cast<EBackgroundRepeat>(m_bgRepeat); }
+    LengthSize backgroundSize() const { return m_backgroundSize; }
 
     BackgroundLayer* next() const { return m_next; }
     BackgroundLayer* next() { return m_next; }
@@ -457,6 +463,7 @@ public:
     bool isBackgroundClipSet() const { return m_clipSet; }
     bool isBackgroundOriginSet() const { return m_originSet; }
     bool isBackgroundRepeatSet() const { return m_repeatSet; }
+    bool isBackgroundSizeSet() const { return m_backgroundSizeSet; }
     
     void setBackgroundImage(CachedImage* i) { m_image = i; m_imageSet = true; }
     void setBackgroundXPosition(const Length& l) { m_xPosition = l; m_xPosSet = true; }
@@ -465,6 +472,7 @@ public:
     void setBackgroundClip(EBackgroundBox b) { m_bgClip = b; m_clipSet = true; }
     void setBackgroundOrigin(EBackgroundBox b) { m_bgOrigin = b; m_originSet = true; }
     void setBackgroundRepeat(EBackgroundRepeat r) { m_bgRepeat = r; m_repeatSet = true; }
+    void setBackgroundSize(const LengthSize& b) { m_backgroundSize = b; m_backgroundSizeSet = true; }
     
     void clearBackgroundImage() { m_imageSet = false; }
     void clearBackgroundXPosition() { m_xPosSet = false; }
@@ -473,6 +481,7 @@ public:
     void clearBackgroundClip() { m_clipSet = false; }
     void clearBackgroundOrigin() { m_originSet = false; }
     void clearBackgroundRepeat() { m_repeatSet = false; }
+    void clearBackgroundSize() { m_backgroundSizeSet = false; }
 
     void setNext(BackgroundLayer* n) { if (m_next != n) { delete m_next; m_next = n; } }
 
@@ -510,6 +519,8 @@ public:
     unsigned m_bgOrigin : 2; // EBackgroundBox
     unsigned m_bgRepeat : 2; // EBackgroundRepeat
 
+    LengthSize m_backgroundSize;
+
     bool m_imageSet : 1;
     bool m_attachmentSet : 1;
     bool m_clipSet : 1;
@@ -517,6 +528,7 @@ public:
     bool m_repeatSet : 1;
     bool m_xPosSet : 1;
     bool m_yPosSet : 1;
+    bool m_backgroundSizeSet : 1;
 
     BackgroundLayer* m_next;
 };
@@ -1246,6 +1258,7 @@ public:
     EBackgroundBox backgroundOrigin() const { return static_cast<EBackgroundBox>(background->m_background.m_bgOrigin); }
     Length backgroundXPosition() const { return background->m_background.m_xPosition; }
     Length backgroundYPosition() const { return background->m_background.m_yPosition; }
+    LengthSize backgroundSize() const { return background->m_background.m_backgroundSize; }
     BackgroundLayer* accessBackgroundLayers() { return &(background.access()->m_background); }
     const BackgroundLayer* backgroundLayers() const { return &(background->m_background); }
 
@@ -1586,6 +1599,7 @@ public:
     static EBackgroundBox initialBackgroundClip() { return BGBORDER; }
     static EBackgroundBox initialBackgroundOrigin() { return BGPADDING; }
     static EBackgroundRepeat initialBackgroundRepeat() { return REPEAT; }
+    static LengthSize initialBackgroundSize() { return LengthSize(); }
     static bool initialBorderCollapse() { return false; }
     static EBorderStyle initialBorderStyle() { return BNONE; }
     static BorderImage initialBorderImage() { return BorderImage(); }