Commit 2d8696cf authored by Hiroki Sato's avatar Hiroki Sato Committed by Commit Bot

Fix scaling computation in ARC A11y

Bug: b:129680977
Test: manual. (ChromeVox and HighlightInputFocus on eve and laser14)
Change-Id: Ifb14d413e1135d4acd8bbc8f24631df6862bc3db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1978202Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Hiroki Sato <hirokisato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728424}
parent 5f5fae90
...@@ -69,11 +69,9 @@ void DispatchFocusChange(arc::mojom::AccessibilityNodeInfoData* node_data, ...@@ -69,11 +69,9 @@ void DispatchFocusChange(arc::mojom::AccessibilityNodeInfoData* node_data,
if (!active_window) if (!active_window)
return; return;
aura::Window* toplevel_window = active_window->GetToplevelWindow();
gfx::Rect bounds_in_screen = gfx::ScaleToEnclosingRect( gfx::Rect bounds_in_screen = gfx::ScaleToEnclosingRect(
node_data->bounds_in_screen, node_data->bounds_in_screen,
1.0f / toplevel_window->layer()->device_scale_factor()); 1.0f / wm_helper->GetDefaultDeviceScaleFactor());
views::Widget* widget = views::Widget::GetWidgetForNativeView(active_window); views::Widget* widget = views::Widget::GetWidgetForNativeView(active_window);
DCHECK(widget); DCHECK(widget);
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "chrome/browser/chromeos/arc/accessibility/accessibility_window_info_data_wrapper.h" #include "chrome/browser/chromeos/arc/accessibility/accessibility_window_info_data_wrapper.h"
#include "chrome/browser/chromeos/arc/accessibility/arc_accessibility_util.h" #include "chrome/browser/chromeos/arc/accessibility/arc_accessibility_util.h"
#include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h"
#include "components/exo/wm_helper.h"
#include "extensions/browser/api/automation_internal/automation_event_router.h" #include "extensions/browser/api/automation_internal/automation_event_router.h"
#include "extensions/common/extension_messages.h" #include "extensions/common/extension_messages.h"
#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_enums.mojom.h"
...@@ -230,10 +231,13 @@ const gfx::Rect AXTreeSourceArc::GetBounds( ...@@ -230,10 +231,13 @@ const gfx::Rect AXTreeSourceArc::GetBounds(
return info_data_bounds; return info_data_bounds;
} }
exo::WMHelper* wm_helper = exo::WMHelper::GetInstance();
if (!wm_helper)
return info_data_bounds;
// TODO(katie): offset_container_id should work and we shouldn't have to // TODO(katie): offset_container_id should work and we shouldn't have to
// go into this code path for each node. // go into this code path for each node.
aura::Window* toplevel_window = active_window->GetToplevelWindow(); aura::Window* toplevel_window = active_window->GetToplevelWindow();
float scale = toplevel_window->layer()->device_scale_factor();
views::Widget* widget = views::Widget::GetWidgetForNativeView(active_window); views::Widget* widget = views::Widget::GetWidgetForNativeView(active_window);
DCHECK(widget); DCHECK(widget);
...@@ -242,6 +246,8 @@ const gfx::Rect AXTreeSourceArc::GetBounds( ...@@ -242,6 +246,8 @@ const gfx::Rect AXTreeSourceArc::GetBounds(
const gfx::Rect bounds = const gfx::Rect bounds =
widget->widget_delegate()->GetContentsView()->GetBoundsInScreen(); widget->widget_delegate()->GetContentsView()->GetBoundsInScreen();
float scale = wm_helper->GetDefaultDeviceScaleFactor();
// Bounds of root node is relative to its container, i.e. contents view // Bounds of root node is relative to its container, i.e. contents view
// (ShellSurfaceBase). // (ShellSurfaceBase).
info_data_bounds.Offset( info_data_bounds.Offset(
...@@ -259,7 +265,9 @@ const gfx::Rect AXTreeSourceArc::GetBounds( ...@@ -259,7 +265,9 @@ const gfx::Rect AXTreeSourceArc::GetBounds(
->GetBoundsForClientView() ->GetBoundsForClientView()
.y()))); .y())));
} }
return info_data_bounds; return gfx::ScaleToEnclosingRect(
info_data_bounds,
toplevel_window->layer()->device_scale_factor() / scale);
} }
void AXTreeSourceArc::InvalidateTree() { void AXTreeSourceArc::InvalidateTree() {
......
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