Commit 260ccf1f authored by Hugo Holgersson's avatar Hugo Holgersson Committed by Commit Bot

Snav: Ensure spatnav uses the visual viewport as starting point

When a page is opened, unless the page auto-focuses an element,
the document <body> is the activeElement (aka focused element).

In this case, spatnav uses heuristics in its search for the next
focusable element to navigate to: the search starts at the visual
viewport.

This fixes the regression (caused by an adaption to root layer
scrolling) described in the bug as well as adding 3 automated
tests that check that spatnav correctly uses the visual viewport.

Bug: 796493

Change-Id: Ie6cd71deaf1d7d7b100792feeaef57ab3fbff903
Reviewed-on: https://chromium-review.googlesource.com/847513Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Commit-Queue: Hugo Holgersson <hugoh@vewd.com>
Cr-Commit-Position: refs/heads/master@{#526655}
parent 57b0df8d
......@@ -12,6 +12,8 @@ crbug.com/417782 fast/loader/scroll-position-restored-on-back-at-load-event.html
crbug.com/417782 fast/loader/scroll-position-restored-on-reload-at-load-event.html [ Failure ]
crbug.com/417782 fast/overflow/overflow-clamp-after-visible-rect-resize.html [ Failure ]
crbug.com/417782 fast/overflow/scrollRevealButton.html [ Failure ]
crbug.com/417782 fast/spatial-navigation/snav-iframe-with-offscreen-focusable-element.html [ Failure ]
crbug.com/417782 fast/spatial-navigation/snav-use-visual-viewport.html [ Failure ]
crbug.com/417782 html/dialog/form-method-dialog.html [ Crash ]
crbug.com/417782 http/tests/devtools/tracing/scroll-invalidations.js [ Failure ]
crbug.com/417782 http/tests/devtools/tracing/timeline-paint/layer-tree.js [ Failure ]
......
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
a {font-size: 200px;}
</style>
<a href="#" id="a">a</a><br>
<a href="#" id="b">b</a><br>
<a href="#" id="c">c</a><br>
<a href="#" id="d">d</a><br>
<a href="#" id="e">e</a><br>
<a href="#" id="f">f</a>
<script>
if (window.testRunner) {
testRunner.overridePreference('WebKitTabToLinksPreferenceKey', 1);
testRunner.overridePreference('WebKitSpatialNavigationEnabled', 1);
testRunner.waitUntilDone();
}
test(() => {
assert_equals(document.activeElement, document.body);
eventSender.keyDown('ArrowDown');
assert_equals(document.activeElement, a);
}, "Spatnav picks the visual viewport's topmost element (a).");
test(() => {
c.scrollIntoView(true);
eventSender.keyDown('ArrowDown');
assert_equals(document.activeElement, c);
}, "Spatnav picks the visual viewport's topmost element (c).");
test(() => {
f.scrollIntoView(false);
eventSender.keyDown('ArrowUp');
assert_equals(document.activeElement, f);
}, "Spatnav picks the visual viewport's bottommost element (f).");
</script>
......@@ -436,11 +436,10 @@ LayoutRect NodeRectInAbsoluteCoordinates(Node* node, bool ignore_border) {
}
LayoutRect FrameRectInAbsoluteCoordinates(LocalFrame* frame) {
ScrollableArea* scrollable_area =
frame->View()->LayoutViewportScrollableArea();
LayoutRect content_rect(scrollable_area->VisibleContentRect());
return LayoutRect(frame->View()->ContentsToRootFrame(LayoutPoint()),
content_rect.Size());
return RectToAbsoluteCoordinates(
frame,
LayoutRect(
frame->View()->LayoutViewportScrollableArea()->VisibleContentRect()));
}
// This method calculates the exitPoint from the startingRect and the entryPoint
......
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