Source/WebCore: [CSS Blending] Add -webkit-blend-mode support for SVG.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Feb 2014 17:10:37 +0000 (17:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Feb 2014 17:10:37 +0000 (17:10 +0000)
commit0d556fc883f68bce8d7354dc315e9218eea8bb5a
tree9af669d83f88fde827c0543b6c7177a332c808b8
parent7bca340238f33c7d427ec5b3d7f5811073096df6
Source/WebCore: [CSS Blending] Add -webkit-blend-mode support for SVG.

https://bugs.webkit.org/show_bug.cgi?id=110427
Patch by Mihai Tica <mitica@adobe.com> on 2014-02-18
Reviewed by Dirk Schulze.

Add support for blend modes to SVG. This includes adding and validating isolation for blending.
Make masked elements isolate blending by creating a transparency layer.

Tests: css3/compositing/svg-blend-color-burn.html
       css3/compositing/svg-blend-color-dodge.html
       css3/compositing/svg-blend-color.html
       css3/compositing/svg-blend-darken.html
       css3/compositing/svg-blend-difference.html
       css3/compositing/svg-blend-exclusion.html
       css3/compositing/svg-blend-hard-light.html
       css3/compositing/svg-blend-hue.html
       css3/compositing/svg-blend-layer-blend.html
       css3/compositing/svg-blend-layer-clip-path.html
       css3/compositing/svg-blend-layer-filter.html
       css3/compositing/svg-blend-layer-mask.html
       css3/compositing/svg-blend-layer-opacity.html
       css3/compositing/svg-blend-layer-shadow.html
       css3/compositing/svg-blend-lighten.html
       css3/compositing/svg-blend-luminosity.html
       css3/compositing/svg-blend-multiply-alpha.html
       css3/compositing/svg-blend-multiply.html
       css3/compositing/svg-blend-normal.html
       css3/compositing/svg-blend-overlay.html
       css3/compositing/svg-blend-saturation.html
       css3/compositing/svg-blend-screen.html
       css3/compositing/svg-blend-soft-light.html

* rendering/RenderElement.cpp:
(WebCore::RenderElement::styleDidChange): Also pass a pointer to the old style when calling SVGRenderSupport::styleChanged.
* rendering/style/RenderStyle.h:  Add blendMode default getter when CSS_COMPOSITING is disabled.
* rendering/style/SVGRenderStyle.h:
(WebCore::SVGRenderStyle::isolatesBlending): Add method.
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::styleChanged): Call updateMaskedAncestorShouldIsolateBlending only when a blend mode is set/unset.
(WebCore::SVGRenderSupport::isolatesBlending): Implement method that decides whether an SVGElement isolates or not blending.
(WebCore::SVGRenderSupport::updateMaskedAncestorShouldIsolateBlending): Traverse to the nearest ancestor having a mask.
- Set a flag causing the creation of a transparency layer when rendering the masked element.
* rendering/svg/SVGRenderSupport.h:
* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::prepareToRenderSVGContent): Call GraphicsContext::setCompositeOperation.
- Isolate blending by creating a transparency layer.
- Isolate group when rendering a masked element having a blended child node.
* svg/SVGGraphicsElement.cpp:
(WebCore::SVGGraphicsElement::SVGGraphicsElement): Set default m_shouldIsolateBlending to false.
* svg/SVGGraphicsElement.h: Add m_shouldIsolateBlending member, getter and setter.
(WebCore::SVGGraphicsElement::shouldIsolateBlending):
(WebCore::SVGGraphicsElement::setShouldIsolateBlending):

LayoutTests: [CSS Blending] Add -webkit-blend-mode support for SVG.
https://bugs.webkit.org/show_bug.cgi?id=110427

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

Test -webkit-blend-mode implementation for simple SVGs. This includes:
- Test each blend operator.
- Test that ensures blending is isolated by other properties: blending, filters, masks, shadow and opacity.

* css3/compositing/svg-blend-color-burn.html: Test blend mode color-burn.
* css3/compositing/svg-blend-color-dodge.html: Test blend mode color-dodge.
* css3/compositing/svg-blend-color.html: Test blend mode color.
* css3/compositing/svg-blend-darken.html: Test blend mode darken.
* css3/compositing/svg-blend-difference.html: Test blend mode difference.
* css3/compositing/svg-blend-exclusion.html: Test blend mode exclusion.
* css3/compositing/svg-blend-hard-light.html: Test blend mode hard-light.
* css3/compositing/svg-blend-hue.html: Test blend mode hue.
* css3/compositing/svg-blend-layer-blend.html: mix-blend-mode should isolate for blending.
* css3/compositing/svg-blend-layer-clip-path.html: clip-path should not isolate for blending.
* css3/compositing/svg-blend-layer-filter.html: filters should isolate for blending.
* css3/compositing/svg-blend-layer-mask.html: masks should isolate for blending.
* css3/compositing/svg-blend-layer-opacity.html: opacity should isolate for blending.
* css3/compositing/svg-blend-layer-shadow.html: -webkit-shadow should isolate for blending.
* css3/compositing/svg-blend-lighten.html: Test blend mode lighten.
* css3/compositing/svg-blend-luminosity.html: Test blend mode luminosity.
* css3/compositing/svg-blend-multiply-alpha.html: Test blend mode multiply while also having alpha set.
* css3/compositing/svg-blend-multiply.html: Test blend mode multiply.
* css3/compositing/svg-blend-normal.html: Test blend mode normal. Note this blend mode has no effect.
* css3/compositing/svg-blend-overlay.html: Test blend mode overlay.
* css3/compositing/svg-blend-saturation.html: Test blend mode saturation.
* css3/compositing/svg-blend-screen.html: Test blend mode screen.
* css3/compositing/svg-blend-soft-light.html: Test blend mode soft-light.
* platform/mac/css3/compositing/svg-blend-color-burn-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-color-burn-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-color-dodge-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-color-dodge-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-color-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-color-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-darken-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-darken-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-difference-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-difference-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-exclusion-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-exclusion-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-hard-light-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-hard-light-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-hue-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-hue-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-layer-blend-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-layer-blend-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-layer-clip-path-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-layer-clip-path-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-layer-filter-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-layer-filter-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-layer-mask-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-layer-mask-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-layer-opacity-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-layer-opacity-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-layer-shadow-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-layer-shadow-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-lighten-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-lighten-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-luminosity-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-luminosity-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-multiply-alpha-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-multiply-alpha-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-multiply-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-multiply-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-normal-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-normal-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-overlay-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-overlay-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-saturation-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-saturation-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-screen-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-screen-expected.txt: Added.
* platform/mac/css3/compositing/svg-blend-soft-light-expected.png: Added.
* platform/mac/css3/compositing/svg-blend-soft-light-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164294 268f45cc-cd09-0410-ab3c-d52691b4dbfc
79 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/compositing/svg-blend-color-burn.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-color-dodge.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-color.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-darken.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-difference.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-exclusion.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-hard-light.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-hue.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-layer-blend.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-layer-clip-path.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-layer-filter.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-layer-mask.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-layer-opacity.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-layer-shadow.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-lighten.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-luminosity.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-multiply-alpha.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-multiply.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-normal.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-overlay.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-saturation.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-screen.html [new file with mode: 0644]
LayoutTests/css3/compositing/svg-blend-soft-light.html [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-color-burn-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-color-burn-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-color-dodge-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-color-dodge-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-color-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-color-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-darken-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-darken-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-difference-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-difference-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-exclusion-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-exclusion-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-hard-light-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-hard-light-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-hue-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-hue-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-blend-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-blend-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-clip-path-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-clip-path-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-filter-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-filter-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-mask-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-mask-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-opacity-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-opacity-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-shadow-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-layer-shadow-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-lighten-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-lighten-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-luminosity-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-luminosity-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-multiply-alpha-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-multiply-alpha-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-multiply-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-multiply-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-normal-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-normal-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-overlay-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-overlay-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-saturation-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-saturation-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-screen-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-screen-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-soft-light-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/compositing/svg-blend-soft-light-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/SVGRenderStyle.h
Source/WebCore/rendering/svg/SVGRenderSupport.cpp
Source/WebCore/rendering/svg/SVGRenderSupport.h
Source/WebCore/rendering/svg/SVGRenderingContext.cpp
Source/WebCore/svg/SVGGraphicsElement.cpp
Source/WebCore/svg/SVGGraphicsElement.h