OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * (C) 2000 Dirk Mueller (mueller@kde.org) |
4 * Copyright (C) 2004, 2005, 2006, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 4 * Copyright (C) 2004, 2005, 2006, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 virtual int baselinePosition(FontBaseline) const OVERRIDE FINAL; | 83 virtual int baselinePosition(FontBaseline) const OVERRIDE FINAL; |
84 virtual LayoutUnit lineHeight() const OVERRIDE FINAL; | 84 virtual LayoutUnit lineHeight() const OVERRIDE FINAL; |
85 | 85 |
86 bool getEmphasisMarkPosition(RenderStyle*, TextEmphasisPosition&) const; | 86 bool getEmphasisMarkPosition(RenderStyle*, TextEmphasisPosition&) const; |
87 | 87 |
88 LayoutRect logicalOverflowRect() const; | 88 LayoutRect logicalOverflowRect() const; |
89 void setLogicalOverflowRect(const LayoutRect&); | 89 void setLogicalOverflowRect(const LayoutRect&); |
90 LayoutUnit logicalTopVisualOverflow() const { return logicalOverflowRect().y
(); } | 90 LayoutUnit logicalTopVisualOverflow() const { return logicalOverflowRect().y
(); } |
91 LayoutUnit logicalBottomVisualOverflow() const { return logicalOverflowRect(
).maxY(); } | 91 LayoutUnit logicalBottomVisualOverflow() const { return logicalOverflowRect(
).maxY(); } |
92 | 92 |
| 93 // charactersWithHyphen, if provided, must not be destroyed before the TextR
un. |
| 94 TextRun constructTextRun(RenderStyle*, const Font&, StringBuilder* character
sWithHyphen = 0) const; |
| 95 TextRun constructTextRun(RenderStyle*, const Font&, StringView, int maximumL
ength, StringBuilder* charactersWithHyphen = 0) const; |
| 96 |
93 #ifndef NDEBUG | 97 #ifndef NDEBUG |
94 virtual void showBox(int = 0) const OVERRIDE; | 98 virtual void showBox(int = 0) const OVERRIDE; |
95 virtual const char* boxName() const OVERRIDE; | 99 virtual const char* boxName() const OVERRIDE; |
96 #endif | 100 #endif |
97 | 101 |
98 enum RotationDirection { Counterclockwise, Clockwise }; | 102 enum RotationDirection { Counterclockwise, Clockwise }; |
99 static AffineTransform rotation(const FloatRect& boxRect, RotationDirection)
; | 103 static AffineTransform rotation(const FloatRect& boxRect, RotationDirection)
; |
100 private: | |
101 LayoutUnit selectionTop(); | |
102 LayoutUnit selectionBottom(); | |
103 LayoutUnit selectionHeight(); | |
104 | |
105 // charactersWithHyphen, if provided, must not be destroyed before the TextR
un. | |
106 TextRun constructTextRun(RenderStyle*, const Font&, StringBuilder* character
sWithHyphen = 0) const; | |
107 TextRun constructTextRun(RenderStyle*, const Font&, StringView, int maximumL
ength, StringBuilder* charactersWithHyphen = 0) const; | |
108 | 104 |
109 public: | 105 public: |
110 TextRun constructTextRunForInspector(RenderStyle*, const Font&) const; | 106 TextRun constructTextRunForInspector(RenderStyle*, const Font&) const; |
111 virtual FloatRect calculateBoundaries() const OVERRIDE { return FloatRect(x(
), y(), width(), height()); } | 107 virtual FloatRect calculateBoundaries() const OVERRIDE { return FloatRect(x(
), y(), width(), height()); } |
112 | 108 |
113 virtual LayoutRect localSelectionRect(int startPos, int endPos); | 109 virtual LayoutRect localSelectionRect(int startPos, int endPos); |
114 bool isSelected(int startPos, int endPos) const; | 110 bool isSelected(int startPos, int endPos) const; |
115 void selectionStartEnd(int& sPos, int& ePos) const; | 111 void selectionStartEnd(int& sPos, int& ePos) const; |
116 | 112 |
| 113 // These functions both paint markers and update the DocumentMarker's render
edRect. |
| 114 virtual void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrig
in, DocumentMarker*, RenderStyle*, const Font&, bool grammar); |
| 115 virtual void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOri
gin, DocumentMarker*, RenderStyle*, const Font&); |
| 116 |
117 protected: | 117 protected: |
118 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou
tUnit lineBottom) OVERRIDE; | 118 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou
tUnit lineBottom) OVERRIDE; |
119 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit
lineTop, LayoutUnit lineBottom) OVERRIDE; | 119 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit
lineTop, LayoutUnit lineBottom) OVERRIDE; |
120 | 120 |
121 private: | 121 private: |
122 virtual void deleteLine() OVERRIDE FINAL; | 122 virtual void deleteLine() OVERRIDE FINAL; |
123 virtual void extractLine() OVERRIDE FINAL; | 123 virtual void extractLine() OVERRIDE FINAL; |
124 virtual void attachLine() OVERRIDE FINAL; | 124 virtual void attachLine() OVERRIDE FINAL; |
125 | 125 |
126 public: | 126 public: |
(...skipping 13 matching lines...) Expand all Loading... |
140 m_logicalWidth += newExpansion; | 140 m_logicalWidth += newExpansion; |
141 } | 141 } |
142 | 142 |
143 private: | 143 private: |
144 virtual bool isInlineTextBox() const OVERRIDE FINAL { return true; } | 144 virtual bool isInlineTextBox() const OVERRIDE FINAL { return true; } |
145 | 145 |
146 public: | 146 public: |
147 virtual int caretMinOffset() const OVERRIDE FINAL; | 147 virtual int caretMinOffset() const OVERRIDE FINAL; |
148 virtual int caretMaxOffset() const OVERRIDE FINAL; | 148 virtual int caretMaxOffset() const OVERRIDE FINAL; |
149 | 149 |
150 private: | |
151 float textPos() const; // returns the x position relative to the left start
of the text line. | 150 float textPos() const; // returns the x position relative to the left start
of the text line. |
152 | 151 |
153 public: | 152 public: |
154 virtual int offsetForPosition(float x, bool includePartialGlyphs = true) con
st; | 153 virtual int offsetForPosition(float x, bool includePartialGlyphs = true) con
st; |
155 virtual float positionForOffset(int offset) const; | 154 virtual float positionForOffset(int offset) const; |
156 | 155 |
157 bool containsCaretOffset(int offset) const; // false for offset after line b
reak | 156 bool containsCaretOffset(int offset) const; // false for offset after line b
reak |
158 | 157 |
159 // Fills a vector with the pixel width of each character. | 158 // Fills a vector with the pixel width of each character. |
160 void characterWidths(Vector<float>&) const; | 159 void characterWidths(Vector<float>&) const; |
161 | 160 |
162 private: | 161 private: |
163 InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderO
bject | 162 InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderO
bject |
164 InlineTextBox* m_nextTextBox; // The next box that also uses our RenderObjec
t | 163 InlineTextBox* m_nextTextBox; // The next box that also uses our RenderObjec
t |
165 | 164 |
166 int m_start; | 165 int m_start; |
167 unsigned short m_len; | 166 unsigned short m_len; |
168 | 167 |
169 unsigned short m_truncation; // Where to truncate when text overflow is appl
ied. We use special constants to | 168 unsigned short m_truncation; // Where to truncate when text overflow is appl
ied. We use special constants to |
170 // denote no truncation (the whole run paints) and full tr
uncation (nothing paints at all). | 169 // denote no truncation (the whole run paints) and full tr
uncation (nothing paints at all). |
171 | 170 |
172 unsigned underlinePaintStart(const CompositionUnderline&); | |
173 unsigned underlinePaintEnd(const CompositionUnderline&); | |
174 | |
175 protected: | |
176 void paintSingleCompositionBackgroundRun(GraphicsContext*, const FloatPoint&
boxOrigin, RenderStyle*, const Font&, Color backgroundColor, int startPos, int
endPos); | |
177 void paintCompositionBackgrounds(GraphicsContext*, const FloatPoint& boxOrig
in, RenderStyle*, const Font&, bool useCustomUnderlines); | |
178 void paintDocumentMarkers(GraphicsContext*, const FloatPoint& boxOrigin, Ren
derStyle*, const Font&, bool background); | |
179 void paintCompositionUnderline(GraphicsContext*, const FloatPoint& boxOrigin
, const CompositionUnderline&); | |
180 | |
181 // These functions both paint markers and update the DocumentMarker's render
edRect. | |
182 virtual void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrig
in, DocumentMarker*, RenderStyle*, const Font&, bool grammar); | |
183 virtual void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOri
gin, DocumentMarker*, RenderStyle*, const Font&); | |
184 | |
185 private: | 171 private: |
186 void paintDecoration(GraphicsContext*, const FloatPoint& boxOrigin, TextDeco
ration); | |
187 void paintSelection(GraphicsContext*, const FloatPoint& boxOrigin, RenderSty
le*, const Font&, Color textColor); | |
188 | |
189 TextRun::ExpansionBehavior expansionBehavior() const | 172 TextRun::ExpansionBehavior expansionBehavior() const |
190 { | 173 { |
191 return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : Tex
tRun::ForbidLeadingExpansion) | 174 return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : Tex
tRun::ForbidLeadingExpansion) |
192 | (expansion() && nextLeafChild() ? TextRun::AllowTrailingExpansion
: TextRun::ForbidTrailingExpansion); | 175 | (expansion() && nextLeafChild() ? TextRun::AllowTrailingExpansion
: TextRun::ForbidTrailingExpansion); |
193 } | 176 } |
194 }; | 177 }; |
195 | 178 |
196 DEFINE_INLINE_BOX_TYPE_CASTS(InlineTextBox); | 179 DEFINE_INLINE_BOX_TYPE_CASTS(InlineTextBox); |
197 | 180 |
198 void alignSelectionRectToDevicePixels(FloatRect&); | 181 void alignSelectionRectToDevicePixels(FloatRect&); |
199 | 182 |
200 inline AffineTransform InlineTextBox::rotation(const FloatRect& boxRect, Rotatio
nDirection rotationDirection) | 183 inline AffineTransform InlineTextBox::rotation(const FloatRect& boxRect, Rotatio
nDirection rotationDirection) |
201 { | 184 { |
202 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect
.x() + boxRect.maxY(), boxRect.maxY() - boxRect.x()) | 185 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect
.x() + boxRect.maxY(), boxRect.maxY() - boxRect.x()) |
203 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x()
+ boxRect.maxY()); | 186 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x()
+ boxRect.maxY()); |
204 } | 187 } |
205 | 188 |
206 } // namespace blink | 189 } // namespace blink |
207 | 190 |
208 #endif // InlineTextBox_h | 191 #endif // InlineTextBox_h |
OLD | NEW |