2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef LayoutSVGResourceClipper_h
21 #define LayoutSVGResourceClipper_h
23 #include "core/layout/svg/LayoutSVGResourceContainer.h"
24 #include "core/svg/SVGClipPathElement.h"
30 class LayoutSVGResourceClipper final
: public LayoutSVGResourceContainer
{
32 explicit LayoutSVGResourceClipper(SVGClipPathElement
*);
33 ~LayoutSVGResourceClipper() override
;
35 const char* name() const override
{ return "LayoutSVGResourceClipper"; }
37 void removeAllClientsFromCache(bool markForInvalidation
= true) override
;
38 void removeClientFromCache(LayoutObject
*, bool markForInvalidation
= true) override
;
40 FloatRect
resourceBoundingBox(const LayoutObject
*);
42 static const LayoutSVGResourceType s_resourceType
= ClipperResourceType
;
43 LayoutSVGResourceType
resourceType() const override
{ return s_resourceType
; }
45 bool hitTestClipContent(const FloatRect
&, const FloatPoint
&);
47 SVGUnitTypes::SVGUnitType
clipPathUnits() const { return toSVGClipPathElement(element())->clipPathUnits()->currentValue()->enumValue(); }
49 bool asPath(const AffineTransform
&, const FloatRect
& referenceBox
, Path
&);
50 PassRefPtr
<const SkPicture
> createContentPicture(AffineTransform
&, const FloatRect
&, GraphicsContext
*);
52 bool hasCycle() { return m_inClipExpansion
; }
53 void beginClipExpansion() { ASSERT(!m_inClipExpansion
); m_inClipExpansion
= true; }
54 void endClipExpansion() { ASSERT(m_inClipExpansion
); m_inClipExpansion
= false; }
56 void calculateClipContentPaintInvalidationRect();
58 RefPtr
<const SkPicture
> m_clipContentPicture
;
59 FloatRect m_clipBoundaries
;
61 // Reference cycle detection.
62 bool m_inClipExpansion
;
65 DEFINE_LAYOUT_SVG_RESOURCE_TYPE_CASTS(LayoutSVGResourceClipper
, ClipperResourceType
);