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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #ifndef WordAwareIterator_h | 26 #ifndef WordAwareIterator_h |
27 #define WordAwareIterator_h | 27 #define WordAwareIterator_h |
28 | 28 |
29 #include "core/editing/iterators/TextIterator.h" | 29 #include "core/editing/iterators/TextIterator.h" |
30 #include "platform/heap/Heap.h" | 30 #include "platform/heap/Heap.h" |
31 #include "wtf/Vector.h" | 31 #include "wtf/Vector.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 // Very similar to the TextIterator, except that the chunks of text returned are
"well behaved", | 35 // Very similar to the TextIterator, except that the chunks of text returned are |
36 // meaning they never end split up a word. This is useful for spellcheck or (pe
rhaps one day) searching. | 36 // "well behaved", meaning they never end split up a word. This is useful for |
| 37 // spellcheck or (perhaps one day) searching. |
37 class WordAwareIterator { | 38 class WordAwareIterator { |
38 STACK_ALLOCATED(); | 39 STACK_ALLOCATED(); |
39 | 40 |
40 public: | 41 public: |
41 explicit WordAwareIterator(const Position& start, const Position& end); | 42 explicit WordAwareIterator(const Position& start, const Position& end); |
42 ~WordAwareIterator(); | 43 ~WordAwareIterator(); |
43 | 44 |
44 bool atEnd() const { return !m_didLookAhead && m_textIterator.atEnd(); } | 45 bool atEnd() const { return !m_didLookAhead && m_textIterator.atEnd(); } |
45 void advance(); | 46 void advance(); |
46 | 47 |
47 String substring(unsigned position, unsigned length) const; | 48 String substring(unsigned position, unsigned length) const; |
48 UChar characterAt(unsigned index) const; | 49 UChar characterAt(unsigned index) const; |
49 int length() const; | 50 int length() const; |
50 | 51 |
51 private: | 52 private: |
52 ForwardsTextBuffer m_buffer; | 53 ForwardsTextBuffer m_buffer; |
53 // Did we have to look ahead in the textIterator to confirm the current chunk? | 54 // Did we have to look ahead in the textIterator to confirm the current chunk? |
54 bool m_didLookAhead; | 55 bool m_didLookAhead; |
55 TextIterator m_textIterator; | 56 TextIterator m_textIterator; |
56 }; | 57 }; |
57 | 58 |
58 } // namespace blink | 59 } // namespace blink |
59 | 60 |
60 #endif // WordAwareIterator_h | 61 #endif // WordAwareIterator_h |
OLD | NEW |