Commit 05fad8d3 authored by Katie Dektar's avatar Katie Dektar Committed by Commit Bot

Fix hit test: DIP must be converted to PX for RenderFrameHost hittest.

This fixes a bug where in gmail selecting text in an open draft also
selected text behind that pop up window. The bug was occuring because
the hittest was returning a node that was behind the open dialog/window,
and select-to-speak walked up its tree to find a higher level root with
which to build the nodes to speak.

The bug only showed up on high density screens because then DIP and
PX were significantly different. On 1:1 screens it could not be
found.

A test is added which fails without this one-line change but passes
with it.

Bug: 792545
Change-Id: I21519b6cfaae97cb11c711b11b7a6b3e4b6fe017
Reviewed-on: https://chromium-review.googlesource.com/826043
Commit-Queue: Katie D <katie@chromium.org>
Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523992}
parent c24f6f7d
...@@ -329,6 +329,12 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTestWithDeviceScaleFactor, LocationScaled) { ...@@ -329,6 +329,12 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTestWithDeviceScaleFactor, LocationScaled) {
<< message_; << message_;
} }
IN_PROC_BROWSER_TEST_F(AutomationApiTestWithDeviceScaleFactor, HitTest) {
StartEmbeddedTestServer();
ASSERT_TRUE(RunExtensionSubtest("automation/tests/desktop", "hit_test.html"))
<< message_;
}
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
} // namespace extensions } // namespace extensions
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "ui/accessibility/platform/aura_window_properties.h" #include "ui/accessibility/platform/aura_window_properties.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/views/accessibility/ax_aura_obj_wrapper.h" #include "ui/views/accessibility/ax_aura_obj_wrapper.h"
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -248,8 +249,11 @@ void AutomationManagerAura::PerformHitTest( ...@@ -248,8 +249,11 @@ void AutomationManagerAura::PerformHitTest(
content::RenderFrameHost* rfh = content::RenderFrameHost* rfh =
content::RenderFrameHost::FromAXTreeID(child_ax_tree_id); content::RenderFrameHost::FromAXTreeID(child_ax_tree_id);
if (rfh) if (rfh) {
// Convert to pixels for the RenderFrameHost HitTest.
window->GetHost()->ConvertDIPToPixels(&action.target_point);
rfh->AccessibilityPerformAction(action); rfh->AccessibilityPerformAction(action);
}
return; return;
} }
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
var allTests = [ var allTests = [
function testHitTestInDesktop() { function testHitTestInDesktop() {
var url = 'data:text/html,<!doctype html>' + var url = 'data:text/html,<!doctype html>' +
encodeURI('<button>Click Me</button>'); encodeURI('<div>Don\'t Click Me</div>' +
'<button>Click Me</button>');
var didHitTest = false; var didHitTest = false;
chrome.automation.getDesktop(function(desktop) { chrome.automation.getDesktop(function(desktop) {
chrome.tabs.create({url: url}); chrome.tabs.create({url: url});
...@@ -14,14 +15,18 @@ var allTests = [ ...@@ -14,14 +15,18 @@ var allTests = [
if (didHitTest) if (didHitTest)
return; return;
if (event.target.url.indexOf('data:') >= 0) { if (event.target.url.indexOf('data:') >= 0) {
var button = desktop.find({ attributes: { name: 'Click Me' } }); var button = desktop.find({ attributes: { name: 'Click Me',
role: 'button' } });
if (button) { if (button) {
didHitTest = true; didHitTest = true;
button.addEventListener(EventType.ALERT, function() { button.addEventListener(EventType.ALERT, function() {
chrome.test.succeed(); chrome.test.succeed();
}, true); }, true);
var cx = button.location.left + button.location.width / 2; // Click just barely on the second button, very close
var cy = button.location.top + button.location.height / 2; // to the first button. This tests that we are converting
// coordinate properly.
var cx = button.location.left + 10;
var cy = button.location.top + 10;
desktop.hitTest(cx, cy, EventType.ALERT); desktop.hitTest(cx, cy, EventType.ALERT);
} }
} }
......
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