OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2009 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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 if (atStartOfLine || !rendered) { | 497 if (atStartOfLine || !rendered) { |
498 if (currentPos.isCandidate()) | 498 if (currentPos.isCandidate()) |
499 return currentPos; | 499 return currentPos; |
500 } else if (rendersInDifferentPosition(currentPos)) | 500 } else if (rendersInDifferentPosition(currentPos)) |
501 return currentPos; | 501 return currentPos; |
502 } | 502 } |
503 | 503 |
504 return *this; | 504 return *this; |
505 } | 505 } |
506 | 506 |
507 // return first following position rendered at a different location, or "this" | |
508 Position Position::nextCharacterPosition(EAffinity affinity) const | |
509 { | |
510 if (isNull()) | |
511 return Position(); | |
512 | |
513 Node* fromRootEditableElement = deprecatedNode()->rootEditableElement(); | |
514 | |
515 bool atEndOfLine = isEndOfLine(VisiblePosition(*this, affinity)); | |
516 bool rendered = isCandidate(); | |
517 | |
518 Position currentPos = *this; | |
519 while (!currentPos.atEndOfTree()) { | |
520 currentPos = currentPos.next(); | |
521 | |
522 if (currentPos.deprecatedNode()->rootEditableElement() != fromRootEditab
leElement) | |
523 return *this; | |
524 | |
525 if (atEndOfLine || !rendered) { | |
526 if (currentPos.isCandidate()) | |
527 return currentPos; | |
528 } else if (rendersInDifferentPosition(currentPos)) | |
529 return currentPos; | |
530 } | |
531 | |
532 return *this; | |
533 } | |
534 | |
535 // Whether or not [node, 0] and [node, lastOffsetForEditing(node)] are their own
VisiblePositions. | 507 // Whether or not [node, 0] and [node, lastOffsetForEditing(node)] are their own
VisiblePositions. |
536 // If true, adjacent candidates are visually distinct. | 508 // If true, adjacent candidates are visually distinct. |
537 // FIXME: Disregard nodes with renderers that have no height, as we do in isCand
idate. | 509 // FIXME: Disregard nodes with renderers that have no height, as we do in isCand
idate. |
538 // FIXME: Share code with isCandidate, if possible. | 510 // FIXME: Share code with isCandidate, if possible. |
539 static bool endsOfNodeAreVisuallyDistinctPositions(Node* node) | 511 static bool endsOfNodeAreVisuallyDistinctPositions(Node* node) |
540 { | 512 { |
541 if (!node || !node->renderer()) | 513 if (!node || !node->renderer()) |
542 return false; | 514 return false; |
543 | 515 |
544 if (!node->renderer()->isInline()) | 516 if (!node->renderer()->isInline()) |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 pos.showTreeForThis(); | 1360 pos.showTreeForThis(); |
1389 } | 1361 } |
1390 | 1362 |
1391 void showTree(const WebCore::Position* pos) | 1363 void showTree(const WebCore::Position* pos) |
1392 { | 1364 { |
1393 if (pos) | 1365 if (pos) |
1394 pos->showTreeForThis(); | 1366 pos->showTreeForThis(); |
1395 } | 1367 } |
1396 | 1368 |
1397 #endif | 1369 #endif |
OLD | NEW |