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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 using namespace HTMLNames; | 50 using namespace HTMLNames; |
51 | 51 |
52 VisiblePosition::VisiblePosition(const Position& position, TextAffinity affinity
) | 52 VisiblePosition::VisiblePosition(const Position& position, TextAffinity affinity
) |
53 { | 53 { |
54 // TODO(yosin) We should make |VisiblePosition| private and make this | 54 // TODO(yosin) We should make |VisiblePosition| private and make this |
55 // constructor to populate member variables by using |visiblePositionOf()|. | 55 // constructor to populate member variables by using |visiblePositionOf()|. |
56 *this = visiblePositionOf(position, affinity); | 56 *this = visiblePositionOf(position, affinity); |
57 } | 57 } |
58 | 58 |
59 VisiblePosition::VisiblePosition(const PositionWithAffinity& positionWithAffinit
y) | |
60 : VisiblePosition(positionWithAffinity.position(), positionWithAffinity.affi
nity()) | |
61 { | |
62 } | |
63 | |
64 VisiblePosition VisiblePosition::createWithoutCanonicalization(const PositionWit
hAffinity& canonicalized) | 59 VisiblePosition VisiblePosition::createWithoutCanonicalization(const PositionWit
hAffinity& canonicalized) |
65 { | 60 { |
66 VisiblePosition visiblePosition; | 61 VisiblePosition visiblePosition; |
67 visiblePosition.m_deepPosition = canonicalized.position(); | 62 visiblePosition.m_deepPosition = canonicalized.position(); |
68 visiblePosition.m_affinity = canonicalized.affinity(); | 63 visiblePosition.m_affinity = canonicalized.affinity(); |
69 return visiblePosition; | 64 return visiblePosition; |
70 } | 65 } |
71 | 66 |
72 // TODO(yosin) We should move |rightVisuallyDistinctCandidate()| with | 67 // TODO(yosin) We should move |rightVisuallyDistinctCandidate()| with |
73 // |rightPositionOf()| to "VisibleUnits.cpp". | 68 // |rightPositionOf()| to "VisibleUnits.cpp". |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 return honorEditingBoundaryAtOrBeforeAlgorithm(pos, anchor); | 427 return honorEditingBoundaryAtOrBeforeAlgorithm(pos, anchor); |
433 } | 428 } |
434 | 429 |
435 PositionInComposedTreeWithAffinity honorEditingBoundaryAtOrBeforeOf(const Positi
onInComposedTreeWithAffinity& pos, const PositionInComposedTree& anchor) | 430 PositionInComposedTreeWithAffinity honorEditingBoundaryAtOrBeforeOf(const Positi
onInComposedTreeWithAffinity& pos, const PositionInComposedTree& anchor) |
436 { | 431 { |
437 return honorEditingBoundaryAtOrBeforeAlgorithm(pos, anchor); | 432 return honorEditingBoundaryAtOrBeforeAlgorithm(pos, anchor); |
438 } | 433 } |
439 | 434 |
440 VisiblePosition honorEditingBoundaryAtOrBefore(const VisiblePosition& pos, const
Position& anchor) | 435 VisiblePosition honorEditingBoundaryAtOrBefore(const VisiblePosition& pos, const
Position& anchor) |
441 { | 436 { |
442 return VisiblePosition(honorEditingBoundaryAtOrBeforeOf(pos.toPositionWithAf
finity(), anchor)); | 437 return visiblePositionOf(honorEditingBoundaryAtOrBeforeOf(pos.toPositionWith
Affinity(), anchor)); |
443 } | 438 } |
444 | 439 |
445 VisiblePosition honorEditingBoundaryAtOrAfter(const VisiblePosition& pos, const
Position& anchor) | 440 VisiblePosition honorEditingBoundaryAtOrAfter(const VisiblePosition& pos, const
Position& anchor) |
446 { | 441 { |
447 if (pos.isNull()) | 442 if (pos.isNull()) |
448 return pos; | 443 return pos; |
449 | 444 |
450 ContainerNode* highestRoot = highestEditableRoot(anchor); | 445 ContainerNode* highestRoot = highestEditableRoot(anchor); |
451 | 446 |
452 // Return empty position if pos is not somewhere inside the editable region
containing this position | 447 // Return empty position if pos is not somewhere inside the editable region
containing this position |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 if (inSameLine(PositionWithAffinityTemplate<Strategy>(deepPosition), Positio
nWithAffinityTemplate<Strategy>(deepPosition, TextAffinity::Upstream))) | 572 if (inSameLine(PositionWithAffinityTemplate<Strategy>(deepPosition), Positio
nWithAffinityTemplate<Strategy>(deepPosition, TextAffinity::Upstream))) |
578 return PositionWithAffinityTemplate<Strategy>(deepPosition); | 573 return PositionWithAffinityTemplate<Strategy>(deepPosition); |
579 return PositionWithAffinityTemplate<Strategy>(deepPosition, TextAffinity::Up
stream); | 574 return PositionWithAffinityTemplate<Strategy>(deepPosition, TextAffinity::Up
stream); |
580 } | 575 } |
581 | 576 |
582 VisiblePosition visiblePositionOf(const Position& position, TextAffinity affinit
y) | 577 VisiblePosition visiblePositionOf(const Position& position, TextAffinity affinit
y) |
583 { | 578 { |
584 return VisiblePosition::createWithoutCanonicalization(visiblePositionOfAlgor
ithm<EditingStrategy>(position, affinity)); | 579 return VisiblePosition::createWithoutCanonicalization(visiblePositionOfAlgor
ithm<EditingStrategy>(position, affinity)); |
585 } | 580 } |
586 | 581 |
| 582 VisiblePosition visiblePositionOf(const PositionWithAffinity& positionWithAffini
ty) |
| 583 { |
| 584 return visiblePositionOf(positionWithAffinity.position(), positionWithAffini
ty.affinity()); |
| 585 } |
| 586 |
587 VisiblePosition visiblePositionOf(const PositionInComposedTree& position, TextAf
finity affinity) | 587 VisiblePosition visiblePositionOf(const PositionInComposedTree& position, TextAf
finity affinity) |
588 { | 588 { |
589 PositionInComposedTreeWithAffinity canonicalized = visiblePositionOfAlgorith
m<EditingInComposedTreeStrategy>(position, affinity); | 589 PositionInComposedTreeWithAffinity canonicalized = visiblePositionOfAlgorith
m<EditingInComposedTreeStrategy>(position, affinity); |
590 return VisiblePosition::createWithoutCanonicalization(PositionWithAffinity(t
oPositionInDOMTree(canonicalized.position()), canonicalized.affinity())); | 590 return VisiblePosition::createWithoutCanonicalization(PositionWithAffinity(t
oPositionInDOMTree(canonicalized.position()), canonicalized.affinity())); |
591 } | 591 } |
592 | 592 |
593 UChar32 characterAfter(const VisiblePosition& visiblePosition) | 593 UChar32 characterAfter(const VisiblePosition& visiblePosition) |
594 { | 594 { |
595 // We canonicalize to the first of two equivalent candidates, but the second | 595 // We canonicalize to the first of two equivalent candidates, but the second |
596 // of the two candidates is the one that will be inside the text node | 596 // of the two candidates is the one that will be inside the text node |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 else | 687 else |
688 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); | 688 fprintf(stderr, "Cannot showTree for (nil) VisiblePosition.\n"); |
689 } | 689 } |
690 | 690 |
691 void showTree(const blink::VisiblePosition& vpos) | 691 void showTree(const blink::VisiblePosition& vpos) |
692 { | 692 { |
693 vpos.showTreeForThis(); | 693 vpos.showTreeForThis(); |
694 } | 694 } |
695 | 695 |
696 #endif | 696 #endif |
OLD | NEW |