OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All |
3 * rights reserved. | 3 * rights reserved. |
4 * Copyright (C) 2005 Alexey Proskuryakov. | 4 * Copyright (C) 2005 Alexey Proskuryakov. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 13 matching lines...) Expand all Loading... |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "core/editing/iterators/WordAwareIterator.h" | 28 #include "core/editing/iterators/WordAwareIterator.h" |
29 | 29 |
30 namespace blink { | 30 namespace blink { |
31 | 31 |
32 WordAwareIterator::WordAwareIterator(const Position& start, const Position& end) | 32 WordAwareIterator::WordAwareIterator(const Position& start, const Position& end) |
33 // So we consider the first chunk from the text iterator. | 33 // So we consider the first chunk from the text iterator. |
34 : m_didLookAhead(true), | 34 : m_didLookAhead(true), m_textIterator(start, end) { |
35 m_textIterator(start, end) { | |
36 advance(); // Get in position over the first chunk of text. | 35 advance(); // Get in position over the first chunk of text. |
37 } | 36 } |
38 | 37 |
39 WordAwareIterator::~WordAwareIterator() {} | 38 WordAwareIterator::~WordAwareIterator() {} |
40 | 39 |
41 // FIXME: Performance could be bad for huge spans next to each other that don't | 40 // FIXME: Performance could be bad for huge spans next to each other that don't |
42 // fall on word boundaries. | 41 // fall on word boundaries. |
43 | 42 |
44 void WordAwareIterator::advance() { | 43 void WordAwareIterator::advance() { |
45 m_buffer.clear(); | 44 m_buffer.clear(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 return m_textIterator.text().substring(position, length); | 94 return m_textIterator.text().substring(position, length); |
96 } | 95 } |
97 | 96 |
98 UChar WordAwareIterator::characterAt(unsigned index) const { | 97 UChar WordAwareIterator::characterAt(unsigned index) const { |
99 if (!m_buffer.isEmpty()) | 98 if (!m_buffer.isEmpty()) |
100 return m_buffer[index]; | 99 return m_buffer[index]; |
101 return m_textIterator.text().characterAt(index); | 100 return m_textIterator.text().characterAt(index); |
102 } | 101 } |
103 | 102 |
104 } // namespace blink | 103 } // namespace blink |
OLD | NEW |