| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/accessibility/ax_position.h" |
| 6 |
| 7 namespace ui { |
| 8 |
| 9 constexpr int AXPositionBase::INVALID_TREE_ID; |
| 10 constexpr int32_t AXPositionBase::INVALID_ANCHOR_ID; |
| 11 constexpr int AXPositionBase::BEFORE_TEXT; |
| 12 constexpr int AXPositionBase::INVALID_INDEX; |
| 13 constexpr int AXPositionBase::INVALID_OFFSET; |
| 14 |
| 15 int AXPositionBase::MaxTextOffsetInParent() const { |
| 16 return MaxTextOffset(); |
| 17 } |
| 18 |
| 19 bool operator==(const AXPositionBase& first, const AXPositionBase& second) { |
| 20 if (first.IsNullPosition() && second.IsNullPosition()) |
| 21 return true; |
| 22 return first.tree_id() == second.tree_id() && |
| 23 first.anchor_id() == second.anchor_id() && |
| 24 first.child_index() == second.child_index() && |
| 25 first.text_offset() == second.text_offset() && |
| 26 first.affinity() == second.affinity(); |
| 27 } |
| 28 |
| 29 bool operator!=(const AXPositionBase& first, const AXPositionBase& second) { |
| 30 return !(first == second); |
| 31 } |
| 32 |
| 33 bool operator<(const AXPositionBase& first, const AXPositionBase& second) { |
| 34 if (first.IsNullPosition() || second.IsNullPosition()) |
| 35 return false; |
| 36 |
| 37 std::unique_ptr<AXPositionBase> first_ancestor = |
| 38 first.LowestCommonAncestor(second)->AsTreePosition(); |
| 39 std::unique_ptr<AXPositionBase> second_ancestor = |
| 40 second.LowestCommonAncestor(first)->AsTreePosition(); |
| 41 DCHECK_EQ(first_ancestor->GetOpaqueAnchor(), |
| 42 second_ancestor->GetOpaqueAnchor()); |
| 43 return !first_ancestor->IsNullPosition() && |
| 44 first_ancestor->AsTextPosition()->text_offset() < |
| 45 second_ancestor->AsTextPosition()->text_offset(); |
| 46 } |
| 47 |
| 48 bool operator<=(const AXPositionBase& first, const AXPositionBase& second) { |
| 49 return first == second || first < second; |
| 50 } |
| 51 |
| 52 bool operator>(const AXPositionBase& first, const AXPositionBase& second) { |
| 53 if (first.IsNullPosition() || second.IsNullPosition()) |
| 54 return false; |
| 55 |
| 56 std::unique_ptr<AXPositionBase> first_ancestor = |
| 57 first.LowestCommonAncestor(second)->AsTreePosition(); |
| 58 std::unique_ptr<AXPositionBase> second_ancestor = |
| 59 second.LowestCommonAncestor(first)->AsTreePosition(); |
| 60 DCHECK_EQ(first_ancestor->GetOpaqueAnchor(), |
| 61 second_ancestor->GetOpaqueAnchor()); |
| 62 return !first_ancestor->IsNullPosition() && |
| 63 first_ancestor->AsTextPosition()->text_offset() > |
| 64 second_ancestor->AsTextPosition()->text_offset(); |
| 65 } |
| 66 |
| 67 bool operator>=(const AXPositionBase& first, const AXPositionBase& second) { |
| 68 return first == second || first > second; |
| 69 } |
| 70 |
| 71 } // namespace ui |
| OLD | NEW |