1 | /* |
2 | * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> |
3 | * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. |
4 | * Copyright (C) 2007 Rob Buis <buis@kde.org> |
5 | * Copyright (C) 2009 Google, Inc. |
6 | * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> |
7 | * |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; either |
11 | * version 2 of the License, or (at your option) any later version. |
12 | * |
13 | * This library is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Library General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU Library General Public License |
19 | * along with this library; see the file COPYING.LIB. If not, write to |
20 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 | * Boston, MA 02110-1301, USA. |
22 | */ |
23 | |
24 | #pragma once |
25 | |
26 | #include "AffineTransform.h" |
27 | #include "FloatRect.h" |
28 | #include "RenderSVGModelObject.h" |
29 | |
30 | namespace WebCore { |
31 | |
32 | class RenderImageResource; |
33 | class SVGImageElement; |
34 | |
35 | class RenderSVGImage final : public RenderSVGModelObject { |
36 | WTF_MAKE_ISO_ALLOCATED(RenderSVGImage); |
37 | public: |
38 | RenderSVGImage(SVGImageElement&, RenderStyle&&); |
39 | virtual ~RenderSVGImage(); |
40 | |
41 | SVGImageElement& imageElement() const; |
42 | |
43 | bool updateImageViewport(); |
44 | void setNeedsBoundariesUpdate() override { m_needsBoundariesUpdate = true; } |
45 | bool needsBoundariesUpdate() override { return m_needsBoundariesUpdate; } |
46 | void setNeedsTransformUpdate() override { m_needsTransformUpdate = true; } |
47 | |
48 | RenderImageResource& imageResource() { return *m_imageResource; } |
49 | const RenderImageResource& imageResource() const { return *m_imageResource; } |
50 | |
51 | // Note: Assumes the PaintInfo context has had all local transforms applied. |
52 | void paintForeground(PaintInfo&); |
53 | |
54 | private: |
55 | void willBeDestroyed() override; |
56 | |
57 | void element() const = delete; |
58 | |
59 | const char* renderName() const override { return "RenderSVGImage" ; } |
60 | bool isSVGImage() const override { return true; } |
61 | bool canHaveChildren() const override { return false; } |
62 | |
63 | const AffineTransform& localToParentTransform() const override { return m_localTransform; } |
64 | |
65 | FloatRect objectBoundingBox() const override { return m_objectBoundingBox; } |
66 | FloatRect strokeBoundingBox() const override { return m_objectBoundingBox; } |
67 | FloatRect repaintRectInLocalCoordinates() const override { return m_repaintBoundingBox; } |
68 | |
69 | void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) override; |
70 | |
71 | void imageChanged(WrappedImagePtr, const IntRect* = nullptr) override; |
72 | |
73 | void layout() override; |
74 | void paint(PaintInfo&, const LayoutPoint&) override; |
75 | |
76 | void invalidateBufferedForeground(); |
77 | |
78 | bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction) override; |
79 | |
80 | AffineTransform localTransform() const override { return m_localTransform; } |
81 | void calculateImageViewport(); |
82 | |
83 | bool m_needsBoundariesUpdate : 1; |
84 | bool m_needsTransformUpdate : 1; |
85 | AffineTransform m_localTransform; |
86 | FloatRect m_objectBoundingBox; |
87 | FloatRect m_repaintBoundingBox; |
88 | FloatRect m_repaintBoundingBoxExcludingShadow; |
89 | std::unique_ptr<RenderImageResource> m_imageResource; |
90 | std::unique_ptr<ImageBuffer> m_bufferedForeground; |
91 | }; |
92 | |
93 | } // namespace WebCore |
94 | |
95 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGImage, isSVGImage()) |
96 | |