Changeset 128700 in webkit


Ignore:
Timestamp:
Sep 15, 2012 9:24:24 PM (12 years ago)
Author:
krit@webkit.org
Message:

Add ClipPathOperation for -webkit-clip-path organization
https://bugs.webkit.org/show_bug.cgi?id=95619

Reviewed by Dean Jackson.

This patch adds a new class ClipPathOperation to manage the values of the
-webkit-clip-path property. ClipPathOperation stores a Path object for clipping and is
a preparation for IRI references of the SVG 'clipPath' element.

The structure of ClipPathOperation is simular to FilterOperation.

ClipPathOperation will be extended to support IRI references directly in a second patch.

No new tests. The changes just affect the backend.

  • GNUmakefile.list.am: Added new ClipPathOperation class.
  • WebCore.gypi: Ditto.
  • WebCore.vcproj/WebCore.vcproj: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • css/CSSComputedStyleDeclaration.cpp: Use ClipPathOperation instead of BasicShape.

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Ditto.

  • css/StyleBuilder.cpp: Ditto.

(WebCore):
(WebCore::ApplyPropertyClipPath::setValue):
(WebCore::ApplyPropertyClipPath::applyValue):
(WebCore::ApplyPropertyClipPath::createHandler):

  • rendering/ClipPathOperation.h: Added. New handler for property values (BasicShape, references).

(WebCore):
(ClipPathOperation):
(WebCore::ClipPathOperation::~ClipPathOperation):
(WebCore::ClipPathOperation::operator!=):
(WebCore::ClipPathOperation::getOperationType): Return the operation type.
(WebCore::ClipPathOperation::isSameType): Helper function for =operator.
(WebCore::ClipPathOperation::ClipPathOperation):
(ShapeClipPathOperation): Inheriting class for managing BasicShapes.
(WebCore::ShapeClipPathOperation::create):
(WebCore::ShapeClipPathOperation::basicShape):
(WebCore::ShapeClipPathOperation::windRule):
(WebCore::ShapeClipPathOperation::path):
(WebCore::ShapeClipPathOperation::operator==):
(WebCore::ShapeClipPathOperation::ShapeClipPathOperation):

  • rendering/RenderLayer.cpp: Use ClipPathOperation to apply clipping.

(WebCore::RenderLayer::paintLayerContents):

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

(StyleRareNonInheritedData):

  • rendering/svg/SVGRenderingContext.cpp: Ditto.

(WebCore::SVGRenderingContext::prepareToRenderSVGContent):

Location:
trunk/Source/WebCore
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r128697 r128700  
     12012-09-11  Dirk Schulze  <krit@webkit.org>
     2
     3        Add ClipPathOperation for -webkit-clip-path organization
     4        https://bugs.webkit.org/show_bug.cgi?id=95619
     5
     6        Reviewed by Dean Jackson.
     7
     8        This patch adds a new class ClipPathOperation to manage the values of the
     9        -webkit-clip-path property. ClipPathOperation stores a Path object for clipping and is
     10        a preparation for IRI references of the SVG 'clipPath' element.
     11
     12        The structure of ClipPathOperation is simular to FilterOperation.
     13
     14        ClipPathOperation will be extended to support IRI references directly in a second patch.
     15
     16        No new tests. The changes just affect the backend.
     17
     18        * GNUmakefile.list.am: Added new ClipPathOperation class.
     19        * WebCore.gypi: Ditto.
     20        * WebCore.vcproj/WebCore.vcproj: Ditto.
     21        * WebCore.xcodeproj/project.pbxproj: Ditto.
     22        * css/CSSComputedStyleDeclaration.cpp: Use ClipPathOperation instead of BasicShape.
     23        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Ditto.
     24        * css/StyleBuilder.cpp: Ditto.
     25        (WebCore):
     26        (WebCore::ApplyPropertyClipPath::setValue):
     27        (WebCore::ApplyPropertyClipPath::applyValue):
     28        (WebCore::ApplyPropertyClipPath::createHandler):
     29        * rendering/ClipPathOperation.h: Added. New handler for property values (BasicShape, references).
     30        (WebCore):
     31        (ClipPathOperation):
     32        (WebCore::ClipPathOperation::~ClipPathOperation):
     33        (WebCore::ClipPathOperation::operator!=):
     34        (WebCore::ClipPathOperation::getOperationType): Return the operation type.
     35        (WebCore::ClipPathOperation::isSameType): Helper function for =operator.
     36        (WebCore::ClipPathOperation::ClipPathOperation):
     37        (ShapeClipPathOperation): Inheriting class for managing BasicShapes.
     38        (WebCore::ShapeClipPathOperation::create):
     39        (WebCore::ShapeClipPathOperation::basicShape):
     40        (WebCore::ShapeClipPathOperation::windRule):
     41        (WebCore::ShapeClipPathOperation::path):
     42        (WebCore::ShapeClipPathOperation::operator==):
     43        (WebCore::ShapeClipPathOperation::ShapeClipPathOperation):
     44        * rendering/RenderLayer.cpp: Use ClipPathOperation to apply clipping.
     45        (WebCore::RenderLayer::paintLayerContents):
     46        * rendering/style/RenderStyle.h:
     47        * rendering/style/StyleRareNonInheritedData.h:
     48        (StyleRareNonInheritedData):
     49        * rendering/svg/SVGRenderingContext.cpp: Ditto.
     50        (WebCore::SVGRenderingContext::prepareToRenderSVGContent):
     51
    1522012-09-15  Andreas Kling  <kling@webkit.org>
    253
  • trunk/Source/WebCore/GNUmakefile.list.am

    r128696 r128700  
    51185118        Source/WebCore/rendering/style/BorderData.h \
    51195119        Source/WebCore/rendering/style/BorderValue.h \
     5120        Source/WebCore/rendering/style/ClipPathOperation.h \
    51205121        Source/WebCore/rendering/style/CollapsedBorderValue.h \
    51215122        Source/WebCore/rendering/style/ContentData.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r128626 r128700  
    592592            'rendering/style/BorderData.h',
    593593            'rendering/style/BorderValue.h',
     594            'rendering/style/ClipPathOperation.h',
    594595            'rendering/style/CollapsedBorderValue.h',
    595596            'rendering/style/ContentData.h',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r128626 r128700  
    4668846688                                        >
    4668946689                                </File>
     46690                                <File
     46691                                        RelativePath="..\rendering\style\ClipPathOperation.h"
     46692                                        >
     46693                                </File>
    4669046694                        </Filter>
    4669146695                        <Filter
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r128626 r128700  
    63176317                FABE72FE1059C21100D999DD /* MathMLNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72FC1059C21100D999DD /* MathMLNames.cpp */; };
    63186318                FB78AD2E151BF5E600FE54D3 /* CSSParserMode.h in Headers */ = {isa = PBXBuildFile; fileRef = FB78AD2C151BF5D200FE54D3 /* CSSParserMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
     6319                FB92DF4B15FED08700994433 /* ClipPathOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = FB92DF4915FED08700994433 /* ClipPathOperation.h */; settings = {ATTRIBUTES = (Private, ); }; };
    63196320                FBC220DF1237FBEB00BCF788 /* GraphicsContext3DOpenGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FBC220DE1237FBEB00BCF788 /* GraphicsContext3DOpenGL.cpp */; };
    63206321                FBD6AF8815EF25C9008B7110 /* CSSBasicShapes.h in Headers */ = {isa = PBXBuildFile; fileRef = FBD6AF8715EF21D4008B7110 /* CSSBasicShapes.h */; };
     
    1373313734                FABE72FC1059C21100D999DD /* MathMLNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLNames.cpp; sourceTree = "<group>"; };
    1373413735                FB78AD2C151BF5D200FE54D3 /* CSSParserMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSParserMode.h; sourceTree = "<group>"; };
     13736                FB92DF4915FED08700994433 /* ClipPathOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClipPathOperation.h; sourceTree = "<group>"; };
    1373513737                FBC220DE1237FBEB00BCF788 /* GraphicsContext3DOpenGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DOpenGL.cpp; sourceTree = "<group>"; };
    1373613738                FBD6AF8215EF21A3008B7110 /* BasicShapes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BasicShapes.cpp; path = style/BasicShapes.cpp; sourceTree = "<group>"; };
     
    2046720469                                BC5EB5E00E81BE8700B25965 /* BorderData.h */,
    2046820470                                BC5EB5DA0E81B7EA00B25965 /* BorderValue.h */,
     20471                                FB92DF4915FED08700994433 /* ClipPathOperation.h */,
    2046920472                                BC5EB5DE0E81B9AB00B25965 /* CollapsedBorderValue.h */,
    2047020473                                BC5EB97E0E82072500B25965 /* ContentData.cpp */,
     
    2555925562                                977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
    2556025563                                FD537353137B651800008DCE /* ZeroPole.h in Headers */,
     25564                                FB92DF4B15FED08700994433 /* ClipPathOperation.h in Headers */,
    2556125565                                4F7B4A6615FF6D6A006B5F22 /* PlatformMemoryInstrumentation.h in Headers */,
    2556225566                        );
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r128626 r128700  
    24182418            return counterToCSSValue(style.get(), propertyID);
    24192419        case CSSPropertyWebkitClipPath:
    2420             if (!style->clipPath())
    2421                 return cssValuePool().createIdentifierValue(CSSValueNone);
    2422             return valueForBasicShape(style->clipPath());
     2420            if (ClipPathOperation* operation = style->clipPath()) {
     2421                if (operation->getOperationType() == ClipPathOperation::SHAPE)
     2422                    return valueForBasicShape(static_cast<ShapeClipPathOperation*>(operation)->basicShape());
     2423            }
     2424            return cssValuePool().createIdentifierValue(CSSValueNone);
    24232425#if ENABLE(CSS_REGIONS)
    24242426        case CSSPropertyWebkitFlowInto:
  • trunk/Source/WebCore/css/StyleBuilder.cpp

    r128660 r128700  
    3434#include "CSSToStyleMap.h"
    3535#include "CSSValueList.h"
     36#include "ClipPathOperation.h"
    3637#include "CursorList.h"
    3738#include "Document.h"
     
    16851686};
    16861687
    1687 template <BasicShape* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<BasicShape>), BasicShape* (*initialFunction)()>
     1688template <ClipPathOperation* (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(PassRefPtr<ClipPathOperation>), ClipPathOperation* (*initialFunction)()>
    16881689class ApplyPropertyClipPath {
    16891690public:
    1690     static void setValue(RenderStyle* style, PassRefPtr<BasicShape> value) { (style->*setterFunction)(value); }
     1691    static void setValue(RenderStyle* style, PassRefPtr<ClipPathOperation> value) { (style->*setterFunction)(value); }
    16911692    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
    16921693    {
     
    16961697                setValue(styleResolver->style(), 0);
    16971698            else if (primitiveValue->isShape()) {
    1698                 RefPtr<BasicShape> clipPathShape = basicShapeForValue(styleResolver, primitiveValue->getShapeValue());
    1699                 setValue(styleResolver->style(), clipPathShape.release());
     1699                setValue(styleResolver->style(), ShapeClipPathOperation::create(basicShapeForValue(styleResolver, primitiveValue->getShapeValue())));
    17001700            }
    17011701        }
     
    17031703    static PropertyHandler createHandler()
    17041704    {
    1705         PropertyHandler handler = ApplyPropertyDefaultBase<BasicShape*, getterFunction, PassRefPtr<BasicShape>, setterFunction, BasicShape*, initialFunction>::createHandler();
     1705        PropertyHandler handler = ApplyPropertyDefaultBase<ClipPathOperation*, getterFunction, PassRefPtr<ClipPathOperation>, setterFunction, ClipPathOperation*, initialFunction>::createHandler();
    17061706        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
    17071707    }
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r128677 r128700  
    31173117    RenderStyle* style = renderer()->style();
    31183118    if (renderer()->hasClipPath() && !context->paintingDisabled() && style) {
    3119         if (BasicShape* clipShape = style->clipPath()) {
    3120             // FIXME: Investigate if it is better to store and update a Path object in RenderStyle.
    3121             // https://bugs.webkit.org/show_bug.cgi?id=95619
    3122             Path clipPath;
    3123             clipShape->path(clipPath, calculateLayerBounds(this, rootLayer, 0));
    3124             transparencyLayerContext->clipPath(clipPath, clipShape->windRule());
     3119        ASSERT(style->clipPath());
     3120        if (style->clipPath()->getOperationType() == ClipPathOperation::SHAPE) {
     3121            ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperation*>(style->clipPath());
     3122            transparencyLayerContext->clipPath(clipPath->path(calculateLayerBounds(this, rootLayer, 0)), clipPath->windRule());
    31253123        }
    31263124    }
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r128508 r128700  
    14631463    static BasicShape* initialWrapShapeOutside() { return 0; }
    14641464
    1465     void setClipPath(PassRefPtr<BasicShape> shape)
    1466     {
    1467         if (rareNonInheritedData->m_clipPath != shape)
    1468             rareNonInheritedData.access()->m_clipPath = shape;
    1469     }
    1470     BasicShape* clipPath() const { return rareNonInheritedData->m_clipPath.get(); }
    1471 
    1472     static BasicShape* initialClipPath() { return 0; }
     1465    void setClipPath(PassRefPtr<ClipPathOperation> operation)
     1466    {
     1467        if (rareNonInheritedData->m_clipPath != operation)
     1468            rareNonInheritedData.access()->m_clipPath = operation;
     1469    }
     1470    ClipPathOperation* clipPath() const { return rareNonInheritedData->m_clipPath.get(); }
     1471
     1472    static ClipPathOperation* initialClipPath() { return 0; }
    14731473
    14741474    Length wrapPadding() const { return rareNonInheritedData->m_wrapPadding; }
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h

    r128418 r128700  
    2727
    2828#include "BasicShapes.h"
     29#include "ClipPathOperation.h"
    2930#include "CounterDirectives.h"
    3031#include "CursorData.h"
     
    139140    Length m_wrapPadding;
    140141
    141     RefPtr<BasicShape> m_clipPath;
     142    RefPtr<ClipPathOperation> m_clipPath;
    142143
    143144    Color m_visitedLinkBackgroundColor;
  • trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp

    r127383 r128700  
    124124    }
    125125
    126     BasicShape* clipShape = style->clipPath();
    127     if (clipShape) {
    128         // FIXME: Investigate if it is better to store and update a Path object in RenderStyle.
    129         // https://bugs.webkit.org/show_bug.cgi?id=95619
    130         Path clipPath;
    131         clipShape->path(clipPath, object->objectBoundingBox());
    132         m_paintInfo->context->clipPath(clipPath, clipShape->windRule());
     126    ClipPathOperation* clipPathOperation = style->clipPath();
     127    if (clipPathOperation && clipPathOperation->getOperationType() == ClipPathOperation::SHAPE) {
     128        ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperation*>(clipPathOperation);
     129        m_paintInfo->context->clipPath(clipPath->path(object->objectBoundingBox()), clipPath->windRule());
    133130    }
    134131
     
    151148
    152149    RenderSVGResourceClipper* clipper = resources->clipper();
    153     if (!clipShape && clipper) {
     150    if (!clipPathOperation && clipper) {
    154151        if (!clipper->applyResource(m_object, style, m_paintInfo->context, ApplyToDefaultMode))
    155152            return;
Note: See TracChangeset for help on using the changeset viewer.