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.
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.
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.
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.
22 #ifndef RenderSVGText_h
23 #define RenderSVGText_h
25 #include "AffineTransform.h"
26 #include "RenderSVGBlock.h"
27 #include "SVGTextLayoutAttributesBuilder.h"
31 class RenderSVGInlineText;
33 class RenderSVGInlineText;
35 class RenderSVGText final : public RenderSVGBlock {
37 RenderSVGText(SVGTextElement&, RenderStyle&&);
38 virtual ~RenderSVGText();
40 SVGTextElement& textElement() const;
42 bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
44 void setNeedsPositioningValuesUpdate() { m_needsPositioningValuesUpdate = true; }
45 void setNeedsTransformUpdate() override { m_needsTransformUpdate = true; }
46 void setNeedsTextMetricsUpdate() { m_needsTextMetricsUpdate = true; }
47 FloatRect repaintRectInLocalCoordinates() const override;
49 static RenderSVGText* locateRenderSVGTextAncestor(RenderObject&);
50 static const RenderSVGText* locateRenderSVGTextAncestor(const RenderObject&);
52 bool needsReordering() const { return m_needsReordering; }
53 Vector<SVGTextLayoutAttributes*>& layoutAttributes() { return m_layoutAttributes; }
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*);
61 FloatRect objectBoundingBox() const override { return frameRect(); }
62 FloatRect strokeBoundingBox() const override;
65 void graphicsElement() const = delete;
67 const char* renderName() const override { return "RenderSVGText"; }
68 bool isSVGText() const override { return true; }
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 RenderRegion*) override;
75 bool requiresLayer() const override { return false; }
76 void layout() override;
78 void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const override;
80 LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const override;
81 LayoutRect computeRectForRepaint(const LayoutRect&, const RenderLayerModelObject* repaintContainer, RepaintContext = { }) const override;
82 FloatRect computeFloatRectForRepaint(const FloatRect&, const RenderLayerModelObject* repaintContainer, bool fixed = false) const override;
84 void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed) const override;
85 const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const override;
86 void addChild(RenderObject* child, RenderObject* beforeChild = nullptr) override;
87 void removeChild(RenderObject&) override;
88 void willBeDestroyed() override;
90 const AffineTransform& localToParentTransform() const override { return m_localTransform; }
91 AffineTransform localTransform() const override { return m_localTransform; }
92 std::unique_ptr<RootInlineBox> createRootInlineBox() override;
94 RenderBlock* firstLineBlock() const override;
95 void updateFirstLetter() override;
97 bool shouldHandleSubtreeMutations() const;
99 bool m_needsReordering : 1;
100 bool m_needsPositioningValuesUpdate : 1;
101 bool m_needsTransformUpdate : 1;
102 bool m_needsTextMetricsUpdate : 1;
103 AffineTransform m_localTransform;
104 SVGTextLayoutAttributesBuilder m_layoutAttributesBuilder;
105 Vector<SVGTextLayoutAttributes*> m_layoutAttributes;
108 } // namespace WebCore
110 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGText, isSVGText())
112 #endif // RenderSVGText_h