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

Unified Diff: ui/accessibility/platform/ax_fake_caret_win.cc

Issue 2781613003: Added a class acting as a fake caret for accessibility. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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..a7a6d2aece601f6d0cbb449ce04f7845662f61db
--- /dev/null
+++ b/ui/accessibility/platform/ax_fake_caret_win.cc
@@ -0,0 +1,57 @@
+// 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 "base/logging.h"
+#include "ui/base/win/atl_module.h"
+
+namespace ui {
+
+AXFakeCaretWin::AXFakeCaretWin() {
+ ui::win::CreateATLModuleIfNeeded();
+}
+
+// static
+void AXFakeCaretWin::SetBounds(gfx::Rect bounds) {
+ bounds_ = bounds;
+}
+
+STDMETHODIMP AXFakeCaretWin::accLocation(LONG* x_left,
+ LONG* y_top,
+ LONG* width,
+ LONG* height,
+ VARIANT var_id) {
+ if (!x_left || !y_top || !width || !height)
+ return E_INVALIDARG;
+ if (var_id.vt != VT_I4 || var_id.lVal != CHILDID_SELF)
+ return E_INVALIDARG;
+
+ *x_left = static_cast<LONG>(bounds().x());
+ *y_top = static_cast<LONG>(bounds().y());
+ *width = static_cast<LONG>(bounds().width());
+ *height = static_cast<LONG>(bounds().height());
+ return S_OK;
+}
+
+STDMETHODIMP AXFakeCaretWin::get_accName(VARIANT var_id, BSTR* name) {
+ if (var_id.vt != VT_I4 || var_id.lVal != CHILDID_SELF)
+ return E_INVALIDARG;
+ if (!name)
+ return E_INVALIDARG;
+ *name = SysAllocString(OBJECT_NAME);
+ return S_OK;
+}
+
+STDMETHODIMP AXFakeCaretWin::get_accRole(VARIANT var_id, VARIANT* role) {
+ if (var_id.vt != VT_I4 || var_id.lVal != CHILDID_SELF)
+ return E_INVALIDARG;
+ if (!role)
+ return E_INVALIDARG;
+ role->vt = VT_I4;
+ role->lVal = ROLE_SYSTEM_CARET;
+ return S_OK;
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698