Commit e92070ac authored by klink@chromium.org's avatar klink@chromium.org

Removes the use of Windows-specific types for accessibility roles and states...

Removes the use of Windows-specific types for accessibility roles and states in Views and Browser\Views. Helps with the porting effort, and makes for a cleaner implementation.
Review URL: http://codereview.chromium.org/93085

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14689 0039d316-1c4b-4281-b951-d872f2087c98
parent ec7690fc
...@@ -613,12 +613,11 @@ void OpaqueBrowserFrameView::ViewHierarchyChanged(bool is_add, ...@@ -613,12 +613,11 @@ void OpaqueBrowserFrameView::ViewHierarchyChanged(bool is_add,
} }
} }
bool OpaqueBrowserFrameView::GetAccessibleRole(VARIANT* role) { bool OpaqueBrowserFrameView::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role); DCHECK(role);
// We aren't actually the client area of the window, but we act like it as // We aren't actually the client area of the window, but we act like it as
// far as MSAA and the UI tests are concerned. // far as accessibility and the UI tests are concerned.
role->vt = VT_I4; *role = AccessibilityTypes::ROLE_CLIENT;
role->lVal = ROLE_SYSTEM_CLIENT;
return true; return true;
} }
......
...@@ -52,7 +52,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView, ...@@ -52,7 +52,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
virtual void ViewHierarchyChanged(bool is_add, virtual void ViewHierarchyChanged(bool is_add,
views::View* parent, views::View* parent,
views::View* child); views::View* child);
virtual bool GetAccessibleRole(VARIANT* role); virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
virtual bool GetAccessibleName(std::wstring* name); virtual bool GetAccessibleName(std::wstring* name);
virtual void SetAccessibleName(const std::wstring& name); virtual void SetAccessibleName(const std::wstring& name);
......
...@@ -566,11 +566,10 @@ void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) { ...@@ -566,11 +566,10 @@ void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) {
location_entry_->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); location_entry_->HandleExternalMsg(msg, flags, screen_point.ToPOINT());
} }
bool LocationBarView::GetAccessibleRole(VARIANT* role) { bool LocationBarView::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role); DCHECK(role);
role->vt = VT_I4; *role = AccessibilityTypes::ROLE_GROUPING;
role->lVal = ROLE_SYSTEM_GROUPING;
return true; return true;
} }
......
...@@ -104,8 +104,8 @@ class LocationBarView : public LocationBar, ...@@ -104,8 +104,8 @@ class LocationBarView : public LocationBar,
virtual SkBitmap GetFavIcon() const; virtual SkBitmap GetFavIcon() const;
virtual std::wstring GetTitle() const; virtual std::wstring GetTitle() const;
// Returns the MSAA role // Returns the accessibility role.
bool GetAccessibleRole(VARIANT* role); bool GetAccessibleRole(AccessibilityTypes::Role* role);
AutocompleteEditView* location_entry() { AutocompleteEditView* location_entry() {
return location_entry_.get(); return location_entry_.get();
......
...@@ -138,11 +138,11 @@ void TabContentsContainerView::RequestFocus() { ...@@ -138,11 +138,11 @@ void TabContentsContainerView::RequestFocus() {
View::RequestFocus(); View::RequestFocus();
} }
bool TabContentsContainerView::GetAccessibleRole(VARIANT* role) { bool TabContentsContainerView::GetAccessibleRole(
AccessibilityTypes::Role* role) {
DCHECK(role); DCHECK(role);
role->vt = VT_I4; *role = AccessibilityTypes::ROLE_GROUPING;
role->lVal = ROLE_SYSTEM_GROUPING;
return true; return true;
} }
......
...@@ -36,6 +36,7 @@ class TabContentsContainerView : public views::HWNDView, ...@@ -36,6 +36,7 @@ class TabContentsContainerView : public views::HWNDView,
virtual void RequestFocus(); virtual void RequestFocus();
virtual void AboutToRequestFocusFromTabTraversal(bool reverse); virtual void AboutToRequestFocusFromTabTraversal(bool reverse);
virtual bool CanProcessTabKeyEvents(); virtual bool CanProcessTabKeyEvents();
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
// Overridden from HWNDView. // Overridden from HWNDView.
virtual views::FocusTraversable* GetFocusTraversableParent(); virtual views::FocusTraversable* GetFocusTraversableParent();
...@@ -46,11 +47,6 @@ class TabContentsContainerView : public views::HWNDView, ...@@ -46,11 +47,6 @@ class TabContentsContainerView : public views::HWNDView,
const NotificationSource& source, const NotificationSource& source,
const NotificationDetails& details); const NotificationDetails& details);
// Returns the MSAA role of the current view. The role is what assistive
// technologies (ATs) use to determine what behavior to expect from a given
// control.
bool GetAccessibleRole(VARIANT* role);
protected: protected:
// Web content should be given first crack at accelerators. This function // Web content should be given first crack at accelerators. This function
// returns false if the current tab is a webcontents. // returns false if the current tab is a webcontents.
......
...@@ -215,11 +215,10 @@ bool Tab::GetTooltipTextOrigin(int x, int y, CPoint* origin) { ...@@ -215,11 +215,10 @@ bool Tab::GetTooltipTextOrigin(int x, int y, CPoint* origin) {
return true; return true;
} }
bool Tab::GetAccessibleRole(VARIANT* role) { bool Tab::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role); DCHECK(role);
role->vt = VT_I4; *role = AccessibilityTypes::ROLE_PAGETAB;
role->lVal = ROLE_SYSTEM_PAGETAB;
return true; return true;
} }
......
...@@ -103,7 +103,7 @@ class Tab : public TabRenderer, ...@@ -103,7 +103,7 @@ class Tab : public TabRenderer,
virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
virtual bool GetTooltipTextOrigin(int x, int y, CPoint* origin); virtual bool GetTooltipTextOrigin(int x, int y, CPoint* origin);
virtual std::string GetClassName() const { return kTabClassName; } virtual std::string GetClassName() const { return kTabClassName; }
virtual bool GetAccessibleRole(VARIANT* role); virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
virtual bool GetAccessibleName(std::wstring* name); virtual bool GetAccessibleName(std::wstring* name);
// views::ContextMenuController overrides: // views::ContextMenuController overrides:
......
...@@ -711,11 +711,10 @@ int TabStrip::OnPerformDrop(const DropTargetEvent& event) { ...@@ -711,11 +711,10 @@ int TabStrip::OnPerformDrop(const DropTargetEvent& event) {
return GetDropEffect(event); return GetDropEffect(event);
} }
bool TabStrip::GetAccessibleRole(VARIANT* role) { bool TabStrip::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role); DCHECK(role);
role->vt = VT_I4; *role = AccessibilityTypes::ROLE_GROUPING;
role->lVal = ROLE_SYSTEM_GROUPING;
return true; return true;
} }
......
...@@ -100,7 +100,7 @@ class TabStrip : public views::View, ...@@ -100,7 +100,7 @@ class TabStrip : public views::View,
virtual int OnDragUpdated(const views::DropTargetEvent& event); virtual int OnDragUpdated(const views::DropTargetEvent& event);
virtual void OnDragExited(); virtual void OnDragExited();
virtual int OnPerformDrop(const views::DropTargetEvent& event); virtual int OnPerformDrop(const views::DropTargetEvent& event);
virtual bool GetAccessibleRole(VARIANT* role); virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
virtual bool GetAccessibleName(std::wstring* name); virtual bool GetAccessibleName(std::wstring* name);
virtual void SetAccessibleName(const std::wstring& name); virtual void SetAccessibleName(const std::wstring& name);
virtual views::View* GetViewForPoint(const gfx::Point& point); virtual views::View* GetViewForPoint(const gfx::Point& point);
......
...@@ -748,11 +748,10 @@ bool BrowserToolbarView::GetAccessibleName(std::wstring* name) { ...@@ -748,11 +748,10 @@ bool BrowserToolbarView::GetAccessibleName(std::wstring* name) {
return false; return false;
} }
bool BrowserToolbarView::GetAccessibleRole(VARIANT* role) { bool BrowserToolbarView::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role); DCHECK(role);
role->vt = VT_I4; *role = AccessibilityTypes::ROLE_TOOLBAR;
role->lVal = ROLE_SYSTEM_TOOLBAR;
return true; return true;
} }
......
...@@ -60,6 +60,9 @@ class BrowserToolbarView : public views::View, ...@@ -60,6 +60,9 @@ class BrowserToolbarView : public views::View,
virtual bool OnKeyPressed(const views::KeyEvent& e); virtual bool OnKeyPressed(const views::KeyEvent& e);
virtual bool OnKeyReleased(const views::KeyEvent& e); virtual bool OnKeyReleased(const views::KeyEvent& e);
virtual gfx::Size GetPreferredSize(); virtual gfx::Size GetPreferredSize();
virtual bool GetAccessibleName(std::wstring* name);
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
virtual void SetAccessibleName(const std::wstring& name);
// Overridden from EncodingMenuControllerDelegate: // Overridden from EncodingMenuControllerDelegate:
virtual bool IsItemChecked(int id) const; virtual bool IsItemChecked(int id) const;
...@@ -91,17 +94,6 @@ class BrowserToolbarView : public views::View, ...@@ -91,17 +94,6 @@ class BrowserToolbarView : public views::View,
virtual void OnInputInProgress(bool in_progress); virtual void OnInputInProgress(bool in_progress);
// Returns a brief, identifying string, containing a unique, readable name.
virtual bool GetAccessibleName(std::wstring* name);
// Returns the MSAA role of the current view. The role is what assistive
// technologies (ATs) use to determine what behavior to expect from a given
// control.
virtual bool GetAccessibleRole(VARIANT* role);
// Assigns an accessible string name.
virtual void SetAccessibleName(const std::wstring& name);
virtual View* GetAccFocusedChildView() { return acc_focused_view_; } virtual View* GetAccFocusedChildView() { return acc_focused_view_; }
// Returns the index of the next view of the toolbar, starting from the given // Returns the index of the next view of the toolbar, starting from the given
......
// Copyright (c) 2006-2009 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.
#ifndef CHROME_COMMON_ACCESSIBILITY_TYPES_H_
#define CHROME_COMMON_ACCESSIBILITY_TYPES_H_
////////////////////////////////////////////////////////////////////////////////
//
// AccessibilityTypes
//
// Provides enumerations used to preserve platform-independence in accessibility
// functions used in various Views, both in Browser\Views and Views.
//
////////////////////////////////////////////////////////////////////////////////
class AccessibilityTypes {
public:
// This defines an enumeration of the supported accessibility roles in our
// Views (e.g. used in View::GetAccessibleRole). Any interface using roles
// must provide a conversion to its own roles (see e.g.
// ViewAccessibility::get_accRole and ViewAccessibility::MSAARole).
enum Role {
ROLE_APPLICATION,
ROLE_BUTTONDROPDOWN,
ROLE_CLIENT,
ROLE_GROUPING,
ROLE_PAGETAB,
ROLE_PUSHBUTTON,
ROLE_TEXT,
ROLE_TOOLBAR
};
// This defines an enumeration of the supported accessibility roles in our
// Views (e.g. used in View::GetAccessibleState). Any interface using roles
// must provide a conversion to its own roles (see e.g.
// ViewAccessibility::get_accState and ViewAccessibility::MSAAState).
enum State {
STATE_HASPOPUP,
STATE_READONLY
};
private:
// Do not instantiate this class.
AccessibilityTypes() {}
~AccessibilityTypes() {}
};
#endif // CHROME_COMMON_ACCESSIBILITY_TYPES_H_
...@@ -357,6 +357,10 @@ ...@@ -357,6 +357,10 @@
> >
</File> </File>
</Filter> </Filter>
<File
RelativePath=".\accessibility_types.h"
>
</File>
<File <File
RelativePath=".\animation.cc" RelativePath=".\animation.cc"
> >
......
...@@ -498,9 +498,11 @@ STDMETHODIMP ViewAccessibility::get_accRole(VARIANT var_id, VARIANT* role) { ...@@ -498,9 +498,11 @@ STDMETHODIMP ViewAccessibility::get_accRole(VARIANT var_id, VARIANT* role) {
return E_INVALIDARG; return E_INVALIDARG;
} }
AccessibilityTypes::Role acc_role;
if (var_id.lVal == CHILDID_SELF) { if (var_id.lVal == CHILDID_SELF) {
// Retrieve parent role. // Retrieve parent role.
if (!view_->GetAccessibleRole(role)) { if (!view_->GetAccessibleRole(&acc_role)) {
return E_FAIL; return E_FAIL;
} }
} else { } else {
...@@ -508,15 +510,14 @@ STDMETHODIMP ViewAccessibility::get_accRole(VARIANT var_id, VARIANT* role) { ...@@ -508,15 +510,14 @@ STDMETHODIMP ViewAccessibility::get_accRole(VARIANT var_id, VARIANT* role) {
return E_INVALIDARG; return E_INVALIDARG;
} }
// Retrieve child role. // Retrieve child role.
if (!view_->GetChildViewAt(var_id.lVal - 1)->GetAccessibleRole(role)) { if (!view_->GetChildViewAt(var_id.lVal - 1)->GetAccessibleRole(&acc_role)) {
role->vt = VT_EMPTY;
return E_FAIL; return E_FAIL;
} }
} }
// Make sure that role is not empty, and has the proper type. role->vt = VT_I4;
if (role->vt == VT_EMPTY) role->lVal = MSAARole(acc_role);
return E_FAIL;
return S_OK; return S_OK;
} }
...@@ -577,35 +578,73 @@ bool ViewAccessibility::IsValidNav(int nav_dir, int start_id, int lower_bound, ...@@ -577,35 +578,73 @@ bool ViewAccessibility::IsValidNav(int nav_dir, int start_id, int lower_bound,
return true; return true;
} }
void ViewAccessibility::SetState(VARIANT* state, views::View* view) { void ViewAccessibility::SetState(VARIANT* msaa_state, views::View* view) {
// Default state; all views can have accessibility focus. // Default state; all views can have accessibility focus.
state->lVal |= STATE_SYSTEM_FOCUSABLE; msaa_state->lVal |= STATE_SYSTEM_FOCUSABLE;
if (!view) if (!view)
return; return;
if (!view->IsEnabled()) { if (!view->IsEnabled()) {
state->lVal |= STATE_SYSTEM_UNAVAILABLE; msaa_state->lVal |= STATE_SYSTEM_UNAVAILABLE;
} }
if (!view->IsVisible()) { if (!view->IsVisible()) {
state->lVal |= STATE_SYSTEM_INVISIBLE; msaa_state->lVal |= STATE_SYSTEM_INVISIBLE;
} }
if (view->IsHotTracked()) { if (view->IsHotTracked()) {
state->lVal |= STATE_SYSTEM_HOTTRACKED; msaa_state->lVal |= STATE_SYSTEM_HOTTRACKED;
} }
if (view->IsPushed()) { if (view->IsPushed()) {
state->lVal |= STATE_SYSTEM_PRESSED; msaa_state->lVal |= STATE_SYSTEM_PRESSED;
} }
// Check both for actual View focus, as well as accessibility focus. // Check both for actual View focus, as well as accessibility focus.
views::View* parent = view->GetParent(); views::View* parent = view->GetParent();
if (view->HasFocus() || if (view->HasFocus() ||
(parent && parent->GetAccFocusedChildView() == view)) { (parent && parent->GetAccFocusedChildView() == view)) {
state->lVal |= STATE_SYSTEM_FOCUSED; msaa_state->lVal |= STATE_SYSTEM_FOCUSED;
} }
// Add on any view-specific states. // Add on any view-specific states.
view->GetAccessibleState(state); AccessibilityTypes::State state;
view->GetAccessibleState(&state);
msaa_state->lVal |= MSAAState(state);
}
long ViewAccessibility::MSAARole(AccessibilityTypes::Role role) {
switch (role) {
case AccessibilityTypes::ROLE_APPLICATION :
return ROLE_SYSTEM_APPLICATION;
case AccessibilityTypes::ROLE_BUTTONDROPDOWN :
return ROLE_SYSTEM_BUTTONDROPDOWN;
case AccessibilityTypes::ROLE_GROUPING :
return ROLE_SYSTEM_GROUPING;
case AccessibilityTypes::ROLE_PAGETAB :
return ROLE_SYSTEM_PAGETAB;
case AccessibilityTypes::ROLE_PUSHBUTTON :
return ROLE_SYSTEM_PUSHBUTTON;
case AccessibilityTypes::ROLE_TEXT :
return ROLE_SYSTEM_TEXT;
case AccessibilityTypes::ROLE_TOOLBAR :
return ROLE_SYSTEM_TOOLBAR;
case AccessibilityTypes::ROLE_CLIENT :
default:
// This is the default role for MSAA.
return ROLE_SYSTEM_CLIENT;
}
}
long ViewAccessibility::MSAAState(AccessibilityTypes::State state) {
switch (state) {
case AccessibilityTypes::STATE_HASPOPUP :
return STATE_SYSTEM_HASPOPUP;
case AccessibilityTypes::STATE_READONLY :
return STATE_SYSTEM_READONLY;
default :
// No default state in MSAA.
return 0;
}
} }
// IAccessible functions not supported. // IAccessible functions not supported.
......
...@@ -125,7 +125,15 @@ class ATL_NO_VTABLE ViewAccessibility ...@@ -125,7 +125,15 @@ class ATL_NO_VTABLE ViewAccessibility
} }
// Helper function which sets applicable states of view. // Helper function which sets applicable states of view.
void SetState(VARIANT* state, views::View* view); void SetState(VARIANT* msaa_state, views::View* view);
// Returns a conversion from the Role (as defined in
// chrome/common/accessibility_types.h) to an MSAA role.
long MSAARole(AccessibilityTypes::Role role);
// Returns a conversion from the State (as defined in
// chrome/common/accessibility_types.h) to MSAA states set.
long MSAAState(AccessibilityTypes::State state);
// Member View needed for view-specific calls. // Member View needed for view-specific calls.
views::View* view_; views::View* view_;
......
...@@ -44,6 +44,11 @@ bool Button::GetAccessibleName(std::wstring* name) { ...@@ -44,6 +44,11 @@ bool Button::GetAccessibleName(std::wstring* name) {
return false; return false;
} }
bool Button::GetAccessibleRole(AccessibilityTypes::Role* role) {
*role = AccessibilityTypes::ROLE_PUSHBUTTON;
return true;
}
void Button::SetAccessibleKeyboardShortcut(const std::wstring& shortcut) { void Button::SetAccessibleKeyboardShortcut(const std::wstring& shortcut) {
accessible_shortcut_.assign(shortcut); accessible_shortcut_.assign(shortcut);
} }
......
...@@ -35,6 +35,7 @@ class Button : public View { ...@@ -35,6 +35,7 @@ class Button : public View {
virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
virtual bool GetAccessibleKeyboardShortcut(std::wstring* shortcut); virtual bool GetAccessibleKeyboardShortcut(std::wstring* shortcut);
virtual bool GetAccessibleName(std::wstring* name); virtual bool GetAccessibleName(std::wstring* name);
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
virtual void SetAccessibleKeyboardShortcut(const std::wstring& shortcut); virtual void SetAccessibleKeyboardShortcut(const std::wstring& shortcut);
virtual void SetAccessibleName(const std::wstring& name); virtual void SetAccessibleName(const std::wstring& name);
......
...@@ -175,18 +175,17 @@ bool ButtonDropDown::GetAccessibleDefaultAction(std::wstring* action) { ...@@ -175,18 +175,17 @@ bool ButtonDropDown::GetAccessibleDefaultAction(std::wstring* action) {
return true; return true;
} }
bool ButtonDropDown::GetAccessibleRole(VARIANT* role) { bool ButtonDropDown::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role); DCHECK(role);
role->vt = VT_I4; *role = AccessibilityTypes::ROLE_BUTTONDROPDOWN;
role->lVal = ROLE_SYSTEM_BUTTONDROPDOWN;
return true; return true;
} }
bool ButtonDropDown::GetAccessibleState(VARIANT* state) { bool ButtonDropDown::GetAccessibleState(AccessibilityTypes::State* state) {
DCHECK(state); DCHECK(state);
state->lVal |= STATE_SYSTEM_HASPOPUP; *state = AccessibilityTypes::STATE_HASPOPUP;
return true; return true;
} }
......
...@@ -24,20 +24,10 @@ class ButtonDropDown : public ImageButton { ...@@ -24,20 +24,10 @@ class ButtonDropDown : public ImageButton {
ButtonDropDown(ButtonListener* listener, Menu::Delegate* menu_delegate); ButtonDropDown(ButtonListener* listener, Menu::Delegate* menu_delegate);
virtual ~ButtonDropDown(); virtual ~ButtonDropDown();
// Returns the MSAA default action of the current view. The string returned // Accessibility accessors, overridden from View.
// describes the default action that will occur when executing virtual bool GetAccessibleDefaultAction(std::wstring* action);
// IAccessible::DoDefaultAction. virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
bool GetAccessibleDefaultAction(std::wstring* action); virtual bool GetAccessibleState(AccessibilityTypes::State* state);
// Returns the MSAA role of the current view. The role is what assistive
// technologies (ATs) use to determine what behavior to expect from a given
// control.
bool GetAccessibleRole(VARIANT* role);
// Returns the MSAA state of the current view. Sets the input VARIANT
// appropriately, and returns true if a change was performed successfully.
// Overriden from View.
virtual bool GetAccessibleState(VARIANT* state);
private: private:
// Overridden from Button // Overridden from Button
......
...@@ -236,18 +236,17 @@ bool MenuButton::GetAccessibleDefaultAction(std::wstring* action) { ...@@ -236,18 +236,17 @@ bool MenuButton::GetAccessibleDefaultAction(std::wstring* action) {
return true; return true;
} }
bool MenuButton::GetAccessibleRole(VARIANT* role) { bool MenuButton::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role); DCHECK(role);
role->vt = VT_I4; *role = AccessibilityTypes::ROLE_BUTTONDROPDOWN;
role->lVal = ROLE_SYSTEM_BUTTONDROPDOWN;
return true; return true;
} }
bool MenuButton::GetAccessibleState(VARIANT* state) { bool MenuButton::GetAccessibleState(AccessibilityTypes::State* state) {
DCHECK(state); DCHECK(state);
state->lVal |= STATE_SYSTEM_HASPOPUP; *state = AccessibilityTypes::STATE_HASPOPUP;
return true; return true;
} }
......
...@@ -53,20 +53,10 @@ class MenuButton : public TextButton { ...@@ -53,20 +53,10 @@ class MenuButton : public TextButton {
virtual bool OnKeyReleased(const KeyEvent& e); virtual bool OnKeyReleased(const KeyEvent& e);
virtual void OnMouseExited(const MouseEvent& event); virtual void OnMouseExited(const MouseEvent& event);
// Returns the MSAA default action of the current view. The string returned // Accessibility accessors, overridden from View.
// describes the default action that will occur when executing virtual bool GetAccessibleDefaultAction(std::wstring* action);
// IAccessible::DoDefaultAction. virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
bool GetAccessibleDefaultAction(std::wstring* action); virtual bool GetAccessibleState(AccessibilityTypes::State* state);
// Returns the MSAA role of the current view. The role is what assistive
// technologies (ATs) use to determine what behavior to expect from a given
// control.
bool GetAccessibleRole(VARIANT* role);
// Returns the MSAA state of the current view. Sets the input VARIANT
// appropriately, and returns true if a change was performed successfully.
// Overriden from View.
virtual bool GetAccessibleState(VARIANT* state);
protected: protected:
// true if the menu is currently visible. // true if the menu is currently visible.
......
...@@ -412,12 +412,10 @@ void Label::SizeToFit(int max_width) { ...@@ -412,12 +412,10 @@ void Label::SizeToFit(int max_width) {
SizeToPreferredSize(); SizeToPreferredSize();
} }
#if defined(OS_WIN) bool Label::GetAccessibleRole(AccessibilityTypes::Role* role) {
bool Label::GetAccessibleRole(VARIANT* role) {
DCHECK(role); DCHECK(role);
role->vt = VT_I4; *role = AccessibilityTypes::ROLE_TEXT;
role->lVal = ROLE_SYSTEM_TEXT;
return true; return true;
} }
...@@ -426,12 +424,11 @@ bool Label::GetAccessibleName(std::wstring* name) { ...@@ -426,12 +424,11 @@ bool Label::GetAccessibleName(std::wstring* name) {
return true; return true;
} }
bool Label::GetAccessibleState(VARIANT* state) { bool Label::GetAccessibleState(AccessibilityTypes::State* state) {
DCHECK(state); DCHECK(state);
state->lVal |= STATE_SYSTEM_READONLY; *state = AccessibilityTypes::STATE_READONLY;
return true; return true;
} }
#endif // defined(OS_WIN)
} // namespace views } // namespace views
...@@ -164,22 +164,10 @@ class Label : public View { ...@@ -164,22 +164,10 @@ class Label : public View {
// wrapped). If 0, no maximum width is enforced. // wrapped). If 0, no maximum width is enforced.
void SizeToFit(int max_width); void SizeToFit(int max_width);
#if defined(OS_WIN) // Accessibility accessors, overridden from View.
// TODO(port): Make portable equivalents of accessibility-related functions. virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
virtual bool GetAccessibleName(std::wstring* name);
// Returns the MSAA role of the current view. The role is what assistive virtual bool GetAccessibleState(AccessibilityTypes::State* state);
// technologies (ATs) use to determine what behavior to expect from a given
// control.
bool GetAccessibleRole(VARIANT* role);
// Returns a brief, identifying string, containing a unique, readable name.
bool GetAccessibleName(std::wstring* name);
// Returns the MSAA state of the current view. Sets the input VARIANT
// appropriately, and returns true if a change was performed successfully.
// Overriden from View.
virtual bool GetAccessibleState(VARIANT* state);
#endif // defined(OS_WIN)
// Gets/sets the flag to determine whether the label should be collapsed when // Gets/sets the flag to determine whether the label should be collapsed when
// it's hidden (not visible). If this flag is true, the label will return a // it's hidden (not visible). If this flag is true, the label will return a
......
...@@ -146,23 +146,17 @@ TEST(LabelTest, Accessibility) { ...@@ -146,23 +146,17 @@ TEST(LabelTest, Accessibility) {
std::wstring test_text(L"My special text."); std::wstring test_text(L"My special text.");
label.SetText(test_text); label.SetText(test_text);
VARIANT role; AccessibilityTypes::Role role;
::VariantInit(&role);
EXPECT_TRUE(label.GetAccessibleRole(&role)); EXPECT_TRUE(label.GetAccessibleRole(&role));
EXPECT_EQ(VT_I4, role.vt); EXPECT_EQ(AccessibilityTypes::ROLE_TEXT, role);
EXPECT_EQ(ROLE_SYSTEM_TEXT, role.lVal);
std::wstring name; std::wstring name;
EXPECT_TRUE(label.GetAccessibleName(&name)); EXPECT_TRUE(label.GetAccessibleName(&name));
EXPECT_STREQ(test_text.c_str(), name.c_str()); EXPECT_STREQ(test_text.c_str(), name.c_str());
VARIANT state; AccessibilityTypes::State state;
::VariantInit(&state);
state.vt = VT_I4;
state.lVal = 0;
EXPECT_TRUE(label.GetAccessibleState(&state)); EXPECT_TRUE(label.GetAccessibleState(&state));
EXPECT_EQ(VT_I4, state.vt); EXPECT_EQ(AccessibilityTypes::STATE_READONLY, state);
EXPECT_EQ(STATE_SYSTEM_READONLY, state.lVal);
} }
TEST(LabelTest, SingleLineSizing) { TEST(LabelTest, SingleLineSizing) {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "base/gfx/rect.h" #include "base/gfx/rect.h"
#include "base/scoped_ptr.h" #include "base/scoped_ptr.h"
#include "chrome/common/accessibility_types.h"
#include "chrome/views/accelerator.h" #include "chrome/views/accelerator.h"
#include "chrome/views/background.h" #include "chrome/views/background.h"
#include "chrome/views/border.h" #include "chrome/views/border.h"
...@@ -559,19 +560,19 @@ class View : public AcceleratorTarget { ...@@ -559,19 +560,19 @@ class View : public AcceleratorTarget {
// successful. // successful.
virtual bool GetAccessibleName(std::wstring* name) { return false; } virtual bool GetAccessibleName(std::wstring* name) { return false; }
#if defined(OS_WIN) // Returns the accessibility role of the current view. The role is what
// TODO(port): Make these functions using VARIANT portable. // assistive technologies (ATs) use to determine what behavior to expect from
// a given control. Sets the input Role appropriately, and returns true if
// Returns the MSAA role of the current view. The role is what assistive
// technologies (ATs) use to determine what behavior to expect from a given
// control. Sets the input VARIANT appropriately, and returns true if
// successful. // successful.
virtual bool GetAccessibleRole(VARIANT* role) { return false; } virtual bool GetAccessibleRole(AccessibilityTypes::Role* role) {
return false;
}
// Returns the MSAA state of the current view. Sets the input VARIANT // Returns the accessibility state of the current view. Sets the input State
// appropriately, and returns true if a change was performed successfully. // appropriately, and returns true if successful.
virtual bool GetAccessibleState(VARIANT* state) { return false; } virtual bool GetAccessibleState(AccessibilityTypes::State* state) {
#endif // defined(OS_WIN) return false;
}
// Assigns a keyboard shortcut string description to the given control. Needed // Assigns a keyboard shortcut string description to the given control. Needed
// as a View does not know which shortcut will be associated with it until it // as a View does not know which shortcut will be associated with it until it
......
...@@ -960,6 +960,13 @@ void RootView::ClearPaintRect() { ...@@ -960,6 +960,13 @@ void RootView::ClearPaintRect() {
// //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
bool RootView::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role);
*role = AccessibilityTypes::ROLE_APPLICATION;
return true;
}
bool RootView::GetAccessibleName(std::wstring* name) { bool RootView::GetAccessibleName(std::wstring* name) {
if (!accessible_name_.empty()) { if (!accessible_name_.empty()) {
*name = accessible_name_; *name = accessible_name_;
......
...@@ -188,18 +188,10 @@ class RootView : public View, ...@@ -188,18 +188,10 @@ class RootView : public View,
void OnPaint(GdkEventExpose* event); void OnPaint(GdkEventExpose* event);
#endif #endif
#if defined(OS_WIN) // Accessibility accessors/mutators, overridden from View.
// Returns the MSAA role of the current view. The role is what assistive virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
// technologies (ATs) use to determine what behavior to expect from a given virtual bool GetAccessibleName(std::wstring* name);
// control. virtual void SetAccessibleName(const std::wstring& name);
bool GetAccessibleRole(VARIANT* role);
#endif
// Returns a brief, identifying string, containing a unique, readable name.
bool GetAccessibleName(std::wstring* name);
// Assigns an accessible string name.
void SetAccessibleName(const std::wstring& name);
protected: protected:
......
...@@ -49,14 +49,6 @@ void RootView::OnPaint(HWND hwnd) { ...@@ -49,14 +49,6 @@ void RootView::OnPaint(HWND hwnd) {
} }
} }
bool RootView::GetAccessibleRole(VARIANT* role) {
DCHECK(role);
role->vt = VT_I4;
role->lVal = ROLE_SYSTEM_APPLICATION;
return true;
}
void RootView::StartDragForViewFromMouseEvent( void RootView::StartDragForViewFromMouseEvent(
View* view, View* view,
IDataObject* data, IDataObject* data,
......
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