Changeset 130592 in webkit


Ignore:
Timestamp:
Oct 6, 2012 6:35:26 PM (12 years ago)
Author:
krit@webkit.org
Message:

-webkit-clip-path should parse IRIs
https://bugs.webkit.org/show_bug.cgi?id=96381

Patch by Raul Hudea <rhudea@adobe.com> on 2012-10-06
Reviewed by Andreas Kling.

Source/WebCore:

Implemented the clipping via referencing a SVG clipPath. Currently it works only if the clipPath is defined
before using it on an HTML element. The forward reference issue is tracked via https://bugs.webkit.org/show_bug.cgi?id=90405.

Tests: css3/masking/clip-path-reference-userSpaceOnUse.html

css3/masking/clip-path-reference.html
fast/masking/parsing-clip-path-iri.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Add handling for SVG clipPath references.

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue): Add handling for SVG clipPath references.

  • css/StyleBuilder.cpp:

(WebCore::ApplyPropertyClipPath::applyValue): Add handling for SVG references.

  • rendering/ClipPathOperation.h:

(ReferenceClipPathOperation): Added a new class corresponding to SVG referenced clipPath.
(WebCore::ReferenceClipPathOperation::create):
(WebCore::ReferenceClipPathOperation::url):
(WebCore::ReferenceClipPathOperation::fragment):
(WebCore::ReferenceClipPathOperation::operator==):
(WebCore::ReferenceClipPathOperation::ReferenceClipPathOperation):
(WebCore):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::paintLayerContents): Add handling for ReferenceClipPathOperation.

  • rendering/svg/RenderSVGResourceClipper.h:

(RenderSVGResourceClipper): Made applyClippingToContext public as it needs to be called directly for HTML elements.

LayoutTests:

Tests for SVG referenced clipPath with both types of clipPathUnits: "userSpaceOnUse" and "objectBoundingBox".

  • css3/masking/clip-path-reference-expected.html: Added.
  • css3/masking/clip-path-reference-userSpaceOnUse-expected.html: Added.
  • css3/masking/clip-path-reference-userSpaceOnUse.html: Added.
  • css3/masking/clip-path-reference.html: Added.
  • fast/masking/parsing-clip-path-iri-expected.txt: Added.
  • fast/masking/parsing-clip-path-iri.html: Added.
  • platform/chromium/TestExpectations:
Location:
trunk
Files:
8 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r130589 r130592  
     12012-10-06  Raul Hudea  <rhudea@adobe.com>
     2
     3        -webkit-clip-path should parse IRIs
     4        https://bugs.webkit.org/show_bug.cgi?id=96381
     5
     6        Reviewed by Andreas Kling.
     7
     8        Tests for SVG referenced clipPath with both types of clipPathUnits: "userSpaceOnUse" and "objectBoundingBox".
     9
     10        * css3/masking/clip-path-reference-expected.html: Added.
     11        * css3/masking/clip-path-reference-userSpaceOnUse-expected.html: Added.
     12        * css3/masking/clip-path-reference-userSpaceOnUse.html: Added.
     13        * css3/masking/clip-path-reference.html: Added.
     14        * fast/masking/parsing-clip-path-iri-expected.txt: Added.
     15        * fast/masking/parsing-clip-path-iri.html: Added.
     16        * platform/chromium/TestExpectations:
     17
    1182012-10-06  Raphael Kubo da Costa  <raphael.kubo.da.costa@intel.com>
    219
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r130575 r130592  
    14451445crbug.com/10342 [ Android Linux Mac ] fast/loader/file-URL-with-port-number.html [ WontFix ]
    14461446
     1447# Clipping differences between Chromium platforms. Needs investigation.
     1448webkit.org/b/98599 css3/masking/clip-path-reference-userSpaceOnUse.html [ ImageOnlyFailure ]
    14471449
    14481450# Started timing out with agl's complex text change.  Page is verrry slow.
  • trunk/Source/WebCore/ChangeLog

    r130591 r130592  
     12012-10-06  Raul Hudea  <rhudea@adobe.com>
     2
     3        -webkit-clip-path should parse IRIs
     4        https://bugs.webkit.org/show_bug.cgi?id=96381
     5
     6        Reviewed by Andreas Kling.
     7
     8        Implemented the clipping via referencing a SVG clipPath. Currently it works only if the clipPath is defined
     9        before using it on an HTML element. The forward reference issue is tracked via https://bugs.webkit.org/show_bug.cgi?id=90405.
     10
     11        Tests: css3/masking/clip-path-reference-userSpaceOnUse.html
     12               css3/masking/clip-path-reference.html
     13               fast/masking/parsing-clip-path-iri.html
     14
     15        * css/CSSComputedStyleDeclaration.cpp:
     16        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Add handling for SVG clipPath references.
     17        * css/CSSParser.cpp:
     18        (WebCore::CSSParser::parseValue): Add handling for SVG clipPath references.
     19        * css/StyleBuilder.cpp:
     20        (WebCore::ApplyPropertyClipPath::applyValue): Add handling for SVG references.
     21        * rendering/ClipPathOperation.h:
     22        (ReferenceClipPathOperation): Added a new class corresponding to SVG referenced clipPath.
     23        (WebCore::ReferenceClipPathOperation::create):
     24        (WebCore::ReferenceClipPathOperation::url):
     25        (WebCore::ReferenceClipPathOperation::fragment):
     26        (WebCore::ReferenceClipPathOperation::operator==):
     27        (WebCore::ReferenceClipPathOperation::ReferenceClipPathOperation):
     28        (WebCore):
     29        * rendering/RenderLayer.cpp:
     30        (WebCore::RenderLayer::paintLayerContents): Add handling for ReferenceClipPathOperation.
     31        * rendering/svg/RenderSVGResourceClipper.h:
     32        (RenderSVGResourceClipper): Made applyClippingToContext public as it needs to be called directly for HTML elements.
     33
    1342012-10-06  Pratik Solanki  <psolanki@apple.com>
    235
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r130277 r130592  
    24692469                if (operation->getOperationType() == ClipPathOperation::SHAPE)
    24702470                    return valueForBasicShape(static_cast<ShapeClipPathOperation*>(operation)->basicShape());
     2471#if ENABLE(SVG)
     2472                else if (operation->getOperationType() == ClipPathOperation::REFERENCE) {
     2473                    ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
     2474                    return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
     2475                }
     2476#endif
    24712477            }
    24722478            return cssValuePool().createIdentifierValue(CSSValueNone);
  • trunk/Source/WebCore/css/CSSParser.cpp

    r130511 r130592  
    27662766        else if (value->unit == CSSParserValue::Function)
    27672767            return parseBasicShape(propId, important);
     2768#if ENABLE(SVG)
     2769        else if (value->unit == CSSPrimitiveValue::CSS_URI) {
     2770            parsedValue = CSSPrimitiveValue::create(value->string, CSSPrimitiveValue::CSS_URI);
     2771            addProperty(propId, parsedValue.release(), important);
     2772            return true;
     2773        }
     2774#endif
    27682775        break;
    27692776#if ENABLE(CSS_EXCLUSIONS)
  • trunk/Source/WebCore/css/StyleBuilder.cpp

    r130142 r130592  
    16991699                setValue(styleResolver->style(), ShapeClipPathOperation::create(basicShapeForValue(styleResolver, primitiveValue->getShapeValue())));
    17001700            }
     1701#if ENABLE(SVG)
     1702            else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI) {
     1703                String cssURLValue = primitiveValue->getStringValue();
     1704                KURL url = styleResolver->document()->completeURL(cssURLValue);
     1705                // FIXME: It doesn't work with forward or external SVG references (see https://bugs.webkit.org/show_bug.cgi?id=90405)
     1706                setValue(styleResolver->style(), ReferenceClipPathOperation::create(cssURLValue, url.fragmentIdentifier()));
     1707            }
     1708#endif
    17011709        }
    17021710    }
  • trunk/Source/WebCore/rendering/ClipPathOperation.h

    r128700 r130592  
    4343public:
    4444    enum OperationType {
    45         // FIXME: Add referencing for IRI https://bugs.webkit.org/show_bug.cgi?id=96381
     45        REFERENCE,
    4646        SHAPE
    4747    };
     
    6262
    6363    OperationType m_type;
     64};
     65
     66class ReferenceClipPathOperation : public ClipPathOperation {
     67public:
     68    static PassRefPtr<ReferenceClipPathOperation> create(const String& url, const String& fragment)
     69    {
     70        return adoptRef(new ReferenceClipPathOperation(url, fragment));
     71    }
     72
     73    const String& url() const { return m_url; }
     74    const String& fragment() const { return m_fragment; }
     75
     76private:
     77    virtual bool operator==(const ClipPathOperation& o) const
     78    {
     79        if (!isSameType(o))
     80            return false;
     81        const ReferenceClipPathOperation* other = static_cast<const ReferenceClipPathOperation*>(&o);
     82        return m_url == other->m_url;
     83    }
     84
     85    ReferenceClipPathOperation(const String& url, const String& fragment)
     86        : ClipPathOperation(REFERENCE)
     87        , m_url(url)
     88        , m_fragment(fragment)
     89    {
     90    }
     91
     92    String m_url;
     93    String m_fragment;
    6494};
    6595
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r130355 r130592  
    8181#include "RenderMarquee.h"
    8282#include "RenderReplica.h"
     83#include "RenderSVGResourceClipper.h"
    8384#include "RenderScrollbar.h"
    8485#include "RenderScrollbarPart.h"
     
    31403141            context->clipPath(clipPath->path(calculateLayerBounds(this, rootLayer, 0)), clipPath->windRule());
    31413142        }
     3143#if ENABLE(SVG)
     3144        else if (style->clipPath()->getOperationType() == ClipPathOperation::REFERENCE) {
     3145            ReferenceClipPathOperation* referenceClipPathOperation = static_cast<ReferenceClipPathOperation*>(style->clipPath());
     3146            Document* document = renderer()->document();
     3147            // FIXME: It doesn't work with forward or external SVG references (https://bugs.webkit.org/show_bug.cgi?id=90405)
     3148            Element* clipPath = document ? document->getElementById(referenceClipPathOperation->fragment()) : 0;
     3149            if (clipPath && clipPath->renderer() && clipPath->renderer()->isSVGResourceContainer())
     3150                static_cast<RenderSVGResourceClipper*>(clipPath->renderer())->applyClippingToContext(renderer(), calculateLayerBounds(this, rootLayer, 0), paintDirtyRect, context);
     3151        }
     3152#endif
    31423153    }
    31433154
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h

    r105978 r130592  
    5353
    5454    virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
     55    // clipPath can be clipped too, but don't have a boundingBox or repaintRect. So we can't call
     56    // applyResource directly and use the rects from the object, since they are empty for RenderSVGResources
     57    // FIXME: We made applyClippingToContext public because we cannot call applyResource on HTML elements (it asserts on RenderObject::objectBoundingBox)
     58    bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect&, GraphicsContext*);
    5559    virtual FloatRect resourceBoundingBox(RenderObject*);
    5660
     
    6367    static RenderSVGResourceType s_resourceType;
    6468private:
    65     // clipPath can be clipped too, but don't have a boundingBox or repaintRect. So we can't call
    66     // applyResource directly and use the rects from the object, since they are empty for RenderSVGResources
    67     bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect&, GraphicsContext*);
    6869    bool pathOnlyClipping(GraphicsContext*, const AffineTransform&, const FloatRect&);
    6970    bool drawContentIntoMaskImage(ClipperData*, const FloatRect& objectBoundingBox);
Note: See TracChangeset for help on using the changeset viewer.