OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 Position p = position; | 251 Position p = position; |
252 Position downstreamStart = p.downstream(); | 252 Position downstreamStart = p.downstream(); |
253 while (!p.atStartOfTree()) { | 253 while (!p.atStartOfTree()) { |
254 p = p.previous(Character); | 254 p = p.previous(Character); |
255 if (p.isCandidate() && p.downstream() != downstreamStart) | 255 if (p.isCandidate() && p.downstream() != downstreamStart) |
256 return p; | 256 return p; |
257 } | 257 } |
258 return Position(); | 258 return Position(); |
259 } | 259 } |
260 | 260 |
261 VisiblePosition firstEditablePositionAfterPositionInRoot(const Position& positio
n, Node* highestRoot) | 261 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position&
position, Node* highestRoot) |
262 { | 262 { |
263 // position falls before highestRoot. | 263 // position falls before highestRoot. |
264 if (comparePositions(position, firstPositionInNode(highestRoot)) == -1 && hi
ghestRoot->rendererIsEditable()) | 264 if (comparePositions(position, firstPositionInNode(highestRoot)) == -1 && hi
ghestRoot->rendererIsEditable()) |
265 return VisiblePosition(firstPositionInNode(highestRoot)); | 265 return VisiblePosition(firstPositionInNode(highestRoot)); |
266 | 266 |
267 Position p = position; | 267 Position p = position; |
268 | 268 |
269 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { | 269 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { |
270 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(p.de
precatedNode()); | 270 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(p.de
precatedNode()); |
271 if (!shadowAncestor) | 271 if (!shadowAncestor) |
272 return VisiblePosition(); | 272 return VisiblePosition(); |
273 | 273 |
274 p = positionAfterNode(shadowAncestor); | 274 p = positionAfterNode(shadowAncestor); |
275 } | 275 } |
276 | 276 |
277 while (p.deprecatedNode() && !isEditablePosition(p) && p.deprecatedNode()->i
sDescendantOf(highestRoot)) | 277 while (p.deprecatedNode() && !isEditablePosition(p) && p.deprecatedNode()->i
sDescendantOf(highestRoot)) |
278 p = isAtomicNode(p.deprecatedNode()) ? positionInParentAfterNode(*p.depr
ecatedNode()) : nextVisuallyDistinctCandidate(p); | 278 p = isAtomicNode(p.deprecatedNode()) ? positionInParentAfterNode(*p.depr
ecatedNode()) : nextVisuallyDistinctCandidate(p); |
279 | 279 |
280 if (p.deprecatedNode() && p.deprecatedNode() != highestRoot && !p.deprecated
Node()->isDescendantOf(highestRoot)) | 280 if (p.deprecatedNode() && p.deprecatedNode() != highestRoot && !p.deprecated
Node()->isDescendantOf(highestRoot)) |
281 return VisiblePosition(); | 281 return VisiblePosition(); |
282 | 282 |
283 return VisiblePosition(p); | 283 return VisiblePosition(p); |
284 } | 284 } |
285 | 285 |
286 VisiblePosition lastEditablePositionBeforePositionInRoot(const Position& positio
n, Node* highestRoot) | 286 VisiblePosition lastEditableVisiblePositionBeforePositionInRoot(const Position&
position, Node* highestRoot) |
287 { | 287 { |
288 // When position falls after highestRoot, the result is easy to compute. | 288 // When position falls after highestRoot, the result is easy to compute. |
289 if (comparePositions(position, lastPositionInNode(highestRoot)) == 1) | 289 if (comparePositions(position, lastPositionInNode(highestRoot)) == 1) |
290 return VisiblePosition(lastPositionInNode(highestRoot)); | 290 return VisiblePosition(lastPositionInNode(highestRoot)); |
291 | 291 |
292 Position p = position; | 292 Position p = position; |
293 | 293 |
294 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { | 294 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { |
295 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(p.de
precatedNode()); | 295 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(p.de
precatedNode()); |
296 if (!shadowAncestor) | 296 if (!shadowAncestor) |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 // if the selection starts just before a paragraph break, skip over it | 1115 // if the selection starts just before a paragraph break, skip over it |
1116 if (isEndOfParagraph(visiblePosition)) | 1116 if (isEndOfParagraph(visiblePosition)) |
1117 return visiblePosition.next().deepEquivalent().downstream(); | 1117 return visiblePosition.next().deepEquivalent().downstream(); |
1118 | 1118 |
1119 // otherwise, make sure to be at the start of the first selected node, | 1119 // otherwise, make sure to be at the start of the first selected node, |
1120 // instead of possibly at the end of the last node before the selection | 1120 // instead of possibly at the end of the last node before the selection |
1121 return visiblePosition.deepEquivalent().downstream(); | 1121 return visiblePosition.deepEquivalent().downstream(); |
1122 } | 1122 } |
1123 | 1123 |
1124 } // namespace WebCore | 1124 } // namespace WebCore |
OLD | NEW |