diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-26 22:23:56 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-26 22:23:56 +0000 |
commit | b50cb74fa00aa7e22edd6c38e4383a66f93198df (patch) | |
tree | 10b40fdbb6c6588b3e312a140167b8bb70234241 /ui | |
parent | c344e9d72379b4eb2fffa04672c44e557aa6b1c1 (diff) | |
download | chromium_src-b50cb74fa00aa7e22edd6c38e4383a66f93198df.zip chromium_src-b50cb74fa00aa7e22edd6c38e4383a66f93198df.tar.gz chromium_src-b50cb74fa00aa7e22edd6c38e4383a66f93198df.tar.bz2 |
Fix incorrect use of AXState caused when refactoring two enums into one.
(Was broken by r253207.)
BUG=347450
Review URL: https://codereview.chromium.org/196133012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259718 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/accessibility/ax_view_state.cc | 12 | ||||
-rw-r--r-- | ui/accessibility/ax_view_state.h | 13 | ||||
-rw-r--r-- | ui/views/accessibility/native_view_accessibility_win.cc | 36 | ||||
-rw-r--r-- | ui/views/accessibility/native_view_accessibility_win.h | 8 | ||||
-rw-r--r-- | ui/views/controls/button/checkbox.cc | 3 | ||||
-rw-r--r-- | ui/views/controls/button/custom_button.cc | 6 | ||||
-rw-r--r-- | ui/views/controls/button/menu_button.cc | 2 | ||||
-rw-r--r-- | ui/views/controls/label.cc | 2 | ||||
-rw-r--r-- | ui/views/controls/label_unittest.cc | 2 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_item_view.cc | 6 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_scroll_view_container.cc | 2 | ||||
-rw-r--r-- | ui/views/controls/progress_bar.cc | 2 | ||||
-rw-r--r-- | ui/views/controls/progress_bar_unittest.cc | 2 | ||||
-rw-r--r-- | ui/views/controls/textfield/textfield.cc | 4 | ||||
-rw-r--r-- | ui/views/controls/tree/tree_view.cc | 2 |
15 files changed, 58 insertions, 44 deletions
diff --git a/ui/accessibility/ax_view_state.cc b/ui/accessibility/ax_view_state.cc index fb19e2d..11044bc 100644 --- a/ui/accessibility/ax_view_state.cc +++ b/ui/accessibility/ax_view_state.cc @@ -8,12 +8,20 @@ namespace ui { AXViewState::AXViewState() : role(AX_ROLE_CLIENT), - state(0), selection_start(-1), selection_end(-1), index(-1), - count(-1) { } + count(-1), + state_(0) { } AXViewState::~AXViewState() { } +void AXViewState::AddStateFlag(ui::AXState state_flag) { + state_ |= (1 << state_flag); +} + +bool AXViewState::HasStateFlag(ui::AXState state_flag) const { + return 0 != (state_ & (1 << state_flag)); +} + } // namespace ui diff --git a/ui/accessibility/ax_view_state.h b/ui/accessibility/ax_view_state.h index 2cb2152..5d72d47 100644 --- a/ui/accessibility/ax_view_state.h +++ b/ui/accessibility/ax_view_state.h @@ -26,13 +26,13 @@ struct AX_EXPORT AXViewState { AXViewState(); ~AXViewState(); + // Set or check bits in |state_|. + void AddStateFlag(ui::AXState state); + bool HasStateFlag(ui::AXState state) const; + // The view's role, like button or list box. AXRole role; - // The view's state, a bitmask containing fields such as checked - // (for a checkbox) and protected (for a password text box). - uint32 state; - // The view's name / label. base::string16 name; @@ -66,6 +66,11 @@ struct AX_EXPORT AXViewState { // be a safe no-op if the view is deleted. Typically, accessible views // should use a WeakPtr when binding the callback. base::Callback<void(const base::string16&)> set_value_callback; + + private: + // The view's state, a bitmask containing fields such as checked + // (for a checkbox) and protected (for a password text box). + uint32 state_; }; } // namespace ui diff --git a/ui/views/accessibility/native_view_accessibility_win.cc b/ui/views/accessibility/native_view_accessibility_win.cc index ead097f..10c17ff 100644 --- a/ui/views/accessibility/native_view_accessibility_win.cc +++ b/ui/views/accessibility/native_view_accessibility_win.cc @@ -837,7 +837,7 @@ STDMETHODIMP NativeViewAccessibilityWin::get_states(AccessibleStates* states) { // in IAccessible2. If any more are added, we may want to // add a helper function like MSAAState. *states = IA2_STATE_OPAQUE; - if (state.state & ui::AX_STATE_EDITABLE) + if (state.HasStateFlag(ui::AX_STATE_EDITABLE)) *states |= IA2_STATE_EDITABLE; return S_OK; @@ -1245,40 +1245,40 @@ int32 NativeViewAccessibilityWin::MSAARole(ui::AXRole role) { } } -int32 NativeViewAccessibilityWin::MSAAState(uint32 state) { +int32 NativeViewAccessibilityWin::MSAAState(const ui::AXViewState& state) { // This maps MSAA states for get_accState(). See also the IAccessible2 // interface get_states(). int32 msaa_state = 0; - if (state & ui::AX_STATE_CHECKED) + if (state.HasStateFlag(ui::AX_STATE_CHECKED)) msaa_state |= STATE_SYSTEM_CHECKED; - if (state & ui::AX_STATE_COLLAPSED) + if (state.HasStateFlag(ui::AX_STATE_COLLAPSED)) msaa_state |= STATE_SYSTEM_COLLAPSED; - if (state & ui::AX_STATE_DEFAULT) + if (state.HasStateFlag(ui::AX_STATE_DEFAULT)) msaa_state |= STATE_SYSTEM_DEFAULT; - if (state & ui::AX_STATE_EXPANDED) + if (state.HasStateFlag(ui::AX_STATE_EXPANDED)) msaa_state |= STATE_SYSTEM_EXPANDED; - if (state & ui::AX_STATE_HASPOPUP) + if (state.HasStateFlag(ui::AX_STATE_HASPOPUP)) msaa_state |= STATE_SYSTEM_HASPOPUP; - if (state & ui::AX_STATE_HOVERED) + if (state.HasStateFlag(ui::AX_STATE_HOVERED)) msaa_state |= STATE_SYSTEM_HOTTRACKED; - if (state & ui::AX_STATE_INVISIBLE) + if (state.HasStateFlag(ui::AX_STATE_INVISIBLE)) msaa_state |= STATE_SYSTEM_INVISIBLE; - if (state & ui::AX_STATE_LINKED) + if (state.HasStateFlag(ui::AX_STATE_LINKED)) msaa_state |= STATE_SYSTEM_LINKED; - if (state & ui::AX_STATE_OFFSCREEN) + if (state.HasStateFlag(ui::AX_STATE_OFFSCREEN)) msaa_state |= STATE_SYSTEM_OFFSCREEN; - if (state & ui::AX_STATE_PRESSED) + if (state.HasStateFlag(ui::AX_STATE_PRESSED)) msaa_state |= STATE_SYSTEM_PRESSED; - if (state & ui::AX_STATE_PROTECTED) + if (state.HasStateFlag(ui::AX_STATE_PROTECTED)) msaa_state |= STATE_SYSTEM_PROTECTED; - if (state & ui::AX_STATE_READ_ONLY) + if (state.HasStateFlag(ui::AX_STATE_READ_ONLY)) msaa_state |= STATE_SYSTEM_READONLY; - if (state & ui::AX_STATE_SELECTED) + if (state.HasStateFlag(ui::AX_STATE_SELECTED)) msaa_state |= STATE_SYSTEM_SELECTED; - if (state & ui::AX_STATE_FOCUSED) + if (state.HasStateFlag(ui::AX_STATE_FOCUSED)) msaa_state |= STATE_SYSTEM_FOCUSED; - if (state & ui::AX_STATE_DISABLED) + if (state.HasStateFlag(ui::AX_STATE_DISABLED)) msaa_state |= STATE_SYSTEM_UNAVAILABLE; return msaa_state; } @@ -1339,7 +1339,7 @@ void NativeViewAccessibilityWin::SetState( // Add on any view-specific states. ui::AXViewState view_state; view->GetAccessibleState(&view_state); - msaa_state->lVal |= MSAAState(view_state.state); + msaa_state->lVal |= MSAAState(view_state); } base::string16 NativeViewAccessibilityWin::TextForIAccessibleText() { diff --git a/ui/views/accessibility/native_view_accessibility_win.h b/ui/views/accessibility/native_view_accessibility_win.h index ffb9a4d..2c8c1fe 100644 --- a/ui/views/accessibility/native_view_accessibility_win.h +++ b/ui/views/accessibility/native_view_accessibility_win.h @@ -337,17 +337,17 @@ NativeViewAccessibilityWin // Static methods - // Returns a conversion from the event (as defined in accessibility_types.h) + // Returns a conversion from the event (as defined in ax_enums.idl) // to an MSAA event. static int32 MSAAEvent(ui::AXEvent event); - // Returns a conversion from the Role (as defined in accessibility_types.h) + // Returns a conversion from the Role (as defined in ax_enums.idl) // to an MSAA role. static int32 MSAARole(ui::AXRole role); - // Returns a conversion from the State (as defined in accessibility_types.h) + // Returns a conversion from the State (as defined in ax_enums.idl) // to MSAA states set. - static int32 MSAAState(uint32 state); + static int32 MSAAState(const ui::AXViewState& state); protected: NativeViewAccessibilityWin(); diff --git a/ui/views/controls/button/checkbox.cc b/ui/views/controls/button/checkbox.cc index 2389b62..22c5f88 100644 --- a/ui/views/controls/button/checkbox.cc +++ b/ui/views/controls/button/checkbox.cc @@ -97,7 +97,8 @@ const char* Checkbox::GetClassName() const { void Checkbox::GetAccessibleState(ui::AXViewState* state) { LabelButton::GetAccessibleState(state); state->role = ui::AX_ROLE_CHECK_BOX; - state->state = checked() ? ui::AX_STATE_CHECKED : 0; + if (checked()) + state->AddStateFlag(ui::AX_STATE_CHECKED); } void Checkbox::OnFocus() { diff --git a/ui/views/controls/button/custom_button.cc b/ui/views/controls/button/custom_button.cc index 4890b13..0e237a3 100644 --- a/ui/views/controls/button/custom_button.cc +++ b/ui/views/controls/button/custom_button.cc @@ -288,13 +288,13 @@ void CustomButton::GetAccessibleState(ui::AXViewState* state) { Button::GetAccessibleState(state); switch (state_) { case STATE_HOVERED: - state->state = ui::AX_STATE_HOVERED; + state->AddStateFlag(ui::AX_STATE_HOVERED); break; case STATE_PRESSED: - state->state = ui::AX_STATE_PRESSED; + state->AddStateFlag(ui::AX_STATE_PRESSED); break; case STATE_DISABLED: - state->state = ui::AX_STATE_DISABLED; + state->AddStateFlag(ui::AX_STATE_DISABLED); break; case STATE_NORMAL: case STATE_COUNT: diff --git a/ui/views/controls/button/menu_button.cc b/ui/views/controls/button/menu_button.cc index 0f6a393..83af3c9 100644 --- a/ui/views/controls/button/menu_button.cc +++ b/ui/views/controls/button/menu_button.cc @@ -244,7 +244,7 @@ void MenuButton::GetAccessibleState(ui::AXViewState* state) { CustomButton::GetAccessibleState(state); state->role = ui::AX_ROLE_POP_UP_BUTTON; state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); - state->state = ui::AX_STATE_HASPOPUP; + state->AddStateFlag(ui::AX_STATE_HASPOPUP); } void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) { diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc index f35d119..7145323 100644 --- a/ui/views/controls/label.cc +++ b/ui/views/controls/label.cc @@ -291,7 +291,7 @@ bool Label::GetTooltipText(const gfx::Point& p, base::string16* tooltip) const { void Label::GetAccessibleState(ui::AXViewState* state) { state->role = ui::AX_ROLE_STATIC_TEXT; - state->state = ui::AX_STATE_READ_ONLY; + state->AddStateFlag(ui::AX_STATE_READ_ONLY); state->name = text_; } diff --git a/ui/views/controls/label_unittest.cc b/ui/views/controls/label_unittest.cc index c4941d8..42cc0cd 100644 --- a/ui/views/controls/label_unittest.cc +++ b/ui/views/controls/label_unittest.cc @@ -154,7 +154,7 @@ TEST(LabelTest, Accessibility) { label.GetAccessibleState(&state); EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, state.role); EXPECT_EQ(test_text, state.name); - EXPECT_TRUE(ui::AX_STATE_READ_ONLY & state.state); + EXPECT_TRUE(state.HasStateFlag(ui::AX_STATE_READ_ONLY)); } TEST(LabelTest, SingleLineSizing) { diff --git a/ui/views/controls/menu/menu_item_view.cc b/ui/views/controls/menu/menu_item_view.cc index 386a23e..9232440 100644 --- a/ui/views/controls/menu/menu_item_view.cc +++ b/ui/views/controls/menu/menu_item_view.cc @@ -168,12 +168,12 @@ void MenuItemView::GetAccessibleState(ui::AXViewState* state) { switch (GetType()) { case SUBMENU: - state->state |= ui::AX_STATE_HASPOPUP; + state->AddStateFlag(ui::AX_STATE_HASPOPUP); break; case CHECKBOX: case RADIO: - state->state |= GetDelegate()->IsItemChecked(GetCommand()) ? - ui::AX_STATE_CHECKED : 0; + if (GetDelegate()->IsItemChecked(GetCommand())) + state->AddStateFlag(ui::AX_STATE_CHECKED); break; case NORMAL: case SEPARATOR: diff --git a/ui/views/controls/menu/menu_scroll_view_container.cc b/ui/views/controls/menu/menu_scroll_view_container.cc index f01bea6..dfb9ef3 100644 --- a/ui/views/controls/menu/menu_scroll_view_container.cc +++ b/ui/views/controls/menu/menu_scroll_view_container.cc @@ -259,7 +259,7 @@ void MenuScrollViewContainer::GetAccessibleState( state->role = ui::AX_ROLE_MENU_BAR; // Some AT (like NVDA) will not process focus events on menu item children // unless a parent claims to be focused. - state->state = ui::AX_STATE_FOCUSED; + state->AddStateFlag(ui::AX_STATE_FOCUSED); } void MenuScrollViewContainer::OnBoundsChanged( diff --git a/ui/views/controls/progress_bar.cc b/ui/views/controls/progress_bar.cc index f1d7b1f..2049f6e 100644 --- a/ui/views/controls/progress_bar.cc +++ b/ui/views/controls/progress_bar.cc @@ -180,7 +180,7 @@ bool ProgressBar::GetTooltipText(const gfx::Point& p, void ProgressBar::GetAccessibleState(ui::AXViewState* state) { state->role = ui::AX_ROLE_PROGRESS_INDICATOR; - state->state = ui::AX_STATE_READ_ONLY; + state->AddStateFlag(ui::AX_STATE_READ_ONLY); } gfx::Size ProgressBar::GetPreferredSize() { diff --git a/ui/views/controls/progress_bar_unittest.cc b/ui/views/controls/progress_bar_unittest.cc index 91515a0..b9067b2 100644 --- a/ui/views/controls/progress_bar_unittest.cc +++ b/ui/views/controls/progress_bar_unittest.cc @@ -29,7 +29,7 @@ TEST(ProgressBarTest, Accessibility) { bar.GetAccessibleState(&state); EXPECT_EQ(ui::AX_ROLE_PROGRESS_INDICATOR, state.role); EXPECT_EQ(base::string16(), state.name); - EXPECT_TRUE(ui::AX_STATE_READ_ONLY & state.state); + EXPECT_TRUE(state.HasStateFlag(ui::AX_STATE_READ_ONLY)); } } // namespace views diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc index f3f5859..98b364e 100644 --- a/ui/views/controls/textfield/textfield.cc +++ b/ui/views/controls/textfield/textfield.cc @@ -736,9 +736,9 @@ void Textfield::GetAccessibleState(ui::AXViewState* state) { state->role = ui::AX_ROLE_TEXT_FIELD; state->name = accessible_name_; if (read_only()) - state->state |= ui::AX_STATE_READ_ONLY; + state->AddStateFlag(ui::AX_STATE_READ_ONLY); if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) - state->state |= ui::AX_STATE_PROTECTED; + state->AddStateFlag(ui::AX_STATE_PROTECTED); state->value = text(); const gfx::Range range = GetSelectedRange(); diff --git a/ui/views/controls/tree/tree_view.cc b/ui/views/controls/tree/tree_view.cc index 77d9780..bf75a65 100644 --- a/ui/views/controls/tree/tree_view.cc +++ b/ui/views/controls/tree/tree_view.cc @@ -406,7 +406,7 @@ void TreeView::ShowContextMenu(const gfx::Point& p, void TreeView::GetAccessibleState(ui::AXViewState* state) { state->role = ui::AX_ROLE_TREE; - state->state = ui::AX_STATE_READ_ONLY; + state->AddStateFlag(ui::AX_STATE_READ_ONLY); if (!selected_node_) return; |