| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 .SetGranularity(granularity_) | 133 .SetGranularity(granularity_) |
| 134 .SetIsDirectional(is_directional_) | 134 .SetIsDirectional(is_directional_) |
| 135 .SetHasTrailingWhitespace(has_trailing_whitespace_) | 135 .SetHasTrailingWhitespace(has_trailing_whitespace_) |
| 136 .Build(); | 136 .Build(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 EphemeralRange FirstEphemeralRangeOf(const VisibleSelection& selection) { | 139 EphemeralRange FirstEphemeralRangeOf(const VisibleSelection& selection) { |
| 140 if (selection.IsNone()) | 140 if (selection.IsNone()) |
| 141 return EphemeralRange(); | 141 return EphemeralRange(); |
| 142 Position start = selection.Start().ParentAnchoredEquivalent(); | 142 Position start = selection.Start().ParentAnchoredEquivalent(); |
| 143 Position end = selection.end().ParentAnchoredEquivalent(); | 143 Position end = selection.End().ParentAnchoredEquivalent(); |
| 144 return EphemeralRange(start, end); | 144 return EphemeralRange(start, end); |
| 145 } | 145 } |
| 146 | 146 |
| 147 template <typename Strategy> | 147 template <typename Strategy> |
| 148 EphemeralRangeTemplate<Strategy> | 148 EphemeralRangeTemplate<Strategy> |
| 149 VisibleSelectionTemplate<Strategy>::ToNormalizedEphemeralRange() const { | 149 VisibleSelectionTemplate<Strategy>::ToNormalizedEphemeralRange() const { |
| 150 if (IsNone()) | 150 if (IsNone()) |
| 151 return EphemeralRangeTemplate<Strategy>(); | 151 return EphemeralRangeTemplate<Strategy>(); |
| 152 | 152 |
| 153 // Make sure we have an updated layout since this function is called | 153 // Make sure we have an updated layout since this function is called |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 selection1.IsDirectional() != selection2.IsDirectional()) | 679 selection1.IsDirectional() != selection2.IsDirectional()) |
| 680 return false; | 680 return false; |
| 681 | 681 |
| 682 if (selection1.IsNone()) | 682 if (selection1.IsNone()) |
| 683 return selection2.IsNone(); | 683 return selection2.IsNone(); |
| 684 | 684 |
| 685 const VisibleSelectionTemplate<Strategy> selection_wrapper1(selection1); | 685 const VisibleSelectionTemplate<Strategy> selection_wrapper1(selection1); |
| 686 const VisibleSelectionTemplate<Strategy> selection_wrapper2(selection2); | 686 const VisibleSelectionTemplate<Strategy> selection_wrapper2(selection2); |
| 687 | 687 |
| 688 return selection_wrapper1.Start() == selection_wrapper2.Start() && | 688 return selection_wrapper1.Start() == selection_wrapper2.Start() && |
| 689 selection_wrapper1.end() == selection_wrapper2.end() && | 689 selection_wrapper1.End() == selection_wrapper2.End() && |
| 690 selection_wrapper1.Base() == selection_wrapper2.Base() && | 690 selection_wrapper1.Base() == selection_wrapper2.Base() && |
| 691 selection_wrapper1.Extent() == selection_wrapper2.Extent(); | 691 selection_wrapper1.Extent() == selection_wrapper2.Extent(); |
| 692 } | 692 } |
| 693 | 693 |
| 694 template <typename Strategy> | 694 template <typename Strategy> |
| 695 bool VisibleSelectionTemplate<Strategy>::operator==( | 695 bool VisibleSelectionTemplate<Strategy>::operator==( |
| 696 const VisibleSelectionTemplate<Strategy>& other) const { | 696 const VisibleSelectionTemplate<Strategy>& other) const { |
| 697 return EqualSelectionsAlgorithm<Strategy>(*this, other); | 697 return EqualSelectionsAlgorithm<Strategy>(*this, other); |
| 698 } | 698 } |
| 699 | 699 |
| 700 template <typename Strategy> | 700 template <typename Strategy> |
| 701 DEFINE_TRACE(VisibleSelectionTemplate<Strategy>) { | 701 DEFINE_TRACE(VisibleSelectionTemplate<Strategy>) { |
| 702 visitor->Trace(base_); | 702 visitor->Trace(base_); |
| 703 visitor->Trace(extent_); | 703 visitor->Trace(extent_); |
| 704 visitor->Trace(start_); | 704 visitor->Trace(start_); |
| 705 visitor->Trace(end_); | 705 visitor->Trace(end_); |
| 706 } | 706 } |
| 707 | 707 |
| 708 #ifndef NDEBUG | 708 #ifndef NDEBUG |
| 709 | 709 |
| 710 template <typename Strategy> | 710 template <typename Strategy> |
| 711 void VisibleSelectionTemplate<Strategy>::ShowTreeForThis() const { | 711 void VisibleSelectionTemplate<Strategy>::ShowTreeForThis() const { |
| 712 if (!Start().AnchorNode()) | 712 if (!Start().AnchorNode()) |
| 713 return; | 713 return; |
| 714 LOG(INFO) << "\n" | 714 LOG(INFO) << "\n" |
| 715 << Start() | 715 << Start() |
| 716 .AnchorNode() | 716 .AnchorNode() |
| 717 ->ToMarkedTreeString(Start().AnchorNode(), "S", | 717 ->ToMarkedTreeString(Start().AnchorNode(), "S", |
| 718 end().AnchorNode(), "E") | 718 End().AnchorNode(), "E") |
| 719 .Utf8() | 719 .Utf8() |
| 720 .data() | 720 .data() |
| 721 << "start: " << Start().ToAnchorTypeAndOffsetString().Utf8().data() | 721 << "start: " << Start().ToAnchorTypeAndOffsetString().Utf8().data() |
| 722 << "\n" | 722 << "\n" |
| 723 << "end: " << end().ToAnchorTypeAndOffsetString().Utf8().data(); | 723 << "end: " << End().ToAnchorTypeAndOffsetString().Utf8().data(); |
| 724 } | 724 } |
| 725 | 725 |
| 726 #endif | 726 #endif |
| 727 | 727 |
| 728 template <typename Strategy> | 728 template <typename Strategy> |
| 729 void VisibleSelectionTemplate<Strategy>::PrintTo( | 729 void VisibleSelectionTemplate<Strategy>::PrintTo( |
| 730 const VisibleSelectionTemplate<Strategy>& selection, | 730 const VisibleSelectionTemplate<Strategy>& selection, |
| 731 std::ostream* ostream) { | 731 std::ostream* ostream) { |
| 732 if (selection.IsNone()) { | 732 if (selection.IsNone()) { |
| 733 *ostream << "VisibleSelection()"; | 733 *ostream << "VisibleSelection()"; |
| 734 return; | 734 return; |
| 735 } | 735 } |
| 736 *ostream << "VisibleSelection(base: " << selection.Base() | 736 *ostream << "VisibleSelection(base: " << selection.Base() |
| 737 << " extent:" << selection.Extent() | 737 << " extent:" << selection.Extent() |
| 738 << " start: " << selection.Start() << " end: " << selection.end() | 738 << " start: " << selection.Start() << " end: " << selection.End() |
| 739 << ' ' << selection.Affinity() << ' ' | 739 << ' ' << selection.Affinity() << ' ' |
| 740 << (selection.IsDirectional() ? "Directional" : "NonDirectional") | 740 << (selection.IsDirectional() ? "Directional" : "NonDirectional") |
| 741 << ')'; | 741 << ')'; |
| 742 } | 742 } |
| 743 | 743 |
| 744 template class CORE_TEMPLATE_EXPORT VisibleSelectionTemplate<EditingStrategy>; | 744 template class CORE_TEMPLATE_EXPORT VisibleSelectionTemplate<EditingStrategy>; |
| 745 template class CORE_TEMPLATE_EXPORT | 745 template class CORE_TEMPLATE_EXPORT |
| 746 VisibleSelectionTemplate<EditingInFlatTreeStrategy>; | 746 VisibleSelectionTemplate<EditingInFlatTreeStrategy>; |
| 747 | 747 |
| 748 std::ostream& operator<<(std::ostream& ostream, | 748 std::ostream& operator<<(std::ostream& ostream, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 772 | 772 |
| 773 void showTree(const blink::VisibleSelectionInFlatTree& sel) { | 773 void showTree(const blink::VisibleSelectionInFlatTree& sel) { |
| 774 sel.ShowTreeForThis(); | 774 sel.ShowTreeForThis(); |
| 775 } | 775 } |
| 776 | 776 |
| 777 void showTree(const blink::VisibleSelectionInFlatTree* sel) { | 777 void showTree(const blink::VisibleSelectionInFlatTree* sel) { |
| 778 if (sel) | 778 if (sel) |
| 779 sel->ShowTreeForThis(); | 779 sel->ShowTreeForThis(); |
| 780 } | 780 } |
| 781 #endif | 781 #endif |
| OLD | NEW |