Changeset 129018 in webkit


Ignore:
Timestamp:
Sep 19, 2012 10:50:26 AM (12 years ago)
Author:
krit@webkit.org
Message:

Implement 'mask-type' for <mask>
https://bugs.webkit.org/show_bug.cgi?id=97011

Reviewed by Andreas Kling.

Source/WebCore:

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.

LayoutTests:

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.
Location:
trunk
Files:
9 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r129014 r129018  
     12012-09-18  Dirk Schulze  <krit@webkit.org>
     2
     3        Implement 'mask-type' for <mask>
     4        https://bugs.webkit.org/show_bug.cgi?id=97011
     5
     6        Reviewed by Andreas Kling.
     7
     8        Added new tests for switching the masking mode on <mask> element with 'mask-type'.
     9
     10        * svg/css/mask-type-expected.txt: Added.
     11        * svg/css/mask-type.html: Added.
     12        * svg/masking/mask-type-alpha-expected.svg: Added.
     13        * svg/masking/mask-type-alpha.svg: Added.
     14        * svg/masking/mask-type-luminance-expected.svg: Added.
     15        * svg/masking/mask-type-luminance.svg: Added.
     16        * svg/masking/mask-type-not-set-expected.svg: Added.
     17        * svg/masking/mask-type-not-set.svg: Added.
     18
    1192012-09-19  Nate Chapin  <japhet@chromium.org>
    220
  • trunk/Source/WebCore/ChangeLog

    r129016 r129018  
     12012-09-18  Dirk Schulze  <krit@webkit.org>
     2
     3        Implement 'mask-type' for <mask>
     4        https://bugs.webkit.org/show_bug.cgi?id=97011
     5
     6        Reviewed by Andreas Kling.
     7
     8        The CSS Masking specification defines the presentation attribute 'mask-type' to
     9        switch between luminance and alpha masking. 'mask-type' just affects the SVG
     10        mask element. The luminance masking is the current behavior of of SVG masking.
     11        Alpha masking is simular to '-webkit-mask-image'.
     12
     13        This patch implements this property and make it possible to switch between both
     14        masking modes. Since the default value is 'luminance', this does not break
     15        exisiting content which is tested with exisiting tests.
     16
     17        http://dvcs.w3.org/hg/FXTF/raw-file/tip/masking/index.html#the-mask-type
     18
     19        Tests: svg/css/mask-type.html
     20               svg/masking/mask-type-alpha-expected.svg
     21               svg/masking/mask-type-alpha.svg
     22               svg/masking/mask-type-luminance-expected.svg
     23               svg/masking/mask-type-luminance.svg
     24               svg/masking/mask-type-not-set-expected.svg
     25               svg/masking/mask-type-not-set.svg
     26
     27        * css/CSSComputedStyleDeclaration.cpp: Add mask-type property.
     28        (WebCore):
     29        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     30        * css/CSSPrimitiveValueMappings.h:
     31        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
     32        (WebCore):
     33        (WebCore::CSSPrimitiveValue::operator EMaskType):
     34        * css/CSSProperty.cpp:
     35        (WebCore::CSSProperty::isInheritedProperty):
     36        * css/SVGCSSComputedStyleDeclaration.cpp:
     37        (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue):
     38        * css/SVGCSSParser.cpp:
     39        (WebCore::CSSParser::parseSVGValue):
     40        * css/SVGCSSPropertyNames.in: Add mask-type.
     41        * css/SVGCSSStyleSelector.cpp:
     42        (WebCore::StyleResolver::applySVGProperty):
     43        * css/SVGCSSValueKeywords.in:
     44        * rendering/style/SVGRenderStyle.cpp:
     45        (WebCore::SVGRenderStyle::diff):
     46        * rendering/style/SVGRenderStyle.h:
     47        (WebCore::SVGRenderStyle::initialMaskType):
     48        (WebCore::SVGRenderStyle::setMaskType):
     49        (SVGRenderStyle):
     50        (WebCore::SVGRenderStyle::maskType):
     51        (WebCore::SVGRenderStyle::setBitDefaults):
     52        * rendering/style/SVGRenderStyleDefs.h:
     53        * rendering/svg/RenderSVGResourceMasker.cpp:
     54
     55            Switch between the two masking modes according to the
     56            computed value of mask-type.
     57
     58        (WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage):
     59        * svg/SVGStyledElement.cpp:
     60        (WebCore::SVGStyledElement::cssPropertyIdForSVGAttributeName):
     61        (WebCore::cssPropertyToTypeMap):
     62        * svg/svgattrs.in: Add the new attribute to the attribute list.
     63
    1642012-09-19  Mark Pilgrim  <pilgrim@chromium.org>
    265
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r128762 r129018  
    378378    CSSPropertyMarkerMid,
    379379    CSSPropertyMarkerStart,
     380    CSSPropertyMaskType,
    380381    CSSPropertyShapeRendering,
    381382    CSSPropertyStroke,
     
    26142615        case CSSPropertyMarkerMid:
    26152616        case CSSPropertyMarkerStart:
     2617        case CSSPropertyMaskType:
    26162618        case CSSPropertyShapeRendering:
    26172619        case CSSPropertyStroke:
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r127737 r129018  
    42784278}
    42794279
     4280template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EMaskType e)
     4281    : CSSValue(PrimitiveClass)
     4282{
     4283    m_primitiveUnitType = CSS_IDENT;
     4284    switch (e) {
     4285    case MT_LUMINANCE:
     4286        m_value.ident = CSSValueLuminance;
     4287        break;
     4288    case MT_ALPHA:
     4289        m_value.ident = CSSValueAlpha;
     4290        break;
     4291    }
     4292}
     4293
     4294template<> inline CSSPrimitiveValue::operator EMaskType() const
     4295{
     4296    switch (m_value.ident) {
     4297    case CSSValueLuminance:
     4298        return MT_LUMINANCE;
     4299    case CSSValueAlpha:
     4300        return MT_ALPHA;
     4301    }
     4302
     4303    ASSERT_NOT_REACHED();
     4304    return MT_LUMINANCE;
     4305}
     4306
    42804307#endif // ENABLE(SVG)
    42814308
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r128762 r129018  
    684684    case CSSPropertyClipPath:
    685685    case CSSPropertyMask:
     686    case CSSPropertyMaskType:
    686687    case CSSPropertyEnableBackground:
    687688    case CSSPropertyFilter:
  • trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp

    r113748 r129018  
    193193        case CSSPropertyVectorEffect:
    194194            return CSSPrimitiveValue::create(svgStyle->vectorEffect());
     195        case CSSPropertyMaskType:
     196            return CSSPrimitiveValue::create(svgStyle->maskType());
    195197        case CSSPropertyMarker:
    196198        case CSSPropertyEnableBackground:
  • trunk/Source/WebCore/css/SVGCSSParser.cpp

    r125252 r129018  
    271271        }
    272272
     273    case CSSPropertyMaskType: // luminance | alpha | inherit
     274        if (id == CSSValueLuminance || id == CSSValueAlpha)
     275            valid_primitive = true;
     276        break;
     277
    273278    /* shorthand properties */
    274279    case CSSPropertyMarker:
  • trunk/Source/WebCore/css/SVGCSSPropertyNames.in

    r119708 r129018  
    3131marker-mid
    3232marker-start
     33mask-type
    3334shape-rendering
    3435stroke
  • trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp

    r121289 r129018  
    583583            break;
    584584        }
     585        case CSSPropertyMaskType: {
     586            HANDLE_INHERIT_AND_INITIAL(maskType, MaskType)
     587            if (!primitiveValue)
     588                break;
     589
     590            svgstyle->setMaskType(*primitiveValue);
     591            break;
     592        }
    585593        default:
    586594            // If you crash here, it's because you added a css property and are not handling it
  • trunk/Source/WebCore/css/SVGCSSValueKeywords.in

    r106980 r129018  
    55//
    66aliceblue
     7alpha
    78antiquewhite
    89// aqua
     
    8990limegreen
    9091linen
     92luminance
    9193magenta
    9294// maroon
  • trunk/Source/WebCore/rendering/style/SVGRenderStyle.cpp

    r98542 r129018  
    224224        return StyleDifferenceRepaint;
    225225
     226    if (svg_noninherited_flags.f.maskType != other->svg_noninherited_flags.f.maskType)
     227        return StyleDifferenceRepaint;
     228
    226229    return StyleDifferenceEqual;
    227230}
  • trunk/Source/WebCore/rendering/style/SVGRenderStyle.h

    r115201 r129018  
    9393    static String initialMarkerMidResource() { return String(); }
    9494    static String initialMarkerEndResource() { return String(); }
     95    static EMaskType initialMaskType() { return MT_LUMINANCE; }
    9596
    9697    static SVGLength initialBaselineShiftValue()
     
    147148    void setGlyphOrientationHorizontal(EGlyphOrientation val) { svg_inherited_flags._glyphOrientationHorizontal = val; }
    148149    void setGlyphOrientationVertical(EGlyphOrientation val) { svg_inherited_flags._glyphOrientationVertical = val; }
    149    
     150    void setMaskType(EMaskType val) { svg_noninherited_flags.f.maskType = val; }
     151
    150152    void setFillOpacity(float obj)
    151153    {
     
    349351    String markerMidResource() const { return inheritedResources->markerMid; }
    350352    String markerEndResource() const { return inheritedResources->markerEnd; }
    351    
     353    EMaskType maskType() const { return (EMaskType) svg_noninherited_flags.f.maskType; }
     354
    352355    const SVGPaint::SVGPaintType& visitedLinkFillPaintType() const { return fill->visitedLinkPaintType; }
    353356    const Color& visitedLinkFillPaintColor() const { return fill->visitedLinkPaintColor; }
     
    417420                unsigned _baselineShift : 2; // EBaselineShift
    418421                unsigned _vectorEffect: 1; // EVectorEffect
    419                 // 21 bits unused
     422                unsigned maskType: 1; // EMaskType
     423                // 20 bits unused
    420424            } f;
    421425            uint32_t _niflags;
     
    462466        svg_noninherited_flags.f._baselineShift = initialBaselineShift();
    463467        svg_noninherited_flags.f._vectorEffect = initialVectorEffect();
     468        svg_noninherited_flags.f.maskType = initialMaskType();
    464469    }
    465470};
  • trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.h

    r97638 r129018  
    8484    };
    8585
     86    enum EMaskType {
     87        MT_LUMINANCE,
     88        MT_ALPHA
     89    };
     90
    8691    class CSSValue;
    8792    class CSSValueList;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp

    r115248 r129018  
    154154#endif
    155155
     156    ASSERT(style());
     157    ASSERT(style()->svgStyle());
    156158    // Create the luminance mask.
    157     maskerData->maskImage->convertToLuminanceMask();
     159    if (style()->svgStyle()->maskType() == MT_LUMINANCE)
     160        maskerData->maskImage->convertToLuminanceMask();
     161
    158162    return true;
    159163}
  • trunk/Source/WebCore/svg/SVGStyledElement.cpp

    r127757 r129018  
    182182        mapAttributeToCSSProperty(propertyNameToIdMap, marker_startAttr);
    183183        mapAttributeToCSSProperty(propertyNameToIdMap, maskAttr);
     184        mapAttributeToCSSProperty(propertyNameToIdMap, mask_typeAttr);
    184185        mapAttributeToCSSProperty(propertyNameToIdMap, opacityAttr);
    185186        mapAttributeToCSSProperty(propertyNameToIdMap, overflowAttr);
     
    252253    s_cssPropertyMap.set(marker_startAttr, AnimatedString);
    253254    s_cssPropertyMap.set(maskAttr, AnimatedString);
     255    s_cssPropertyMap.set(mask_typeAttr, AnimatedString);
    254256    s_cssPropertyMap.set(opacityAttr, AnimatedNumber);
    255257    s_cssPropertyMap.set(overflowAttr, AnimatedString);
  • trunk/Source/WebCore/svg/svgattrs.in

    r109916 r129018  
    116116markerWidth
    117117mask
     118mask-type
    118119maskContentUnits
    119120maskUnits
Note: See TracChangeset for help on using the changeset viewer.