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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 TextIteratorIgnoresStyleVisibility = 1 << 2, | 44 TextIteratorIgnoresStyleVisibility = 1 << 2, |
45 TextIteratorEmitsOriginalText = 1 << 3, | 45 TextIteratorEmitsOriginalText = 1 << 3, |
46 TextIteratorStopsOnFormControls = 1 << 4, | 46 TextIteratorStopsOnFormControls = 1 << 4, |
47 TextIteratorEmitsImageAltText = 1 << 5, | 47 TextIteratorEmitsImageAltText = 1 << 5, |
48 TextIteratorEntersAuthorShadowRoots = 1 << 6, | 48 TextIteratorEntersAuthorShadowRoots = 1 << 6, |
49 TextIteratorEmitsObjectReplacementCharacter = 1 << 7 | 49 TextIteratorEmitsObjectReplacementCharacter = 1 << 7 |
50 }; | 50 }; |
51 typedef unsigned TextIteratorBehaviorFlags; | 51 typedef unsigned TextIteratorBehaviorFlags; |
52 | 52 |
53 String plainText(const Range*, TextIteratorBehaviorFlags = TextIteratorDefaultBe
havior); | 53 String plainText(const Range*, TextIteratorBehaviorFlags = TextIteratorDefaultBe
havior); |
| 54 String plainText(const Position& start, const Position& end, TextIteratorBehavio
rFlags = TextIteratorDefaultBehavior); |
54 PassRefPtrWillBeRawPtr<Range> findPlainText(const Range*, const String&, FindOpt
ions); | 55 PassRefPtrWillBeRawPtr<Range> findPlainText(const Range*, const String&, FindOpt
ions); |
55 void findPlainText(const Position& inputStart, const Position& inputEnd, const S
tring&, FindOptions, Position& resultStart, Position& resultEnd); | 56 void findPlainText(const Position& inputStart, const Position& inputEnd, const S
tring&, FindOptions, Position& resultStart, Position& resultEnd); |
56 | 57 |
57 class BitStack { | 58 class BitStack { |
58 public: | 59 public: |
59 BitStack(); | 60 BitStack(); |
60 ~BitStack(); | 61 ~BitStack(); |
61 | 62 |
62 void push(bool); | 63 void push(bool); |
63 void pop(); | 64 void pop(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 int endOffset() const; | 118 int endOffset() const; |
118 Position startPosition() const; | 119 Position startPosition() const; |
119 Position endPosition() const; | 120 Position endPosition() const; |
120 | 121 |
121 // Computes the length of the given range using a text iterator. The default | 122 // Computes the length of the given range using a text iterator. The default |
122 // iteration behavior is to always emit object replacement characters for | 123 // iteration behavior is to always emit object replacement characters for |
123 // replaced elements. When |forSelectionPreservation| is set to true, it | 124 // replaced elements. When |forSelectionPreservation| is set to true, it |
124 // also emits spaces for other non-text nodes using the | 125 // also emits spaces for other non-text nodes using the |
125 // |TextIteratorEmitsCharactersBetweenAllVisiblePosition| mode. | 126 // |TextIteratorEmitsCharactersBetweenAllVisiblePosition| mode. |
126 static int rangeLength(const Range*, bool forSelectionPreservation = false); | 127 static int rangeLength(const Range*, bool forSelectionPreservation = false); |
| 128 static int rangeLength(const Position& start, const Position& end, bool forS
electionPreservation = false); |
127 static PassRefPtrWillBeRawPtr<Range> subrange(Range* entireRange, int charac
terOffset, int characterCount); | 129 static PassRefPtrWillBeRawPtr<Range> subrange(Range* entireRange, int charac
terOffset, int characterCount); |
| 130 static void subrange(Position& start, Position& end, int characterOffset, in
t characterCount); |
128 | 131 |
129 private: | 132 private: |
130 enum IterationProgress { | 133 enum IterationProgress { |
131 HandledNone, | 134 HandledNone, |
132 HandledAuthorShadowRoots, | 135 HandledAuthorShadowRoots, |
133 HandledUserAgentShadowRoot, | 136 HandledUserAgentShadowRoot, |
134 HandledNode, | 137 HandledNode, |
135 HandledChildren | 138 HandledChildren |
136 }; | 139 }; |
137 | 140 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 bool m_atBreak; | 377 bool m_atBreak; |
375 | 378 |
376 SimplifiedBackwardsTextIterator m_textIterator; | 379 SimplifiedBackwardsTextIterator m_textIterator; |
377 }; | 380 }; |
378 | 381 |
379 // Very similar to the TextIterator, except that the chunks of text returned are
"well behaved", | 382 // Very similar to the TextIterator, except that the chunks of text returned are
"well behaved", |
380 // meaning they never end split up a word. This is useful for spellcheck or (pe
rhaps one day) searching. | 383 // meaning they never end split up a word. This is useful for spellcheck or (pe
rhaps one day) searching. |
381 class WordAwareIterator { | 384 class WordAwareIterator { |
382 STACK_ALLOCATED(); | 385 STACK_ALLOCATED(); |
383 public: | 386 public: |
384 explicit WordAwareIterator(const Range*); | 387 explicit WordAwareIterator(const Position& start, const Position& end); |
385 ~WordAwareIterator(); | 388 ~WordAwareIterator(); |
386 | 389 |
387 bool atEnd() const { return !m_didLookAhead && m_textIterator.atEnd(); } | 390 bool atEnd() const { return !m_didLookAhead && m_textIterator.atEnd(); } |
388 void advance(); | 391 void advance(); |
389 | 392 |
390 String substring(unsigned position, unsigned length) const; | 393 String substring(unsigned position, unsigned length) const; |
391 UChar characterAt(unsigned index) const; | 394 UChar characterAt(unsigned index) const; |
392 int length() const; | 395 int length() const; |
393 | 396 |
394 private: | 397 private: |
395 Vector<UChar> m_buffer; | 398 Vector<UChar> m_buffer; |
396 // Did we have to look ahead in the textIterator to confirm the current chun
k? | 399 // Did we have to look ahead in the textIterator to confirm the current chun
k? |
397 bool m_didLookAhead; | 400 bool m_didLookAhead; |
398 TextIterator m_textIterator; | 401 TextIterator m_textIterator; |
399 }; | 402 }; |
400 | 403 |
401 } | 404 } |
402 | 405 |
403 #endif | 406 #endif |
OLD | NEW |