1/* 2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> 3 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2008 Rob Buis <buis@kde.org> 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 RenderSVGInlineText_h 23#define RenderSVGInlineText_h 24 25#include "Font.h" 26#include "RenderText.h" 27#include "SVGTextLayoutAttributes.h" 28#include "Text.h" 29 30namespace WebCore { 31 32class SVGInlineTextBox; 33 34class RenderSVGInlineText final : public RenderText { 35public: 36 RenderSVGInlineText(Text&, const String&); 37 38 Text& textNode() const { return toText(nodeForNonAnonymous()); } 39 40 bool characterStartsNewTextChunk(int position) const; 41 SVGTextLayoutAttributes* layoutAttributes() { return &m_layoutAttributes; } 42 43 float scalingFactor() const { return m_scalingFactor; } 44 const Font& scaledFont() const { return m_scaledFont; } 45 void updateScaledFont(); 46 static void computeNewScaledFontForStyle(const RenderObject&, const RenderStyle&, float& scalingFactor, Font& scaledFont); 47 48 // Preserves floating point precision for the use in DRT. It knows how to round and does a better job than enclosingIntRect. 49 FloatRect floatLinesBoundingBox() const; 50 51private: 52 virtual const char* renderName() const override { return "RenderSVGInlineText"; } 53 54 virtual String originalText() const override; 55 virtual void setRenderedText(const String&) override; 56 virtual void styleDidChange(StyleDifference, const RenderStyle*) override; 57 58 virtual FloatRect objectBoundingBox() const override { return floatLinesBoundingBox(); } 59 60 virtual bool isSVGInlineText() const override { return true; } 61 62 virtual VisiblePosition positionForPoint(const LayoutPoint&, const RenderRegion*) override; 63 virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0) override; 64 virtual IntRect linesBoundingBox() const override; 65 virtual std::unique_ptr<InlineTextBox> createTextBox() override; 66 67 float m_scalingFactor; 68 Font m_scaledFont; 69 SVGTextLayoutAttributes m_layoutAttributes; 70}; 71 72RENDER_OBJECT_TYPE_CASTS(RenderSVGInlineText, isSVGInlineText()) 73 74} 75 76#endif // RenderSVGInlineText_h 77