Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: Source/core/editing/iterators/CharacterIterator.cpp

Issue 1300823002: Introduce PositionAlgorithm<Strategy>::editingPositionOf() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-18T17:38:11 Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
3 * Copyright (C) 2005 Alexey Proskuryakov. 3 * Copyright (C) 2005 Alexey Proskuryakov.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return m_textIterator.endOffsetInCurrentContainer(); 100 return m_textIterator.endOffsetInCurrentContainer();
101 } 101 }
102 102
103 template <typename Strategy> 103 template <typename Strategy>
104 PositionAlgorithm<Strategy> CharacterIteratorAlgorithm<Strategy>::startPosition( ) const 104 PositionAlgorithm<Strategy> CharacterIteratorAlgorithm<Strategy>::startPosition( ) const
105 { 105 {
106 if (!m_textIterator.atEnd()) { 106 if (!m_textIterator.atEnd()) {
107 if (m_textIterator.length() > 1) { 107 if (m_textIterator.length() > 1) {
108 Node* n = m_textIterator.currentContainer(); 108 Node* n = m_textIterator.currentContainer();
109 int offset = m_textIterator.startOffsetInCurrentContainer() + m_runO ffset; 109 int offset = m_textIterator.startOffsetInCurrentContainer() + m_runO ffset;
110 return PositionAlgorithm<Strategy>::createLegacyEditingPosition(n, o ffset); 110 return PositionAlgorithm<Strategy>::editingPositionOf(n, offset);
111 } 111 }
112 ASSERT(!m_runOffset); 112 ASSERT(!m_runOffset);
113 } 113 }
114 return m_textIterator.startPositionInCurrentContainer(); 114 return m_textIterator.startPositionInCurrentContainer();
115 } 115 }
116 116
117 template <typename Strategy> 117 template <typename Strategy>
118 PositionAlgorithm<Strategy> CharacterIteratorAlgorithm<Strategy>::endPosition() const 118 PositionAlgorithm<Strategy> CharacterIteratorAlgorithm<Strategy>::endPosition() const
119 { 119 {
120 if (!m_textIterator.atEnd()) { 120 if (!m_textIterator.atEnd()) {
121 if (m_textIterator.length() > 1) { 121 if (m_textIterator.length() > 1) {
122 Node* n = m_textIterator.currentContainer(); 122 Node* n = m_textIterator.currentContainer();
123 int offset = m_textIterator.startOffsetInCurrentContainer() + m_runO ffset; 123 int offset = m_textIterator.startOffsetInCurrentContainer() + m_runO ffset;
124 return PositionAlgorithm<Strategy>::createLegacyEditingPosition(n, o ffset + 1); 124 return PositionAlgorithm<Strategy>::editingPositionOf(n, offset + 1) ;
125 } 125 }
126 ASSERT(!m_runOffset); 126 ASSERT(!m_runOffset);
127 } 127 }
128 return m_textIterator.endPositionInCurrentContainer(); 128 return m_textIterator.endPositionInCurrentContainer();
129 } 129 }
130 130
131 template <typename Strategy> 131 template <typename Strategy>
132 void CharacterIteratorAlgorithm<Strategy>::advance(int count) 132 void CharacterIteratorAlgorithm<Strategy>::advance(int count)
133 { 133 {
134 if (count <= 0) { 134 if (count <= 0) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 EphemeralRange calculateCharacterSubrange(const EphemeralRange& range, int chara cterOffset, int characterCount) 188 EphemeralRange calculateCharacterSubrange(const EphemeralRange& range, int chara cterOffset, int characterCount)
189 { 189 {
190 CharacterIterator entireRangeIterator(range, TextIteratorEmitsObjectReplacem entCharacter); 190 CharacterIterator entireRangeIterator(range, TextIteratorEmitsObjectReplacem entCharacter);
191 return entireRangeIterator.calculateCharacterSubrange(characterOffset, chara cterCount); 191 return entireRangeIterator.calculateCharacterSubrange(characterOffset, chara cterCount);
192 } 192 }
193 193
194 template class CORE_TEMPLATE_EXPORT CharacterIteratorAlgorithm<EditingStrategy>; 194 template class CORE_TEMPLATE_EXPORT CharacterIteratorAlgorithm<EditingStrategy>;
195 template class CORE_TEMPLATE_EXPORT CharacterIteratorAlgorithm<EditingInComposed TreeStrategy>; 195 template class CORE_TEMPLATE_EXPORT CharacterIteratorAlgorithm<EditingInComposed TreeStrategy>;
196 196
197 } // namespace blink 197 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698