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

Side by Side Diff: ui/accessibility/platform/ax_system_caret_win.cc

Issue 2962273002: Revert of Added a system caret used for accessibility on Windows. (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « ui/accessibility/platform/ax_system_caret_win.h ('k') | ui/base/ime/input_method_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/platform/ax_system_caret_win.h"
6
7 #include <windows.h>
8
9 #include "base/logging.h"
10 #include "ui/accessibility/ax_enums.h"
11 #include "ui/accessibility/platform/ax_platform_node_win.h"
12 #include "ui/accessibility/platform/ax_platform_unique_id.h"
13 #include "ui/gfx/geometry/rect_conversions.h"
14 #include "ui/gfx/geometry/rect_f.h"
15
16 namespace ui {
17
18 AXSystemCaretWin::AXSystemCaretWin(gfx::AcceleratedWidget event_target)
19 : event_target_(event_target) {
20 caret_ = static_cast<AXPlatformNodeWin*>(AXPlatformNodeWin::Create(this));
21 data_.id = GetNextAXPlatformNodeUniqueId();
22 data_.role = AX_ROLE_CARET;
23 // |get_accState| should return 0 which means that the caret is visible.
24 data_.state = 0;
25 // According to MSDN, "Edit" should be the name of the caret object.
26 data_.SetName(L"Edit");
27 data_.offset_container_id = -1;
28 }
29
30 AXSystemCaretWin::~AXSystemCaretWin() {
31 caret_->Destroy();
32 caret_ = nullptr;
33 }
34
35 base::win::ScopedComPtr<IAccessible> AXSystemCaretWin::GetCaret() const {
36 base::win::ScopedComPtr<IAccessible> caret_accessible;
37 HRESULT hr = caret_->QueryInterface(
38 IID_IAccessible,
39 reinterpret_cast<void**>(caret_accessible.GetAddressOf()));
40 DCHECK(SUCCEEDED(hr));
41 return caret_accessible;
42 }
43
44 void AXSystemCaretWin::MoveCaretTo(const gfx::Rect& bounds) {
45 if (bounds.IsEmpty())
46 return;
47 data_.location = gfx::RectF(bounds);
48 if (event_target_) {
49 ::NotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, event_target_, OBJID_CARET,
50 -data_.id);
51 }
52 }
53
54 const AXNodeData& AXSystemCaretWin::GetData() const {
55 return data_;
56 }
57
58 const ui::AXTreeData& AXSystemCaretWin::GetTreeData() const {
59 CR_DEFINE_STATIC_LOCAL(ui::AXTreeData, empty_data, ());
60 return empty_data;
61 }
62
63 gfx::NativeWindow AXSystemCaretWin::GetTopLevelWidget() {
64 return nullptr;
65 }
66
67 gfx::NativeViewAccessible AXSystemCaretWin::GetParent() {
68 if (!event_target_)
69 return nullptr;
70
71 gfx::NativeViewAccessible parent;
72 HRESULT hr =
73 ::AccessibleObjectFromWindow(event_target_, OBJID_WINDOW, IID_IAccessible,
74 reinterpret_cast<void**>(&parent));
75 if (SUCCEEDED(hr))
76 return parent;
77 return nullptr;
78 }
79
80 int AXSystemCaretWin::GetChildCount() {
81 return 0;
82 }
83
84 gfx::NativeViewAccessible AXSystemCaretWin::ChildAtIndex(int index) {
85 return nullptr;
86 }
87
88 gfx::Rect AXSystemCaretWin::GetScreenBoundsRect() const {
89 gfx::Rect bounds = ToEnclosingRect(data_.location);
90 return bounds;
91 }
92
93 gfx::NativeViewAccessible AXSystemCaretWin::HitTestSync(int x, int y) {
94 return nullptr;
95 }
96
97 gfx::NativeViewAccessible AXSystemCaretWin::GetFocus() {
98 return nullptr;
99 }
100
101 gfx::AcceleratedWidget
102 AXSystemCaretWin::GetTargetForNativeAccessibilityEvent() {
103 return event_target_;
104 }
105
106 bool AXSystemCaretWin::AccessibilityPerformAction(
107 const ui::AXActionData& data) {
108 return false;
109 }
110
111 bool AXSystemCaretWin::ShouldIgnoreHoveredStateForTesting() {
112 return false;
113 }
114
115 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_system_caret_win.h ('k') | ui/base/ime/input_method_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698