summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-03 00:56:12 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-03 00:56:12 +0000
commitd5c8101d795d43c265d81277305958d38160ab19 (patch)
treef9d114bcacebec4839356c4feccad2c56932b5b6 /views
parentf6b551d4bbde5c66782225ecc8c9aec81c974d07 (diff)
downloadchromium_src-d5c8101d795d43c265d81277305958d38160ab19.zip
chromium_src-d5c8101d795d43c265d81277305958d38160ab19.tar.gz
chromium_src-d5c8101d795d43c265d81277305958d38160ab19.tar.bz2
Eliminate a lot of duplicated implementations of Get/SetAccessibleName() by just putting it on the base class. Also cleans up a couple other misc. accessibility functions in view.h.
BUG=none TEST=none Review URL: http://codereview.chromium.org/1512012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43558 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/button/button.cc20
-rw-r--r--views/controls/button/button.h5
-rw-r--r--views/controls/combobox/combobox.cc16
-rw-r--r--views/controls/combobox/combobox.h4
-rw-r--r--views/controls/progress_bar.cc16
-rw-r--r--views/controls/progress_bar.h2
-rw-r--r--views/controls/resize_gripper.cc13
-rw-r--r--views/controls/resize_gripper.h2
-rw-r--r--views/controls/single_split_view.cc12
-rw-r--r--views/controls/single_split_view.h2
-rw-r--r--views/controls/textfield/textfield.cc16
-rw-r--r--views/controls/textfield/textfield.h2
-rw-r--r--views/view.cc13
-rw-r--r--views/view.h17
-rw-r--r--views/widget/root_view.cc12
-rw-r--r--views/widget/root_view.h2
-rw-r--r--views/window/non_client_view.cc12
-rw-r--r--views/window/non_client_view.h2
18 files changed, 26 insertions, 142 deletions
diff --git a/views/controls/button/button.cc b/views/controls/button/button.cc
index 1183951..0305451 100644
--- a/views/controls/button/button.cc
+++ b/views/controls/button/button.cc
@@ -17,6 +17,10 @@ void Button::SetTooltipText(const std::wstring& tooltip_text) {
TooltipTextChanged();
}
+void Button::SetAccessibleKeyboardShortcut(const std::wstring& shortcut) {
+ accessible_shortcut_.assign(shortcut);
+}
+
////////////////////////////////////////////////////////////////////////////////
// Button, View overrides:
@@ -36,27 +40,11 @@ bool Button::GetAccessibleKeyboardShortcut(std::wstring* shortcut) {
return false;
}
-bool Button::GetAccessibleName(std::wstring* name) {
- if (!accessible_name_.empty()) {
- *name = accessible_name_;
- return true;
- }
- 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);
-}
-
-void Button::SetAccessibleName(const std::wstring& name) {
- accessible_name_.assign(name);
-}
-
////////////////////////////////////////////////////////////////////////////////
// Button, protected:
diff --git a/views/controls/button/button.h b/views/controls/button/button.h
index f9f6e5d..016fd74 100644
--- a/views/controls/button/button.h
+++ b/views/controls/button/button.h
@@ -32,13 +32,12 @@ class Button : public View {
int mouse_event_flags() const { return mouse_event_flags_; }
+ void SetAccessibleKeyboardShortcut(const std::wstring& shortcut);
+
// Overridden from View:
virtual bool GetTooltipText(const gfx::Point& p, 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);
protected:
// Construct the Button with a Listener. The listener can be NULL. This can be
diff --git a/views/controls/combobox/combobox.cc b/views/controls/combobox/combobox.cc
index 70ba1cc..594dbf3 100644
--- a/views/controls/combobox/combobox.cc
+++ b/views/controls/combobox/combobox.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -85,16 +85,6 @@ void Combobox::PaintFocusBorder(gfx::Canvas* canvas) {
View::PaintFocusBorder(canvas);
}
-bool Combobox::GetAccessibleName(std::wstring* name) {
- DCHECK(name);
-
- if (!accessible_name_.empty()) {
- *name = accessible_name_;
- return true;
- }
- return false;
-}
-
bool Combobox::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role);
@@ -102,10 +92,6 @@ bool Combobox::GetAccessibleRole(AccessibilityTypes::Role* role) {
return true;
}
-void Combobox::SetAccessibleName(const std::wstring& name) {
- accessible_name_.assign(name);
-}
-
bool Combobox::GetAccessibleValue(std::wstring* value) {
DCHECK(value);
diff --git a/views/controls/combobox/combobox.h b/views/controls/combobox/combobox.h
index b2a8388..ccb9ea6 100644
--- a/views/controls/combobox/combobox.h
+++ b/views/controls/combobox/combobox.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -57,9 +57,7 @@ class Combobox : public View {
virtual void SetEnabled(bool enabled);
virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e);
virtual void PaintFocusBorder(gfx::Canvas* canvas);
- virtual bool GetAccessibleName(std::wstring* name);
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
- virtual void SetAccessibleName(const std::wstring& name);
virtual bool GetAccessibleValue(std::wstring* value);
protected:
diff --git a/views/controls/progress_bar.cc b/views/controls/progress_bar.cc
index 4c0cb33..de9cd59 100644
--- a/views/controls/progress_bar.cc
+++ b/views/controls/progress_bar.cc
@@ -193,18 +193,6 @@ bool ProgressBar::GetAccessibleRole(AccessibilityTypes::Role* role) {
return true;
}
-bool ProgressBar::GetAccessibleName(std::wstring* name) {
- DCHECK(name);
- if (name == NULL)
- return false;
-
- if (!accessible_name_.empty()) {
- *name = accessible_name_;
- return true;
- }
- return false;
-}
-
bool ProgressBar::GetAccessibleState(AccessibilityTypes::State* state) {
DCHECK(state);
if (state == NULL)
@@ -213,8 +201,4 @@ bool ProgressBar::GetAccessibleState(AccessibilityTypes::State* state) {
return true;
}
-void ProgressBar::SetAccessibleName(const std::wstring& name) {
- accessible_name_.assign(name);
-}
-
} // namespace views
diff --git a/views/controls/progress_bar.h b/views/controls/progress_bar.h
index 1047da3..345db81 100644
--- a/views/controls/progress_bar.h
+++ b/views/controls/progress_bar.h
@@ -58,9 +58,7 @@ class ProgressBar : public View {
// Accessibility accessors, overridden from View.
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
- virtual bool GetAccessibleName(std::wstring* name);
virtual bool GetAccessibleState(AccessibilityTypes::State* state);
- virtual void SetAccessibleName(const std::wstring& name);
// Maximum value of progress.
static const int kMaxProgress;
diff --git a/views/controls/resize_gripper.cc b/views/controls/resize_gripper.cc
index b4fd55f..1a49957 100644
--- a/views/controls/resize_gripper.cc
+++ b/views/controls/resize_gripper.cc
@@ -82,19 +82,6 @@ bool ResizeGripper::GetAccessibleRole(AccessibilityTypes::Role* role) {
return true;
}
-bool ResizeGripper::GetAccessibleName(std::wstring* name) {
- DCHECK(name);
- if (!accessible_name_.empty()) {
- *name = accessible_name_;
- return true;
- }
- return false;
-}
-
-void ResizeGripper::SetAccessibleName(const std::wstring& name) {
- accessible_name_.assign(name);
-}
-
void ResizeGripper::ReportResizeAmount(int resize_amount, bool last_update) {
gfx::Point point(resize_amount, 0);
View::ConvertPointToScreen(this, &point);
diff --git a/views/controls/resize_gripper.h b/views/controls/resize_gripper.h
index 8586a22..8b46a629 100644
--- a/views/controls/resize_gripper.h
+++ b/views/controls/resize_gripper.h
@@ -45,8 +45,6 @@ class ResizeGripper : public ImageView {
virtual bool OnMouseDragged(const views::MouseEvent& event);
virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
- virtual bool GetAccessibleName(std::wstring* name);
- virtual void SetAccessibleName(const std::wstring& name);
static const char kViewClassName[];
diff --git a/views/controls/single_split_view.cc b/views/controls/single_split_view.cc
index 73feef2..f76acb3 100644
--- a/views/controls/single_split_view.cc
+++ b/views/controls/single_split_view.cc
@@ -99,18 +99,6 @@ bool SingleSplitView::GetAccessibleRole(AccessibilityTypes::Role* role) {
return true;
}
-bool SingleSplitView::GetAccessibleName(std::wstring* name) {
- if (!accessible_name_.empty()) {
- *name = accessible_name_;
- return true;
- }
- return false;
-}
-
-void SingleSplitView::SetAccessibleName(const std::wstring& name) {
- accessible_name_ = name;
-}
-
gfx::Size SingleSplitView::GetPreferredSize() {
int width = 0;
int height = 0;
diff --git a/views/controls/single_split_view.h b/views/controls/single_split_view.h
index 6dc3f91..f11313d 100644
--- a/views/controls/single_split_view.h
+++ b/views/controls/single_split_view.h
@@ -26,8 +26,6 @@ class SingleSplitView : public views::View {
virtual void Layout();
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
- virtual bool GetAccessibleName(std::wstring* name);
- virtual void SetAccessibleName(const std::wstring& name);
// SingleSplitView's preferred size is the sum of the preferred widths
// and the max of the heights.
diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc
index 71f66b4..54e34dd 100644
--- a/views/controls/textfield/textfield.cc
+++ b/views/controls/textfield/textfield.cc
@@ -260,18 +260,6 @@ bool Textfield::GetAccessibleRole(AccessibilityTypes::Role* role) {
return true;
}
-bool Textfield::GetAccessibleName(std::wstring* name) {
- DCHECK(name);
- if (!name)
- return false;
-
- if (!accessible_name_.empty()) {
- *name = accessible_name_;
- return true;
- }
- return false;
-}
-
bool Textfield::GetAccessibleState(AccessibilityTypes::State* state) {
DCHECK(state);
if (!state)
@@ -281,10 +269,6 @@ bool Textfield::GetAccessibleState(AccessibilityTypes::State* state) {
return true;
}
-void Textfield::SetAccessibleName(const std::wstring& name) {
- accessible_name_.assign(name);
-}
-
bool Textfield::GetAccessibleValue(std::wstring* value) {
DCHECK(value);
if (!value)
diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h
index 7b36547..8be768a 100644
--- a/views/controls/textfield/textfield.h
+++ b/views/controls/textfield/textfield.h
@@ -223,9 +223,7 @@ class Textfield : public View {
// Accessibility accessors, overridden from View:
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
- virtual bool GetAccessibleName(std::wstring* name);
virtual bool GetAccessibleState(AccessibilityTypes::State* state);
- virtual void SetAccessibleName(const std::wstring& name);
virtual bool GetAccessibleValue(std::wstring* value);
protected:
diff --git a/views/view.cc b/views/view.cc
index c5359a7..3bdb2a2 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -1123,6 +1123,19 @@ bool View::InDrag() {
return root_view ? (root_view->GetDragView() == this) : false;
}
+bool View::GetAccessibleName(std::wstring* name) {
+ DCHECK(name);
+
+ if (accessible_name_.empty())
+ return false;
+ *name = accessible_name_;
+ return true;
+}
+
+void View::SetAccessibleName(const std::wstring& name) {
+ accessible_name_ = name;
+}
+
// static
void View::ConvertPointToView(const View* src,
const View* dst,
diff --git a/views/view.h b/views/view.h
index e2a76ac..d8177aa 100644
--- a/views/view.h
+++ b/views/view.h
@@ -573,7 +573,7 @@ class View : public AcceleratorTarget {
// Returns a brief, identifying string, containing a unique, readable name of
// a given control. Sets the input string appropriately, and returns true if
// successful.
- virtual bool GetAccessibleName(std::wstring* name) { return false; }
+ bool GetAccessibleName(std::wstring* name);
// Returns the accessibility role of the current view. The role is what
// assistive technologies (ATs) use to determine what behavior to expect from
@@ -593,20 +593,10 @@ class View : public AcceleratorTarget {
// appropriately, and returns true if successful.
virtual bool GetAccessibleValue(std::wstring* value) { return false; }
- // 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
- // is created to be a certain type.
- virtual void SetAccessibleKeyboardShortcut(const std::wstring& shortcut) {}
-
// Assigns a string name to the given control. Needed as a View does not know
// which name will be associated with it until it is created to be a
// certain type.
- virtual void SetAccessibleName(const std::wstring& name) {}
-
- // Assigns a string value to the given control. Needed as a View does not know
- // which value will be associated with it until it is created to be a
- // certain type.
- virtual void SetAccessibleValue(const std::wstring& value) {}
+ void SetAccessibleName(const std::wstring& name);
// Returns an instance of a wrapper class implementing the (platform-specific)
// accessibility interface for a given View. If one exists, it will be
@@ -1267,6 +1257,9 @@ class View : public AcceleratorTarget {
// List of descendants wanting notification when their visible bounds change.
scoped_ptr<ViewList> descendants_to_notify_;
+ // Name for this view, which can be retrieved by accessibility APIs.
+ std::wstring accessible_name_;
+
// Next view to be focused when the Tab key is pressed.
View* next_focusable_view_;
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index fcfdf4f..179d49d 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -908,18 +908,6 @@ bool RootView::GetAccessibleRole(AccessibilityTypes::Role* role) {
return true;
}
-bool RootView::GetAccessibleName(std::wstring* name) {
- if (!accessible_name_.empty()) {
- *name = accessible_name_;
- return true;
- }
- return false;
-}
-
-void RootView::SetAccessibleName(const std::wstring& name) {
- accessible_name_.assign(name);
-}
-
View* RootView::GetDragView() {
return drag_view_;
}
diff --git a/views/widget/root_view.h b/views/widget/root_view.h
index bfc3b2c..2d74b1f 100644
--- a/views/widget/root_view.h
+++ b/views/widget/root_view.h
@@ -177,8 +177,6 @@ class RootView : public View,
// Accessibility accessors/mutators, overridden from View.
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
- virtual bool GetAccessibleName(std::wstring* name);
- virtual void SetAccessibleName(const std::wstring& name);
protected:
diff --git a/views/window/non_client_view.cc b/views/window/non_client_view.cc
index fcf4353..e2d1a5c 100644
--- a/views/window/non_client_view.cc
+++ b/views/window/non_client_view.cc
@@ -182,18 +182,6 @@ bool NonClientView::GetAccessibleRole(AccessibilityTypes::Role* role) {
return true;
}
-bool NonClientView::GetAccessibleName(std::wstring* name) {
- if (!accessible_name_.empty()) {
- *name = accessible_name_;
- return true;
- }
- return false;
-}
-
-void NonClientView::SetAccessibleName(const std::wstring& name) {
- accessible_name_ = name;
-}
-
////////////////////////////////////////////////////////////////////////////////
// NonClientFrameView, View overrides:
diff --git a/views/window/non_client_view.h b/views/window/non_client_view.h
index cb94d25..54c04b7 100644
--- a/views/window/non_client_view.h
+++ b/views/window/non_client_view.h
@@ -209,8 +209,6 @@ class NonClientView : public View {
virtual gfx::Size GetMinimumSize();
virtual void Layout();
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
- virtual bool GetAccessibleName(std::wstring* name);
- virtual void SetAccessibleName(const std::wstring& name);
protected:
// NonClientView, View overrides: