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#ifndef RenderCombineText_h
22#define RenderCombineText_h
23
24#include "Font.h"
25#include "RenderElement.h"
26#include "RenderText.h"
27#include "Text.h"
28
29namespace WebCore {
30
31class RenderCombineText final : public RenderText {
32public:
33    RenderCombineText(Text&, PassRefPtr<StringImpl>);
34
35    Text& textNode() const { return toText(nodeForNonAnonymous()); }
36
37    void combineText();
38    void adjustTextOrigin(FloatPoint& textOrigin, const FloatRect& boxRect) const;
39    void getStringToRender(int, String&, int& length) const;
40    bool isCombined() const { return m_isCombined; }
41    float combinedTextWidth(const Font& font) const { return font.size(); }
42    const Font& originalFont() const { return parent()->style().font(); }
43    const Font& textCombineFont() const { return m_combineFontStyle->font(); }
44
45private:
46    void node() const = delete;
47
48    virtual bool isCombineText() const { return true; }
49    virtual float width(unsigned from, unsigned length, const Font&, float xPosition, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
50    virtual const char* renderName() const { return "RenderCombineText"; }
51    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
52    virtual void setRenderedText(const String&) override;
53
54    RefPtr<RenderStyle> m_combineFontStyle;
55    float m_combinedTextWidth;
56    bool m_isCombined : 1;
57    bool m_needsFontUpdate : 1;
58};
59
60RENDER_OBJECT_TYPE_CASTS(RenderCombineText, isCombineText())
61
62} // namespace WebCore
63
64#endif // RenderCombineText_h
65