| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
#ifndef RenderText_h |
|---|
| 24 |
#define RenderText_h |
|---|
| 25 |
|
|---|
| 26 |
#include "RenderObject.h" |
|---|
| 27 |
|
|---|
| 28 |
namespace WebCore { |
|---|
| 29 |
|
|---|
| 30 |
class InlineTextBox; |
|---|
| 31 |
class StringImpl; |
|---|
| 32 |
|
|---|
| 33 |
class RenderText : public RenderObject { |
|---|
| 34 |
public: |
|---|
| 35 |
RenderText(Node*, PassRefPtr<StringImpl>); |
|---|
| 36 |
#ifndef NDEBUG |
|---|
| 37 |
virtual ~RenderText(); |
|---|
| 38 |
#endif |
|---|
| 39 |
|
|---|
| 40 |
virtual const char* renderName() const; |
|---|
| 41 |
|
|---|
| 42 |
virtual bool isTextFragment() const; |
|---|
| 43 |
virtual bool isWordBreak() const; |
|---|
| 44 |
|
|---|
| 45 |
virtual PassRefPtr<StringImpl> originalText() const; |
|---|
| 46 |
|
|---|
| 47 |
virtual void setStyle(RenderStyle*); |
|---|
| 48 |
|
|---|
| 49 |
void extractTextBox(InlineTextBox*); |
|---|
| 50 |
void attachTextBox(InlineTextBox*); |
|---|
| 51 |
void removeTextBox(InlineTextBox*); |
|---|
| 52 |
|
|---|
| 53 |
virtual void destroy(); |
|---|
| 54 |
|
|---|
| 55 |
StringImpl* text() const { return m_text.get(); } |
|---|
| 56 |
|
|---|
| 57 |
virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox, bool isOnlyRun = false); |
|---|
| 58 |
virtual InlineTextBox* createInlineTextBox(); |
|---|
| 59 |
virtual void dirtyLineBoxes(bool fullLayout, bool isRootInlineBox = false); |
|---|
| 60 |
|
|---|
| 61 |
virtual void paint(PaintInfo&, int tx, int ty) { ASSERT_NOT_REACHED(); } |
|---|
| 62 |
virtual void layout() { ASSERT_NOT_REACHED(); } |
|---|
| 63 |
|
|---|
| 64 |
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int, int, int, int, HitTestAction) { ASSERT_NOT_REACHED(); return false; } |
|---|
| 65 |
|
|---|
| 66 |
virtual void absoluteRects(Vector<IntRect>&, int tx, int ty, bool topLevel = true); |
|---|
| 67 |
virtual void addLineBoxRects(Vector<IntRect>&, unsigned startOffset = 0, unsigned endOffset = UINT_MAX, bool useSelectionHeight = false); |
|---|
| 68 |
|
|---|
| 69 |
virtual VisiblePosition positionForCoordinates(int x, int y); |
|---|
| 70 |
|
|---|
| 71 |
const UChar* characters() const { return m_text->characters(); } |
|---|
| 72 |
unsigned textLength() const { return m_text->length(); } |
|---|
| 73 |
virtual void position(InlineBox*); |
|---|
| 74 |
|
|---|
| 75 |
virtual unsigned width(unsigned from, unsigned len, const Font&, int xPos) const; |
|---|
| 76 |
virtual unsigned width(unsigned from, unsigned len, int xPos, bool firstLine = false) const; |
|---|
| 77 |
virtual int width() const; |
|---|
| 78 |
virtual int height() const; |
|---|
| 79 |
|
|---|
| 80 |
virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const; |
|---|
| 81 |
|
|---|
| 82 |
virtual int minPrefWidth() const; |
|---|
| 83 |
virtual int maxPrefWidth() const; |
|---|
| 84 |
|
|---|
| 85 |
void trimmedPrefWidths(int leadWidth, |
|---|
| 86 |
int& beginMinW, bool& beginWS, |
|---|
| 87 |
int& endMinW, bool& endWS, |
|---|
| 88 |
bool& hasBreakableChar, bool& hasBreak, |
|---|
| 89 |
int& beginMaxW, int& endMaxW, |
|---|
| 90 |
int& minW, int& maxW, bool& stripFrontSpaces); |
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
int minXPos() const; |
|---|
| 95 |
|
|---|
| 96 |
virtual int xPos() const; |
|---|
| 97 |
virtual int yPos() const; |
|---|
| 98 |
|
|---|
| 99 |
virtual int verticalPositionHint(bool firstLine) const; |
|---|
| 100 |
|
|---|
| 101 |
void setText(PassRefPtr<StringImpl>, bool force = false); |
|---|
| 102 |
void setTextWithOffset(PassRefPtr<StringImpl>, unsigned offset, unsigned len, bool force = false); |
|---|
| 103 |
|
|---|
| 104 |
virtual bool canBeSelectionLeaf() const { return true; } |
|---|
| 105 |
virtual SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); } |
|---|
| 106 |
virtual void setSelectionState(SelectionState s); |
|---|
| 107 |
virtual IntRect selectionRect(bool clipToVisibleContent = true); |
|---|
| 108 |
virtual IntRect caretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0); |
|---|
| 109 |
|
|---|
| 110 |
virtual int marginLeft() const { return style()->marginLeft().calcMinValue(0); } |
|---|
| 111 |
virtual int marginRight() const { return style()->marginRight().calcMinValue(0); } |
|---|
| 112 |
|
|---|
| 113 |
virtual IntRect absoluteClippedOverflowRect(); |
|---|
| 114 |
|
|---|
| 115 |
InlineTextBox* firstTextBox() const { return m_firstTextBox; } |
|---|
| 116 |
InlineTextBox* lastTextBox() const { return m_lastTextBox; } |
|---|
| 117 |
|
|---|
| 118 |
virtual int caretMinOffset() const; |
|---|
| 119 |
virtual int caretMaxOffset() const; |
|---|
| 120 |
virtual unsigned caretMaxRenderedOffset() const; |
|---|
| 121 |
|
|---|
| 122 |
virtual int previousOffset(int current) const; |
|---|
| 123 |
virtual int nextOffset(int current) const; |
|---|
| 124 |
|
|---|
| 125 |
bool containsReversedText() const { return m_containsReversedText; } |
|---|
| 126 |
|
|---|
| 127 |
InlineTextBox* findNextInlineTextBox(int offset, int& pos) const; |
|---|
| 128 |
|
|---|
| 129 |
bool allowTabs() const { return !style()->collapseWhiteSpace(); } |
|---|
| 130 |
|
|---|
| 131 |
void checkConsistency() const; |
|---|
| 132 |
|
|---|
| 133 |
protected: |
|---|
| 134 |
virtual void setTextInternal(PassRefPtr<StringImpl>); |
|---|
| 135 |
virtual void calcPrefWidths(int leadWidth); |
|---|
| 136 |
virtual UChar previousCharacter(); |
|---|
| 137 |
|
|---|
| 138 |
private: |
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
virtual unsigned length() const { return textLength(); } |
|---|
| 143 |
|
|---|
| 144 |
void deleteTextBoxes(); |
|---|
| 145 |
bool containsOnlyWhitespace(unsigned from, unsigned len) const; |
|---|
| 146 |
int widthFromCache(const Font&, int start, int len, int xPos) const; |
|---|
| 147 |
bool isAllASCII() const { return m_isAllASCII; } |
|---|
| 148 |
|
|---|
| 149 |
RefPtr<StringImpl> m_text; |
|---|
| 150 |
|
|---|
| 151 |
InlineTextBox* m_firstTextBox; |
|---|
| 152 |
InlineTextBox* m_lastTextBox; |
|---|
| 153 |
|
|---|
| 154 |
int m_minWidth; |
|---|
| 155 |
int m_maxWidth; |
|---|
| 156 |
int m_beginMinWidth; |
|---|
| 157 |
int m_endMinWidth; |
|---|
| 158 |
|
|---|
| 159 |
unsigned m_selectionState : 3; |
|---|
| 160 |
bool m_hasBreakableChar : 1; |
|---|
| 161 |
bool m_hasBreak : 1; |
|---|
| 162 |
bool m_hasTab : 1; |
|---|
| 163 |
bool m_hasBeginWS : 1; |
|---|
| 164 |
bool m_hasEndWS : 1; |
|---|
| 165 |
bool m_linesDirty : 1; |
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
bool m_containsReversedText : 1; |
|---|
| 170 |
bool m_isAllASCII : 1; |
|---|
| 171 |
}; |
|---|
| 172 |
|
|---|
| 173 |
#ifdef NDEBUG |
|---|
| 174 |
inline void RenderText::checkConsistency() const |
|---|
| 175 |
{ |
|---|
| 176 |
} |
|---|
| 177 |
#endif |
|---|
| 178 |
|
|---|
| 179 |
} |
|---|
| 180 |
|
|---|
| 181 |
#endif |
|---|
| 182 |
|
|---|