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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 if (pos.atStartOfTree()) | 87 if (pos.atStartOfTree()) |
88 return VisiblePosition(); | 88 return VisiblePosition(); |
89 | 89 |
90 VisiblePosition prev = VisiblePosition(pos, DOWNSTREAM); | 90 VisiblePosition prev = VisiblePosition(pos, DOWNSTREAM); |
91 ASSERT(prev.deepEquivalent() != m_deepPosition); | 91 ASSERT(prev.deepEquivalent() != m_deepPosition); |
92 | 92 |
93 #if ENABLE(ASSERT) | 93 #if ENABLE(ASSERT) |
94 // we should always be able to make the affinity DOWNSTREAM, because going p
revious from an | 94 // we should always be able to make the affinity DOWNSTREAM, because going p
revious from an |
95 // UPSTREAM position can never yield another UPSTREAM position (unless line
wrap length is 0!). | 95 // UPSTREAM position can never yield another UPSTREAM position (unless line
wrap length is 0!). |
96 if (prev.isNotNull() && m_affinity == UPSTREAM) { | 96 if (prev.isNotNull() && m_affinity == UPSTREAM) { |
97 ASSERT(inSameLine(PositionWithAffinity(prev.deepEquivalent(), DOWNSTREAM
), PositionWithAffinity(prev.deepEquivalent(), UPSTREAM))); | 97 ASSERT(inSameLine(PositionWithAffinity(prev.deepEquivalent()), PositionW
ithAffinity(prev.deepEquivalent(), UPSTREAM))); |
98 } | 98 } |
99 #endif | 99 #endif |
100 | 100 |
101 switch (rule) { | 101 switch (rule) { |
102 case CanCrossEditingBoundary: | 102 case CanCrossEditingBoundary: |
103 return prev; | 103 return prev; |
104 case CannotCrossEditingBoundary: | 104 case CannotCrossEditingBoundary: |
105 return honorEditingBoundaryAtOrBefore(prev); | 105 return honorEditingBoundaryAtOrBefore(prev); |
106 case CanSkipOverEditingBoundary: | 106 case CanSkipOverEditingBoundary: |
107 return skipToStartOfEditingBoundary(prev); | 107 return skipToStartOfEditingBoundary(prev); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 | 645 |
646 if (m_affinity != UPSTREAM) | 646 if (m_affinity != UPSTREAM) |
647 return; | 647 return; |
648 | 648 |
649 if (isNull()) { | 649 if (isNull()) { |
650 m_affinity = DOWNSTREAM; | 650 m_affinity = DOWNSTREAM; |
651 return; | 651 return; |
652 } | 652 } |
653 | 653 |
654 // When not at a line wrap, make sure to end up with DOWNSTREAM affinity. | 654 // When not at a line wrap, make sure to end up with DOWNSTREAM affinity. |
655 if (!inSameLine(PositionWithAffinityTemplate<Strategy>(deepPosition, DOWNSTR
EAM), PositionWithAffinityTemplate<Strategy>(deepPosition, UPSTREAM))) | 655 if (!inSameLine(PositionWithAffinityTemplate<Strategy>(deepPosition), Positi
onWithAffinityTemplate<Strategy>(deepPosition, UPSTREAM))) |
656 return; | 656 return; |
657 m_affinity = DOWNSTREAM; | 657 m_affinity = DOWNSTREAM; |
658 } | 658 } |
659 | 659 |
660 UChar32 VisiblePosition::characterAfter() const | 660 UChar32 VisiblePosition::characterAfter() const |
661 { | 661 { |
662 // We canonicalize to the first of two equivalent candidates, but the second | 662 // We canonicalize to the first of two equivalent candidates, but the second |
663 // of the two candidates is the one that will be inside the text node | 663 // of the two candidates is the one that will be inside the text node |
664 // containing the character after this visible position. | 664 // containing the character after this visible position. |
665 Position pos = m_deepPosition.downstream(); | 665 Position pos = m_deepPosition.downstream(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 else | 765 else |
766 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); | 766 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); |
767 } | 767 } |
768 | 768 |
769 void showTree(const blink::VisiblePosition& vpos) | 769 void showTree(const blink::VisiblePosition& vpos) |
770 { | 770 { |
771 vpos.showTreeForThis(); | 771 vpos.showTreeForThis(); |
772 } | 772 } |
773 | 773 |
774 #endif | 774 #endif |
OLD | NEW |