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-2009, 2013 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004-2009, 2013 Apple Inc. All rights reserved. |
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 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 * | 20 * |
21 */ | 21 */ |
22 | 22 |
23 #ifndef RenderText_h | 23 #ifndef LayoutText_h |
24 #define RenderText_h | 24 #define LayoutText_h |
25 | 25 |
26 #include "core/dom/Text.h" | 26 #include "core/dom/Text.h" |
27 #include "core/layout/LayoutObject.h" | 27 #include "core/layout/LayoutObject.h" |
28 #include "core/layout/line/FloatToLayoutUnit.h" | 28 #include "core/layout/line/FloatToLayoutUnit.h" |
29 #include "platform/LengthFunctions.h" | 29 #include "platform/LengthFunctions.h" |
30 #include "platform/text/TextPath.h" | 30 #include "platform/text/TextPath.h" |
31 #include "wtf/Forward.h" | 31 #include "wtf/Forward.h" |
32 #include "wtf/PassRefPtr.h" | 32 #include "wtf/PassRefPtr.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 class AbstractInlineTextBox; | 36 class AbstractInlineTextBox; |
37 class InlineTextBox; | 37 class InlineTextBox; |
38 | 38 |
39 class RenderText : public LayoutObject { | 39 class LayoutText : public LayoutObject { |
40 public: | 40 public: |
41 // FIXME: If the node argument is not a Text node or the string argument is | 41 // FIXME: If the node argument is not a Text node or the string argument is |
42 // not the content of the Text node, updating text-transform property | 42 // not the content of the Text node, updating text-transform property |
43 // doesn't re-transform the string. | 43 // doesn't re-transform the string. |
44 RenderText(Node*, PassRefPtr<StringImpl>); | 44 LayoutText(Node*, PassRefPtr<StringImpl>); |
45 #if ENABLE(ASSERT) | 45 #if ENABLE(ASSERT) |
46 virtual ~RenderText(); | 46 virtual ~LayoutText(); |
47 #endif | 47 #endif |
48 | 48 |
49 virtual const char* renderName() const override; | 49 virtual const char* renderName() const override; |
50 | 50 |
51 virtual bool isTextFragment() const; | 51 virtual bool isTextFragment() const; |
52 virtual bool isWordBreak() const; | 52 virtual bool isWordBreak() const; |
53 | 53 |
54 virtual PassRefPtr<StringImpl> originalText() const; | 54 virtual PassRefPtr<StringImpl> originalText() const; |
55 | 55 |
56 void extractTextBox(InlineTextBox*); | 56 void extractTextBox(InlineTextBox*); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 virtual InlineTextBox* createTextBox(int start, unsigned short length); // S
ubclassed by SVG. | 155 virtual InlineTextBox* createTextBox(int start, unsigned short length); // S
ubclassed by SVG. |
156 | 156 |
157 virtual void invalidateDisplayItemClients(DisplayItemList*) const override; | 157 virtual void invalidateDisplayItemClients(DisplayItemList*) const override; |
158 | 158 |
159 private: | 159 private: |
160 void computePreferredLogicalWidths(float leadWidth); | 160 void computePreferredLogicalWidths(float leadWidth); |
161 void computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFont
Data*>& fallbackFonts, GlyphOverflow&); | 161 void computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFont
Data*>& fallbackFonts, GlyphOverflow&); |
162 | 162 |
163 bool computeCanUseSimpleFontCodePath() const; | 163 bool computeCanUseSimpleFontCodePath() const; |
164 | 164 |
165 // Make length() private so that callers that have a RenderText* | 165 // Make length() private so that callers that have a LayoutText* |
166 // will use the more efficient textLength() instead, while | 166 // will use the more efficient textLength() instead, while |
167 // callers with a LayoutObject* can continue to use length(). | 167 // callers with a LayoutObject* can continue to use length(). |
168 virtual unsigned length() const override final { return textLength(); } | 168 virtual unsigned length() const override final { return textLength(); } |
169 | 169 |
170 virtual void paint(const PaintInfo&, const LayoutPoint&) override final { AS
SERT_NOT_REACHED(); } | 170 virtual void paint(const PaintInfo&, const LayoutPoint&) override final { AS
SERT_NOT_REACHED(); } |
171 virtual void layout() override final { ASSERT_NOT_REACHED(); } | 171 virtual void layout() override final { ASSERT_NOT_REACHED(); } |
172 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation&, const LayoutPoint&, HitTestAction) override final { ASSERT_NOT_REACH
ED(); return false; } | 172 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation&, const LayoutPoint&, HitTestAction) override final { ASSERT_NOT_REACH
ED(); return false; } |
173 | 173 |
174 void deleteTextBoxes(); | 174 void deleteTextBoxes(); |
175 bool containsOnlyWhitespace(unsigned from, unsigned len) const; | 175 bool containsOnlyWhitespace(unsigned from, unsigned len) const; |
176 float widthFromCache(const Font&, int start, int len, float xPos, TextDirect
ion, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow*) const; | 176 float widthFromCache(const Font&, int start, int len, float xPos, TextDirect
ion, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow*) const; |
177 bool isAllASCII() const { return m_isAllASCII; } | 177 bool isAllASCII() const { return m_isAllASCII; } |
178 | 178 |
179 void secureText(UChar mask); | 179 void secureText(UChar mask); |
180 | 180 |
181 bool isText() const = delete; // This will catch anyone doing an unnecessary
check. | 181 bool isText() const = delete; // This will catch anyone doing an unnecessary
check. |
182 | 182 |
183 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxMo
delObject* paintInvalidationContainer, const PaintInvalidationState* = 0) const
override; | 183 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxMo
delObject* paintInvalidationContainer, const PaintInvalidationState* = 0) const
override; |
184 | 184 |
185 void checkConsistency() const; | 185 void checkConsistency() const; |
186 | 186 |
187 // We put the bitfield first to minimize padding on 64-bit. | 187 // We put the bitfield first to minimize padding on 64-bit. |
188 bool m_hasBreakableChar : 1; // Whether or not we can be broken into multipl
e lines. | 188 bool m_hasBreakableChar : 1; // Whether or not we can be broken into multipl
e lines. |
189 bool m_hasBreak : 1; // Whether or not we have a hard break (e.g., <pre> wit
h '\n'). | 189 bool m_hasBreak : 1; // Whether or not we have a hard break (e.g., <pre> wit
h '\n'). |
190 bool m_hasTab : 1; // Whether or not we have a variable width tab character
(e.g., <pre> with '\t'). | 190 bool m_hasTab : 1; // Whether or not we have a variable width tab character
(e.g., <pre> with '\t'). |
191 bool m_hasBreakableStart : 1; | 191 bool m_hasBreakableStart : 1; |
192 bool m_hasBreakableEnd : 1; | 192 bool m_hasBreakableEnd : 1; |
193 bool m_hasEndWhiteSpace : 1; | 193 bool m_hasEndWhiteSpace : 1; |
194 bool m_linesDirty : 1; // This bit indicates that the text run has already d
irtied specific | 194 // This bit indicates that the text run has already dirtied specific |
195 // line boxes, and this hint will enable layoutInline
Children to avoid | 195 // line boxes, and this hint will enable layoutInlineChildren to avoid |
196 // just dirtying everything when character data is mo
dified (e.g., appended/inserted | 196 // just dirtying everything when character data is modified (e.g., appended/
inserted |
197 // or removed). | 197 // or removed). |
| 198 bool m_linesDirty : 1; |
198 bool m_containsReversedText : 1; | 199 bool m_containsReversedText : 1; |
199 bool m_isAllASCII : 1; | 200 bool m_isAllASCII : 1; |
200 bool m_canUseSimpleFontCodePath : 1; | 201 bool m_canUseSimpleFontCodePath : 1; |
201 mutable bool m_knownToHaveNoOverflowAndNoFallbackFonts : 1; | 202 mutable bool m_knownToHaveNoOverflowAndNoFallbackFonts : 1; |
202 | 203 |
203 float m_minWidth; | 204 float m_minWidth; |
204 float m_maxWidth; | 205 float m_maxWidth; |
205 float m_firstLineMinWidth; | 206 float m_firstLineMinWidth; |
206 float m_lastLineLineMinWidth; | 207 float m_lastLineLineMinWidth; |
207 | 208 |
208 String m_text; | 209 String m_text; |
209 | 210 |
210 InlineTextBox* m_firstTextBox; | 211 InlineTextBox* m_firstTextBox; |
211 InlineTextBox* m_lastTextBox; | 212 InlineTextBox* m_lastTextBox; |
212 }; | 213 }; |
213 | 214 |
214 inline UChar RenderText::uncheckedCharacterAt(unsigned i) const | 215 inline UChar LayoutText::uncheckedCharacterAt(unsigned i) const |
215 { | 216 { |
216 ASSERT_WITH_SECURITY_IMPLICATION(i < textLength()); | 217 ASSERT_WITH_SECURITY_IMPLICATION(i < textLength()); |
217 return is8Bit() ? characters8()[i] : characters16()[i]; | 218 return is8Bit() ? characters8()[i] : characters16()[i]; |
218 } | 219 } |
219 | 220 |
220 inline UChar RenderText::characterAt(unsigned i) const | 221 inline UChar LayoutText::characterAt(unsigned i) const |
221 { | 222 { |
222 if (i >= textLength()) | 223 if (i >= textLength()) |
223 return 0; | 224 return 0; |
224 | 225 |
225 return uncheckedCharacterAt(i); | 226 return uncheckedCharacterAt(i); |
226 } | 227 } |
227 | 228 |
228 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(RenderText, isText()); | 229 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutText, isText()); |
229 | 230 |
230 #if !ENABLE(ASSERT) | 231 #if !ENABLE(ASSERT) |
231 inline void RenderText::checkConsistency() const | 232 inline void LayoutText::checkConsistency() const |
232 { | 233 { |
233 } | 234 } |
234 #endif | 235 #endif |
235 | 236 |
236 inline RenderText* Text::renderer() const | 237 inline LayoutText* Text::renderer() const |
237 { | 238 { |
238 return toRenderText(CharacterData::renderer()); | 239 return toLayoutText(CharacterData::renderer()); |
239 } | 240 } |
240 | 241 |
241 void applyTextTransform(const LayoutStyle*, String&, UChar); | 242 void applyTextTransform(const LayoutStyle*, String&, UChar); |
242 | 243 |
243 } // namespace blink | 244 } // namespace blink |
244 | 245 |
245 #endif // RenderText_h | 246 #endif // LayoutText_h |
OLD | NEW |