Support "plus-lighter" in mix-blend mode
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2015 00:08:32 +0000 (00:08 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2015 00:08:32 +0000 (00:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142416
<rdar://problem/19993979>

Reviewed by Darin Adler and Sam Weinig.

Source/WebCore:

Support the "plus-lighter" blending mode to CSS.
See my reply to: https://lists.w3.org/Archives/Public/public-fx/2015JanMar/0021.html

Test: css3/blending/svg-blend-plus-lighter.html

* css/CSSParser.cpp:
(WebCore::isValidKeywordPropertyAndValue): mix-blend-mode can now accept the
new keyword.
* css/CSSPrimitiveValueMappings.h: Add the mappings to/from the GraphicsType.
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator BlendMode):
* css/CSSValueKeywords.in: Add comment to show plus-darker and plus-lighter
are available.
* platform/graphics/GraphicsTypes.cpp: New GraphicsType for PlusLighter.
* platform/graphics/GraphicsTypes.h:
* platform/graphics/ca/mac/PlatformCAFiltersMac.mm: Map to the CA filter.
(PlatformCAFilters::setBlendingFiltersOnLayer):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::setPlatformCompositeOperation): Map to the CG
blending flag.

Source/WebKit2:

Output the appropriate blending type when logging.

* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTextStream::operator<<):

LayoutTests:

Add tests and new expected results for plus-lighter.

* css3/blending/blend-mode-property-parsing-expected.txt:
* css3/blending/blend-mode-simple-composited.html:
* css3/blending/blend-mode-simple.html:
* css3/blending/script-tests/blend-mode-property-parsing.js:
* css3/blending/svg-blend-plus-lighter.html: Added.
* platform/mac/css3/blending/blend-mode-simple-composited-expected.png:
* platform/mac/css3/blending/blend-mode-simple-composited-expected.txt:
* platform/mac/css3/blending/blend-mode-simple-expected.png:
* platform/mac/css3/blending/blend-mode-simple-expected.txt:
* platform/mac/css3/blending/svg-blend-plus-lighter-expected.txt: Added.

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/blending/blend-mode-property-parsing-expected.txt
LayoutTests/css3/blending/blend-mode-simple-composited.html
LayoutTests/css3/blending/blend-mode-simple.html
LayoutTests/css3/blending/script-tests/blend-mode-property-parsing.js
LayoutTests/css3/blending/svg-blend-plus-lighter.html [new file with mode: 0644]
LayoutTests/platform/mac/css3/blending/blend-mode-simple-composited-expected.png
LayoutTests/platform/mac/css3/blending/blend-mode-simple-composited-expected.txt
LayoutTests/platform/mac/css3/blending/blend-mode-simple-expected.png
LayoutTests/platform/mac/css3/blending/blend-mode-simple-expected.txt
LayoutTests/platform/mac/css3/blending/svg-blend-plus-lighter-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/platform/graphics/GraphicsTypes.cpp
Source/WebCore/platform/graphics/GraphicsTypes.h
Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

index bd00199..617e1f7 100644 (file)
@@ -1,3 +1,24 @@
+2015-03-06  Dean Jackson  <dino@apple.com>
+
+        Support "plus-lighter" in mix-blend mode
+        https://bugs.webkit.org/show_bug.cgi?id=142416
+        <rdar://problem/19993979>
+
+        Reviewed by Darin Adler and Sam Weinig.
+
+        Add tests and new expected results for plus-lighter.
+
+        * css3/blending/blend-mode-property-parsing-expected.txt:
+        * css3/blending/blend-mode-simple-composited.html:
+        * css3/blending/blend-mode-simple.html:
+        * css3/blending/script-tests/blend-mode-property-parsing.js:
+        * css3/blending/svg-blend-plus-lighter.html: Added.
+        * platform/mac/css3/blending/blend-mode-simple-composited-expected.png:
+        * platform/mac/css3/blending/blend-mode-simple-composited-expected.txt:
+        * platform/mac/css3/blending/blend-mode-simple-expected.png:
+        * platform/mac/css3/blending/blend-mode-simple-expected.txt:
+        * platform/mac/css3/blending/svg-blend-plus-lighter-expected.txt: Added.
+
 2015-03-06  Brent Fulgham  <bfulgham@apple.com>
 
         Add 'initial' keyword support for scroll snap CSS properties
index abace3e..7110b30 100644 (file)
@@ -107,6 +107,14 @@ PASS declaration.getPropertyValue('mix-blend-mode') is 'plus-darker'
 PASS jsWrapperClass(blendModeRule) is 'CSSPrimitiveValue'
 PASS jsWrapperClass(blendModeRule.__proto__) is 'CSSPrimitiveValuePrototype'
 PASS jsWrapperClass(blendModeRule.constructor) is 'CSSPrimitiveValueConstructor'
+
+Basic reference : plus-lighter
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('mix-blend-mode') is 'plus-lighter'
+PASS jsWrapperClass(blendModeRule) is 'CSSPrimitiveValue'
+PASS jsWrapperClass(blendModeRule.__proto__) is 'CSSPrimitiveValuePrototype'
+PASS jsWrapperClass(blendModeRule.constructor) is 'CSSPrimitiveValueConstructor'
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 2ade2a8..7aaeda2 100644 (file)
@@ -35,5 +35,6 @@
         <li><img style="mix-blend-mode: difference" src="resources/ducky.png"></li>
         <li><img style="mix-blend-mode: exclusion" src="resources/ducky.png"></li>
         <li><img style="mix-blend-mode: plus-darker" src="resources/ducky.png"></li>
+        <li><img style="mix-blend-mode: plus-lighter" src="resources/ducky.png"></li>
     </ul>
 </body>
index b29e067..8529f33 100644 (file)
@@ -39,5 +39,6 @@
         <li><img style="mix-blend-mode: difference" src="resources/ducky.png"></li>
         <li><img style="mix-blend-mode: exclusion" src="resources/ducky.png"></li>
         <li><img style="mix-blend-mode: plus-darker" src="resources/ducky.png"></li>
+        <li><img style="mix-blend-mode: plus-lighter" src="resources/ducky.png"></li>
     </ul>
 </body>
index 852f331..741b815 100644 (file)
@@ -43,7 +43,7 @@ function testBlendModeRule(description, rule, expectedLength, expectedValue, exp
     shouldBeType("blendModeRule", "CSSPrimitiveValue");
 }
 
-var blendmodes = ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "plus-darker"];
+var blendmodes = ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "plus-darker", "plus-lighter"];
 
 for(x in blendmodes)
    testBlendModeRule("Basic reference", blendmodes[x], 1, blendmodes[x]);
diff --git a/LayoutTests/css3/blending/svg-blend-plus-lighter.html b/LayoutTests/css3/blending/svg-blend-plus-lighter.html
new file mode 100644 (file)
index 0000000..9d0b105
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="400px" height="400px" >
+<defs>
+  <g id="patch">
+    <rect x="0" y="0" width="10" height="40" fill="rgb(255,0,0)"/>
+    <rect x="10" y="0" width="10" height="40" fill="rgb(0,255,0)"/>
+    <rect x="20" y="0" width="10" height="40" fill="rgb(0,0,255)"/>
+    <rect x="30" y="0" width="10" height="40" fill="rgb(127,127,0)"/>
+  </g>
+  <rect x="0" y="0" width="10" height="10" fill="rgb(255,0,0)"/>
+</defs>
+<g transform="scale(4 4)">
+  <use xlink:href="#patch" x="0" y="0" width="40" height="10"></use>
+  <use xlink:href="#patch" x="0" y="0" width="40" height="10" transform="rotate(90 20 20)" style="mix-blend-mode: plus-lighter"></use>
+</g>
+</svg>
+</body>
+</html>
index 904706c..cae29e3 100644 (file)
Binary files a/LayoutTests/platform/mac/css3/blending/blend-mode-simple-composited-expected.png and b/LayoutTests/platform/mac/css3/blending/blend-mode-simple-composited-expected.png differ
index 290efab..b7b6636 100644 (file)
@@ -17,6 +17,7 @@ layer at (0,0) size 800x436 isolatesBlending
         RenderBlock (floating) {LI} at (45,285) size 130x130
         RenderBlock (floating) {LI} at (185,285) size 130x130
         RenderBlock (floating) {LI} at (325,285) size 130x130
+        RenderBlock (floating) {LI} at (465,285) size 130x130
 layer at (53,21) size 130x130
   RenderImage {IMG} at (0,0) size 130x130
 layer at (193,21) size 130x130 blendMode: overlay
@@ -43,3 +44,5 @@ layer at (193,301) size 130x130 blendMode: exclusion
   RenderImage {IMG} at (0,0) size 130x130
 layer at (333,301) size 130x130 blendMode: plus-darker
   RenderImage {IMG} at (0,0) size 130x130
+layer at (473,301) size 130x130 blendMode: plus-lighter
+  RenderImage {IMG} at (0,0) size 130x130
index 8fda7ae..077caef 100644 (file)
Binary files a/LayoutTests/platform/mac/css3/blending/blend-mode-simple-expected.png and b/LayoutTests/platform/mac/css3/blending/blend-mode-simple-expected.png differ
index 5e26b3e..aea7172 100644 (file)
@@ -18,6 +18,7 @@ layer at (0,0) size 800x436 isolatesBlending
         RenderBlock (floating) {LI} at (45,285) size 130x130
         RenderBlock (floating) {LI} at (185,285) size 130x130
         RenderBlock (floating) {LI} at (325,285) size 130x130
+        RenderBlock (floating) {LI} at (465,285) size 130x130
 layer at (193,21) size 130x130 blendMode: overlay
   RenderImage {IMG} at (0,0) size 130x130
 layer at (333,21) size 130x130 blendMode: screen
@@ -42,3 +43,5 @@ layer at (193,301) size 130x130 blendMode: exclusion
   RenderImage {IMG} at (0,0) size 130x130
 layer at (333,301) size 130x130 blendMode: plus-darker
   RenderImage {IMG} at (0,0) size 130x130
+layer at (473,301) size 130x130 blendMode: plus-lighter
+  RenderImage {IMG} at (0,0) size 130x130
diff --git a/LayoutTests/platform/mac/css3/blending/svg-blend-plus-lighter-expected.txt b/LayoutTests/platform/mac/css3/blending/svg-blend-plus-lighter-expected.txt
new file mode 100644 (file)
index 0000000..41e2833
--- /dev/null
@@ -0,0 +1,27 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x420
+  RenderBlock {HTML} at (0,0) size 800x420
+    RenderBody {BODY} at (8,8) size 784x404
+      RenderSVGRoot {svg} at (8,8) size 160x160
+        RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+          RenderSVGContainer {g} at (8,8) size 40x40
+            RenderSVGRect {rect} at (8,8) size 10x40 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=10.00] [height=40.00]
+            RenderSVGRect {rect} at (18,8) size 10x40 [fill={[type=SOLID] [color=#00FF00]}] [x=10.00] [y=0.00] [width=10.00] [height=40.00]
+            RenderSVGRect {rect} at (28,8) size 10x40 [fill={[type=SOLID] [color=#0000FF]}] [x=20.00] [y=0.00] [width=10.00] [height=40.00]
+            RenderSVGRect {rect} at (38,8) size 10x40 [fill={[type=SOLID] [color=#7F7F00]}] [x=30.00] [y=0.00] [width=10.00] [height=40.00]
+          RenderSVGRect {rect} at (8,8) size 10x10 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=10.00] [height=10.00]
+        RenderSVGContainer {g} at (8,8) size 160x160 [transform={m=((4.00,0.00)(0.00,4.00)) t=(0.00,0.00)}]
+          RenderSVGContainer {use} at (8,8) size 160x160
+            RenderSVGContainer {g} at (8,8) size 160x160
+              RenderSVGRect {rect} at (8,8) size 40x160 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (48,8) size 40x160 [fill={[type=SOLID] [color=#00FF00]}] [x=10.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (88,8) size 40x160 [fill={[type=SOLID] [color=#0000FF]}] [x=20.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (128,8) size 40x160 [fill={[type=SOLID] [color=#7F7F00]}] [x=30.00] [y=0.00] [width=10.00] [height=40.00]
+          RenderSVGContainer {use} at (8,8) size 160x160 [transform={m=((0.00,1.00)(-1.00,0.00)) t=(40.00,0.00)}]
+            RenderSVGContainer {g} at (8,8) size 160x160
+              RenderSVGRect {rect} at (8,8) size 160x40 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (8,48) size 160x40 [fill={[type=SOLID] [color=#00FF00]}] [x=10.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (8,88) size 160x40 [fill={[type=SOLID] [color=#0000FF]}] [x=20.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (8,128) size 160x40 [fill={[type=SOLID] [color=#7F7F00]}] [x=30.00] [y=0.00] [width=10.00] [height=40.00]
+      RenderText {#text} at (0,0) size 0x0
index 4940d96..987457c 100644 (file)
@@ -1,3 +1,32 @@
+2015-03-06  Dean Jackson  <dino@apple.com>
+
+        Support "plus-lighter" in mix-blend mode
+        https://bugs.webkit.org/show_bug.cgi?id=142416
+        <rdar://problem/19993979>
+
+        Reviewed by Darin Adler and Sam Weinig.
+
+        Support the "plus-lighter" blending mode to CSS.
+        See my reply to: https://lists.w3.org/Archives/Public/public-fx/2015JanMar/0021.html
+
+        Test: css3/blending/svg-blend-plus-lighter.html
+
+        * css/CSSParser.cpp:
+        (WebCore::isValidKeywordPropertyAndValue): mix-blend-mode can now accept the
+        new keyword.
+        * css/CSSPrimitiveValueMappings.h: Add the mappings to/from the GraphicsType.
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator BlendMode):
+        * css/CSSValueKeywords.in: Add comment to show plus-darker and plus-lighter
+        are available.
+        * platform/graphics/GraphicsTypes.cpp: New GraphicsType for PlusLighter.
+        * platform/graphics/GraphicsTypes.h:
+        * platform/graphics/ca/mac/PlatformCAFiltersMac.mm: Map to the CA filter.
+        (PlatformCAFilters::setBlendingFiltersOnLayer):
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::setPlatformCompositeOperation): Map to the CG
+        blending flag.
+
 2015-03-06  Alex Christensen  <achristensen@webkit.org>
 
         Soft link MediaAccessibility using new macros.
index 3583d21..380aeae 100644 (file)
@@ -820,7 +820,7 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
         if (parserContext.isCSSCompositingEnabled && (valueID == CSSValueNormal || valueID == CSSValueMultiply || valueID == CSSValueScreen
             || valueID == CSSValueOverlay || valueID == CSSValueDarken || valueID == CSSValueLighten ||  valueID == CSSValueColorDodge
             || valueID == CSSValueColorBurn || valueID == CSSValueHardLight || valueID == CSSValueSoftLight || valueID == CSSValueDifference
-            || valueID == CSSValueExclusion || valueID == CSSValuePlusDarker))
+            || valueID == CSSValueExclusion || valueID == CSSValuePlusDarker || valueID == CSSValuePlusLighter))
             return true;
         break;
     case CSSPropertyIsolation:
index 81bcd86..bfb4983 100644 (file)
@@ -4118,6 +4118,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BlendMode blendMode)
     case BlendModePlusDarker:
         m_value.valueID = CSSValuePlusDarker;
         break;
+    case BlendModePlusLighter:
+        m_value.valueID = CSSValuePlusLighter;
+        break;
     }
 }
 
@@ -4160,6 +4163,8 @@ template<> inline CSSPrimitiveValue::operator BlendMode() const
         return BlendModeLuminosity;
     case CSSValuePlusDarker:
         return BlendModePlusDarker;
+    case CSSValuePlusLighter:
+        return BlendModePlusLighter;
     default:
         break;
     }
index ca8730b..52d631e 100644 (file)
@@ -1056,6 +1056,8 @@ hue
 saturation
 color
 luminosity
+// plus-darker
+// plus-lighter
 
 // isolation
 // auto
index 736fb3e..c726527 100644 (file)
@@ -66,7 +66,8 @@ static const char* const blendOperatorNames[] = {
     "saturation",
     "color",
     "luminosity",
-    "plus-darker"
+    "plus-darker",
+    "plus-lighter"
 };
 const int numCompositeOperatorNames = WTF_ARRAY_LENGTH(compositeOperatorNames);
 const int numBlendOperatorNames = WTF_ARRAY_LENGTH(blendOperatorNames);
index d43f491..afb6173 100644 (file)
@@ -64,7 +64,8 @@ namespace WebCore {
         BlendModeSaturation,
         BlendModeColor,
         BlendModeLuminosity,
-        BlendModePlusDarker
+        BlendModePlusDarker,
+        BlendModePlusLighter
     };
 
     enum GradientSpreadMethod {
index 9623c06..7981517 100644 (file)
@@ -580,6 +580,9 @@ void PlatformCAFilters::setBlendingFiltersOnLayer(PlatformLayer* layer, const Bl
         case BlendModePlusDarker:
             filter = [CAFilter filterWithType:kCAFilterPlusD];
             break;
+        case BlendModePlusLighter:
+            filter = [CAFilter filterWithType:kCAFilterPlusL];
+            break;
         default:
             ASSERT_NOT_REACHED();
     }
index c7b4ff2..bab1634 100644 (file)
@@ -1537,6 +1537,9 @@ void GraphicsContext::setPlatformCompositeOperation(CompositeOperator mode, Blen
         case BlendModePlusDarker:
             target = kCGBlendModePlusDarker;
             break;
+        case BlendModePlusLighter:
+            target = kCGBlendModePlusLighter;
+            break;
         default:
             break;
         }
index ec52ef0..3739e5e 100644 (file)
@@ -1,3 +1,16 @@
+2015-03-06  Dean Jackson  <dino@apple.com>
+
+        Support "plus-lighter" in mix-blend mode
+        https://bugs.webkit.org/show_bug.cgi?id=142416
+        <rdar://problem/19993979>
+
+        Reviewed by Darin Adler and Sam Weinig.
+
+        Output the appropriate blending type when logging.
+
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTextStream::operator<<):
+
 2015-03-06  Beth Dakin  <bdakin@apple.com>
 
         REGRESSION (r180782): Data Detector popovers are not dismissed on scroll or zoom
index c957480..1b73aae 100644 (file)
@@ -848,6 +848,7 @@ RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(BlendMode blend
     case BlendModeColor: ts << "color"; break;
     case BlendModeLuminosity: ts << "luminosity"; break;
     case BlendModePlusDarker: ts << "plus-darker"; break;
+    case BlendModePlusLighter: ts << "plus-lighter"; break;
     }
     return ts;
 }