Commit c2865852 authored by Katie Dektar's avatar Katie Dektar Committed by Commit Bot

Fixes accessiblity updates in native views that scroll or animate.

Bug: 789920,778080,789282

Change-Id: Ie4b9d18ffbff48602126f6a4024fdd39f49fe032
Reviewed-on: https://chromium-review.googlesource.com/815878
Commit-Queue: Katie D <katie@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523654}
parent 3b36628a
......@@ -124,6 +124,10 @@ void AXWindowObjWrapper::OnWindowBoundsChanged(
Widget* widget = Widget::GetWidgetForNativeView(window);
if (widget) {
AXAuraObjCache::GetInstance()->FireEvent(
AXAuraObjCache::GetInstance()->GetOrCreate(widget),
ui::AX_EVENT_LOCATION_CHANGED);
views::View* root_view = widget->GetRootView();
if (root_view)
root_view->NotifyAccessibilityEvent(ui::AX_EVENT_LOCATION_CHANGED, true);
......
......@@ -1464,8 +1464,12 @@ void View::NotifyAccessibilityEvent(
if (native_view_accessibility_)
native_view_accessibility_->NotifyAccessibilityEvent(event_type);
}
OnAccessibilityEvent(event_type);
}
void View::OnAccessibilityEvent(ui::AXEvent event_type) {}
// Scrolling -------------------------------------------------------------------
void View::ScrollRectToVisible(const gfx::Rect& rect) {
......@@ -2283,6 +2287,8 @@ void View::BoundsChanged(const gfx::Rect& previous_bounds) {
}
OnBoundsChanged(previous_bounds);
if (bounds_ != previous_bounds)
NotifyAccessibilityEvent(ui::AX_EVENT_LOCATION_CHANGED, false);
if (needs_layout_ || previous_bounds.size() != size()) {
needs_layout_ = false;
......
......@@ -1098,6 +1098,10 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
void NotifyAccessibilityEvent(ui::AXEvent event_type,
bool send_native_event);
// Views may override this function to know when an accessibility
// event is fired. This will be called by NotifyAccessibilityEvent.
virtual void OnAccessibilityEvent(ui::AXEvent event_type);
// Scrolling -----------------------------------------------------------------
// TODO(beng): Figure out if this can live somewhere other than View, i.e.
// closer to ScrollView.
......
......@@ -262,6 +262,8 @@ class TestView : public View {
void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override;
void OnAccessibilityEvent(ui::AXEvent event_type) override;
// OnBoundsChanged.
bool did_change_bounds_;
gfx::Rect new_bounds_;
......@@ -288,6 +290,9 @@ class TestView : public View {
// Value to return from CanProcessEventsWithinSubtree().
bool can_process_events_within_subtree_;
// Accessibility events
ui::AXEvent last_a11y_event_;
};
////////////////////////////////////////////////////////////////////////////////
......@@ -323,6 +328,31 @@ TEST_F(ViewTest, LayoutCalledInvalidateAndOriginChanges) {
// OnBoundsChanged
////////////////////////////////////////////////////////////////////////////////
void TestView::OnAccessibilityEvent(ui::AXEvent event_type) {
last_a11y_event_ = event_type;
}
TEST_F(ViewTest, OnBoundsChangedFiresA11yEvent) {
TestView v;
// Should change when scaled or moved.
gfx::Rect initial(0, 0, 200, 200);
gfx::Rect scaled(0, 0, 250, 250);
gfx::Rect moved(100, 100, 250, 250);
v.last_a11y_event_ = ui::AX_EVENT_NONE;
v.SetBoundsRect(initial);
EXPECT_EQ(v.last_a11y_event_, ui::AX_EVENT_LOCATION_CHANGED);
v.last_a11y_event_ = ui::AX_EVENT_NONE;
v.SetBoundsRect(scaled);
EXPECT_EQ(v.last_a11y_event_, ui::AX_EVENT_LOCATION_CHANGED);
v.last_a11y_event_ = ui::AX_EVENT_NONE;
v.SetBoundsRect(moved);
EXPECT_EQ(v.last_a11y_event_, ui::AX_EVENT_LOCATION_CHANGED);
}
void TestView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
did_change_bounds_ = true;
new_bounds_ = bounds();
......
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