Commit 63821a1f authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Chromium LUCI CQ

Introduced const correctness in ViewAccessibility::Next/PreviousFocus methods

Once a getter method is not marked const, it could force other parts of the codebase to drop const as well, requiring a larger refactoring to fix in the future.
Also took the opportunity to add a comment describing the related member variables
and clarify some other comments.

Split out from a larger patch dealing with ignored Views.

AX-Relnotes: n/a.

TBR=aleventhal@chromium.org, dmazzoni@chromium.org

Change-Id: Ic7c4f6d38f83ef2a22401b0edd342cef5f61c58c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2581220Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835348}
parent 40876277
......@@ -255,7 +255,7 @@ void ViewAccessibility::SetPopupFocusOverride() {}
void ViewAccessibility::EndPopupFocusOverride() {}
bool ViewAccessibility::IsFocusedForTesting() {
bool ViewAccessibility::IsFocusedForTesting() const {
return view_->HasFocus() && !focused_virtual_child_;
}
......@@ -329,11 +329,11 @@ void ViewAccessibility::OverridePreviousFocus(Widget* widget) {
previous_focus_ = widget;
}
Widget* ViewAccessibility::GetNextFocus() {
Widget* ViewAccessibility::GetNextFocus() const {
return next_focus_;
}
Widget* ViewAccessibility::GetPreviousFocus() {
Widget* ViewAccessibility::GetPreviousFocus() const {
return previous_focus_;
}
......
......@@ -83,20 +83,23 @@ class VIEWS_EXPORT ViewAccessibility {
void OverrideDescribedBy(View* described_by_view);
void OverrideHasPopup(const ax::mojom::HasPopup has_popup);
// Override indexes used by some screen readers when describing elements in a
// menu, list, etc. If not specified, a view's index in its parent and its
// parent's number of children provide the values for these.
// Override information provided to users by screen readers when describing
// elements in a menu, listbox, or another set-like item. For example, "New
// tab, menu item 1 of 5". If not specified, a view's index in its parent and
// its parent's number of children provide the values for |pos_in_set| and
// |set_size| respectively.
//
// Note: |pos_in_set| is 1-indexed.
// Note that |pos_in_set| is one-based, i.e. it starts from 1 not 0.
void OverridePosInSet(int pos_in_set, int set_size);
// Override the next or previous focused widget. Some screen readers may
// utilize this information to transition focus from the beginning or end of
// one window to another when navigating by its default navigation method.
// Override the next or previous focused widget. Some assistive technologies,
// such as screen readers, may utilize this information to transition focus
// from the beginning or end of one widget to another when navigating by its
// default navigation method.
void OverrideNextFocus(Widget* widget);
void OverridePreviousFocus(Widget* widget);
Widget* GetNextFocus();
Widget* GetPreviousFocus();
Widget* GetNextFocus() const;
Widget* GetPreviousFocus() const;
// Returns the accessibility object that represents the View whose
// accessibility is managed by this instance. This may be an AXPlatformNode or
......@@ -164,7 +167,7 @@ class VIEWS_EXPORT ViewAccessibility {
virtual void EndPopupFocusOverride();
// Return true if this view is considered focused.
virtual bool IsFocusedForTesting();
virtual bool IsFocusedForTesting() const;
// Call when a menu closes, to restore focus to where it was previously.
virtual void FireFocusAfterMenuClose();
......@@ -212,6 +215,8 @@ class VIEWS_EXPORT ViewAccessibility {
// "presentational".
bool is_ignored_;
// Used by the Views system to help some assistive technologies, such as
// screen readers, transition focus from one widget to another.
Widget* next_focus_ = nullptr;
Widget* previous_focus_ = nullptr;
};
......
......@@ -159,7 +159,7 @@ void ViewAXPlatformNodeDelegate::EndPopupFocusOverride() {
ui::AXPlatformNode::SetPopupFocusOverride(nullptr);
}
bool ViewAXPlatformNodeDelegate::IsFocusedForTesting() {
bool ViewAXPlatformNodeDelegate::IsFocusedForTesting() const {
if (ui::AXPlatformNode::GetPopupFocusOverride())
return ui::AXPlatformNode::GetPopupFocusOverride() ==
GetNativeViewAccessible();
......
......@@ -96,7 +96,7 @@ class ViewAXPlatformNodeDelegate : public ViewAccessibility,
base::Optional<int> GetSetSize() const override;
void SetPopupFocusOverride() override;
void EndPopupFocusOverride() override;
bool IsFocusedForTesting() override;
bool IsFocusedForTesting() const override;
protected:
explicit ViewAXPlatformNodeDelegate(View* view);
......
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