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