Using the filter functional notation for background images results in wrong backgroun...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Aug 2015 22:44:45 +0000 (22:44 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Aug 2015 22:44:45 +0000 (22:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148221
rdar://problem/22379518

Reviewed by Daniel Bates.

Do not ignore the size argument, when the filter image is being drawn onto the context.
When the size is ignored, we end up painting the image with its native size while the filter
is applied on the size of the generated image.

Source/WebCore:

Test: fast/filter-image/background-filter-image.html

* css/CSSFilterImageValue.cpp:
(WebCore::CSSFilterImageValue::image):

LayoutTests:

* fast/filter-image/background-filter-image-expected.html: Added.
* fast/filter-image/background-filter-image.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/filter-image/background-filter-image-expected.html [new file with mode: 0644]
LayoutTests/fast/filter-image/background-filter-image.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSFilterImageValue.cpp

index 7365db2..e31b58a 100644 (file)
@@ -1,3 +1,18 @@
+2015-08-25  Zalan Bujtas  <zalan@apple.com>
+
+        Using the filter functional notation for background images results in wrong background-size rendering
+        https://bugs.webkit.org/show_bug.cgi?id=148221
+        rdar://problem/22379518
+
+        Reviewed by Daniel Bates.
+
+        Do not ignore the size argument, when the filter image is being drawn onto the context.
+        When the size is ignored, we end up painting the image with its native size while the filter
+        is applied on the size of the generated image.
+
+        * fast/filter-image/background-filter-image-expected.html: Added.
+        * fast/filter-image/background-filter-image.html: Added.
+
 2015-08-25  Nan Wang  <n_wang@apple.com>
 
         [Mac] accessibility/document-attributes.html fails
diff --git a/LayoutTests/fast/filter-image/background-filter-image-expected.html b/LayoutTests/fast/filter-image/background-filter-image-expected.html
new file mode 100644 (file)
index 0000000..d19a8ea
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that background images with filters scale properly.</title>
+<style>
+  img {
+    width: 100px;
+    height: 100px;
+    filter: sepia(1);
+  }
+</style>
+</head>
+<body>
+  <img src="../replaced/resources/compass.jpg">
+</body>
+</html>
diff --git a/LayoutTests/fast/filter-image/background-filter-image.html b/LayoutTests/fast/filter-image/background-filter-image.html
new file mode 100644 (file)
index 0000000..3a15fa9
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that background images with filters scale properly.</title>
+<style>
+  div {
+    background-image: filter(url(../replaced/resources/compass.jpg), sepia(1));
+    background-size: 100px 100px;
+    width: 100px;
+    height: 100px;
+  }
+</style>
+</head>
+<body>
+  <div></div>
+</body>
+</html>
index 71cc75c..aab5d1e 100644 (file)
@@ -1,3 +1,20 @@
+2015-08-25  Zalan Bujtas  <zalan@apple.com>
+
+        Using the filter functional notation for background images results in wrong background-size rendering
+        https://bugs.webkit.org/show_bug.cgi?id=148221
+        rdar://problem/22379518
+
+        Reviewed by Daniel Bates.
+
+        Do not ignore the size argument, when the filter image is being drawn onto the context.
+        When the size is ignored, we end up painting the image with its native size while the filter
+        is applied on the size of the generated image.
+
+        Test: fast/filter-image/background-filter-image.html
+
+        * css/CSSFilterImageValue.cpp:
+        (WebCore::CSSFilterImageValue::image):
+
 2015-08-25  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         IconDatabase: syncThreadMainLoop() is unlocking m_syncLock twice when thread termination is requested
index 5d80331..1733a37 100644 (file)
@@ -123,12 +123,13 @@ RefPtr<Image> CSSFilterImageValue::image(RenderElement* renderer, const FloatSiz
     std::unique_ptr<ImageBuffer> texture = ImageBuffer::create(size);
     if (!texture)
         return Image::nullImage();
-    texture->context()->drawImage(image, ColorSpaceDeviceRGB, IntPoint());
+    FloatRect imageRect = FloatRect(FloatPoint(), size);
+    texture->context()->drawImage(image, ColorSpaceDeviceRGB, imageRect);
 
     RefPtr<FilterEffectRenderer> filterRenderer = FilterEffectRenderer::create();
     filterRenderer->setSourceImage(WTF::move(texture));
-    filterRenderer->setSourceImageRect(FloatRect(FloatPoint(), size));
-    filterRenderer->setFilterRegion(FloatRect(FloatPoint(), size));
+    filterRenderer->setSourceImageRect(imageRect);
+    filterRenderer->setFilterRegion(imageRect);
     if (!filterRenderer->build(renderer, m_filterOperations, FilterFunction))
         return Image::nullImage();
     filterRenderer->apply();