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 * |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "platform/LengthFunctions.h" | 30 #include "platform/LengthFunctions.h" |
31 #include "platform/text/TextPath.h" | 31 #include "platform/text/TextPath.h" |
32 #include "wtf/Forward.h" | 32 #include "wtf/Forward.h" |
33 #include "wtf/PassRefPtr.h" | 33 #include "wtf/PassRefPtr.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 class AbstractInlineTextBox; | 37 class AbstractInlineTextBox; |
38 class InlineTextBox; | 38 class InlineTextBox; |
39 | 39 |
| 40 // LayoutText is the root class for anything that represents |
| 41 // a text node (see core/dom/Text.h). |
| 42 // |
| 43 // This is a common node in the tree so to the limit memory overhead, |
| 44 // this class inherits directly from LayoutObject. |
| 45 // Also this class is used by both CSS and SVG layouts so LayoutObject |
| 46 // was a natural choice. |
| 47 // |
| 48 // The actual layout of text is handled by the containing inline |
| 49 // (LayoutInline) or block (LayoutBlock). They will invoke the Unicode |
| 50 // Bidirectional Algorithm to break the text into actual lines. |
| 51 // The result of layout is the line box tree, which represents lines |
| 52 // on the screen. It is stored into m_firstTextBox and m_lastTextBox. |
| 53 // To understand how lines are broken by the bidi algorithm, read e.g. |
| 54 // LayoutBlockFlow::layoutInlineChildren. |
| 55 // |
| 56 // |
| 57 // ***** LINE BOXES OWNERSHIP ***** |
| 58 // m_firstTextBox and m_lastTextBox are not owned by LayoutText |
| 59 // but are pointers into the enclosing inline / block (see LayoutInline's |
| 60 // and LayoutBlock's m_lineBoxes). |
| 61 // |
| 62 // |
| 63 // This class implements the preferred logical widths computation |
| 64 // for its underlying text. The widths are stored into m_minWidth |
| 65 // and m_maxWidth. They are computed lazily based on |
| 66 // m_preferredLogicalWidthsDirty. |
| 67 // |
| 68 // The previous comment applies also for painting. See e.g. |
| 69 // BlockPainter::paintContents in particular the use of LineBoxListPainter. |
40 class CORE_EXPORT LayoutText : public LayoutObject { | 70 class CORE_EXPORT LayoutText : public LayoutObject { |
41 public: | 71 public: |
42 // FIXME: If the node argument is not a Text node or the string argument is | 72 // FIXME: If the node argument is not a Text node or the string argument is |
43 // not the content of the Text node, updating text-transform property | 73 // not the content of the Text node, updating text-transform property |
44 // doesn't re-transform the string. | 74 // doesn't re-transform the string. |
45 LayoutText(Node*, PassRefPtr<StringImpl>); | 75 LayoutText(Node*, PassRefPtr<StringImpl>); |
46 #if ENABLE(ASSERT) | 76 #if ENABLE(ASSERT) |
47 ~LayoutText() override; | 77 ~LayoutText() override; |
48 #endif | 78 #endif |
49 | 79 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 void computePreferredLogicalWidths(float leadWidth); | 194 void computePreferredLogicalWidths(float leadWidth); |
165 void computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFont
Data*>& fallbackFonts, FloatRect& glyphBounds); | 195 void computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFont
Data*>& fallbackFonts, FloatRect& glyphBounds); |
166 | 196 |
167 bool computeCanUseSimpleFontCodePath() const; | 197 bool computeCanUseSimpleFontCodePath() const; |
168 | 198 |
169 // Make length() private so that callers that have a LayoutText* | 199 // Make length() private so that callers that have a LayoutText* |
170 // will use the more efficient textLength() instead, while | 200 // will use the more efficient textLength() instead, while |
171 // callers with a LayoutObject* can continue to use length(). | 201 // callers with a LayoutObject* can continue to use length(). |
172 unsigned length() const final { return textLength(); } | 202 unsigned length() const final { return textLength(); } |
173 | 203 |
| 204 // See the class comment as to why we shouldn't call this function directly. |
174 void paint(const PaintInfo&, const LayoutPoint&) final { ASSERT_NOT_REACHED(
); } | 205 void paint(const PaintInfo&, const LayoutPoint&) final { ASSERT_NOT_REACHED(
); } |
175 void layout() final { ASSERT_NOT_REACHED(); } | 206 void layout() final { ASSERT_NOT_REACHED(); } |
176 bool nodeAtPoint(HitTestResult&, const HitTestLocation&, const LayoutPoint&,
HitTestAction) final { ASSERT_NOT_REACHED(); return false; } | 207 bool nodeAtPoint(HitTestResult&, const HitTestLocation&, const LayoutPoint&,
HitTestAction) final { ASSERT_NOT_REACHED(); return false; } |
177 | 208 |
178 void deleteTextBoxes(); | 209 void deleteTextBoxes(); |
179 bool containsOnlyWhitespace(unsigned from, unsigned len) const; | 210 bool containsOnlyWhitespace(unsigned from, unsigned len) const; |
180 float widthFromFont(const Font&, int start, int len, float leadWidth, float
textWidthSoFar, TextDirection, HashSet<const SimpleFontData*>* fallbackFonts, Fl
oatRect* glyphBoundsAccumulation) const; | 211 float widthFromFont(const Font&, int start, int len, float leadWidth, float
textWidthSoFar, TextDirection, HashSet<const SimpleFontData*>* fallbackFonts, Fl
oatRect* glyphBoundsAccumulation) const; |
181 | 212 |
182 void secureText(UChar mask); | 213 void secureText(UChar mask); |
183 | 214 |
(...skipping 19 matching lines...) Expand all Loading... |
203 bool m_canUseSimpleFontCodePath : 1; | 234 bool m_canUseSimpleFontCodePath : 1; |
204 mutable bool m_knownToHaveNoOverflowAndNoFallbackFonts : 1; | 235 mutable bool m_knownToHaveNoOverflowAndNoFallbackFonts : 1; |
205 | 236 |
206 float m_minWidth; | 237 float m_minWidth; |
207 float m_maxWidth; | 238 float m_maxWidth; |
208 float m_firstLineMinWidth; | 239 float m_firstLineMinWidth; |
209 float m_lastLineLineMinWidth; | 240 float m_lastLineLineMinWidth; |
210 | 241 |
211 String m_text; | 242 String m_text; |
212 | 243 |
| 244 // The line boxes associated with this object. |
| 245 // Read the LINE BOXES OWNERSHIP section in the class header comment. |
213 InlineTextBox* m_firstTextBox; | 246 InlineTextBox* m_firstTextBox; |
214 InlineTextBox* m_lastTextBox; | 247 InlineTextBox* m_lastTextBox; |
215 }; | 248 }; |
216 | 249 |
217 inline UChar LayoutText::uncheckedCharacterAt(unsigned i) const | 250 inline UChar LayoutText::uncheckedCharacterAt(unsigned i) const |
218 { | 251 { |
219 ASSERT_WITH_SECURITY_IMPLICATION(i < textLength()); | 252 ASSERT_WITH_SECURITY_IMPLICATION(i < textLength()); |
220 return is8Bit() ? characters8()[i] : characters16()[i]; | 253 return is8Bit() ? characters8()[i] : characters16()[i]; |
221 } | 254 } |
222 | 255 |
(...skipping 22 matching lines...) Expand all Loading... |
245 inline LayoutText* Text::layoutObject() const | 278 inline LayoutText* Text::layoutObject() const |
246 { | 279 { |
247 return toLayoutText(CharacterData::layoutObject()); | 280 return toLayoutText(CharacterData::layoutObject()); |
248 } | 281 } |
249 | 282 |
250 void applyTextTransform(const ComputedStyle*, String&, UChar); | 283 void applyTextTransform(const ComputedStyle*, String&, UChar); |
251 | 284 |
252 } // namespace blink | 285 } // namespace blink |
253 | 286 |
254 #endif // LayoutText_h | 287 #endif // LayoutText_h |
OLD | NEW |