OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class LayoutText; | 42 class LayoutText; |
43 class LayoutTextFragment; | 43 class LayoutTextFragment; |
44 | 44 |
45 CORE_EXPORT String | 45 CORE_EXPORT String |
46 plainText(const EphemeralRange&, | 46 plainText(const EphemeralRange&, |
47 TextIteratorBehaviorFlags = TextIteratorDefaultBehavior); | 47 TextIteratorBehaviorFlags = TextIteratorDefaultBehavior); |
48 | 48 |
49 String plainText(const EphemeralRangeInFlatTree&, | 49 String plainText(const EphemeralRangeInFlatTree&, |
50 TextIteratorBehaviorFlags = TextIteratorDefaultBehavior); | 50 TextIteratorBehaviorFlags = TextIteratorDefaultBehavior); |
51 | 51 |
52 // Iterates through the DOM range, returning all the text, and 0-length boundari
es | 52 // Iterates through the DOM range, returning all the text, and 0-length |
53 // at points where replaced elements break up the text flow. The text comes bac
k in | 53 // boundaries at points where replaced elements break up the text flow. The |
54 // chunks so as to optimize for performance of the iteration. | 54 // text comes back in chunks so as to optimize for performance of the iteration. |
55 | 55 |
56 template <typename Strategy> | 56 template <typename Strategy> |
57 class CORE_TEMPLATE_CLASS_EXPORT TextIteratorAlgorithm { | 57 class CORE_TEMPLATE_CLASS_EXPORT TextIteratorAlgorithm { |
58 STACK_ALLOCATED(); | 58 STACK_ALLOCATED(); |
59 | 59 |
60 public: | 60 public: |
61 // [start, end] indicates the document range that the iteration should take pl
ace within (both ends inclusive). | 61 // [start, end] indicates the document range that the iteration should take |
| 62 // place within (both ends inclusive). |
62 TextIteratorAlgorithm( | 63 TextIteratorAlgorithm( |
63 const PositionTemplate<Strategy>& start, | 64 const PositionTemplate<Strategy>& start, |
64 const PositionTemplate<Strategy>& end, | 65 const PositionTemplate<Strategy>& end, |
65 TextIteratorBehaviorFlags = TextIteratorDefaultBehavior); | 66 TextIteratorBehaviorFlags = TextIteratorDefaultBehavior); |
66 ~TextIteratorAlgorithm(); | 67 ~TextIteratorAlgorithm(); |
67 | 68 |
68 bool atEnd() const { return !m_textState.positionNode() || m_shouldStop; } | 69 bool atEnd() const { return !m_textState.positionNode() || m_shouldStop; } |
69 void advance(); | 70 void advance(); |
70 bool isInsideAtomicInlineElement() const; | 71 bool isInsideAtomicInlineElement() const; |
71 bool isInTextSecurityMode() const; | 72 bool isInTextSecurityMode() const; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 int textStartOffset, | 144 int textStartOffset, |
144 int textEndOffset); | 145 int textEndOffset); |
145 void emitText(Node* textNode, | 146 void emitText(Node* textNode, |
146 LayoutText* layoutObject, | 147 LayoutText* layoutObject, |
147 int textStartOffset, | 148 int textStartOffset, |
148 int textEndOffset); | 149 int textEndOffset); |
149 size_t restoreCollapsedTrailingSpace(InlineTextBox* nextTextBox, | 150 size_t restoreCollapsedTrailingSpace(InlineTextBox* nextTextBox, |
150 size_t subrunEnd); | 151 size_t subrunEnd); |
151 unsigned restoreCollapsedLeadingSpace(unsigned runStart); | 152 unsigned restoreCollapsedLeadingSpace(unsigned runStart); |
152 | 153 |
153 // Used by selection preservation code. There should be one character emitted
between every VisiblePosition | 154 // Used by selection preservation code. There should be one character emitted |
154 // in the Range used to create the TextIterator. | 155 // between every VisiblePosition in the Range used to create the TextIterator. |
155 // FIXME <rdar://problem/6028818>: This functionality should eventually be pha
sed out when we rewrite | 156 // FIXME <rdar://problem/6028818>: This functionality should eventually be |
156 // moveParagraphs to not clone/destroy moved content. | 157 // phased out when we rewrite moveParagraphs to not clone/destroy moved |
| 158 // content. |
157 bool emitsCharactersBetweenAllVisiblePositions() const { | 159 bool emitsCharactersBetweenAllVisiblePositions() const { |
158 return m_behavior & TextIteratorEmitsCharactersBetweenAllVisiblePositions; | 160 return m_behavior & TextIteratorEmitsCharactersBetweenAllVisiblePositions; |
159 } | 161 } |
160 | 162 |
161 bool entersTextControls() const { | 163 bool entersTextControls() const { |
162 return m_behavior & TextIteratorEntersTextControls; | 164 return m_behavior & TextIteratorEntersTextControls; |
163 } | 165 } |
164 | 166 |
165 // Used in pasting inside password field. | 167 // Used in pasting inside password field. |
166 bool emitsOriginalText() const { | 168 bool emitsOriginalText() const { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // The range. | 220 // The range. |
219 Member<Node> m_startContainer; | 221 Member<Node> m_startContainer; |
220 int m_startOffset; | 222 int m_startOffset; |
221 Member<Node> m_endContainer; | 223 Member<Node> m_endContainer; |
222 int m_endOffset; | 224 int m_endOffset; |
223 // |m_endNode| stores |Strategy::childAt(*m_endContainer, m_endOffset - 1)|, | 225 // |m_endNode| stores |Strategy::childAt(*m_endContainer, m_endOffset - 1)|, |
224 // if it exists, or |nullptr| otherwise. | 226 // if it exists, or |nullptr| otherwise. |
225 Member<Node> m_endNode; | 227 Member<Node> m_endNode; |
226 Member<Node> m_pastEndNode; | 228 Member<Node> m_pastEndNode; |
227 | 229 |
228 // Used when there is still some pending text from the current node; when thes
e | 230 // Used when there is still some pending text from the current node; when |
229 // are false and 0, we go back to normal iterating. | 231 // these are false and 0, we go back to normal iterating. |
230 bool m_needsAnotherNewline; | 232 bool m_needsAnotherNewline; |
231 InlineTextBox* m_textBox; | 233 InlineTextBox* m_textBox; |
232 // Used when iteration over :first-letter text to save pointer to | 234 // Used when iteration over :first-letter text to save pointer to |
233 // remaining text box. | 235 // remaining text box. |
234 InlineTextBox* m_remainingTextBox; | 236 InlineTextBox* m_remainingTextBox; |
235 // Used to point to LayoutText object for :first-letter. | 237 // Used to point to LayoutText object for :first-letter. |
236 LayoutText* m_firstLetterText; | 238 LayoutText* m_firstLetterText; |
237 | 239 |
238 // Used to do the whitespace collapsing logic. | 240 // Used to do the whitespace collapsing logic. |
239 Member<Text> m_lastTextNode; | 241 Member<Text> m_lastTextNode; |
240 bool m_lastTextNodeEndedWithCollapsedSpace; | 242 bool m_lastTextNodeEndedWithCollapsedSpace; |
241 | 243 |
242 // Used when text boxes are out of order (Hebrew/Arabic w/ embeded LTR text) | 244 // Used when text boxes are out of order (Hebrew/Arabic w/ embeded LTR text) |
243 Vector<InlineTextBox*> m_sortedTextBoxes; | 245 Vector<InlineTextBox*> m_sortedTextBoxes; |
244 size_t m_sortedTextBoxesPosition; | 246 size_t m_sortedTextBoxesPosition; |
245 | 247 |
246 const TextIteratorBehaviorFlags m_behavior; | 248 const TextIteratorBehaviorFlags m_behavior; |
247 | 249 |
248 // Used when deciding text fragment created by :first-letter should be looked
into. | 250 // Used when deciding text fragment created by :first-letter should be looked |
| 251 // into. |
249 bool m_handledFirstLetter; | 252 bool m_handledFirstLetter; |
250 // Used when stopsOnFormControls() is true to determine if the iterator should
keep advancing. | 253 // Used when stopsOnFormControls() is true to determine if the iterator should |
| 254 // keep advancing. |
251 bool m_shouldStop; | 255 bool m_shouldStop; |
252 // Used for use counter |InnerTextWithShadowTree| and | 256 // Used for use counter |InnerTextWithShadowTree| and |
253 // |SelectionToStringWithShadowTree|, we should not use other purpose. | 257 // |SelectionToStringWithShadowTree|, we should not use other purpose. |
254 bool m_handleShadowRoot; | 258 bool m_handleShadowRoot; |
255 | 259 |
256 // Contains state of emitted text. | 260 // Contains state of emitted text. |
257 TextIteratorTextState m_textState; | 261 TextIteratorTextState m_textState; |
258 }; | 262 }; |
259 | 263 |
260 extern template class CORE_EXTERN_TEMPLATE_EXPORT | 264 extern template class CORE_EXTERN_TEMPLATE_EXPORT |
261 TextIteratorAlgorithm<EditingStrategy>; | 265 TextIteratorAlgorithm<EditingStrategy>; |
262 extern template class CORE_EXTERN_TEMPLATE_EXPORT | 266 extern template class CORE_EXTERN_TEMPLATE_EXPORT |
263 TextIteratorAlgorithm<EditingInFlatTreeStrategy>; | 267 TextIteratorAlgorithm<EditingInFlatTreeStrategy>; |
264 | 268 |
265 using TextIterator = TextIteratorAlgorithm<EditingStrategy>; | 269 using TextIterator = TextIteratorAlgorithm<EditingStrategy>; |
266 using TextIteratorInFlatTree = TextIteratorAlgorithm<EditingInFlatTreeStrategy>; | 270 using TextIteratorInFlatTree = TextIteratorAlgorithm<EditingInFlatTreeStrategy>; |
267 | 271 |
268 } // namespace blink | 272 } // namespace blink |
269 | 273 |
270 #endif // TextIterator_h | 274 #endif // TextIterator_h |
OLD | NEW |