Home | History | Annotate | Download | only in rendering
      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;
     35     bool isCombined() const { return m_isCombined; }
     36     float combinedTextWidth(const Font& font) const { return font.size(); }
     37     const Font& originalFont() const { return parent()->style()->font(); }
     38 
     39 private:
     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;
     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 
     51 inline RenderCombineText* toRenderCombineText(RenderObject* object)
     52 {
     53     ASSERT(!object || object->isCombineText());
     54     return static_cast<RenderCombineText*>(object);
     55 }
     56 
     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