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#ifndef RenderSVGText_h 23#define RenderSVGText_h 24 25#include "AffineTransform.h" 26#include "RenderSVGBlock.h" 27#include "SVGTextLayoutAttributesBuilder.h" 28 29namespace WebCore { 30 31class RenderSVGInlineText; 32class SVGTextElement; 33class RenderSVGInlineText; 34 35class RenderSVGText final : public RenderSVGBlock { 36public: 37 RenderSVGText(SVGTextElement&, PassRef<RenderStyle>); 38 virtual ~RenderSVGText(); 39 40 SVGTextElement& textElement() const; 41 42 virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const; 43 44 void setNeedsPositioningValuesUpdate() { m_needsPositioningValuesUpdate = true; } 45 virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; } 46 void setNeedsTextMetricsUpdate() { m_needsTextMetricsUpdate = true; } 47 virtual FloatRect repaintRectInLocalCoordinates() const; 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 virtual FloatRect objectBoundingBox() const override { return frameRect(); } 62 virtual FloatRect strokeBoundingBox() const override; 63 64private: 65 void graphicsElement() const = delete; 66 67 virtual const char* renderName() const { return "RenderSVGText"; } 68 virtual bool isSVGText() const { return true; } 69 70 virtual void paint(PaintInfo&, const LayoutPoint&); 71 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override; 72 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction); 73 virtual VisiblePosition positionForPoint(const LayoutPoint&, const RenderRegion*); 74 75 virtual bool requiresLayer() const { return false; } 76 virtual void layout(); 77 78 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const; 79 80 virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const override; 81 virtual void computeRectForRepaint(const RenderLayerModelObject* repaintContainer, LayoutRect&, bool fixed = false) const override; 82 virtual void computeFloatRectForRepaint(const RenderLayerModelObject* repaintContainer, FloatRect&, bool fixed = false) const override; 83 84 virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0) const override; 85 virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const override; 86 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); 87 virtual RenderObject* removeChild(RenderObject&) override; 88 virtual void willBeDestroyed() override; 89 90 virtual const AffineTransform& localToParentTransform() const { return m_localTransform; } 91 virtual AffineTransform localTransform() const { return m_localTransform; } 92 virtual std::unique_ptr<RootInlineBox> createRootInlineBox() override; 93 94 virtual RenderBlock* firstLineBlock() const; 95 virtual void updateFirstLetter(); 96 97 bool shouldHandleSubtreeMutations() const; 98 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; 106}; 107 108RENDER_OBJECT_TYPE_CASTS(RenderSVGText, isSVGText()) 109 110} 111 112#endif 113