OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, 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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 // manipulate selections that are not currently valid. | 648 // manipulate selections that are not currently valid. |
649 template <typename Strategy> | 649 template <typename Strategy> |
650 void VisibleSelectionTemplate<Strategy>::setWithoutValidation(const PositionTemp
late<Strategy>& base, const PositionTemplate<Strategy>& extent) | 650 void VisibleSelectionTemplate<Strategy>::setWithoutValidation(const PositionTemp
late<Strategy>& base, const PositionTemplate<Strategy>& extent) |
651 { | 651 { |
652 if (base.isNull() || extent.isNull()) { | 652 if (base.isNull() || extent.isNull()) { |
653 m_base = m_extent = m_start = m_end = PositionTemplate<Strategy>(); | 653 m_base = m_extent = m_start = m_end = PositionTemplate<Strategy>(); |
654 updateSelectionType(); | 654 updateSelectionType(); |
655 return; | 655 return; |
656 } | 656 } |
657 | 657 |
658 // TODO(hajimehoshi): We doubt this assertion is needed. This was introduced | |
659 // by http://trac.webkit.org/browser/trunk/WebCore/editing/Selection.cpp?ann
otate=blame&rev=21071 | |
660 ASSERT(m_affinity == TextAffinity::Downstream); | |
661 | |
662 m_base = base; | 658 m_base = base; |
663 m_extent = extent; | 659 m_extent = extent; |
664 m_baseIsFirst = base.compareTo(extent) <= 0; | 660 m_baseIsFirst = base.compareTo(extent) <= 0; |
665 if (m_baseIsFirst) { | 661 if (m_baseIsFirst) { |
666 m_start = base; | 662 m_start = base; |
667 m_end = extent; | 663 m_end = extent; |
668 } else { | 664 } else { |
669 m_start = extent; | 665 m_start = extent; |
670 m_end = base; | 666 m_end = base; |
671 } | 667 } |
672 m_selectionType = base == extent ? CaretSelection : RangeSelection; | 668 m_selectionType = base == extent ? CaretSelection : RangeSelection; |
| 669 if (m_selectionType != CaretSelection) { |
| 670 // Since |m_affinity| for non-|CaretSelection| is always |Downstream|, |
| 671 // we should keep this invariant. Note: This function can be called with |
| 672 // |m_affinity| is |TextAffinity::Upstream|. |
| 673 m_affinity = TextAffinity::Downstream; |
| 674 } |
673 didChange(); | 675 didChange(); |
674 } | 676 } |
675 | 677 |
676 static PositionInComposedTree adjustPositionInComposedTreeForStart(const Positio
nInComposedTree& position, Node* shadowHost) | 678 static PositionInComposedTree adjustPositionInComposedTreeForStart(const Positio
nInComposedTree& position, Node* shadowHost) |
677 { | 679 { |
678 if (isEnclosedBy(position, *shadowHost)) { | 680 if (isEnclosedBy(position, *shadowHost)) { |
679 if (position.isBeforeChildren()) | 681 if (position.isBeforeChildren()) |
680 return PositionInComposedTree::beforeNode(shadowHost); | 682 return PositionInComposedTree::beforeNode(shadowHost); |
681 return PositionInComposedTree::afterNode(shadowHost); | 683 return PositionInComposedTree::afterNode(shadowHost); |
682 } | 684 } |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 { | 1137 { |
1136 sel.showTreeForThis(); | 1138 sel.showTreeForThis(); |
1137 } | 1139 } |
1138 | 1140 |
1139 void showTree(const blink::VisibleSelectionInComposedTree* sel) | 1141 void showTree(const blink::VisibleSelectionInComposedTree* sel) |
1140 { | 1142 { |
1141 if (sel) | 1143 if (sel) |
1142 sel->showTreeForThis(); | 1144 sel->showTreeForThis(); |
1143 } | 1145 } |
1144 #endif | 1146 #endif |
OLD | NEW |