OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 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 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/editing/PositionIterator.h" | 27 #include "core/editing/PositionIterator.h" |
28 | 28 |
29 namespace blink { | 29 namespace blink { |
30 | 30 |
| 31 static const int kInvalidOffset = -1; |
| 32 |
31 template <typename Strategy> | 33 template <typename Strategy> |
32 PositionIteratorAlgorithm<Strategy>::PositionIteratorAlgorithm(Node* anchorNode,
int offsetInAnchor) | 34 PositionIteratorAlgorithm<Strategy>::PositionIteratorAlgorithm(Node* anchorNode,
int offsetInAnchor) |
33 : m_anchorNode(anchorNode) | 35 : m_anchorNode(anchorNode) |
34 , m_nodeAfterPositionInAnchor(Strategy::childAt(*anchorNode, offsetInAnchor)
) | 36 , m_nodeAfterPositionInAnchor(Strategy::childAt(*anchorNode, offsetInAnchor)
) |
35 , m_offsetInAnchor(m_nodeAfterPositionInAnchor ? 0 : offsetInAnchor) | 37 , m_offsetInAnchor(m_nodeAfterPositionInAnchor ? 0 : offsetInAnchor) |
| 38 , m_depthToAnchorNode(0) |
| 39 , m_domTreeVersion(anchorNode->document().domTreeVersion()) |
36 { | 40 { |
| 41 for (Node* node = Strategy::parent(*anchorNode); node; node = Strategy::pare
nt(*node)) { |
| 42 // Each m_offsetsInAnchorNode[offset] should be an index of node in |
| 43 // parent, but delay to calculate the index until it is needed for |
| 44 // performance. |
| 45 m_offsetsInAnchorNode.append(kInvalidOffset); |
| 46 ++m_depthToAnchorNode; |
| 47 } |
| 48 if (m_nodeAfterPositionInAnchor) |
| 49 m_offsetsInAnchorNode.append(offsetInAnchor); |
37 } | 50 } |
38 template <typename Strategy> | 51 template <typename Strategy> |
39 PositionIteratorAlgorithm<Strategy>::PositionIteratorAlgorithm(const PositionTem
plate<Strategy>& pos) | 52 PositionIteratorAlgorithm<Strategy>::PositionIteratorAlgorithm(const PositionTem
plate<Strategy>& pos) |
40 : PositionIteratorAlgorithm(pos.anchorNode(), pos.computeEditingOffset()) | 53 : PositionIteratorAlgorithm(pos.anchorNode(), pos.computeEditingOffset()) |
41 { | 54 { |
42 } | 55 } |
43 | 56 |
44 template <typename Strategy> | 57 template <typename Strategy> |
45 PositionIteratorAlgorithm<Strategy>::PositionIteratorAlgorithm() | 58 PositionIteratorAlgorithm<Strategy>::PositionIteratorAlgorithm() |
46 : m_anchorNode(nullptr) | 59 : m_anchorNode(nullptr) |
47 , m_nodeAfterPositionInAnchor(nullptr) | 60 , m_nodeAfterPositionInAnchor(nullptr) |
48 , m_offsetInAnchor(0) | 61 , m_offsetInAnchor(0) |
| 62 , m_depthToAnchorNode(0) |
| 63 , m_domTreeVersion(0) |
49 { | 64 { |
50 } | 65 } |
51 | 66 |
52 template <typename Strategy> | 67 template <typename Strategy> |
53 PositionTemplate<Strategy> PositionIteratorAlgorithm<Strategy>::deprecatedComput
ePosition() const | 68 PositionTemplate<Strategy> PositionIteratorAlgorithm<Strategy>::deprecatedComput
ePosition() const |
54 { | 69 { |
| 70 // TODO(yoichio): Share code to check domTreeVersion with EphemeralRange. |
| 71 ASSERT(isValid()); |
55 if (m_nodeAfterPositionInAnchor) { | 72 if (m_nodeAfterPositionInAnchor) { |
56 ASSERT(Strategy::parent(*m_nodeAfterPositionInAnchor) == m_anchorNode); | 73 ASSERT(Strategy::parent(*m_nodeAfterPositionInAnchor) == m_anchorNode); |
| 74 ASSERT(m_offsetsInAnchorNode[m_depthToAnchorNode] != kInvalidOffset); |
57 // FIXME: This check is inadaquete because any ancestor could be ignored
by editing | 75 // FIXME: This check is inadaquete because any ancestor could be ignored
by editing |
58 if (Strategy::editingIgnoresContent(Strategy::parent(*m_nodeAfterPositio
nInAnchor))) | 76 if (Strategy::editingIgnoresContent(Strategy::parent(*m_nodeAfterPositio
nInAnchor))) |
59 return PositionTemplate<Strategy>::beforeNode(m_anchorNode); | 77 return PositionTemplate<Strategy>::beforeNode(m_anchorNode); |
60 return PositionTemplate<Strategy>::inParentBeforeNode(*m_nodeAfterPositi
onInAnchor); | 78 return PositionTemplate<Strategy>(m_anchorNode, m_offsetsInAnchorNode[m_
depthToAnchorNode]); |
61 } | 79 } |
62 if (Strategy::hasChildren(*m_anchorNode)) | 80 if (Strategy::hasChildren(*m_anchorNode)) |
63 return PositionTemplate<Strategy>::lastPositionInOrAfterNode(m_anchorNod
e); | 81 return PositionTemplate<Strategy>::lastPositionInOrAfterNode(m_anchorNod
e); |
64 return PositionTemplate<Strategy>::editingPositionOf(m_anchorNode, m_offsetI
nAnchor); | 82 return PositionTemplate<Strategy>::editingPositionOf(m_anchorNode, m_offsetI
nAnchor); |
65 } | 83 } |
66 | 84 |
67 template <typename Strategy> | 85 template <typename Strategy> |
68 PositionTemplate<Strategy> PositionIteratorAlgorithm<Strategy>::computePosition(
) const | 86 PositionTemplate<Strategy> PositionIteratorAlgorithm<Strategy>::computePosition(
) const |
69 { | 87 { |
| 88 ASSERT(isValid()); |
| 89 // Assume that we have the following DOM tree: |
| 90 // A |
| 91 // |-B |
| 92 // | |-E |
| 93 // | +-F |
| 94 // | |
| 95 // |-C |
| 96 // +-D |
| 97 // |-G |
| 98 // +-H |
70 if (m_nodeAfterPositionInAnchor) { | 99 if (m_nodeAfterPositionInAnchor) { |
| 100 // For example, position is before E, F. |
71 ASSERT(Strategy::parent(*m_nodeAfterPositionInAnchor) == m_anchorNode); | 101 ASSERT(Strategy::parent(*m_nodeAfterPositionInAnchor) == m_anchorNode); |
72 return PositionTemplate<Strategy>::inParentBeforeNode(*m_nodeAfterPositi
onInAnchor); | 102 ASSERT(m_offsetsInAnchorNode[m_depthToAnchorNode] != kInvalidOffset); |
| 103 // TODO(yoichio): This should be equivalent to |
| 104 // PositionTemplate<Strategy>(m_anchorNode, PositionAnchorType::BeforeAn
chor); |
| 105 return PositionTemplate<Strategy>(m_anchorNode, m_offsetsInAnchorNode[m_
depthToAnchorNode]); |
73 } | 106 } |
74 if (Strategy::hasChildren(*m_anchorNode)) | 107 if (Strategy::hasChildren(*m_anchorNode)) |
| 108 // For example, position is the end of B. |
75 return PositionTemplate<Strategy>::lastPositionInOrAfterNode(m_anchorNod
e); | 109 return PositionTemplate<Strategy>::lastPositionInOrAfterNode(m_anchorNod
e); |
76 if (m_anchorNode->isTextNode()) | 110 if (m_anchorNode->isTextNode()) |
77 return PositionTemplate<Strategy>(m_anchorNode, m_offsetInAnchor); | 111 return PositionTemplate<Strategy>(m_anchorNode, m_offsetInAnchor); |
78 if (m_offsetInAnchor) | 112 if (m_offsetInAnchor) |
| 113 // For example, position is after G. |
79 return PositionTemplate<Strategy>(m_anchorNode, PositionAnchorType::Afte
rAnchor); | 114 return PositionTemplate<Strategy>(m_anchorNode, PositionAnchorType::Afte
rAnchor); |
| 115 // For example, position is before G. |
80 return PositionTemplate<Strategy>(m_anchorNode, PositionAnchorType::BeforeAn
chor); | 116 return PositionTemplate<Strategy>(m_anchorNode, PositionAnchorType::BeforeAn
chor); |
81 } | 117 } |
82 | 118 |
83 template <typename Strategy> | 119 template <typename Strategy> |
84 void PositionIteratorAlgorithm<Strategy>::increment() | 120 void PositionIteratorAlgorithm<Strategy>::increment() |
85 { | 121 { |
| 122 ASSERT(isValid()); |
86 if (!m_anchorNode) | 123 if (!m_anchorNode) |
87 return; | 124 return; |
88 | 125 |
| 126 // Assume that we have the following DOM tree: |
| 127 // A |
| 128 // |-B |
| 129 // | |-E |
| 130 // | +-F |
| 131 // | |
| 132 // |-C |
| 133 // +-D |
| 134 // |-G |
| 135 // +-H |
| 136 // Let |anchor| as |m_anchorNode| and |
| 137 // |child| as |m_nodeAfterPositionInAnchor|. |
89 if (m_nodeAfterPositionInAnchor) { | 138 if (m_nodeAfterPositionInAnchor) { |
| 139 // Case #1: Move to position before the first child of |
| 140 // |m_nodeAfterPositionInAnchor|. |
| 141 // This is a point just before |child|. |
| 142 // Let |anchor| is A and |child| is B, |
| 143 // then next |anchor| is B and |child| is E. |
90 m_anchorNode = m_nodeAfterPositionInAnchor; | 144 m_anchorNode = m_nodeAfterPositionInAnchor; |
91 m_nodeAfterPositionInAnchor = Strategy::firstChild(*m_anchorNode); | 145 m_nodeAfterPositionInAnchor = Strategy::firstChild(*m_anchorNode); |
92 m_offsetInAnchor = 0; | 146 m_offsetInAnchor = 0; |
| 147 // Increment depth intializing with 0. |
| 148 ++m_depthToAnchorNode; |
| 149 if (m_depthToAnchorNode == m_offsetsInAnchorNode.size()) |
| 150 m_offsetsInAnchorNode.append(0); |
| 151 else |
| 152 m_offsetsInAnchorNode[m_depthToAnchorNode] = 0; |
93 return; | 153 return; |
94 } | 154 } |
95 | 155 |
96 if (m_anchorNode->layoutObject() && !Strategy::hasChildren(*m_anchorNode) &&
m_offsetInAnchor < Strategy::lastOffsetForEditing(m_anchorNode)) { | 156 if (m_anchorNode->layoutObject() && !Strategy::hasChildren(*m_anchorNode) &&
m_offsetInAnchor < Strategy::lastOffsetForEditing(m_anchorNode)) { |
| 157 // Case #2. This is the next of Case #1 or #2 itself. |
| 158 // Position is (|anchor|, |m_offsetInAchor|). |
| 159 // In this case |anchor| is a leaf(E,F,C,G or H) and |
| 160 // |m_offsetInAnchor| is not on the end of |anchor|. |
| 161 // Then just increment |m_offsetInAnchor|. |
97 m_offsetInAnchor = uncheckedNextOffset(m_anchorNode, m_offsetInAnchor); | 162 m_offsetInAnchor = uncheckedNextOffset(m_anchorNode, m_offsetInAnchor); |
98 } else { | 163 } else { |
| 164 // Case #3. This is the next of Case #2 or #3. |
| 165 // Position is the end of |anchor|. |
| 166 // 3-a. If |anchor| has next sibling (let E), |
| 167 // next |anchor| is B and |child| is F (next is Case #1.) |
| 168 // 3-b. If |anchor| doesn't have next sibling (let F), |
| 169 // next |anchor| is B and |child| is null. (next is Case #3.) |
99 m_nodeAfterPositionInAnchor = m_anchorNode; | 170 m_nodeAfterPositionInAnchor = m_anchorNode; |
100 m_anchorNode = Strategy::parent(*m_nodeAfterPositionInAnchor); | 171 m_anchorNode = Strategy::parent(*m_nodeAfterPositionInAnchor); |
| 172 if (!m_anchorNode) |
| 173 return; |
| 174 ASSERT(m_depthToAnchorNode > 0); |
| 175 --m_depthToAnchorNode; |
| 176 // Increment offset of |child| or initialize if it have never been |
| 177 // used. |
| 178 if (m_offsetsInAnchorNode[m_depthToAnchorNode] == kInvalidOffset) |
| 179 m_offsetsInAnchorNode[m_depthToAnchorNode] = Strategy::index(*m_node
AfterPositionInAnchor) + 1; |
| 180 else |
| 181 ++m_offsetsInAnchorNode[m_depthToAnchorNode]; |
101 m_nodeAfterPositionInAnchor = Strategy::nextSibling(*m_nodeAfterPosition
InAnchor); | 182 m_nodeAfterPositionInAnchor = Strategy::nextSibling(*m_nodeAfterPosition
InAnchor); |
102 m_offsetInAnchor = 0; | 183 m_offsetInAnchor = 0; |
103 } | 184 } |
104 } | 185 } |
105 | 186 |
106 template <typename Strategy> | 187 template <typename Strategy> |
107 void PositionIteratorAlgorithm<Strategy>::decrement() | 188 void PositionIteratorAlgorithm<Strategy>::decrement() |
108 { | 189 { |
| 190 ASSERT(isValid()); |
109 if (!m_anchorNode) | 191 if (!m_anchorNode) |
110 return; | 192 return; |
111 | 193 |
| 194 // Assume that we have the following DOM tree: |
| 195 // A |
| 196 // |-B |
| 197 // | |-E |
| 198 // | +-F |
| 199 // | |
| 200 // |-C |
| 201 // +-D |
| 202 // |-G |
| 203 // +-H |
| 204 // Let |anchor| as |m_anchorNode| and |
| 205 // |child| as |m_nodeAfterPositionInAnchor|. |
| 206 // decrement() is complex but logically reverse of increment(), of course:) |
112 if (m_nodeAfterPositionInAnchor) { | 207 if (m_nodeAfterPositionInAnchor) { |
113 m_anchorNode = Strategy::previousSibling(*m_nodeAfterPositionInAnchor); | 208 m_anchorNode = Strategy::previousSibling(*m_nodeAfterPositionInAnchor); |
114 if (m_anchorNode) { | 209 if (m_anchorNode) { |
| 210 // Case #1-a. This is a revese of increment()::Case#3-a. |
| 211 // |child| has a previous sibling. |
| 212 // Let |anchor| is B and |child| is F, |
| 213 // next |anchor| is E and |child| is null. |
115 m_nodeAfterPositionInAnchor = nullptr; | 214 m_nodeAfterPositionInAnchor = nullptr; |
116 m_offsetInAnchor = Strategy::hasChildren(*m_anchorNode) ? 0 : Strate
gy::lastOffsetForEditing(m_anchorNode); | 215 m_offsetInAnchor = Strategy::hasChildren(*m_anchorNode) ? 0 : Strate
gy::lastOffsetForEditing(m_anchorNode); |
| 216 // Decrement offset of |child| or initialize if it have never been |
| 217 // used. |
| 218 if (m_offsetsInAnchorNode[m_depthToAnchorNode] == kInvalidOffset) |
| 219 m_offsetsInAnchorNode[m_depthToAnchorNode] = Strategy::index(*m_
nodeAfterPositionInAnchor); |
| 220 else |
| 221 --m_offsetsInAnchorNode[m_depthToAnchorNode]; |
| 222 ASSERT(m_offsetsInAnchorNode[m_depthToAnchorNode] >= 0); |
| 223 // Increment depth intializing with last offset. |
| 224 ++m_depthToAnchorNode; |
| 225 if (m_depthToAnchorNode >= m_offsetsInAnchorNode.size()) |
| 226 m_offsetsInAnchorNode.append(m_offsetInAnchor); |
| 227 else |
| 228 m_offsetsInAnchorNode[m_depthToAnchorNode] = m_offsetInAnchor; |
| 229 return; |
117 } else { | 230 } else { |
| 231 // Case #1-b. This is a revese of increment()::Case#1. |
| 232 // |child| doesn't have a previous sibling. |
| 233 // Let |anchor| is B and |child| is E, |
| 234 // next |anchor| is A and |child| is B. |
118 m_nodeAfterPositionInAnchor = Strategy::parent(*m_nodeAfterPositionI
nAnchor); | 235 m_nodeAfterPositionInAnchor = Strategy::parent(*m_nodeAfterPositionI
nAnchor); |
119 m_anchorNode = Strategy::parent(*m_nodeAfterPositionInAnchor); | 236 m_anchorNode = Strategy::parent(*m_nodeAfterPositionInAnchor); |
| 237 if (!m_anchorNode) |
| 238 return; |
120 m_offsetInAnchor = 0; | 239 m_offsetInAnchor = 0; |
| 240 // Decrement depth and intialize if needs. |
| 241 ASSERT(m_depthToAnchorNode > 0); |
| 242 --m_depthToAnchorNode; |
| 243 if (m_offsetsInAnchorNode[m_depthToAnchorNode] == kInvalidOffset) |
| 244 m_offsetsInAnchorNode[m_depthToAnchorNode] = Strategy::index(*m_
nodeAfterPositionInAnchor); |
121 } | 245 } |
122 return; | 246 return; |
123 } | 247 } |
124 | 248 |
125 if (Strategy::hasChildren(*m_anchorNode)) { | 249 if (Strategy::hasChildren(*m_anchorNode)) { |
| 250 // Case #2. This is a reverse of increment()::Case3-b. |
| 251 // Let |anchor| is B, next |anchor| is F. |
126 m_anchorNode = Strategy::lastChild(*m_anchorNode); | 252 m_anchorNode = Strategy::lastChild(*m_anchorNode); |
127 m_offsetInAnchor = Strategy::hasChildren(*m_anchorNode)? 0 : Strategy::l
astOffsetForEditing(m_anchorNode); | 253 m_offsetInAnchor = Strategy::hasChildren(*m_anchorNode)? 0 : Strategy::l
astOffsetForEditing(m_anchorNode); |
| 254 // Decrement depth initializing with -1 because |
| 255 // |m_nodeAfterPositionInAnchor| is null so still unneeded. |
| 256 if (m_depthToAnchorNode >= m_offsetsInAnchorNode.size()) |
| 257 m_offsetsInAnchorNode.append(kInvalidOffset); |
| 258 else |
| 259 m_offsetsInAnchorNode[m_depthToAnchorNode] = kInvalidOffset; |
| 260 ++m_depthToAnchorNode; |
| 261 return; |
128 } else { | 262 } else { |
129 if (m_offsetInAnchor && m_anchorNode->layoutObject()) { | 263 if (m_offsetInAnchor && m_anchorNode->layoutObject()) { |
| 264 // Case #3-a. This is a reverse of increment()::Case#2. |
| 265 // In this case |anchor| is a leaf(E,F,C,G or H) and |
| 266 // |m_offsetInAnchor| is not on the beginning of |anchor|. |
| 267 // Then just decrement |m_offsetInAnchor|. |
130 m_offsetInAnchor = uncheckedPreviousOffset(m_anchorNode, m_offsetInA
nchor); | 268 m_offsetInAnchor = uncheckedPreviousOffset(m_anchorNode, m_offsetInA
nchor); |
| 269 return; |
131 } else { | 270 } else { |
| 271 // Case #3-b. This is a reverse of increment()::Case#1. |
| 272 // In this case |anchor| is a leaf(E,F,C,G or H) and |
| 273 // |m_offsetInAnchor| is on the beginning of |anchor|. |
| 274 // Let |anchor| is E, |
| 275 // next |anchor| is B and |child| is E. |
132 m_nodeAfterPositionInAnchor = m_anchorNode; | 276 m_nodeAfterPositionInAnchor = m_anchorNode; |
133 m_anchorNode = Strategy::parent(*m_anchorNode); | 277 m_anchorNode = Strategy::parent(*m_anchorNode); |
| 278 if (!m_anchorNode) |
| 279 return; |
| 280 ASSERT(m_depthToAnchorNode > 0); |
| 281 --m_depthToAnchorNode; |
| 282 if (m_offsetsInAnchorNode[m_depthToAnchorNode] == kInvalidOffset) |
| 283 m_offsetsInAnchorNode[m_depthToAnchorNode] = Strategy::index(*m_
nodeAfterPositionInAnchor); |
134 } | 284 } |
135 } | 285 } |
136 } | 286 } |
137 | 287 |
138 template <typename Strategy> | 288 template <typename Strategy> |
139 bool PositionIteratorAlgorithm<Strategy>::atStart() const | 289 bool PositionIteratorAlgorithm<Strategy>::atStart() const |
140 { | 290 { |
| 291 ASSERT(isValid()); |
141 if (!m_anchorNode) | 292 if (!m_anchorNode) |
142 return true; | 293 return true; |
143 if (Strategy::parent(*m_anchorNode)) | 294 if (Strategy::parent(*m_anchorNode)) |
144 return false; | 295 return false; |
145 return (!Strategy::hasChildren(*m_anchorNode) && !m_offsetInAnchor) || (m_no
deAfterPositionInAnchor && !Strategy::previousSibling(*m_nodeAfterPositionInAnch
or)); | 296 return (!Strategy::hasChildren(*m_anchorNode) && !m_offsetInAnchor) || (m_no
deAfterPositionInAnchor && !Strategy::previousSibling(*m_nodeAfterPositionInAnch
or)); |
146 } | 297 } |
147 | 298 |
148 template <typename Strategy> | 299 template <typename Strategy> |
149 bool PositionIteratorAlgorithm<Strategy>::atEnd() const | 300 bool PositionIteratorAlgorithm<Strategy>::atEnd() const |
150 { | 301 { |
| 302 ASSERT(isValid()); |
151 if (!m_anchorNode) | 303 if (!m_anchorNode) |
152 return true; | 304 return true; |
153 if (m_nodeAfterPositionInAnchor) | 305 if (m_nodeAfterPositionInAnchor) |
154 return false; | 306 return false; |
155 return !Strategy::parent(*m_anchorNode) && (Strategy::hasChildren(*m_anchorN
ode) || m_offsetInAnchor >= Strategy::lastOffsetForEditing(m_anchorNode)); | 307 return !Strategy::parent(*m_anchorNode) && (Strategy::hasChildren(*m_anchorN
ode) || m_offsetInAnchor >= Strategy::lastOffsetForEditing(m_anchorNode)); |
156 } | 308 } |
157 | 309 |
158 template <typename Strategy> | 310 template <typename Strategy> |
159 bool PositionIteratorAlgorithm<Strategy>::atStartOfNode() const | 311 bool PositionIteratorAlgorithm<Strategy>::atStartOfNode() const |
160 { | 312 { |
| 313 ASSERT(isValid()); |
161 if (!m_anchorNode) | 314 if (!m_anchorNode) |
162 return true; | 315 return true; |
163 if (!m_nodeAfterPositionInAnchor) | 316 if (!m_nodeAfterPositionInAnchor) |
164 return !Strategy::hasChildren(*m_anchorNode) && !m_offsetInAnchor; | 317 return !Strategy::hasChildren(*m_anchorNode) && !m_offsetInAnchor; |
165 return !Strategy::previousSibling(*m_nodeAfterPositionInAnchor); | 318 return !Strategy::previousSibling(*m_nodeAfterPositionInAnchor); |
166 } | 319 } |
167 | 320 |
168 template <typename Strategy> | 321 template <typename Strategy> |
169 bool PositionIteratorAlgorithm<Strategy>::atEndOfNode() const | 322 bool PositionIteratorAlgorithm<Strategy>::atEndOfNode() const |
170 { | 323 { |
| 324 ASSERT(isValid()); |
171 if (!m_anchorNode) | 325 if (!m_anchorNode) |
172 return true; | 326 return true; |
173 if (m_nodeAfterPositionInAnchor) | 327 if (m_nodeAfterPositionInAnchor) |
174 return false; | 328 return false; |
175 return Strategy::hasChildren(*m_anchorNode) || m_offsetInAnchor >= Strategy:
:lastOffsetForEditing(m_anchorNode); | 329 return Strategy::hasChildren(*m_anchorNode) || m_offsetInAnchor >= Strategy:
:lastOffsetForEditing(m_anchorNode); |
176 } | 330 } |
177 | 331 |
178 template class PositionIteratorAlgorithm<EditingStrategy>; | 332 template class PositionIteratorAlgorithm<EditingStrategy>; |
179 template class PositionIteratorAlgorithm<EditingInComposedTreeStrategy>; | 333 template class PositionIteratorAlgorithm<EditingInComposedTreeStrategy>; |
180 | 334 |
181 } // namespace blink | 335 } // namespace blink |
OLD | NEW |