Diff
Modified: trunk/LayoutTests/ChangeLog (129017 => 129018)
--- trunk/LayoutTests/ChangeLog 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/LayoutTests/ChangeLog 2012-09-19 17:50:26 UTC (rev 129018)
@@ -1,3 +1,21 @@
+2012-09-18 Dirk Schulze <k...@webkit.org>
+
+ Implement 'mask-type' for <mask>
+ https://bugs.webkit.org/show_bug.cgi?id=97011
+
+ Reviewed by Andreas Kling.
+
+ Added new tests for switching the masking mode on <mask> element with 'mask-type'.
+
+ * svg/css/mask-type-expected.txt: Added.
+ * svg/css/mask-type.html: Added.
+ * svg/masking/mask-type-alpha-expected.svg: Added.
+ * svg/masking/mask-type-alpha.svg: Added.
+ * svg/masking/mask-type-luminance-expected.svg: Added.
+ * svg/masking/mask-type-luminance.svg: Added.
+ * svg/masking/mask-type-not-set-expected.svg: Added.
+ * svg/masking/mask-type-not-set.svg: Added.
+
2012-09-19 Nate Chapin <jap...@chromium.org>
chromium TestExpectations update.
Added: trunk/LayoutTests/svg/css/mask-type-expected.txt (0 => 129018)
--- trunk/LayoutTests/svg/css/mask-type-expected.txt (rev 0)
+++ trunk/LayoutTests/svg/css/mask-type-expected.txt 2012-09-19 17:50:26 UTC (rev 129018)
@@ -0,0 +1,15 @@
+Test that clip-path shapes accept different length units
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS computedStyle("mask-type", "") is "luminance"
+PASS computedStyle("mask-type", "alpha") is "alpha"
+PASS computedStyle("mask-type", "luminance") is "luminance"
+PASS computedStyle("mask-type", "0") is "luminance"
+PASS computedStyle("mask-type", "1") is "luminance"
+PASS computedStyle("mask-type", "linearRGB") is "luminance"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/svg/css/mask-type.html (0 => 129018)
--- trunk/LayoutTests/svg/css/mask-type.html (rev 0)
+++ trunk/LayoutTests/svg/css/mask-type.html 2012-09-19 17:50:26 UTC (rev 129018)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<style>
+* { font-size: 16px; }
+div { font-size: 8px; }
+</style>
+<body>
+<svg><mask id="mask"></mask></svg>
+<script src=""
+<script>
+description('Test that clip-path shapes accept different length units');
+
+var mask = document.getElementById('mask');
+
+function computedStyle(property, value) {
+ mask.style.setProperty(property, value);
+ return getComputedStyle(mask).getPropertyValue(property);
+}
+
+function test(property, value, expected) {
+ if (expected === null)
+ shouldBeNull('computedStyle("' + property + '", "' + value + '")');
+ else
+ shouldBeEqualToString('computedStyle("' + property + '", "' + value + '")', expected);
+}
+
+test("mask-type", "", "luminance");
+test("mask-type", "alpha", "alpha");
+test("mask-type", "luminance", "luminance");
+
+// negative tests
+test("mask-type", "0", "luminance");
+test("mask-type", "1", "luminance");
+test("mask-type", "linearRGB", "luminance");
+
+</script>
+<script src=""
+</svg>
\ No newline at end of file
Added: trunk/LayoutTests/svg/masking/mask-type-alpha-expected.svg (0 => 129018)
--- trunk/LayoutTests/svg/masking/mask-type-alpha-expected.svg (rev 0)
+++ trunk/LayoutTests/svg/masking/mask-type-alpha-expected.svg 2012-09-19 17:50:26 UTC (rev 129018)
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<circle cx="100" cy="100" rx="100" fill="green"/>
+</svg>
\ No newline at end of file
Added: trunk/LayoutTests/svg/masking/mask-type-alpha.svg (0 => 129018)
--- trunk/LayoutTests/svg/masking/mask-type-alpha.svg (rev 0)
+++ trunk/LayoutTests/svg/masking/mask-type-alpha.svg 2012-09-19 17:50:26 UTC (rev 129018)
@@ -0,0 +1,9 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+ <mask id="mask" mask-type="alpha">
+ <rect width="200" height="200" fill="black" opacity="0"/>
+ <circle cx="100" cy="100" rx="100" fill="black"/>
+ </mask>
+</defs>
+<rect width="200" height="200" fill="green" mask="url(#mask)"/>
+</svg>
\ No newline at end of file
Added: trunk/LayoutTests/svg/masking/mask-type-luminance-expected.svg (0 => 129018)
--- trunk/LayoutTests/svg/masking/mask-type-luminance-expected.svg (rev 0)
+++ trunk/LayoutTests/svg/masking/mask-type-luminance-expected.svg 2012-09-19 17:50:26 UTC (rev 129018)
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<circle cx="100" cy="100" rx="100" fill="green"/>
+</svg>
\ No newline at end of file
Added: trunk/LayoutTests/svg/masking/mask-type-luminance.svg (0 => 129018)
--- trunk/LayoutTests/svg/masking/mask-type-luminance.svg (rev 0)
+++ trunk/LayoutTests/svg/masking/mask-type-luminance.svg 2012-09-19 17:50:26 UTC (rev 129018)
@@ -0,0 +1,9 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+ <mask id="mask" mask-type="luminance">
+ <rect width="200" height="200" fill="black"/>
+ <circle cx="100" cy="100" rx="100" fill="white"/>
+ </mask>
+</defs>
+<rect width="200" height="200" fill="green" mask="url(#mask)"/>
+</svg>
\ No newline at end of file
Added: trunk/LayoutTests/svg/masking/mask-type-not-set-expected.svg (0 => 129018)
--- trunk/LayoutTests/svg/masking/mask-type-not-set-expected.svg (rev 0)
+++ trunk/LayoutTests/svg/masking/mask-type-not-set-expected.svg 2012-09-19 17:50:26 UTC (rev 129018)
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<circle cx="100" cy="100" rx="100" fill="green"/>
+</svg>
\ No newline at end of file
Added: trunk/LayoutTests/svg/masking/mask-type-not-set.svg (0 => 129018)
--- trunk/LayoutTests/svg/masking/mask-type-not-set.svg (rev 0)
+++ trunk/LayoutTests/svg/masking/mask-type-not-set.svg 2012-09-19 17:50:26 UTC (rev 129018)
@@ -0,0 +1,9 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<defs>
+ <mask id="mask">
+ <rect width="200" height="200" fill="black"/>
+ <circle cx="100" cy="100" rx="100" fill="white"/>
+ </mask>
+</defs>
+<rect width="200" height="200" fill="green" mask="url(#mask)"/>
+</svg>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (129017 => 129018)
--- trunk/Source/WebCore/ChangeLog 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/ChangeLog 2012-09-19 17:50:26 UTC (rev 129018)
@@ -1,3 +1,66 @@
+2012-09-18 Dirk Schulze <k...@webkit.org>
+
+ Implement 'mask-type' for <mask>
+ https://bugs.webkit.org/show_bug.cgi?id=97011
+
+ Reviewed by Andreas Kling.
+
+ The CSS Masking specification defines the presentation attribute 'mask-type' to
+ switch between luminance and alpha masking. 'mask-type' just affects the SVG
+ mask element. The luminance masking is the current behavior of of SVG masking.
+ Alpha masking is simular to '-webkit-mask-image'.
+
+ This patch implements this property and make it possible to switch between both
+ masking modes. Since the default value is 'luminance', this does not break
+ exisiting content which is tested with exisiting tests.
+
+ http://dvcs.w3.org/hg/FXTF/raw-file/tip/masking/index.html#the-mask-type
+
+ Tests: svg/css/mask-type.html
+ svg/masking/mask-type-alpha-expected.svg
+ svg/masking/mask-type-alpha.svg
+ svg/masking/mask-type-luminance-expected.svg
+ svg/masking/mask-type-luminance.svg
+ svg/masking/mask-type-not-set-expected.svg
+ svg/masking/mask-type-not-set.svg
+
+ * css/CSSComputedStyleDeclaration.cpp: Add mask-type property.
+ (WebCore):
+ (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+ * css/CSSPrimitiveValueMappings.h:
+ (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+ (WebCore):
+ (WebCore::CSSPrimitiveValue::operator EMaskType):
+ * css/CSSProperty.cpp:
+ (WebCore::CSSProperty::isInheritedProperty):
+ * css/SVGCSSComputedStyleDeclaration.cpp:
+ (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue):
+ * css/SVGCSSParser.cpp:
+ (WebCore::CSSParser::parseSVGValue):
+ * css/SVGCSSPropertyNames.in: Add mask-type.
+ * css/SVGCSSStyleSelector.cpp:
+ (WebCore::StyleResolver::applySVGProperty):
+ * css/SVGCSSValueKeywords.in:
+ * rendering/style/SVGRenderStyle.cpp:
+ (WebCore::SVGRenderStyle::diff):
+ * rendering/style/SVGRenderStyle.h:
+ (WebCore::SVGRenderStyle::initialMaskType):
+ (WebCore::SVGRenderStyle::setMaskType):
+ (SVGRenderStyle):
+ (WebCore::SVGRenderStyle::maskType):
+ (WebCore::SVGRenderStyle::setBitDefaults):
+ * rendering/style/SVGRenderStyleDefs.h:
+ * rendering/svg/RenderSVGResourceMasker.cpp:
+
+ Switch between the two masking modes according to the
+ computed value of mask-type.
+
+ (WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage):
+ * svg/SVGStyledElement.cpp:
+ (WebCore::SVGStyledElement::cssPropertyIdForSVGAttributeName):
+ (WebCore::cssPropertyToTypeMap):
+ * svg/svgattrs.in: Add the new attribute to the attribute list.
+
2012-09-19 Mark Pilgrim <pilg...@chromium.org>
[Chromium] Remove unused popupsAllowed function from PlatformSupport
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (129017 => 129018)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2012-09-19 17:50:26 UTC (rev 129018)
@@ -377,6 +377,7 @@
CSSPropertyMarkerEnd,
CSSPropertyMarkerMid,
CSSPropertyMarkerStart,
+ CSSPropertyMaskType,
CSSPropertyShapeRendering,
CSSPropertyStroke,
CSSPropertyStrokeDasharray,
@@ -2613,6 +2614,7 @@
case CSSPropertyMarkerEnd:
case CSSPropertyMarkerMid:
case CSSPropertyMarkerStart:
+ case CSSPropertyMaskType:
case CSSPropertyShapeRendering:
case CSSPropertyStroke:
case CSSPropertyStrokeDasharray:
Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (129017 => 129018)
--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2012-09-19 17:50:26 UTC (rev 129018)
@@ -4277,6 +4277,33 @@
return VE_NONE;
}
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMaskType e)
+ : CSSValue(PrimitiveClass)
+{
+ m_primitiveUnitType = CSS_IDENT;
+ switch (e) {
+ case MT_LUMINANCE:
+ m_value.ident = CSSValueLuminance;
+ break;
+ case MT_ALPHA:
+ m_value.ident = CSSValueAlpha;
+ break;
+ }
+}
+
+template<> inline CSSPrimitiveValue::operator EMaskType() const
+{
+ switch (m_value.ident) {
+ case CSSValueLuminance:
+ return MT_LUMINANCE;
+ case CSSValueAlpha:
+ return MT_ALPHA;
+ }
+
+ ASSERT_NOT_REACHED();
+ return MT_LUMINANCE;
+}
+
#endif // ENABLE(SVG)
#if ENABLE(CSS_IMAGE_ORIENTATION)
Modified: trunk/Source/WebCore/css/CSSProperty.cpp (129017 => 129018)
--- trunk/Source/WebCore/css/CSSProperty.cpp 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/css/CSSProperty.cpp 2012-09-19 17:50:26 UTC (rev 129018)
@@ -683,6 +683,7 @@
#if ENABLE(SVG)
case CSSPropertyClipPath:
case CSSPropertyMask:
+ case CSSPropertyMaskType:
case CSSPropertyEnableBackground:
case CSSPropertyFilter:
case CSSPropertyFloodColor:
Modified: trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp (129017 => 129018)
--- trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp 2012-09-19 17:50:26 UTC (rev 129018)
@@ -192,6 +192,8 @@
return valueForShadow(svgStyle->shadow(), propertyID, style);
case CSSPropertyVectorEffect:
return CSSPrimitiveValue::create(svgStyle->vectorEffect());
+ case CSSPropertyMaskType:
+ return CSSPrimitiveValue::create(svgStyle->maskType());
case CSSPropertyMarker:
case CSSPropertyEnableBackground:
case CSSPropertyColorProfile:
Modified: trunk/Source/WebCore/css/SVGCSSParser.cpp (129017 => 129018)
--- trunk/Source/WebCore/css/SVGCSSParser.cpp 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/css/SVGCSSParser.cpp 2012-09-19 17:50:26 UTC (rev 129018)
@@ -270,6 +270,11 @@
return false;
}
+ case CSSPropertyMaskType: // luminance | alpha | inherit
+ if (id == CSSValueLuminance || id == CSSValueAlpha)
+ valid_primitive = true;
+ break;
+
/* shorthand properties */
case CSSPropertyMarker:
{
Modified: trunk/Source/WebCore/css/SVGCSSPropertyNames.in (129017 => 129018)
--- trunk/Source/WebCore/css/SVGCSSPropertyNames.in 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/css/SVGCSSPropertyNames.in 2012-09-19 17:50:26 UTC (rev 129018)
@@ -30,6 +30,7 @@
marker-end
marker-mid
marker-start
+mask-type
shape-rendering
stroke
stroke-dasharray
Modified: trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp (129017 => 129018)
--- trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp 2012-09-19 17:50:26 UTC (rev 129018)
@@ -582,6 +582,14 @@
svgstyle->setVectorEffect(*primitiveValue);
break;
}
+ case CSSPropertyMaskType: {
+ HANDLE_INHERIT_AND_INITIAL(maskType, MaskType)
+ if (!primitiveValue)
+ break;
+
+ svgstyle->setMaskType(*primitiveValue);
+ break;
+ }
default:
// If you crash here, it's because you added a css property and are not handling it
// in either this switch statement or the one in StyleResolver::applyProperty
Modified: trunk/Source/WebCore/css/SVGCSSValueKeywords.in (129017 => 129018)
--- trunk/Source/WebCore/css/SVGCSSValueKeywords.in 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/css/SVGCSSValueKeywords.in 2012-09-19 17:50:26 UTC (rev 129018)
@@ -4,6 +4,7 @@
// CSS_PROP_*_COLOR
//
aliceblue
+alpha
antiquewhite
// aqua
aquamarine
@@ -88,6 +89,7 @@
// lime
limegreen
linen
+luminance
magenta
// maroon
mediumaquamarine
Modified: trunk/Source/WebCore/rendering/style/SVGRenderStyle.cpp (129017 => 129018)
--- trunk/Source/WebCore/rendering/style/SVGRenderStyle.cpp 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/rendering/style/SVGRenderStyle.cpp 2012-09-19 17:50:26 UTC (rev 129018)
@@ -223,6 +223,9 @@
if (svg_noninherited_flags.f._vectorEffect != other->svg_noninherited_flags.f._vectorEffect)
return StyleDifferenceRepaint;
+ if (svg_noninherited_flags.f.maskType != other->svg_noninherited_flags.f.maskType)
+ return StyleDifferenceRepaint;
+
return StyleDifferenceEqual;
}
Modified: trunk/Source/WebCore/rendering/style/SVGRenderStyle.h (129017 => 129018)
--- trunk/Source/WebCore/rendering/style/SVGRenderStyle.h 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/rendering/style/SVGRenderStyle.h 2012-09-19 17:50:26 UTC (rev 129018)
@@ -92,6 +92,7 @@
static String initialMarkerStartResource() { return String(); }
static String initialMarkerMidResource() { return String(); }
static String initialMarkerEndResource() { return String(); }
+ static EMaskType initialMaskType() { return MT_LUMINANCE; }
static SVGLength initialBaselineShiftValue()
{
@@ -146,7 +147,8 @@
void setWritingMode(SVGWritingMode val) { svg_inherited_flags._writingMode = val; }
void setGlyphOrientationHorizontal(EGlyphOrientation val) { svg_inherited_flags._glyphOrientationHorizontal = val; }
void setGlyphOrientationVertical(EGlyphOrientation val) { svg_inherited_flags._glyphOrientationVertical = val; }
-
+ void setMaskType(EMaskType val) { svg_noninherited_flags.f.maskType = val; }
+
void setFillOpacity(float obj)
{
if (!(fill->opacity == obj))
@@ -348,7 +350,8 @@
String markerStartResource() const { return inheritedResources->markerStart; }
String markerMidResource() const { return inheritedResources->markerMid; }
String markerEndResource() const { return inheritedResources->markerEnd; }
-
+ EMaskType maskType() const { return (EMaskType) svg_noninherited_flags.f.maskType; }
+
const SVGPaint::SVGPaintType& visitedLinkFillPaintType() const { return fill->visitedLinkPaintType; }
const Color& visitedLinkFillPaintColor() const { return fill->visitedLinkPaintColor; }
const String& visitedLinkFillPaintUri() const { return fill->visitedLinkPaintUri; }
@@ -416,7 +419,8 @@
unsigned _dominantBaseline : 4; // EDominantBaseline
unsigned _baselineShift : 2; // EBaselineShift
unsigned _vectorEffect: 1; // EVectorEffect
- // 21 bits unused
+ unsigned maskType: 1; // EMaskType
+ // 20 bits unused
} f;
uint32_t _niflags;
};
@@ -461,6 +465,7 @@
svg_noninherited_flags.f._dominantBaseline = initialDominantBaseline();
svg_noninherited_flags.f._baselineShift = initialBaselineShift();
svg_noninherited_flags.f._vectorEffect = initialVectorEffect();
+ svg_noninherited_flags.f.maskType = initialMaskType();
}
};
Modified: trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.h (129017 => 129018)
--- trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.h 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.h 2012-09-19 17:50:26 UTC (rev 129018)
@@ -83,6 +83,11 @@
VE_NON_SCALING_STROKE
};
+ enum EMaskType {
+ MT_LUMINANCE,
+ MT_ALPHA
+ };
+
class CSSValue;
class CSSValueList;
class SVGPaint;
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp (129017 => 129018)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp 2012-09-19 17:50:26 UTC (rev 129018)
@@ -153,8 +153,12 @@
UNUSED_PARAM(colorSpace);
#endif
+ ASSERT(style());
+ ASSERT(style()->svgStyle());
// Create the luminance mask.
- maskerData->maskImage->convertToLuminanceMask();
+ if (style()->svgStyle()->maskType() == MT_LUMINANCE)
+ maskerData->maskImage->convertToLuminanceMask();
+
return true;
}
Modified: trunk/Source/WebCore/svg/SVGStyledElement.cpp (129017 => 129018)
--- trunk/Source/WebCore/svg/SVGStyledElement.cpp 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/svg/SVGStyledElement.cpp 2012-09-19 17:50:26 UTC (rev 129018)
@@ -181,6 +181,7 @@
mapAttributeToCSSProperty(propertyNameToIdMap, marker_midAttr);
mapAttributeToCSSProperty(propertyNameToIdMap, marker_startAttr);
mapAttributeToCSSProperty(propertyNameToIdMap, maskAttr);
+ mapAttributeToCSSProperty(propertyNameToIdMap, mask_typeAttr);
mapAttributeToCSSProperty(propertyNameToIdMap, opacityAttr);
mapAttributeToCSSProperty(propertyNameToIdMap, overflowAttr);
mapAttributeToCSSProperty(propertyNameToIdMap, pointer_eventsAttr);
@@ -251,6 +252,7 @@
s_cssPropertyMap.set(marker_midAttr, AnimatedString);
s_cssPropertyMap.set(marker_startAttr, AnimatedString);
s_cssPropertyMap.set(maskAttr, AnimatedString);
+ s_cssPropertyMap.set(mask_typeAttr, AnimatedString);
s_cssPropertyMap.set(opacityAttr, AnimatedNumber);
s_cssPropertyMap.set(overflowAttr, AnimatedString);
s_cssPropertyMap.set(pointer_eventsAttr, AnimatedString);
Modified: trunk/Source/WebCore/svg/svgattrs.in (129017 => 129018)
--- trunk/Source/WebCore/svg/svgattrs.in 2012-09-19 17:47:21 UTC (rev 129017)
+++ trunk/Source/WebCore/svg/svgattrs.in 2012-09-19 17:50:26 UTC (rev 129018)
@@ -115,6 +115,7 @@
markerUnits
markerWidth
mask
+mask-type
maskContentUnits
maskUnits
mathematical