Changeset 127327 in webkit


Ignore:
Timestamp:
Aug 31, 2012 3:29:48 PM (12 years ago)
Author:
krit@webkit.org
Message:

Introduce new CSS property for clip-path
https://bugs.webkit.org/show_bug.cgi?id=95474

Reviewed by Tim Horton.

Source/WebCore:

This path introduces the new, prefixed CSS property 'clip-path' from the
CSS Masking specification. In a first step the property just accepts
'none' and the the basic shapes from CSS Exclusion. Later it will also be
possible to reference SVG 'clipPath' elements - like Firefox already does.
To enable the parsing of the shapes, the exclusion compiler flags
around the shape parser were removed.

http://dvcs.w3.org/hg/FXTF/raw-file/tip/masking/index.html

Test: fast/masking/parsing-clip-path-shape.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Return CSSValue for CSSPropertyWebkitClipPath.

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue): Add CSSPropertyWebkitClipPath.
(WebCore::CSSParser::parseBasicShape): Modify parser function to accept CSSPropertyWebkitClipPath as well.

  • css/CSSParser.h:
  • css/CSSProperty.cpp:

(WebCore::CSSProperty::isInheritedProperty):

  • css/CSSPropertyNames.in: Added property name -webkit-clip-path.
  • css/StyleBuilder.cpp:

(ApplyPropertyClipPath): New property applier just for -webkit-clip-path.
(WebCore::ApplyPropertyClipPath::setValue):
(WebCore::ApplyPropertyClipPath::applyValue):
(WebCore::ApplyPropertyClipPath::createHandler):
(WebCore::StyleBuilder::StyleBuilder):

  • rendering/style/RenderStyle.cpp: Repaint if there is a difference between two BasicShapes.

(WebCore::RenderStyle::diff):

  • rendering/style/RenderStyle.h:
  • rendering/style/StyleRareNonInheritedData.cpp:

(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator==):
(WebCore::StyleRareNonInheritedData::reportMemoryUsage):

  • rendering/style/StyleRareNonInheritedData.h: Add new member variable for clip shape.

(StyleRareNonInheritedData):

LayoutTests:

Test parsing behavior of basic shapes on new introduced '-webkit-clip-path' CSS property.

  • fast/masking/parsing-clip-path-shape-expected.txt: Added.
  • fast/masking/parsing-clip-path-shape.html: Added.
Location:
trunk
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r127324 r127327  
     12012-08-30  Dirk Schulze  <krit@webkit.org>
     2
     3        Introduce new CSS property for clip-path
     4        https://bugs.webkit.org/show_bug.cgi?id=95474
     5
     6        Reviewed by Tim Horton.
     7
     8        Test parsing behavior of basic shapes on new introduced '-webkit-clip-path' CSS property.
     9
     10        * fast/masking/parsing-clip-path-shape-expected.txt: Added.
     11        * fast/masking/parsing-clip-path-shape.html: Added.
     12
    1132012-08-31  Geoffrey Garen  <ggaren@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r127325 r127327  
     12012-08-30  Dirk Schulze  <krit@webkit.org>
     2
     3        Introduce new CSS property for clip-path
     4        https://bugs.webkit.org/show_bug.cgi?id=95474
     5
     6        Reviewed by Tim Horton.
     7
     8        This path introduces the new, prefixed CSS property 'clip-path' from the
     9        CSS Masking specification. In a first step the property just accepts
     10        'none' and the the basic shapes from CSS Exclusion. Later it will also be
     11        possible to reference SVG 'clipPath' elements - like Firefox already does.
     12        To enable the parsing of the shapes, the exclusion compiler flags
     13        around the shape parser were removed.
     14
     15        http://dvcs.w3.org/hg/FXTF/raw-file/tip/masking/index.html
     16
     17        Test: fast/masking/parsing-clip-path-shape.html
     18
     19        * css/CSSComputedStyleDeclaration.cpp:
     20        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Return CSSValue for CSSPropertyWebkitClipPath.
     21        * css/CSSParser.cpp:
     22        (WebCore::CSSParser::parseValue): Add CSSPropertyWebkitClipPath.
     23        (WebCore::CSSParser::parseBasicShape): Modify parser function to accept CSSPropertyWebkitClipPath as well.
     24        * css/CSSParser.h:
     25        * css/CSSProperty.cpp:
     26        (WebCore::CSSProperty::isInheritedProperty):
     27        * css/CSSPropertyNames.in: Added property name -webkit-clip-path.
     28        * css/StyleBuilder.cpp:
     29        (ApplyPropertyClipPath): New property applier just for -webkit-clip-path.
     30        (WebCore::ApplyPropertyClipPath::setValue):
     31        (WebCore::ApplyPropertyClipPath::applyValue):
     32        (WebCore::ApplyPropertyClipPath::createHandler):
     33        (WebCore::StyleBuilder::StyleBuilder):
     34        * rendering/style/RenderStyle.cpp: Repaint if there is a difference between two BasicShapes.
     35        (WebCore::RenderStyle::diff):
     36        * rendering/style/RenderStyle.h:
     37        * rendering/style/StyleRareNonInheritedData.cpp:
     38        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
     39        (WebCore::StyleRareNonInheritedData::operator==):
     40        (WebCore::StyleRareNonInheritedData::reportMemoryUsage):
     41        * rendering/style/StyleRareNonInheritedData.h: Add new member variable for clip shape.
     42        (StyleRareNonInheritedData):
     43
    1442012-08-31  Joshua Netterfield  <jnetterfield@rim.com>
    245
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r127318 r127327  
    2626
    2727#include "AnimationController.h"
     28#include "BasicShapeFunctions.h"
     29#include "BasicShapes.h"
    2830#include "CSSAspectRatioValue.h"
     31#include "CSSBasicShapes.h"
    2932#include "CSSBorderImage.h"
    3033#include "CSSLineBoxContainValue.h"
     
    6063#include "WebKitFontFamilyNames.h"
    6164#include <wtf/text/StringBuilder.h>
    62 
    63 #if ENABLE(CSS_EXCLUSIONS)
    64 #include "BasicShapeFunctions.h"
    65 #include "BasicShapes.h"
    66 #include "CSSBasicShapes.h"
    67 #endif
    6865
    6966#if ENABLE(CSS_SHADERS)
     
    236233    CSSPropertyWebkitBoxReflect,
    237234    CSSPropertyWebkitBoxShadow,
     235    CSSPropertyWebkitClipPath,
    238236    CSSPropertyWebkitColorCorrection,
    239237    CSSPropertyWebkitColumnBreakAfter,
     
    24042402        case CSSPropertyCounterReset:
    24052403            return counterToCSSValue(style.get(), propertyID);
     2404        case CSSPropertyWebkitClipPath:
     2405            if (!style->clipPath())
     2406                return cssValuePool().createIdentifierValue(CSSValueNone);
     2407            return valueForBasicShape(style->clipPath());
    24062408#if ENABLE(CSS_REGIONS)
    24072409        case CSSPropertyWebkitFlowInto:
  • trunk/Source/WebCore/css/CSSParser.cpp

    r127318 r127327  
    27442744            return parseFontVariantLigatures(important);
    27452745        break;
     2746    case CSSPropertyWebkitClipPath:
     2747        if (id == CSSValueNone)
     2748            validPrimitive = true;
     2749        else if (value->unit == CSSParserValue::Function)
     2750            return parseBasicShape(propId, important);
     2751        break;
    27462752#if ENABLE(CSS_EXCLUSIONS)
    27472753    case CSSPropertyWebkitShapeInside:
     
    27522758            validPrimitive = true;
    27532759        else if (value->unit == CSSParserValue::Function)
    2754             return parseBasicShape((propId == CSSPropertyWebkitShapeInside), important);
     2760            return parseBasicShape(propId, important);
    27552761        break;
    27562762    case CSSPropertyWebkitWrapMargin:
     
    45364542}
    45374543
    4538 #if ENABLE(CSS_EXCLUSIONS)
    4539 
    45404544PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeRectangle(CSSParserValueList* args)
    45414545{
     
    47484752}
    47494753
    4750 bool CSSParser::parseBasicShape(bool shapeInside, bool important)
     4754bool CSSParser::parseBasicShape(CSSPropertyID propId, bool important)
    47514755{
    47524756    CSSParserValue* value = m_valueList->current();
     4757    ASSERT(value->unit == CSSParserValue::Function);
    47534758    CSSParserValueList* args = value->function->args.get();
    47544759
     
    47574762
    47584763    RefPtr<CSSBasicShape> shape;
    4759 
    47604764    if (equalIgnoringCase(value->function->name, "rectangle("))
    47614765        shape = parseBasicShapeRectangle(args);
     
    47674771        shape = parseBasicShapePolygon(args);
    47684772
    4769     if (shape) {
    4770         addProperty(shapeInside ? CSSPropertyWebkitShapeInside : CSSPropertyWebkitShapeOutside, cssValuePool().createValue(shape.release()), important);
    4771         m_valueList->next();
    4772         return true;
    4773     }
    4774 
    4775     return false;
    4776 }
    4777 
    4778 #endif
     4773    if (!shape)
     4774        return false;
     4775
     4776    addProperty(propId, cssValuePool().createValue(shape.release()), important);
     4777    m_valueList->next();
     4778    return true;
     4779}
    47794780
    47804781// [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 'font-family'
  • trunk/Source/WebCore/css/CSSParser.h

    r127277 r127327  
    151151    bool parseClipShape(CSSPropertyID, bool important);
    152152
    153     bool parseBasicShape(bool shapeInside, bool important);
     153    bool parseBasicShape(CSSPropertyID, bool important);
    154154    PassRefPtr<CSSBasicShape> parseBasicShapeRectangle(CSSParserValueList* args);
    155155    PassRefPtr<CSSBasicShape> parseBasicShapeCircle(CSSParserValueList* args);
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r127318 r127327  
    562562    case CSSPropertyWebkitBoxReflect:
    563563    case CSSPropertyWebkitBoxShadow:
     564    case CSSPropertyWebkitClipPath:
    564565    case CSSPropertyWebkitColumnAxis:
    565566    case CSSPropertyWebkitColumnBreakAfter:
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r127318 r127327  
    9696clear
    9797clip
     98-webkit-clip-path
    9899content
    99100counter-increment
  • trunk/Source/WebCore/css/StyleBuilder.cpp

    r127318 r127327  
    17021702    {
    17031703        return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
     1704    }
     1705};
     1706
     1707template <BasicShape* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<BasicShape>), BasicShape* (*initialFunction)()>
     1708class ApplyPropertyClipPath {
     1709public:
     1710    static void setValue(RenderStyle* style, PassRefPtr<BasicShape> value) { (style->*setterFunction)(value); }
     1711    static void applyValue(StyleResolver* styleResolver, CSSValue* value)
     1712    {
     1713        if (value->isPrimitiveValue()) {
     1714            CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     1715            if (primitiveValue->getIdent() == CSSValueNone)
     1716                setValue(styleResolver->style(), 0);
     1717            else if (primitiveValue->isShape()) {
     1718                RefPtr<BasicShape> clipPathShape = basicShapeForValue(styleResolver, primitiveValue->getShapeValue());
     1719                setValue(styleResolver->style(), clipPathShape.release());
     1720            }
     1721        }
     1722    }
     1723    static PropertyHandler createHandler()
     1724    {
     1725        PropertyHandler handler = ApplyPropertyDefaultBase<BasicShape*, getterFunction, PassRefPtr<BasicShape>, setterFunction, BasicShape*, initialFunction>::createHandler();
     1726        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
    17041727    }
    17051728};
     
    20492072    setPropertyHandler(CSSPropertyWebkitUserModify, ApplyPropertyDefault<EUserModify, &RenderStyle::userModify, EUserModify, &RenderStyle::setUserModify, EUserModify, &RenderStyle::initialUserModify>::createHandler());
    20502073    setPropertyHandler(CSSPropertyWebkitUserSelect, ApplyPropertyDefault<EUserSelect, &RenderStyle::userSelect, EUserSelect, &RenderStyle::setUserSelect, EUserSelect, &RenderStyle::initialUserSelect>::createHandler());
     2074    setPropertyHandler(CSSPropertyWebkitClipPath, ApplyPropertyClipPath<&RenderStyle::clipPath, &RenderStyle::setClipPath, &RenderStyle::initialClipPath>::createHandler());
     2075
    20512076#if ENABLE(CSS_EXCLUSIONS)
    20522077    setPropertyHandler(CSSPropertyWebkitWrap, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitWrapFlow, CSSPropertyWebkitWrapMargin, CSSPropertyWebkitWrapPadding>::createHandler());
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r127112 r127327  
    681681        if (rareNonInheritedData->m_wrapShapeOutside != other->rareNonInheritedData->m_wrapShapeOutside)
    682682            return StyleDifferenceRepaint;
     683
     684        if (rareNonInheritedData->m_clipPath != other->rareNonInheritedData->m_clipPath)
     685            return StyleDifferenceRepaint;
     686
    683687
    684688#if USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r127318 r127327  
    14641464    static BasicShape* initialWrapShapeInside() { return 0; }
    14651465    static BasicShape* initialWrapShapeOutside() { return 0; }
     1466
     1467    void setClipPath(PassRefPtr<BasicShape> shape)
     1468    {
     1469        if (rareNonInheritedData->m_clipPath != shape)
     1470            rareNonInheritedData.access()->m_clipPath = shape;
     1471    }
     1472    BasicShape* clipPath() const { return rareNonInheritedData->m_clipPath.get(); }
     1473
     1474    static BasicShape* initialClipPath() { return 0; }
    14661475
    14671476    Length wrapPadding() const { return rareNonInheritedData->m_wrapPadding; }
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp

    r126154 r127327  
    4949    , m_wrapMargin(RenderStyle::initialWrapMargin())
    5050    , m_wrapPadding(RenderStyle::initialWrapPadding())
     51    , m_clipPath(RenderStyle::initialClipPath())
    5152    , m_visitedLinkBackgroundColor(RenderStyle::initialBackgroundColor())
    5253    , m_order(RenderStyle::initialOrder())
     
    119120    , m_wrapMargin(o.m_wrapMargin)
    120121    , m_wrapPadding(o.m_wrapPadding)
     122    , m_clipPath(o.m_clipPath)
    121123    , m_visitedLinkBackgroundColor(o.m_visitedLinkBackgroundColor)
    122124    , m_visitedLinkOutlineColor(o.m_visitedLinkOutlineColor)
     
    200202        && m_wrapMargin == o.m_wrapMargin
    201203        && m_wrapPadding == o.m_wrapPadding
     204        && m_clipPath == o.m_clipPath
    202205        && m_visitedLinkBackgroundColor == o.m_visitedLinkBackgroundColor
    203206        && m_visitedLinkOutlineColor == o.m_visitedLinkOutlineColor
     
    324327    info.addMember(m_wrapShapeInside);
    325328    info.addMember(m_wrapShapeOutside);
     329    info.addMember(m_clipPath);
    326330    info.addInstrumentedMember(m_flowThread);
    327331    info.addInstrumentedMember(m_regionThread);
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h

    r127155 r127327  
    139139    Length m_wrapMargin;
    140140    Length m_wrapPadding;
    141    
     141
     142    RefPtr<BasicShape> m_clipPath;
     143
    142144    Color m_visitedLinkBackgroundColor;
    143145    Color m_visitedLinkOutlineColor;
Note: See TracChangeset for help on using the changeset viewer.