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 namespace content { |
| 8 |
| 9 AXPlatformPosition::AXPlatformPosition(AXTreeIDRegistry::AXTreeID tree_id, int32
_t anchor_id, int child_index, int text_offset, AXPositionType type) : AXPositio
n(tree_id, anchor_id, offset, type) { |
| 10 } |
| 11 |
| 12 AXPlatformPosition::~AXPlatformPosition() { |
| 13 } |
| 14 |
| 15 BrowserAccessibility* AXPlatformPosition::GetPlatformNodeInTree(AXTreeIDRegistry
::AXTreeID tree_id, int32-t node_id) const { |
| 16 if (IsNullPosition()) |
| 17 return nullptr; |
| 18 |
| 19 auto manager = BrowserAccessibilityManager::FromID(tree_id_); |
| 20 if (!manager) |
| 21 return nullptr; |
| 22 return manager->GetFromID(id); |
| 23 } |
| 24 |
| 25 AXNode* AXPlatformPosition::GetNodeInTree(AXTreeIDRegistry::AXTreeID tree_id, in
t32-t node_id) const { |
| 26 BrowserAccessibility* anchor = GetPlatformNodeFromID(tree_id, node_id); |
| 27 return anchor ? anchor->node() : nullptr; |
| 28 } |
| 29 |
| 30 int AXPlatformPosition::MaxTextOffset() const { |
| 31 if (IsNullPosition()) |
| 32 return -1; |
| 33 |
| 34 BrowserAccessibility* anchor = GetPlatformNodeInTree(tree_id_, get_anchor_id()
); |
| 35 if (!anchor) |
| 36 return -1; |
| 37 return static_cast<int>(anchor->GetText().length()); |
| 38 } |
| 39 |
| 40 } // namespace content |
OLD | NEW |