OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "content/browser/accessibility/ax_platform_position.h" |
| 6 |
| 7 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 8 |
| 9 namespace content { |
| 10 |
| 11 AXPlatformPosition::AXPlatformPosition(AXTreeID tree_id, |
| 12 int32_t anchor_id, |
| 13 int child_index, |
| 14 int text_offset, |
| 15 ui::AXPositionType type) |
| 16 : AXPosition(tree_id, anchor_id, child_index, text_offset, type) {} |
| 17 |
| 18 AXPlatformPosition::~AXPlatformPosition() {} |
| 19 |
| 20 BrowserAccessibility* AXPlatformPosition::GetNodeInTree(AXTreeID tree_id, |
| 21 int32_t node_id) const { |
| 22 if (IsNullPosition()) |
| 23 return nullptr; |
| 24 |
| 25 auto manager = BrowserAccessibilityManager::FromID(tree_id); |
| 26 if (!manager) |
| 27 return nullptr; |
| 28 return manager->GetFromID(node_id); |
| 29 } |
| 30 |
| 31 int AXPlatformPosition::MaxTextOffset() const { |
| 32 if (IsNullPosition()) |
| 33 return -1; |
| 34 |
| 35 BrowserAccessibility* anchor = GetNodeInTree(get_tree_id(), get_anchor_id()); |
| 36 if (!anchor) |
| 37 return -1; |
| 38 return static_cast<int>(anchor->GetText().length()); |
| 39 } |
| 40 |
| 41 } // namespace content |
OLD | NEW |