Commit 05f23a14 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Make Search+a, w read the window title

Bug: 875437
Change-Id: I708517acb953d5ec0cb243c30c44c349f40fbe9b
Reviewed-on: https://chromium-review.googlesource.com/c/1324869
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606968}
parent dcb66f0f
......@@ -652,17 +652,24 @@ CommandHandler.onCommand = function(command) {
case 'readCurrentTitle':
var target = ChromeVoxState.instance.currentRange.start.node;
var output = new Output();
target = AutomationUtil.getTopLevelRoot(target) || target.parent;
// Search for a container (e.g. rootWebArea, window) with a title-like
// string.
while (target && !target.name && !target.docUrl)
target = target.parent;
if (!target)
return false;
if (target.root && target.root.role == RoleType.DESKTOP) {
// Search for the first container with a name.
while (target && (!target.name || !AutomationPredicate.root(target)))
target = target.parent;
} else {
// Search for a window with a title.
while (target && (!target.name || target.role != RoleType.WINDOW))
target = target.parent;
}
if (!target)
output.format('@no_title');
else
output.withString(target.name || target.docUrl);
output.withString(target.name);
output.go();
return false;
......
......@@ -18,26 +18,25 @@
namespace views {
void FireLocationChanges(aura::Window* window) {
// A helper to fire 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) {
AXAuraObjCache::GetInstance()->FireEvent(
AXAuraObjCache::GetInstance()->GetOrCreate(window),
ax::mojom::Event::kLocationChanged);
AXAuraObjCache::GetInstance()->GetOrCreate(window), event_type);
Widget* widget = Widget::GetWidgetForNativeView(window);
if (widget) {
AXAuraObjCache::GetInstance()->FireEvent(
AXAuraObjCache::GetInstance()->GetOrCreate(widget),
ax::mojom::Event::kLocationChanged);
AXAuraObjCache::GetInstance()->GetOrCreate(widget), event_type);
views::View* root_view = widget->GetRootView();
if (root_view)
root_view->NotifyAccessibilityEvent(ax::mojom::Event::kLocationChanged,
true);
root_view->NotifyAccessibilityEvent(event_type, true);
}
aura::Window::Windows children = window->children();
for (size_t i = 0; i < children.size(); ++i)
FireLocationChanges(children[i]);
FireEvent(children[i], ax::mojom::Event::kLocationChanged);
}
AXWindowObjWrapper::AXWindowObjWrapper(aura::Window* window)
......@@ -143,7 +142,7 @@ void AXWindowObjWrapper::OnWindowBoundsChanged(
if (window != window_)
return;
FireLocationChanges(window_);
FireEvent(window_, ax::mojom::Event::kLocationChanged);
}
void AXWindowObjWrapper::OnWindowPropertyChanged(aura::Window* window,
......@@ -166,7 +165,11 @@ void AXWindowObjWrapper::OnWindowTransformed(aura::Window* window,
if (window != window_)
return;
FireLocationChanges(window_);
FireEvent(window_, ax::mojom::Event::kLocationChanged);
}
void AXWindowObjWrapper::OnWindowTitleChanged(aura::Window* window) {
FireEvent(window, ax::mojom::Event::kTextChanged);
}
} // namespace views
......@@ -52,6 +52,7 @@ class AXWindowObjWrapper : public AXAuraObjWrapper,
void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
void OnWindowTransformed(aura::Window* window,
ui::PropertyChangeReason reason) override;
void OnWindowTitleChanged(aura::Window* window) override;
private:
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