OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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_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(gfx::Rect& bounds) { |
| 42 data_.location = gfx::RectF(bounds); |
| 43 if (event_target_) { |
| 44 ::NotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, event_target_, OBJID_CARET, |
| 45 -data_.id); |
| 46 } |
| 47 } |
| 48 |
| 49 const AXNodeData& AXFakeCaretWin::GetData() const { |
| 50 return data_; |
| 51 } |
| 52 |
| 53 gfx::NativeWindow AXFakeCaretWin::GetTopLevelWidget() { |
| 54 return nullptr; |
| 55 } |
| 56 |
| 57 gfx::NativeViewAccessible AXFakeCaretWin::GetParent() { |
| 58 if (!event_target_) |
| 59 return nullptr; |
| 60 |
| 61 gfx::NativeViewAccessible parent; |
| 62 HRESULT hr = |
| 63 ::AccessibleObjectFromWindow(event_target_, OBJID_WINDOW, IID_IAccessible, |
| 64 reinterpret_cast<void**>(&parent)); |
| 65 if (SUCCEEDED(hr)) |
| 66 return parent; |
| 67 return nullptr; |
| 68 } |
| 69 |
| 70 int AXFakeCaretWin::GetChildCount() { |
| 71 return 0; |
| 72 } |
| 73 |
| 74 gfx::NativeViewAccessible AXFakeCaretWin::ChildAtIndex(int index) { |
| 75 return nullptr; |
| 76 } |
| 77 |
| 78 gfx::Rect AXFakeCaretWin::GetScreenBoundsRect() const { |
| 79 gfx::Rect bounds = ToEnclosingRect(data_.location); |
| 80 return bounds; |
| 81 } |
| 82 |
| 83 gfx::NativeViewAccessible AXFakeCaretWin::HitTestSync(int x, int y) { |
| 84 return nullptr; |
| 85 } |
| 86 |
| 87 gfx::NativeViewAccessible AXFakeCaretWin::GetFocus() { |
| 88 return nullptr; |
| 89 } |
| 90 |
| 91 gfx::AcceleratedWidget AXFakeCaretWin::GetTargetForNativeAccessibilityEvent() { |
| 92 return event_target_; |
| 93 } |
| 94 |
| 95 bool AXFakeCaretWin::AccessibilityPerformAction(const ui::AXActionData& data) { |
| 96 return false; |
| 97 } |
| 98 |
| 99 } // namespace ui |
OLD | NEW |