1 | /* |
2 | * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public License |
15 | * along with this library; see the file COPYING.LIB. If not, write to |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | * |
19 | */ |
20 | |
21 | #pragma once |
22 | |
23 | #include "FontCascade.h" |
24 | #include "RenderText.h" |
25 | #include "Text.h" |
26 | |
27 | namespace WebCore { |
28 | |
29 | class RenderCombineText final : public RenderText { |
30 | WTF_MAKE_ISO_ALLOCATED(RenderCombineText); |
31 | public: |
32 | RenderCombineText(Text&, const String&); |
33 | |
34 | Text& textNode() const { return downcast<Text>(nodeForNonAnonymous()); } |
35 | |
36 | void combineTextIfNeeded(); |
37 | Optional<FloatPoint> computeTextOrigin(const FloatRect& boxRect) const; |
38 | String combinedStringForRendering() const; |
39 | bool isCombined() const { return m_isCombined; } |
40 | float combinedTextWidth(const FontCascade& font) const { return font.size(); } |
41 | const FontCascade& originalFont() const { return parent()->style().fontCascade(); } |
42 | const FontCascade& textCombineFont() const { return m_combineFontStyle->fontCascade(); } |
43 | |
44 | private: |
45 | void node() const = delete; |
46 | |
47 | bool isCombineText() const override { return true; } |
48 | float width(unsigned from, unsigned length, const FontCascade&, float xPosition, HashSet<const Font*>* fallbackFonts = 0, GlyphOverflow* = 0) const override; |
49 | const char* renderName() const override { return "RenderCombineText" ; } |
50 | void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; |
51 | void setRenderedText(const String&) override; |
52 | |
53 | std::unique_ptr<RenderStyle> m_combineFontStyle; |
54 | float m_combinedTextWidth { 0 }; |
55 | float m_combinedTextAscent { 0 }; |
56 | float m_combinedTextDescent { 0 }; |
57 | bool m_isCombined : 1; |
58 | bool m_needsFontUpdate : 1; |
59 | }; |
60 | |
61 | } // namespace WebCore |
62 | |
63 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderCombineText, isCombineText()) |
64 | |