Source/WebCore: Background-blend-mode doesn't work for an element with an
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Jan 2014 16:15:45 +0000 (16:15 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Jan 2014 16:15:45 +0000 (16:15 +0000)
SVG image as background and border-style or padding set.
The problem consisted in the drawing path using the default
blending parameter at all times.
https://bugs.webkit.org/show_bug.cgi?id=118894

Patch by Mihai Tica <mitica@adobe.com> on 2014-01-20
Reviewed by Dirk Schulze.

Test: css3/compositing/background-blend-mode-data-uri-svg-image.html

* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::drawPatternForContainer): Pass blendMode to Image::drawPattern.
* svg/graphics/SVGImage.h: Add a blendMode parameter to drawPatternForContainer.
* svg/graphics/SVGImageForContainer.cpp:
(WebCore::SVGImageForContainer::drawPattern): Pass blendMode to drawPatternForContainer call.

LayoutTests: Background-blend-mode doesn't work for an element with an
SVG image as background and border-style or padding set.
Tests now use rectangles instead of circles for SVGs.
https://bugs.webkit.org/show_bug.cgi?id=118894

Patch by Mihai Tica <mitica@adobe.com> on 2014-01-20
Reviewed by Dirk Schulze.

* css3/compositing/background-blend-mode-data-uri-svg-image-expected.html:
* css3/compositing/background-blend-mode-data-uri-svg-image.html:
* platform/efl/TestExpectations: pass tests for efl, blendMode is not implemented.
* platform/mac/TestExpectations: marking test as ImageOnlyFailure due to slight pixel inconsistencies between the result and the formula.

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

LayoutTests/ChangeLog
LayoutTests/css3/compositing/background-blend-mode-data-uri-svg-image-expected.html [new file with mode: 0644]
LayoutTests/css3/compositing/background-blend-mode-data-uri-svg-image.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebCore/svg/graphics/SVGImage.h
Source/WebCore/svg/graphics/SVGImageForContainer.cpp

index 801289a..38734e9 100644 (file)
@@ -1,3 +1,17 @@
+2014-01-20  Mihai Tica  <mitica@adobe.com>
+
+        Background-blend-mode doesn't work for an element with an
+        SVG image as background and border-style or padding set.
+        Tests now use rectangles instead of circles for SVGs.
+        https://bugs.webkit.org/show_bug.cgi?id=118894
+
+        Reviewed by Dirk Schulze.
+
+        * css3/compositing/background-blend-mode-data-uri-svg-image-expected.html:
+        * css3/compositing/background-blend-mode-data-uri-svg-image.html:
+        * platform/efl/TestExpectations: pass tests for efl, blendMode is not implemented.
+        * platform/mac/TestExpectations: marking test as ImageOnlyFailure due to slight pixel inconsistencies between the result and the formula.
+
 2014-01-20  Zalan Bujtas  <zalan@apple.com>
 
         Subpixel layout: setSimpleLineLayoutEnabled() produces different layout when line position has CSS px fractions.
diff --git a/LayoutTests/css3/compositing/background-blend-mode-data-uri-svg-image-expected.html b/LayoutTests/css3/compositing/background-blend-mode-data-uri-svg-image-expected.html
new file mode 100644 (file)
index 0000000..84a41b3
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML>
+
+<!-- This file should two green squares, each having a dotted border. -->
+
+<style>
+    div {
+        border: 5px navy;
+        border-style: dotted double;
+        background: #0F0;
+        width: 130px;
+        height: 130px;
+    }
+</style>
+
+<div></div>
+<div></div>
diff --git a/LayoutTests/css3/compositing/background-blend-mode-data-uri-svg-image.html b/LayoutTests/css3/compositing/background-blend-mode-data-uri-svg-image.html
new file mode 100644 (file)
index 0000000..35f4d6f
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+
+<!-- This file should two green squares, each having a dotted border. -->
+
+<style>
+    div {
+        border: 5px navy;
+        border-style: dotted double;
+        background: url('data:image/svg+xml;utf8, \
+            <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100"> \
+                <rect width="100" height="100" fill="#F00"/> \
+            </svg>'
+            ), #FF0;
+        width: 130px;
+        height: 130px;
+        -webkit-background-blend-mode: difference, normal
+    }
+</style>
+
+<script type="text/javascript">
+    if (window.testRunner)
+        window.testRunner.overridePreference("WebKitAcceleratedCompositingEnabled", "1");
+</script>
+
+<!-- Test the software path. -->
+<div></div>
+
+<!-- Test the hardware path. -->
+<div style="-webkit-transform: translateZ(0)"></div>
index 1e950a2..1de0807 100644 (file)
@@ -497,6 +497,7 @@ webkit.org/b/99200 css3/compositing/blend-mode-overflow.html [ Skip ]
 webkit.org/b/99200 css3/compositing/blend-mode-reflection.html [ Skip ]
 webkit.org/b/99200 css3/compositing/blend-mode-simple.html [ Skip ]
 webkit.org/b/99200 css3/compositing/blend-mode-should-not-have-compositing-layer.html [ Skip ]
+webkit.org/b/118894 css3/compositing/background-blend-mode-data-uri-svg-image-expected.html [ Skip ]
 
 # No concept of secure text input
 editing/secure-input [ Failure ]
index 888c9c8..db73219 100644 (file)
@@ -615,6 +615,9 @@ compositing/overflow/textarea-scroll-touch.html
 compositing/overflow/updating-scrolling-content.html
 compositing/overflow/scrolling-without-painting.html
 
+# Blend mode result is slightly different than the applied formula.
+css3/compositing/background-blend-mode-data-uri-svg-image-expected.html [ ImageOnlyFailure Pass ]
+
 # https://bugs.webkit.org/show_bug.cgi?id=110871
 compositing/overlap-blending/reflection-opacity-huge.html
 
index e80af2d..8fc1436 100644 (file)
@@ -1,3 +1,21 @@
+2014-01-20  Mihai Tica  <mitica@adobe.com>
+
+        Background-blend-mode doesn't work for an element with an
+        SVG image as background and border-style or padding set.
+        The problem consisted in the drawing path using the default
+        blending parameter at all times.
+        https://bugs.webkit.org/show_bug.cgi?id=118894
+
+        Reviewed by Dirk Schulze.
+
+        Test: css3/compositing/background-blend-mode-data-uri-svg-image.html
+
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::drawPatternForContainer): Pass blendMode to Image::drawPattern.
+        * svg/graphics/SVGImage.h: Add a blendMode parameter to drawPatternForContainer.
+        * svg/graphics/SVGImageForContainer.cpp:
+        (WebCore::SVGImageForContainer::drawPattern): Pass blendMode to drawPatternForContainer call.
+
 2014-01-20  Zalan Bujtas  <zalan@apple.com>
 
         Subpixel layout: setSimpleLineLayoutEnabled() produces different layout when line position has CSS px fractions.
index 6d7b256..521fbdf 100644 (file)
@@ -182,7 +182,7 @@ PassNativeImagePtr SVGImage::nativeImageForCurrentFrame()
 #endif
 
 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& srcRect,
-    const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace colorSpace, CompositeOperator compositeOp, const FloatRect& dstRect)
+    const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace colorSpace, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode blendMode)
 {
     FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize);
     zoomedContainerRect.scale(zoom);
@@ -213,7 +213,7 @@ void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize
     unscaledPatternTransform.scale(1 / imageBufferScale.width(), 1 / imageBufferScale.height());
 
     context->setDrawLuminanceMask(false);
-    image->drawPattern(context, scaledSrcRect, unscaledPatternTransform, phase, colorSpace, compositeOp, dstRect);
+    image->drawPattern(context, scaledSrcRect, unscaledPatternTransform, phase, colorSpace, compositeOp, dstRect, blendMode);
 }
 
 void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp, BlendMode blendMode, ImageOrientationDescription)
index 7db1c43..62f9f1d 100644 (file)
@@ -92,7 +92,7 @@ private:
     virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode, ImageOrientationDescription) override;
     void drawForContainer(GraphicsContext*, const FloatSize, float, const FloatRect&, const FloatRect&, ColorSpace, CompositeOperator, BlendMode);
     void drawPatternForContainer(GraphicsContext*, const FloatSize, float, const FloatRect&, const AffineTransform&, const FloatPoint&, ColorSpace,
-        CompositeOperator, const FloatRect&);
+        CompositeOperator, const FloatRect&, BlendMode);
 
     std::unique_ptr<SVGImageChromeClient> m_chromeClient;
     std::unique_ptr<Page> m_page;
index 3f45209..33d7877 100644 (file)
@@ -43,10 +43,10 @@ void SVGImageForContainer::draw(GraphicsContext* context, const FloatRect& dstRe
 }
 
 void SVGImageForContainer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
-    const FloatPoint& phase, ColorSpace colorSpace, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode)
+    const FloatPoint& phase, ColorSpace colorSpace, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode blendMode)
 {
     m_image->setSpaceSize(spaceSize());
-    m_image->drawPatternForContainer(context, m_containerSize, m_zoom, srcRect, patternTransform, phase, colorSpace, compositeOp, dstRect);
+    m_image->drawPatternForContainer(context, m_containerSize, m_zoom, srcRect, patternTransform, phase, colorSpace, compositeOp, dstRect, blendMode);
 }
 
 PassNativeImagePtr SVGImageForContainer::nativeImageForCurrentFrame()