Commit 8662ae7b authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fix AXWindowObjWrapper::FireEvent

Removes unneeded parameter and mistaken firing of location changes for every call to FireEvent.

Change-Id: Id1e3e75980d6c3459485cb2e02dd184e499fd936
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1893355Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711570}
parent 2e150240
......@@ -37,6 +37,28 @@ Widget* GetWidgetForWindow(aura::Window* window) {
return widget;
}
// Fires location change events on a window, taking into account its
// associated widget, that widget's root view, and descendant windows.
void FireLocationChangesRecursively(aura::Window* window,
AXAuraObjCache* cache) {
cache->FireEvent(cache->GetOrCreate(window),
ax::mojom::Event::kLocationChanged);
Widget* widget = GetWidgetForWindow(window);
if (widget) {
cache->FireEvent(cache->GetOrCreate(widget),
ax::mojom::Event::kLocationChanged);
views::View* root_view = widget->GetRootView();
if (root_view)
root_view->NotifyAccessibilityEvent(ax::mojom::Event::kLocationChanged,
true);
}
for (auto* child : window->children())
FireLocationChangesRecursively(child, cache);
}
} // namespace
AXWindowObjWrapper::AXWindowObjWrapper(AXAuraObjCache* aura_obj_cache,
......@@ -144,53 +166,34 @@ void AXWindowObjWrapper::OnWindowBoundsChanged(
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) {
if (window != window_)
return;
FireEvent(window_, ax::mojom::Event::kLocationChanged);
if (window == window_)
FireLocationChangesRecursively(window_, aura_obj_cache_);
}
void AXWindowObjWrapper::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
if (window == window_ && key == ui::kChildAXTreeID) {
aura_obj_cache_->FireEvent(this, ax::mojom::Event::kChildrenChanged);
}
if (window == window_ && key == ui::kChildAXTreeID)
FireEvent(ax::mojom::Event::kChildrenChanged);
}
void AXWindowObjWrapper::OnWindowVisibilityChanged(aura::Window* window,
bool visible) {
aura_obj_cache_->FireEvent(this, ax::mojom::Event::kStateChanged);
FireEvent(ax::mojom::Event::kStateChanged);
}
void AXWindowObjWrapper::OnWindowTransformed(aura::Window* window,
ui::PropertyChangeReason reason) {
if (window != window_)
return;
FireEvent(window_, ax::mojom::Event::kLocationChanged);
if (window == window_)
FireLocationChangesRecursively(window_, aura_obj_cache_);
}
void AXWindowObjWrapper::OnWindowTitleChanged(aura::Window* window) {
FireEvent(window, ax::mojom::Event::kTextChanged);
FireEvent(ax::mojom::Event::kTextChanged);
}
void AXWindowObjWrapper::FireEvent(aura::Window* window,
ax::mojom::Event event_type) {
aura_obj_cache_->FireEvent(aura_obj_cache_->GetOrCreate(window), event_type);
Widget* widget = GetWidgetForWindow(window);
if (widget) {
aura_obj_cache_->FireEvent(aura_obj_cache_->GetOrCreate(widget),
event_type);
views::View* root_view = widget->GetRootView();
if (root_view)
root_view->NotifyAccessibilityEvent(event_type, true);
}
for (auto* child : window->children())
FireEvent(child, ax::mojom::Event::kLocationChanged);
void AXWindowObjWrapper::FireEvent(ax::mojom::Event event_type) {
aura_obj_cache_->FireEvent(aura_obj_cache_->GetOrCreate(window_), event_type);
}
} // namespace views
......@@ -52,9 +52,8 @@ class AXWindowObjWrapper : public AXAuraObjWrapper,
void OnWindowTitleChanged(aura::Window* window) override;
private:
// Fires an event on a window, taking into account its associated widget and
// that widget's root view.
void FireEvent(aura::Window* window, ax::mojom::Event event_type);
// Fires an accessibility event.
void FireEvent(ax::mojom::Event event_type);
aura::Window* window_;
......
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