Chromium Code Reviews| Index: ui/accessibility/platform/ax_fake_caret_win.cc |
| diff --git a/ui/accessibility/platform/ax_fake_caret_win.cc b/ui/accessibility/platform/ax_fake_caret_win.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b4a29a05696e6bd58253a35c7288ec6fff071e34 |
| --- /dev/null |
| +++ b/ui/accessibility/platform/ax_fake_caret_win.cc |
| @@ -0,0 +1,85 @@ |
| +// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/accessibility/platform/ax_fake_caret_win.h" |
| + |
| +#include "ui/accessibility/ax_enums.h" |
| +#include "ui/accessibility/platform/ax_platform_node_win.h" |
| +#include "ui/gfx/geometry/rect_conversions.h" |
| +#include "ui/gfx/geometry/rect_f.h" |
| + |
| +namespace ui { |
| + |
| +AXFakeCaretWin::AXFakeCaretWin() { |
| + caret_ = static_cast<AXPlatformNodeWin*>(AXPlatformNodeWin::Create(this)); |
| + data_.id = 0; |
| + data_.role = AX_ROLE_DIV; |
|
dmazzoni
2017/04/17 05:07:35
We should create AX_ROLE_CARET and map it to ROLE_
|
| + data_.state = 0; |
| + data_.SetName(L"caret"); |
| + data_.offset_container_id = -1; |
| +} |
| + |
| +AXFakeCaretWin::~AXFakeCaretWin() { |
| + caret_->Destroy(); |
| + caret_ = nullptr; |
| +} |
| + |
| +base::win::ScopedComPtr<IAccessible> AXFakeCaretWin::GetCaret() const { |
| + base::win::ScopedComPtr<IAccessible> caret_accessible; |
|
dmazzoni
2017/04/17 05:07:35
I don't think you need this. Just call caret_->Get
|
| + HRESULT hr = caret_->QueryInterface( |
| + IID_IAccessible, reinterpret_cast<void**>(caret_accessible.Receive())); |
| + DCHECK(SUCCEEDED(hr)); |
| + return caret_accessible; |
| +} |
| + |
| +void AXFakeCaretWin::SetBounds(gfx::Rect bounds) { |
| + caret_->Lock(); |
|
dmazzoni
2017/04/17 05:07:35
Why are you locking / unlocking? It's not clear wh
|
| + data_.location = gfx::RectF(bounds); |
| + caret_->Unlock(); |
| +} |
| + |
| +const AXNodeData& AXFakeCaretWin::GetData() const { |
| + return data_; |
| +} |
| + |
| +gfx::NativeWindow AXFakeCaretWin::GetTopLevelWidget() { |
| + return nullptr; |
| +} |
| + |
| +gfx::NativeViewAccessible AXFakeCaretWin::GetParent() { |
| + return nullptr; |
| +} |
| + |
| +int AXFakeCaretWin::GetChildCount() { |
| + return 0; |
| +} |
| + |
| +gfx::NativeViewAccessible AXFakeCaretWin::ChildAtIndex(int index) { |
| + return nullptr; |
| +} |
| + |
| +gfx::Rect AXFakeCaretWin::GetScreenBoundsRect() const { |
| + caret_->Lock(); |
| + gfx::Rect bounds = ToEnclosingRect(data_.location); |
| + caret_->Unlock(); |
| + return bounds; |
| +} |
| + |
| +gfx::NativeViewAccessible AXFakeCaretWin::HitTestSync(int x, int y) { |
| + return nullptr; |
| +} |
| + |
| +gfx::NativeViewAccessible AXFakeCaretWin::GetFocus() { |
| + return nullptr; |
| +} |
| + |
| +gfx::AcceleratedWidget AXFakeCaretWin::GetTargetForNativeAccessibilityEvent() { |
| + return gfx::kNullAcceleratedWidget; |
| +} |
| + |
| +bool AXFakeCaretWin::AccessibilityPerformAction(const ui::AXActionData& data) { |
| + return false; |
| +} |
| + |
| +} // namespace ui |