Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: content/browser/accessibility/ax_platform_position.cc

Issue 2271893002: Creates AXPosition to uniquely identify a position in the accessibility tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test skeleton. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698