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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 editablePosition = isAtomicNode(editablePosition.deprecatedNode()) ? pos
itionInParentAfterNode(*editablePosition.deprecatedNode()) : nextVisuallyDistinc
tCandidate(editablePosition); | 278 editablePosition = isAtomicNode(editablePosition.deprecatedNode()) ? pos
itionInParentAfterNode(*editablePosition.deprecatedNode()) : nextVisuallyDistinc
tCandidate(editablePosition); |
279 | 279 |
280 if (editablePosition.deprecatedNode() && editablePosition.deprecatedNode() !
= highestRoot && !editablePosition.deprecatedNode()->isDescendantOf(highestRoot)
) | 280 if (editablePosition.deprecatedNode() && editablePosition.deprecatedNode() !
= highestRoot && !editablePosition.deprecatedNode()->isDescendantOf(highestRoot)
) |
281 return VisiblePosition(); | 281 return VisiblePosition(); |
282 | 282 |
283 return VisiblePosition(editablePosition); | 283 return VisiblePosition(editablePosition); |
284 } | 284 } |
285 | 285 |
286 VisiblePosition lastEditableVisiblePositionBeforePositionInRoot(const Position&
position, Node* highestRoot) | 286 VisiblePosition lastEditableVisiblePositionBeforePositionInRoot(const Position&
position, Node* highestRoot) |
287 { | 287 { |
| 288 return VisiblePosition(lastEditablePositionBeforePositionInRoot(position, hi
ghestRoot)); |
| 289 } |
| 290 |
| 291 Position lastEditablePositionBeforePositionInRoot(const Position& position, Node
* highestRoot) |
| 292 { |
288 // When position falls after highestRoot, the result is easy to compute. | 293 // When position falls after highestRoot, the result is easy to compute. |
289 if (comparePositions(position, lastPositionInNode(highestRoot)) == 1) | 294 if (comparePositions(position, lastPositionInNode(highestRoot)) == 1) |
290 return VisiblePosition(lastPositionInNode(highestRoot)); | 295 return lastPositionInNode(highestRoot); |
291 | 296 |
292 Position editablePosition = position; | 297 Position editablePosition = position; |
293 | 298 |
294 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { | 299 if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) { |
295 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(edit
ablePosition.deprecatedNode()); | 300 Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(edit
ablePosition.deprecatedNode()); |
296 if (!shadowAncestor) | 301 if (!shadowAncestor) |
297 return VisiblePosition(); | 302 return Position(); |
298 | 303 |
299 editablePosition = firstPositionInOrBeforeNode(shadowAncestor); | 304 editablePosition = firstPositionInOrBeforeNode(shadowAncestor); |
300 } | 305 } |
301 | 306 |
302 while (editablePosition.deprecatedNode() && !isEditablePosition(editablePosi
tion) && editablePosition.deprecatedNode()->isDescendantOf(highestRoot)) | 307 while (editablePosition.deprecatedNode() && !isEditablePosition(editablePosi
tion) && editablePosition.deprecatedNode()->isDescendantOf(highestRoot)) |
303 editablePosition = isAtomicNode(editablePosition.deprecatedNode()) ? pos
itionInParentBeforeNode(*editablePosition.deprecatedNode()) : previousVisuallyDi
stinctCandidate(editablePosition); | 308 editablePosition = isAtomicNode(editablePosition.deprecatedNode()) ? pos
itionInParentBeforeNode(*editablePosition.deprecatedNode()) : previousVisuallyDi
stinctCandidate(editablePosition); |
304 | 309 |
305 if (editablePosition.deprecatedNode() && editablePosition.deprecatedNode() !
= highestRoot && !editablePosition.deprecatedNode()->isDescendantOf(highestRoot)
) | 310 if (editablePosition.deprecatedNode() && editablePosition.deprecatedNode() !
= highestRoot && !editablePosition.deprecatedNode()->isDescendantOf(highestRoot)
) |
306 return VisiblePosition(); | 311 return Position(); |
307 | 312 return editablePosition; |
308 return VisiblePosition(editablePosition); | |
309 } | 313 } |
310 | 314 |
311 // FIXME: The method name, comment, and code say three different things here! | 315 // FIXME: The method name, comment, and code say three different things here! |
312 // Whether or not content before and after this node will collapse onto the same
line as it. | 316 // Whether or not content before and after this node will collapse onto the same
line as it. |
313 bool isBlock(const Node* node) | 317 bool isBlock(const Node* node) |
314 { | 318 { |
315 return node && node->renderer() && !node->renderer()->isInline() && !node->r
enderer()->isRubyText(); | 319 return node && node->renderer() && !node->renderer()->isInline() && !node->r
enderer()->isRubyText(); |
316 } | 320 } |
317 | 321 |
318 bool isInline(const Node* node) | 322 bool isInline(const Node* node) |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 // if the selection starts just before a paragraph break, skip over it | 1119 // if the selection starts just before a paragraph break, skip over it |
1116 if (isEndOfParagraph(visiblePosition)) | 1120 if (isEndOfParagraph(visiblePosition)) |
1117 return visiblePosition.next().deepEquivalent().downstream(); | 1121 return visiblePosition.next().deepEquivalent().downstream(); |
1118 | 1122 |
1119 // otherwise, make sure to be at the start of the first selected node, | 1123 // 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 | 1124 // instead of possibly at the end of the last node before the selection |
1121 return visiblePosition.deepEquivalent().downstream(); | 1125 return visiblePosition.deepEquivalent().downstream(); |
1122 } | 1126 } |
1123 | 1127 |
1124 } // namespace WebCore | 1128 } // namespace WebCore |
OLD | NEW |