1 | /* |
2 | * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
3 | * |
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. |
8 | * |
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. |
13 | * |
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. |
18 | */ |
19 | |
20 | #pragma once |
21 | |
22 | #include "RenderSVGResourceContainer.h" |
23 | #include "SVGMarkerElement.h" |
24 | |
25 | namespace WebCore { |
26 | |
27 | class AffineTransform; |
28 | class RenderObject; |
29 | |
30 | class RenderSVGResourceMarker final : public RenderSVGResourceContainer { |
31 | WTF_MAKE_ISO_ALLOCATED(RenderSVGResourceMarker); |
32 | public: |
33 | RenderSVGResourceMarker(SVGMarkerElement&, RenderStyle&&); |
34 | virtual ~RenderSVGResourceMarker(); |
35 | |
36 | SVGMarkerElement& markerElement() const { return downcast<SVGMarkerElement>(RenderSVGResourceContainer::element()); } |
37 | |
38 | void removeAllClientsFromCache(bool markForInvalidation = true) override; |
39 | void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override; |
40 | |
41 | void draw(PaintInfo&, const AffineTransform&); |
42 | |
43 | // Calculates marker boundaries, mapped to the target element's coordinate space |
44 | FloatRect markerBoundaries(const AffineTransform& markerTransformation) const; |
45 | |
46 | void applyViewportClip(PaintInfo&) override; |
47 | void layout() override; |
48 | void calcViewport() override; |
49 | |
50 | const AffineTransform& localToParentTransform() const override; |
51 | AffineTransform markerTransformation(const FloatPoint& origin, float angle, float strokeWidth) const; |
52 | |
53 | bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>) override { return false; } |
54 | FloatRect resourceBoundingBox(const RenderObject&) override { return FloatRect(); } |
55 | |
56 | FloatPoint referencePoint() const; |
57 | float angle() const; |
58 | SVGMarkerUnitsType markerUnits() const { return markerElement().markerUnits(); } |
59 | |
60 | RenderSVGResourceType resourceType() const override { return MarkerResourceType; } |
61 | |
62 | private: |
63 | void element() const = delete; |
64 | |
65 | const char* renderName() const override { return "RenderSVGResourceMarker" ; } |
66 | |
67 | // Generates a transformation matrix usable to render marker content. Handles scaling the marker content |
68 | // acording to SVGs markerUnits="strokeWidth" concept, when a strokeWidth value != -1 is passed in. |
69 | AffineTransform markerContentTransformation(const AffineTransform& contentTransformation, const FloatPoint& origin, float strokeWidth = -1) const; |
70 | |
71 | AffineTransform viewportTransform() const; |
72 | |
73 | mutable AffineTransform m_localToParentTransform; |
74 | FloatRect m_viewport; |
75 | }; |
76 | |
77 | } // namespace WebCore |
78 | |
79 | SPECIALIZE_TYPE_TRAITS_RENDER_SVG_RESOURCE(RenderSVGResourceMarker, MarkerResourceType) |
80 | |