Changeset 19027 for trunk/WebCore/rendering/RenderText.h
- Timestamp:
- 01/22/07 09:28:57 (2 years ago)
- Files:
-
- 1 modified
-
trunk/WebCore/rendering/RenderText.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/rendering/RenderText.h
r18724 r19027 25 25 26 26 #include "RenderObject.h" 27 #include "Text.h"28 27 29 28 namespace WebCore { 30 29 31 // Define a constant for soft hyphen's unicode value.32 const unsigned short SOFT_HYPHEN = 173;33 34 class DocumentMarker;35 class InlineBox;36 30 class InlineTextBox; 37 class Position;38 class String;39 31 class StringImpl; 40 32 41 33 class RenderText : public RenderObject { 42 friend class InlineTextBox;43 34 public: 44 RenderText(Node*, StringImpl*);35 RenderText(Node*, PassRefPtr<StringImpl>); 45 36 46 37 virtual const char* renderName() const { return "RenderText"; } … … 48 39 virtual bool isTextFragment() const { return false; } 49 40 50 virtual PassRefPtr<StringImpl> original String() const;41 virtual PassRefPtr<StringImpl> originalText() const; 51 42 52 43 virtual void setStyle(RenderStyle*); … … 55 46 void attachTextBox(InlineTextBox*); 56 47 void removeTextBox(InlineTextBox*); 57 void deleteTextBoxes(); 48 58 49 virtual void destroy(); 59 50 60 String data() const { return m_str.get(); } 61 StringImpl* string() const { return m_str.get(); } 51 StringImpl* text() const { return m_text.get(); } 62 52 63 virtual InlineBox* createInlineBox(bool ,bool, bool isOnlyRun = false);53 virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox, bool isOnlyRun = false); 64 54 virtual void dirtyLineBoxes(bool fullLayout, bool isRootInlineBox = false); 65 55 … … 74 64 virtual VisiblePosition positionForCoordinates(int x, int y); 75 65 76 virtual unsigned length() const { return m_str->length(); } 77 const UChar* text() const { return m_str->characters(); } 78 unsigned stringLength() const { return m_str->length(); } // non virtual implementation of length() 66 const UChar* characters() const { return m_text->characters(); } 67 unsigned textLength() const { return m_text->length(); } // non virtual implementation of length() 79 68 virtual void position(InlineBox*); 80 69 81 virtual unsigned width(unsigned from, unsigned len, const Font *, int xPos) const;70 virtual unsigned width(unsigned from, unsigned len, const Font&, int xPos) const; 82 71 virtual unsigned width(unsigned from, unsigned len, int xPos, bool firstLine = false) const; 83 72 virtual int width() const; … … 86 75 virtual short lineHeight(bool firstLine, bool isRootLineBox = false) const; 87 76 88 // overrides89 77 virtual void calcMinMaxWidth(); 90 78 virtual int minWidth() const { return m_minWidth; } 91 79 virtual int maxWidth() const { return m_maxWidth; } 92 80 93 // widths 94 void calcMinMaxWidth(int leadWidth); 95 virtual void trimmedMinMaxWidth(int leadWidth, 96 int& beginMinW, bool& beginWS, 97 int& endMinW, bool& endWS, 98 bool& hasBreakableChar, bool& hasBreak, 99 int& beginMaxW, int& endMaxW, 100 int& minW, int& maxW, bool& stripFrontSpaces); 101 102 bool containsOnlyWhitespace(unsigned from, unsigned len) const; 81 void trimmedMinMaxWidth(int leadWidth, 82 int& beginMinW, bool& beginWS, 83 int& endMinW, bool& endWS, 84 bool& hasBreakableChar, bool& hasBreak, 85 int& beginMaxW, int& endMaxW, 86 int& minW, int& maxW, bool& stripFrontSpaces); 103 87 104 88 // returns the minimum x position of all runs relative to the parent. … … 109 93 virtual int yPos() const; 110 94 111 virtual const Font& font();112 95 virtual short verticalPositionHint(bool firstLine) const; 113 96 … … 125 108 126 109 virtual IntRect getAbsoluteRepaintRect(); 127 128 const Font* font(bool firstLine) const;129 130 Text* element() const { return static_cast<Text*>(RenderObject::element()); }131 110 132 111 InlineTextBox* firstTextBox() const { return m_firstTextBox; } … … 147 126 148 127 protected: 149 void set InternalString(PassRefPtr<StringImpl>);128 void setTextInternal(PassRefPtr<StringImpl>); 150 129 151 130 private: 152 void cacheWidths();153 int widthFromCache(const Font*, int start, int len, int tabWidth, int xPos) const;154 bool shouldUseMonospaceCache(const Font*) const;155 bool allAscii() const;131 // Make length() private so that callers that have a RenderText* 132 // will use the more efficient textLength() instead, while 133 // callers with a RenderObject* can continue to use length(). 134 virtual unsigned length() const { return textLength(); } 156 135 157 // members 158 RefPtr<StringImpl> m_str; 136 void deleteTextBoxes(); 137 bool containsOnlyWhitespace(unsigned from, unsigned len) const; 138 void calcMinMaxWidthInternal(int leadWidth); 139 140 void updateMonospaceCharacterWidth(); 141 int widthFromCache(const Font&, int start, int len, int tabWidth, int xPos) const; 142 bool isAllASCII() const { return m_isAllASCII; } 143 144 RefPtr<StringImpl> m_text; 159 145 160 146 InlineTextBox* m_firstTextBox; … … 172 158 bool m_hasBeginWS : 1; // Whether or not we begin with WS (only true if we aren't pre) 173 159 bool m_hasEndWS : 1; // Whether or not we end with WS (only true if we aren't pre) 174 175 160 bool m_linesDirty : 1; // This bit indicates that the text run has already dirtied specific 176 161 // line boxes, and this hint will enable layoutInlineChildren to avoid … … 178 163 // or removed). 179 164 bool m_containsReversedText : 1; 165 bool m_isAllASCII : 1; 180 166 181 // 22 bits left182 mutable bool m_allAsciiChecked:1;183 mutable bool m_allAscii:1;184 167 int m_monospaceCharacterWidth; 185 168 };