OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. | 3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. |
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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 // to it is allowed. VisibleSelection::adjustForEditableContent has this pr
oblem too. | 468 // to it is allowed. VisibleSelection::adjustForEditableContent has this pr
oblem too. |
469 if (highestEditableRoot(pos.deepEquivalent()) == highestRoot) | 469 if (highestEditableRoot(pos.deepEquivalent()) == highestRoot) |
470 return pos; | 470 return pos; |
471 | 471 |
472 // Return empty position if this position is non-editable, but pos is editab
le | 472 // Return empty position if this position is non-editable, but pos is editab
le |
473 // FIXME: Move to the previous non-editable region. | 473 // FIXME: Move to the previous non-editable region. |
474 if (!highestRoot) | 474 if (!highestRoot) |
475 return VisiblePosition(); | 475 return VisiblePosition(); |
476 | 476 |
477 // Return the last position before pos that is in the same editable region a
s this position | 477 // Return the last position before pos that is in the same editable region a
s this position |
478 return lastEditablePositionBeforePositionInRoot(pos.deepEquivalent(), highes
tRoot); | 478 return lastEditableVisiblePositionBeforePositionInRoot(pos.deepEquivalent(),
highestRoot); |
479 } | 479 } |
480 | 480 |
481 VisiblePosition VisiblePosition::honorEditingBoundaryAtOrAfter(const VisiblePosi
tion &pos) const | 481 VisiblePosition VisiblePosition::honorEditingBoundaryAtOrAfter(const VisiblePosi
tion &pos) const |
482 { | 482 { |
483 if (pos.isNull()) | 483 if (pos.isNull()) |
484 return pos; | 484 return pos; |
485 | 485 |
486 Node* highestRoot = highestEditableRoot(deepEquivalent()); | 486 Node* highestRoot = highestEditableRoot(deepEquivalent()); |
487 | 487 |
488 // Return empty position if pos is not somewhere inside the editable region
containing this position | 488 // Return empty position if pos is not somewhere inside the editable region
containing this position |
489 if (highestRoot && !pos.deepEquivalent().deprecatedNode()->isDescendantOf(hi
ghestRoot)) | 489 if (highestRoot && !pos.deepEquivalent().deprecatedNode()->isDescendantOf(hi
ghestRoot)) |
490 return VisiblePosition(); | 490 return VisiblePosition(); |
491 | 491 |
492 // Return pos itself if the two are from the very same editable region, or b
oth are non-editable | 492 // Return pos itself if the two are from the very same editable region, or b
oth are non-editable |
493 // FIXME: In the non-editable case, just because the new position is non-edi
table doesn't mean movement | 493 // FIXME: In the non-editable case, just because the new position is non-edi
table doesn't mean movement |
494 // to it is allowed. VisibleSelection::adjustForEditableContent has this pr
oblem too. | 494 // to it is allowed. VisibleSelection::adjustForEditableContent has this pr
oblem too. |
495 if (highestEditableRoot(pos.deepEquivalent()) == highestRoot) | 495 if (highestEditableRoot(pos.deepEquivalent()) == highestRoot) |
496 return pos; | 496 return pos; |
497 | 497 |
498 // Return empty position if this position is non-editable, but pos is editab
le | 498 // Return empty position if this position is non-editable, but pos is editab
le |
499 // FIXME: Move to the next non-editable region. | 499 // FIXME: Move to the next non-editable region. |
500 if (!highestRoot) | 500 if (!highestRoot) |
501 return VisiblePosition(); | 501 return VisiblePosition(); |
502 | 502 |
503 // Return the next position after pos that is in the same editable region as
this position | 503 // Return the next position after pos that is in the same editable region as
this position |
504 return firstEditablePositionAfterPositionInRoot(pos.deepEquivalent(), highes
tRoot); | 504 return firstEditableVisiblePositionAfterPositionInRoot(pos.deepEquivalent(),
highestRoot); |
505 } | 505 } |
506 | 506 |
507 VisiblePosition VisiblePosition::skipToStartOfEditingBoundary(const VisiblePosit
ion &pos) const | 507 VisiblePosition VisiblePosition::skipToStartOfEditingBoundary(const VisiblePosit
ion &pos) const |
508 { | 508 { |
509 if (pos.isNull()) | 509 if (pos.isNull()) |
510 return pos; | 510 return pos; |
511 | 511 |
512 Node* highestRoot = highestEditableRoot(deepEquivalent()); | 512 Node* highestRoot = highestEditableRoot(deepEquivalent()); |
513 Node* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); | 513 Node* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); |
514 | 514 |
515 // Return pos itself if the two are from the very same editable region, or b
oth are non-editable. | 515 // Return pos itself if the two are from the very same editable region, or b
oth are non-editable. |
516 if (highestRootOfPos == highestRoot) | 516 if (highestRootOfPos == highestRoot) |
517 return pos; | 517 return pos; |
518 | 518 |
519 // If |pos| has an editable root, skip to the start | 519 // If |pos| has an editable root, skip to the start |
520 if (highestRootOfPos) | 520 if (highestRootOfPos) |
521 return VisiblePosition(previousVisuallyDistinctCandidate(Position(highes
tRootOfPos, Position::PositionIsBeforeAnchor).parentAnchoredEquivalent())); | 521 return VisiblePosition(previousVisuallyDistinctCandidate(Position(highes
tRootOfPos, Position::PositionIsBeforeAnchor).parentAnchoredEquivalent())); |
522 | 522 |
523 // That must mean that |pos| is not editable. Return the last position befor
e pos that is in the same editable region as this position | 523 // That must mean that |pos| is not editable. Return the last position befor
e pos that is in the same editable region as this position |
524 return lastEditablePositionBeforePositionInRoot(pos.deepEquivalent(), highes
tRoot); | 524 return lastEditableVisiblePositionBeforePositionInRoot(pos.deepEquivalent(),
highestRoot); |
525 } | 525 } |
526 | 526 |
527 VisiblePosition VisiblePosition::skipToEndOfEditingBoundary(const VisiblePositio
n &pos) const | 527 VisiblePosition VisiblePosition::skipToEndOfEditingBoundary(const VisiblePositio
n &pos) const |
528 { | 528 { |
529 if (pos.isNull()) | 529 if (pos.isNull()) |
530 return pos; | 530 return pos; |
531 | 531 |
532 Node* highestRoot = highestEditableRoot(deepEquivalent()); | 532 Node* highestRoot = highestEditableRoot(deepEquivalent()); |
533 Node* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); | 533 Node* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); |
534 | 534 |
535 // Return pos itself if the two are from the very same editable region, or b
oth are non-editable. | 535 // Return pos itself if the two are from the very same editable region, or b
oth are non-editable. |
536 if (highestRootOfPos == highestRoot) | 536 if (highestRootOfPos == highestRoot) |
537 return pos; | 537 return pos; |
538 | 538 |
539 // If |pos| has an editable root, skip to the end | 539 // If |pos| has an editable root, skip to the end |
540 if (highestRootOfPos) | 540 if (highestRootOfPos) |
541 return VisiblePosition(Position(highestRootOfPos, Position::PositionIsAf
terAnchor).parentAnchoredEquivalent()); | 541 return VisiblePosition(Position(highestRootOfPos, Position::PositionIsAf
terAnchor).parentAnchoredEquivalent()); |
542 | 542 |
543 // That must mean that |pos| is not editable. Return the next position after
pos that is in the same editable region as this position | 543 // That must mean that |pos| is not editable. Return the next position after
pos that is in the same editable region as this position |
544 return firstEditablePositionAfterPositionInRoot(pos.deepEquivalent(), highes
tRoot); | 544 return firstEditableVisiblePositionAfterPositionInRoot(pos.deepEquivalent(),
highestRoot); |
545 } | 545 } |
546 | 546 |
547 static Position canonicalizeCandidate(const Position& candidate) | 547 static Position canonicalizeCandidate(const Position& candidate) |
548 { | 548 { |
549 if (candidate.isNull()) | 549 if (candidate.isNull()) |
550 return Position(); | 550 return Position(); |
551 ASSERT(candidate.isCandidate()); | 551 ASSERT(candidate.isCandidate()); |
552 Position upstream = candidate.upstream(); | 552 Position upstream = candidate.upstream(); |
553 if (upstream.isCandidate()) | 553 if (upstream.isCandidate()) |
554 return upstream; | 554 return upstream; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 if (vpos) | 804 if (vpos) |
805 vpos->showTreeForThis(); | 805 vpos->showTreeForThis(); |
806 } | 806 } |
807 | 807 |
808 void showTree(const WebCore::VisiblePosition& vpos) | 808 void showTree(const WebCore::VisiblePosition& vpos) |
809 { | 809 { |
810 vpos.showTreeForThis(); | 810 vpos.showTreeForThis(); |
811 } | 811 } |
812 | 812 |
813 #endif | 813 #endif |
OLD | NEW |