Commit b25275a4 authored by Doug Turner's avatar Doug Turner Committed by Commit Bot

Forward 4 methods from BrowserAccessibilityComWin to AXPlatformNodeWin

Continuing on removing stuff from the browser side, this CL forwards four
more methods to the platform node side:

get_attributes, get_uniqueID, get_windowHandle, get_indexInParent

Bug: 703369
Change-Id: I5b1996b131733f4792611a5f9ce14d030f1f4d1c
Reviewed-on: https://chromium-review.googlesource.com/619988Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Doug Turner <dougt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496443}
parent dc02fb5f
......@@ -89,68 +89,8 @@ BrowserAccessibilityComWin::~BrowserAccessibilityComWin() {
//
STDMETHODIMP BrowserAccessibilityComWin::get_attributes(BSTR* attributes) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_GET_ATTRIBUTES);
if (!owner())
return E_FAIL;
AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes);
if (!attributes)
return E_INVALIDARG;
*attributes = nullptr;
if (!owner())
return E_FAIL;
base::string16 str;
for (const base::string16& attribute : ia2_attributes())
str += attribute + L';';
if (str.empty())
return S_FALSE;
*attributes = SysAllocString(str.c_str());
DCHECK(*attributes);
return S_OK;
}
STDMETHODIMP BrowserAccessibilityComWin::get_uniqueID(LONG* unique_id) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNIQUE_ID);
if (!owner())
return E_FAIL;
if (!unique_id)
return E_INVALIDARG;
*unique_id = -AXPlatformNodeWin::unique_id();
return S_OK;
}
STDMETHODIMP BrowserAccessibilityComWin::get_windowHandle(HWND* window_handle) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_WINDOW_HANDLE);
if (!owner())
return E_FAIL;
if (!window_handle)
return E_INVALIDARG;
*window_handle =
Manager()->ToBrowserAccessibilityManagerWin()->GetParentHWND();
if (!*window_handle)
return E_FAIL;
return S_OK;
}
STDMETHODIMP BrowserAccessibilityComWin::get_indexInParent(
LONG* index_in_parent) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INDEX_IN_PARENT);
if (!owner())
return E_FAIL;
if (!index_in_parent)
return E_INVALIDARG;
*index_in_parent = GetIndexInParent();
return S_OK;
// This can be removed once the rest of the interface has been removed.
return AXPlatformNodeWin::get_attributes(attributes);
}
STDMETHODIMP BrowserAccessibilityComWin::scrollTo(IA2ScrollType scroll_type) {
......
......@@ -98,22 +98,8 @@ class __declspec(uuid("562072fe-3390-43b1-9e2c-dd4118f5ac79"))
//
// IAccessible2 methods.
//
// Returns the attributes specific to this IAccessible2 object,
// such as a cell's formula.
CONTENT_EXPORT STDMETHODIMP get_attributes(BSTR* attributes) override;
// Get the unique ID of this object so that the client knows if it's
// been encountered previously.
CONTENT_EXPORT STDMETHODIMP get_uniqueID(LONG* unique_id) override;
// Get the window handle of the enclosing window.
CONTENT_EXPORT STDMETHODIMP get_windowHandle(HWND* window_handle) override;
// Get this object's index in its parent object.
CONTENT_EXPORT STDMETHODIMP get_indexInParent(LONG* index_in_parent) override;
CONTENT_EXPORT STDMETHODIMP scrollTo(enum IA2ScrollType scroll_type) override;
CONTENT_EXPORT STDMETHODIMP
......
......@@ -1184,12 +1184,14 @@ STDMETHODIMP AXPlatformNodeWin::get_states(AccessibleStates* states) {
}
STDMETHODIMP AXPlatformNodeWin::get_uniqueID(LONG* unique_id) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNIQUE_ID);
COM_OBJECT_VALIDATE_1_ARG(unique_id);
*unique_id = -unique_id_;
return S_OK;
}
STDMETHODIMP AXPlatformNodeWin::get_windowHandle(HWND* window_handle) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_WINDOW_HANDLE);
COM_OBJECT_VALIDATE_1_ARG(window_handle);
*window_handle = delegate_->GetTargetForNativeAccessibilityEvent();
return *window_handle ? S_OK : S_FALSE;
......@@ -1245,16 +1247,17 @@ STDMETHODIMP AXPlatformNodeWin::get_relationTargetsOfType(
STDMETHODIMP AXPlatformNodeWin::get_attributes(BSTR* attributes) {
COM_OBJECT_VALIDATE_1_ARG(attributes);
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_GET_ATTRIBUTES);
AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
*attributes = nullptr;
base::string16 attributes_str;
std::vector<base::string16> computed_attributes = ComputeIA2Attributes();
for (const base::string16& attribute : computed_attributes)
attributes_str += attribute + L';';
// Text fields need to report the attribute "text-model:a1" to instruct
// screen readers to use IAccessible2 APIs to handle text editing in this
// object (as opposed to treating it like a native Windows text box).
// The text-model:a1 attribute is documented here:
// http://www.linuxfoundation.org/collaborate/workgroups/accessibility/ia2/ia2_implementation_guide
if (GetData().role == ui::AX_ROLE_TEXT_FIELD) {
attributes_str = L"text-model:a1;";
}
if (attributes_str.empty())
return S_FALSE;
*attributes = SysAllocString(attributes_str.c_str());
DCHECK(*attributes);
......@@ -1263,6 +1266,7 @@ STDMETHODIMP AXPlatformNodeWin::get_attributes(BSTR* attributes) {
STDMETHODIMP AXPlatformNodeWin::get_indexInParent(LONG* index_in_parent) {
COM_OBJECT_VALIDATE_1_ARG(index_in_parent);
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INDEX_IN_PARENT);
*index_in_parent = GetIndexInParent();
if (*index_in_parent < 0)
return E_FAIL;
......@@ -3271,6 +3275,15 @@ std::vector<base::string16> AXPlatformNodeWin::ComputeIA2Attributes() {
result.push_back(L"src:" + src);
}
// Text fields need to report the attribute "text-model:a1" to instruct
// screen readers to use IAccessible2 APIs to handle text editing in this
// object (as opposed to treating it like a native Windows text box).
// The text-model:a1 attribute is documented here:
// http://www.linuxfoundation.org/collaborate/workgroups/accessibility/ia2/ia2_implementation_guide
if (GetData().role == ui::AX_ROLE_TEXT_FIELD) {
result.push_back(L"text-model:a1;");
}
// Expose input-text type attribute.
base::string16 type;
base::string16 html_tag = GetString16Attribute(ui::AX_ATTR_HTML_TAG);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment