Skip to content

Commit

Permalink
Add support for lighter operator in feComposite
Browse files Browse the repository at this point in the history
Spec: https://www.w3.org/TR/filter-effects-1/#attr-valuedef-operator-lighter

Lighter is defined in the compositing & blending spec as equivalent to porter-duff plus, https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators_plus.

The 'lighter' composite mode already works in <canvas> (via globalCompositeOperation), and it's the same there.

Chrome implemented support in https://bugs.chromium.org/p/chromium/issues/detail?id=439037

Per w3c/svgwg#424 we should expose the new value in webidl and Chrome uses 7 too (https://codereview.chromium.org/779963002/patch/120001/130009)

Differential Revision: https://phabricator.services.mozilla.com/D100605

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1518099
gecko-commit: 12325181f43aee1257922717f8ae4d52e4e502d6
gecko-reviewers: jrmuizel, emilio
  • Loading branch information
longsonr authored and moz-wptsync-bot committed Jan 6, 2021
1 parent e04f27b commit 939a0c0
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@
assert_equals(feCompositeElement.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_XOR);
assert_equals(feCompositeElement.getAttribute('operator'), "xor");

// Switch to 'lighter'.
feCompositeElement.operator.baseVal = SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_LIGHTER;
assert_equals(feCompositeElement.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_LIGHTER);
assert_equals(feCompositeElement.getAttribute('operator'), "lighter");

// Switch to 'arithmetic'.
feCompositeElement.operator.baseVal = SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_ARITHMETIC;
assert_equals(feCompositeElement.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_ARITHMETIC);
assert_equals(feCompositeElement.getAttribute('operator'), "arithmetic");

// Try setting invalid values.
assert_throws_js(TypeError, function() { feCompositeElement.operator.baseVal = 7; });
assert_throws_js(TypeError, function() { feCompositeElement.operator.baseVal = 8; });
assert_equals(feCompositeElement.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_ARITHMETIC);
assert_equals(feCompositeElement.getAttribute('operator'), "arithmetic");

Expand All @@ -56,10 +61,5 @@
feCompositeElement.operator.baseVal = SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER;
assert_equals(feCompositeElement.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER);
assert_equals(feCompositeElement.getAttribute('operator'), "over");

// Switch to 'lighter'.
assert_equals(SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_LIGHTER, undefined);
feCompositeElement.setAttribute("operator", "lighter");
assert_equals(feCompositeElement.operator.baseVal, SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_UNKNOWN);
});
</script>
</script>

0 comments on commit 939a0c0

Please sign in to comment.