Skip to content

Commit

Permalink
Fix hit test: DIP must be converted to PX for RenderFrameHost hittest.
Browse files Browse the repository at this point in the history
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: Alice Boxhall <aboxhall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523992}
  • Loading branch information
dektar authored and Commit Bot committed Dec 14, 2017
1 parent c24f6f7 commit 05fad8d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTestWithDeviceScaleFactor, LocationScaled) {
<< message_;
}

IN_PROC_BROWSER_TEST_F(AutomationApiTestWithDeviceScaleFactor, HitTest) {
StartEmbeddedTestServer();
ASSERT_TRUE(RunExtensionSubtest("automation/tests/desktop", "hit_test.html"))
<< message_;
}

#endif // defined(OS_CHROMEOS)

} // namespace extensions
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ui/accessibility/platform/aura_window_properties.h"
#include "ui/aura/env.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/view.h"
#include "ui/views/widget/widget.h"
Expand Down Expand Up @@ -248,8 +249,11 @@ void AutomationManagerAura::PerformHitTest(

content::RenderFrameHost* rfh =
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);
}
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
var allTests = [
function testHitTestInDesktop() {
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;
chrome.automation.getDesktop(function(desktop) {
chrome.tabs.create({url: url});
Expand All @@ -14,14 +15,18 @@ var allTests = [
if (didHitTest)
return;
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) {
didHitTest = true;
button.addEventListener(EventType.ALERT, function() {
chrome.test.succeed();
}, true);
var cx = button.location.left + button.location.width / 2;
var cy = button.location.top + button.location.height / 2;
// Click just barely on the second button, very close
// 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);
}
}
Expand Down

0 comments on commit 05fad8d

Please sign in to comment.