1 | /* |
2 | * Copyright (C) 2006 Apple Inc. |
3 | * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
4 | * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Library General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Library General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Library General Public License |
17 | * along with this library; see the file COPYING.LIB. If not, write to |
18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | * Boston, MA 02110-1301, USA. |
20 | */ |
21 | |
22 | #pragma once |
23 | |
24 | #include "AffineTransform.h" |
25 | #include "RenderSVGBlock.h" |
26 | #include "SVGTextLayoutAttributesBuilder.h" |
27 | |
28 | namespace WebCore { |
29 | |
30 | class RenderSVGInlineText; |
31 | class SVGTextElement; |
32 | class RenderSVGInlineText; |
33 | |
34 | class RenderSVGText final : public RenderSVGBlock { |
35 | WTF_MAKE_ISO_ALLOCATED(RenderSVGText); |
36 | public: |
37 | RenderSVGText(SVGTextElement&, RenderStyle&&); |
38 | virtual ~RenderSVGText(); |
39 | |
40 | SVGTextElement& textElement() const; |
41 | |
42 | bool isChildAllowed(const RenderObject&, const RenderStyle&) const override; |
43 | |
44 | void setNeedsPositioningValuesUpdate() { m_needsPositioningValuesUpdate = true; } |
45 | void setNeedsTransformUpdate() override { m_needsTransformUpdate = true; } |
46 | void setNeedsTextMetricsUpdate() { m_needsTextMetricsUpdate = true; } |
47 | FloatRect repaintRectInLocalCoordinates() const override; |
48 | |
49 | static RenderSVGText* locateRenderSVGTextAncestor(RenderObject&); |
50 | static const RenderSVGText* locateRenderSVGTextAncestor(const RenderObject&); |
51 | |
52 | bool needsReordering() const { return m_needsReordering; } |
53 | Vector<SVGTextLayoutAttributes*>& layoutAttributes() { return m_layoutAttributes; } |
54 | |
55 | void subtreeChildWasAdded(RenderObject*); |
56 | void subtreeChildWillBeRemoved(RenderObject*, Vector<SVGTextLayoutAttributes*, 2>& affectedAttributes); |
57 | void subtreeChildWasRemoved(const Vector<SVGTextLayoutAttributes*, 2>& affectedAttributes); |
58 | void subtreeStyleDidChange(RenderSVGInlineText*); |
59 | void subtreeTextDidChange(RenderSVGInlineText*); |
60 | |
61 | FloatRect objectBoundingBox() const override { return frameRect(); } |
62 | FloatRect strokeBoundingBox() const override; |
63 | |
64 | private: |
65 | void graphicsElement() const = delete; |
66 | |
67 | const char* renderName() const override { return "RenderSVGText" ; } |
68 | bool isSVGText() const override { return true; } |
69 | |
70 | void paint(PaintInfo&, const LayoutPoint&) override; |
71 | bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override; |
72 | bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction) override; |
73 | VisiblePosition positionForPoint(const LayoutPoint&, const RenderFragmentContainer*) override; |
74 | |
75 | bool requiresLayer() const override { return false; } |
76 | void layout() override; |
77 | |
78 | void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const override; |
79 | |
80 | LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const override; |
81 | Optional<LayoutRect> computeVisibleRectInContainer(const LayoutRect&, const RenderLayerModelObject* container, VisibleRectContext) const override; |
82 | Optional<FloatRect> computeFloatVisibleRectInContainer(const FloatRect&, const RenderLayerModelObject* container, VisibleRectContext) const override; |
83 | |
84 | void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed) const override; |
85 | const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const override; |
86 | void willBeDestroyed() override; |
87 | |
88 | const AffineTransform& localToParentTransform() const override { return m_localTransform; } |
89 | AffineTransform localTransform() const override { return m_localTransform; } |
90 | std::unique_ptr<RootInlineBox> createRootInlineBox() override; |
91 | |
92 | RenderBlock* firstLineBlock() const override; |
93 | |
94 | bool shouldHandleSubtreeMutations() const; |
95 | |
96 | bool m_needsReordering : 1; |
97 | bool m_needsPositioningValuesUpdate : 1; |
98 | bool m_needsTransformUpdate : 1; |
99 | bool m_needsTextMetricsUpdate : 1; |
100 | AffineTransform m_localTransform; |
101 | SVGTextLayoutAttributesBuilder m_layoutAttributesBuilder; |
102 | Vector<SVGTextLayoutAttributes*> m_layoutAttributes; |
103 | }; |
104 | |
105 | } // namespace WebCore |
106 | |
107 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGText, isSVGText()) |
108 | |