OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | |
sadrul
2017/05/11 17:46:34
No (c) in new files.
| |
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_fake_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 AXFakeCaretWin::AXFakeCaretWin(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 data_.state = 0; | |
24 data_.SetName(L"caret"); | |
25 data_.offset_container_id = -1; | |
26 } | |
27 | |
28 AXFakeCaretWin::~AXFakeCaretWin() { | |
29 caret_->Destroy(); | |
30 caret_ = nullptr; | |
31 } | |
32 | |
33 base::win::ScopedComPtr<IAccessible> AXFakeCaretWin::GetCaret() const { | |
34 base::win::ScopedComPtr<IAccessible> caret_accessible; | |
35 HRESULT hr = caret_->QueryInterface( | |
36 IID_IAccessible, reinterpret_cast<void**>(caret_accessible.Receive())); | |
37 DCHECK(SUCCEEDED(hr)); | |
38 return caret_accessible; | |
39 } | |
40 | |
41 void AXFakeCaretWin::MoveCaretTo(const gfx::Rect& bounds) { | |
42 if (bounds.IsEmpty()) | |
43 return; | |
44 data_.location = gfx::RectF(bounds); | |
45 if (event_target_) { | |
46 ::NotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, event_target_, OBJID_CARET, | |
47 -data_.id); | |
48 } | |
49 } | |
50 | |
51 const AXNodeData& AXFakeCaretWin::GetData() const { | |
52 return data_; | |
53 } | |
54 | |
55 gfx::NativeWindow AXFakeCaretWin::GetTopLevelWidget() { | |
56 return nullptr; | |
57 } | |
58 | |
59 gfx::NativeViewAccessible AXFakeCaretWin::GetParent() { | |
60 if (!event_target_) | |
61 return nullptr; | |
62 | |
63 gfx::NativeViewAccessible parent; | |
64 HRESULT hr = | |
65 ::AccessibleObjectFromWindow(event_target_, OBJID_WINDOW, IID_IAccessible, | |
66 reinterpret_cast<void**>(&parent)); | |
67 if (SUCCEEDED(hr)) | |
68 return parent; | |
69 return nullptr; | |
70 } | |
71 | |
72 int AXFakeCaretWin::GetChildCount() { | |
73 return 0; | |
74 } | |
75 | |
76 gfx::NativeViewAccessible AXFakeCaretWin::ChildAtIndex(int index) { | |
77 return nullptr; | |
78 } | |
79 | |
80 gfx::Rect AXFakeCaretWin::GetScreenBoundsRect() const { | |
81 gfx::Rect bounds = ToEnclosingRect(data_.location); | |
82 return bounds; | |
83 } | |
84 | |
85 gfx::NativeViewAccessible AXFakeCaretWin::HitTestSync(int x, int y) { | |
86 return nullptr; | |
87 } | |
88 | |
89 gfx::NativeViewAccessible AXFakeCaretWin::GetFocus() { | |
90 return nullptr; | |
91 } | |
92 | |
93 gfx::AcceleratedWidget AXFakeCaretWin::GetTargetForNativeAccessibilityEvent() { | |
94 return event_target_; | |
95 } | |
96 | |
97 bool AXFakeCaretWin::AccessibilityPerformAction(const ui::AXActionData& data) { | |
98 return false; | |
99 } | |
100 | |
101 } // namespace ui | |
OLD | NEW |