| 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 450 |
| 451 // FIXME: This may need to do something different from "after". | 451 // FIXME: This may need to do something different from "after". |
| 452 return honorEditingBoundaryAtOrAfter(right); | 452 return honorEditingBoundaryAtOrAfter(right); |
| 453 } | 453 } |
| 454 | 454 |
| 455 VisiblePosition VisiblePosition::honorEditingBoundaryAtOrBefore(const VisiblePos
ition &pos) const | 455 VisiblePosition VisiblePosition::honorEditingBoundaryAtOrBefore(const VisiblePos
ition &pos) const |
| 456 { | 456 { |
| 457 if (pos.isNull()) | 457 if (pos.isNull()) |
| 458 return pos; | 458 return pos; |
| 459 | 459 |
| 460 Node* highestRoot = highestEditableRoot(deepEquivalent()); | 460 ContainerNode* highestRoot = highestEditableRoot(deepEquivalent()); |
| 461 | 461 |
| 462 // Return empty position if pos is not somewhere inside the editable region
containing this position | 462 // Return empty position if pos is not somewhere inside the editable region
containing this position |
| 463 if (highestRoot && !pos.deepEquivalent().deprecatedNode()->isDescendantOf(hi
ghestRoot)) | 463 if (highestRoot && !pos.deepEquivalent().deprecatedNode()->isDescendantOf(hi
ghestRoot)) |
| 464 return VisiblePosition(); | 464 return VisiblePosition(); |
| 465 | 465 |
| 466 // Return pos itself if the two are from the very same editable region, or b
oth are non-editable | 466 // Return pos itself if the two are from the very same editable region, or b
oth are non-editable |
| 467 // FIXME: In the non-editable case, just because the new position is non-edi
table doesn't mean movement | 467 // FIXME: In the non-editable case, just because the new position is non-edi
table doesn't mean movement |
| 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 lastEditableVisiblePositionBeforePositionInRoot(pos.deepEquivalent(),
highestRoot); | 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 ContainerNode* 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 firstEditableVisiblePositionAfterPositionInRoot(pos.deepEquivalent(),
highestRoot); | 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 ContainerNode* highestRoot = highestEditableRoot(deepEquivalent()); |
| 513 Node* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); | 513 ContainerNode* 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 lastEditableVisiblePositionBeforePositionInRoot(pos.deepEquivalent(),
highestRoot); | 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 ContainerNode* highestRoot = highestEditableRoot(deepEquivalent()); |
| 533 Node* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); | 533 ContainerNode* 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 |
| (...skipping 260 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 blink::VisiblePosition& vpos) | 808 void showTree(const blink::VisiblePosition& vpos) |
| 809 { | 809 { |
| 810 vpos.showTreeForThis(); | 810 vpos.showTreeForThis(); |
| 811 } | 811 } |
| 812 | 812 |
| 813 #endif | 813 #endif |
| OLD | NEW |