summaryrefslogtreecommitdiffstats
path: root/chrome/views/controls
diff options
context:
space:
mode:
authorklink@chromium.org <klink@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-28 00:12:01 +0000
committerklink@chromium.org <klink@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-28 00:12:01 +0000
commite92070ac9982489502180c006fe7911889c8fbee (patch)
tree577f25e7a8b61fd5b497886f57d89770f19f60cb /chrome/views/controls
parentec7690fc03aef949ea4eece3c17b3f78b265006e (diff)
downloadchromium_src-e92070ac9982489502180c006fe7911889c8fbee.zip
chromium_src-e92070ac9982489502180c006fe7911889c8fbee.tar.gz
chromium_src-e92070ac9982489502180c006fe7911889c8fbee.tar.bz2
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
Diffstat (limited to 'chrome/views/controls')
-rw-r--r--chrome/views/controls/button/button.cc5
-rw-r--r--chrome/views/controls/button/button.h1
-rw-r--r--chrome/views/controls/button/button_dropdown.cc9
-rw-r--r--chrome/views/controls/button/button_dropdown.h18
-rw-r--r--chrome/views/controls/button/menu_button.cc9
-rw-r--r--chrome/views/controls/button/menu_button.h18
-rw-r--r--chrome/views/controls/label.cc11
-rw-r--r--chrome/views/controls/label.h20
-rw-r--r--chrome/views/controls/label_unittest.cc14
9 files changed, 34 insertions, 71 deletions
diff --git a/chrome/views/controls/button/button.cc b/chrome/views/controls/button/button.cc
index 29b5da8..605b409 100644
--- a/chrome/views/controls/button/button.cc
+++ b/chrome/views/controls/button/button.cc
@@ -44,6 +44,11 @@ bool Button::GetAccessibleName(std::wstring* name) {
return false;
}
+bool Button::GetAccessibleRole(AccessibilityTypes::Role* role) {
+ *role = AccessibilityTypes::ROLE_PUSHBUTTON;
+ return true;
+}
+
void Button::SetAccessibleKeyboardShortcut(const std::wstring& shortcut) {
accessible_shortcut_.assign(shortcut);
}
diff --git a/chrome/views/controls/button/button.h b/chrome/views/controls/button/button.h
index f00f8a1..40ee98155 100644
--- a/chrome/views/controls/button/button.h
+++ b/chrome/views/controls/button/button.h
@@ -35,6 +35,7 @@ class Button : public View {
virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
virtual bool GetAccessibleKeyboardShortcut(std::wstring* shortcut);
virtual bool GetAccessibleName(std::wstring* name);
+ virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
virtual void SetAccessibleKeyboardShortcut(const std::wstring& shortcut);
virtual void SetAccessibleName(const std::wstring& name);
diff --git a/chrome/views/controls/button/button_dropdown.cc b/chrome/views/controls/button/button_dropdown.cc
index c2ea7cc..89abf85 100644
--- a/chrome/views/controls/button/button_dropdown.cc
+++ b/chrome/views/controls/button/button_dropdown.cc
@@ -175,18 +175,17 @@ bool ButtonDropDown::GetAccessibleDefaultAction(std::wstring* action) {
return true;
}
-bool ButtonDropDown::GetAccessibleRole(VARIANT* role) {
+bool ButtonDropDown::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role);
- role->vt = VT_I4;
- role->lVal = ROLE_SYSTEM_BUTTONDROPDOWN;
+ *role = AccessibilityTypes::ROLE_BUTTONDROPDOWN;
return true;
}
-bool ButtonDropDown::GetAccessibleState(VARIANT* state) {
+bool ButtonDropDown::GetAccessibleState(AccessibilityTypes::State* state) {
DCHECK(state);
- state->lVal |= STATE_SYSTEM_HASPOPUP;
+ *state = AccessibilityTypes::STATE_HASPOPUP;
return true;
}
diff --git a/chrome/views/controls/button/button_dropdown.h b/chrome/views/controls/button/button_dropdown.h
index b46158b..3e43df5 100644
--- a/chrome/views/controls/button/button_dropdown.h
+++ b/chrome/views/controls/button/button_dropdown.h
@@ -24,20 +24,10 @@ class ButtonDropDown : public ImageButton {
ButtonDropDown(ButtonListener* listener, Menu::Delegate* menu_delegate);
virtual ~ButtonDropDown();
- // Returns the MSAA default action of the current view. The string returned
- // describes the default action that will occur when executing
- // IAccessible::DoDefaultAction.
- bool GetAccessibleDefaultAction(std::wstring* action);
-
- // 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);
+ // Accessibility accessors, overridden from View.
+ virtual bool GetAccessibleDefaultAction(std::wstring* action);
+ virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
+ virtual bool GetAccessibleState(AccessibilityTypes::State* state);
private:
// Overridden from Button
diff --git a/chrome/views/controls/button/menu_button.cc b/chrome/views/controls/button/menu_button.cc
index 0bcd2ae..4687132 100644
--- a/chrome/views/controls/button/menu_button.cc
+++ b/chrome/views/controls/button/menu_button.cc
@@ -236,18 +236,17 @@ bool MenuButton::GetAccessibleDefaultAction(std::wstring* action) {
return true;
}
-bool MenuButton::GetAccessibleRole(VARIANT* role) {
+bool MenuButton::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role);
- role->vt = VT_I4;
- role->lVal = ROLE_SYSTEM_BUTTONDROPDOWN;
+ *role = AccessibilityTypes::ROLE_BUTTONDROPDOWN;
return true;
}
-bool MenuButton::GetAccessibleState(VARIANT* state) {
+bool MenuButton::GetAccessibleState(AccessibilityTypes::State* state) {
DCHECK(state);
- state->lVal |= STATE_SYSTEM_HASPOPUP;
+ *state = AccessibilityTypes::STATE_HASPOPUP;
return true;
}
diff --git a/chrome/views/controls/button/menu_button.h b/chrome/views/controls/button/menu_button.h
index 438d191..119abb2 100644
--- a/chrome/views/controls/button/menu_button.h
+++ b/chrome/views/controls/button/menu_button.h
@@ -53,20 +53,10 @@ class MenuButton : public TextButton {
virtual bool OnKeyReleased(const KeyEvent& e);
virtual void OnMouseExited(const MouseEvent& event);
- // Returns the MSAA default action of the current view. The string returned
- // describes the default action that will occur when executing
- // IAccessible::DoDefaultAction.
- bool GetAccessibleDefaultAction(std::wstring* action);
-
- // 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);
+ // Accessibility accessors, overridden from View.
+ virtual bool GetAccessibleDefaultAction(std::wstring* action);
+ virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
+ virtual bool GetAccessibleState(AccessibilityTypes::State* state);
protected:
// true if the menu is currently visible.
diff --git a/chrome/views/controls/label.cc b/chrome/views/controls/label.cc
index 22c11d7..7f1a886 100644
--- a/chrome/views/controls/label.cc
+++ b/chrome/views/controls/label.cc
@@ -412,12 +412,10 @@ void Label::SizeToFit(int max_width) {
SizeToPreferredSize();
}
-#if defined(OS_WIN)
-bool Label::GetAccessibleRole(VARIANT* role) {
+bool Label::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role);
- role->vt = VT_I4;
- role->lVal = ROLE_SYSTEM_TEXT;
+ *role = AccessibilityTypes::ROLE_TEXT;
return true;
}
@@ -426,12 +424,11 @@ bool Label::GetAccessibleName(std::wstring* name) {
return true;
}
-bool Label::GetAccessibleState(VARIANT* state) {
+bool Label::GetAccessibleState(AccessibilityTypes::State* state) {
DCHECK(state);
- state->lVal |= STATE_SYSTEM_READONLY;
+ *state = AccessibilityTypes::STATE_READONLY;
return true;
}
-#endif // defined(OS_WIN)
} // namespace views
diff --git a/chrome/views/controls/label.h b/chrome/views/controls/label.h
index 15e90ae..fc4f897 100644
--- a/chrome/views/controls/label.h
+++ b/chrome/views/controls/label.h
@@ -164,22 +164,10 @@ class Label : public View {
// wrapped). If 0, no maximum width is enforced.
void SizeToFit(int max_width);
-#if defined(OS_WIN)
- // TODO(port): Make portable equivalents of accessibility-related functions.
-
- // 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 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)
+ // Accessibility accessors, overridden from View.
+ virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
+ virtual bool GetAccessibleName(std::wstring* name);
+ virtual bool GetAccessibleState(AccessibilityTypes::State* state);
// 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
diff --git a/chrome/views/controls/label_unittest.cc b/chrome/views/controls/label_unittest.cc
index 58d6655..fb1d057 100644
--- a/chrome/views/controls/label_unittest.cc
+++ b/chrome/views/controls/label_unittest.cc
@@ -146,23 +146,17 @@ TEST(LabelTest, Accessibility) {
std::wstring test_text(L"My special text.");
label.SetText(test_text);
- VARIANT role;
- ::VariantInit(&role);
+ AccessibilityTypes::Role role;
EXPECT_TRUE(label.GetAccessibleRole(&role));
- EXPECT_EQ(VT_I4, role.vt);
- EXPECT_EQ(ROLE_SYSTEM_TEXT, role.lVal);
+ EXPECT_EQ(AccessibilityTypes::ROLE_TEXT, role);
std::wstring name;
EXPECT_TRUE(label.GetAccessibleName(&name));
EXPECT_STREQ(test_text.c_str(), name.c_str());
- VARIANT state;
- ::VariantInit(&state);
- state.vt = VT_I4;
- state.lVal = 0;
+ AccessibilityTypes::State state;
EXPECT_TRUE(label.GetAccessibleState(&state));
- EXPECT_EQ(VT_I4, state.vt);
- EXPECT_EQ(STATE_SYSTEM_READONLY, state.lVal);
+ EXPECT_EQ(AccessibilityTypes::STATE_READONLY, state);
}
TEST(LabelTest, SingleLineSizing) {