• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "RenderText.h"
25 
26 namespace WebCore {
27 
28 class RenderCombineText : public RenderText {
29 public:
30     RenderCombineText(Node*, PassRefPtr<StringImpl>);
31 
32     void combineText();
33     void adjustTextOrigin(FloatPoint& textOrigin, const FloatRect& boxRect) const;
34     void charactersToRender(int start, const UChar*& characters, int& length) const;
isCombined()35     bool isCombined() const { return m_isCombined; }
combinedTextWidth(const Font & font)36     float combinedTextWidth(const Font& font) const { return font.size(); }
originalFont()37     const Font& originalFont() const { return parent()->style()->font(); }
38 
39 private:
isCombineText()40     virtual bool isCombineText() const { return true; }
41     virtual float width(unsigned from, unsigned length, const Font&, float xPosition, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
renderName()42     virtual const char* renderName() const { return "RenderCombineText"; }
43     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
44     virtual void setTextInternal(PassRefPtr<StringImpl>);
45 
46     float m_combinedTextWidth;
47     bool m_isCombined : 1;
48     bool m_needsFontUpdate : 1;
49 };
50 
toRenderCombineText(RenderObject * object)51 inline RenderCombineText* toRenderCombineText(RenderObject* object)
52 {
53     ASSERT(!object || object->isCombineText());
54     return static_cast<RenderCombineText*>(object);
55 }
56 
toRenderCombineText(const RenderObject * object)57 inline const RenderCombineText* toRenderCombineText(const RenderObject* object)
58 {
59     ASSERT(!object || object->isCombineText());
60     return static_cast<const RenderCombineText*>(object);
61 }
62 
63 // This will catch anyone doing an unnecessary cast.
64 void toRenderCombineText(const RenderCombineText*);
65 
66 } // namespace WebCore
67 
68 #endif // RenderCombineText_h
69