diff options
Diffstat (limited to 'chromium/ui/views/controls/scroll_view.cc')
-rw-r--r-- | chromium/ui/views/controls/scroll_view.cc | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/chromium/ui/views/controls/scroll_view.cc b/chromium/ui/views/controls/scroll_view.cc index 8f1244d79c2..c161189c9fb 100644 --- a/chromium/ui/views/controls/scroll_view.cc +++ b/chromium/ui/views/controls/scroll_view.cc @@ -12,6 +12,9 @@ #include "base/macros.h" #include "base/numerics/ranges.h" #include "build/build_config.h" +#include "ui/accessibility/ax_action_data.h" +#include "ui/accessibility/ax_enums.mojom.h" +#include "ui/accessibility/ax_node_data.h" #include "ui/base/ui_base_features.h" #include "ui/compositor/overscroll/scroll_input_handler.h" #include "ui/events/event.h" @@ -377,7 +380,7 @@ void ScrollView::Layout() { // When horizontal scrollbar is disabled, it should not matter // if its OverlapsContent matches vertical bar's. if (!hide_horizontal_scrollbar_) { -#if defined(OS_MACOSX) +#if defined(OS_APPLE) // On Mac, scrollbars may update their style one at a time, so they may // temporarily be of different types. Refuse to lay out at this point. if (horiz_sb_->OverlapsContent() != vert_sb_->OverlapsContent()) @@ -641,6 +644,70 @@ void ScrollView::OnThemeChanged() { UpdateBackground(); } +void ScrollView::GetAccessibleNodeData(ui::AXNodeData* node_data) { + View::GetAccessibleNodeData(node_data); + if (!contents_) + return; + + ScrollBar* horizontal = horizontal_scroll_bar(); + if (horizontal) { + node_data->AddIntAttribute(ax::mojom::IntAttribute::kScrollX, + CurrentOffset().x()); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kScrollXMin, + horizontal->GetMinPosition()); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kScrollXMax, + horizontal->GetMaxPosition()); + } + ScrollBar* vertical = vertical_scroll_bar(); + if (vertical) { + node_data->AddIntAttribute(ax::mojom::IntAttribute::kScrollY, + CurrentOffset().y()); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kScrollYMin, + vertical->GetMinPosition()); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kScrollYMax, + vertical->GetMaxPosition()); + } + if (horizontal || vertical) + node_data->AddBoolAttribute(ax::mojom::BoolAttribute::kScrollable, true); +} + +bool ScrollView::HandleAccessibleAction(const ui::AXActionData& action_data) { + if (!contents_) + return View::HandleAccessibleAction(action_data); + + ScrollBar* horizontal = horizontal_scroll_bar(); + ScrollBar* vertical = vertical_scroll_bar(); + switch (action_data.action) { + case ax::mojom::Action::kScrollLeft: + if (horizontal) + return horizontal->ScrollByAmount(ScrollBar::ScrollAmount::kPrevPage); + else + return false; + case ax::mojom::Action::kScrollRight: + if (horizontal) + return horizontal->ScrollByAmount(ScrollBar::ScrollAmount::kNextPage); + else + return false; + case ax::mojom::Action::kScrollUp: + if (vertical) + return vertical->ScrollByAmount(ScrollBar::ScrollAmount::kPrevPage); + else + return false; + case ax::mojom::Action::kScrollDown: + if (vertical) + return vertical->ScrollByAmount(ScrollBar::ScrollAmount::kNextPage); + else + return false; + case ax::mojom::Action::kSetScrollOffset: + ScrollToOffset(gfx::ScrollOffset(action_data.target_point.x(), + action_data.target_point.y())); + return true; + default: + return View::HandleAccessibleAction(action_data); + break; + } +} + void ScrollView::ScrollToPosition(ScrollBar* source, int position) { if (!contents_) return; |