Commit 5165b8fb authored by Stefan Zager's avatar Stefan Zager Committed by Commit Bot

[RootLayerScrolls] Fix spatial navigation

Add some calls to LayoutViewportScrollableArea and replace some
faulty custom geometry logic with calls into LocalFrameView.

BUG=711468
R=skobes@chromium.org,bokan@chromium.org

Change-Id: Id937278809ed59710a76722d6219b98f539d6e06
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_root_layer_scrolls
Reviewed-on: https://chromium-review.googlesource.com/822159Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523634}
parent 142124b8
...@@ -12,10 +12,6 @@ crbug.com/417782 fast/loader/scroll-position-restored-on-back-at-load-event.html ...@@ -12,10 +12,6 @@ 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/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/overflow-clamp-after-visible-rect-resize.html [ Failure ]
crbug.com/417782 fast/overflow/scrollRevealButton.html [ Failure ] crbug.com/417782 fast/overflow/scrollRevealButton.html [ Failure ]
crbug.com/417782 [ Linux Mac ] fast/spatial-navigation/snav-iframe-no-focusable-content.html [ Failure ]
crbug.com/417782 [ Linux Mac ] fast/spatial-navigation/snav-iframe-with-offscreen-focusable-element.html [ Failure ]
crbug.com/417782 [ Linux Mac ] fast/spatial-navigation/snav-media-elements.html [ Failure ]
crbug.com/417782 [ Linux ] fast/spatial-navigation/snav-unit-overflow-and-scroll-in-direction.html [ Failure ]
crbug.com/417782 html/dialog/form-method-dialog.html [ Crash ] 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/scroll-invalidations.js [ Failure ]
crbug.com/417782 http/tests/devtools/tracing/timeline-paint/layer-tree.js [ Failure ] crbug.com/417782 http/tests/devtools/tracing/timeline-paint/layer-tree.js [ Failure ]
......
...@@ -154,7 +154,8 @@ bool HasOffscreenRect(Node* node, WebFocusType type) { ...@@ -154,7 +154,8 @@ bool HasOffscreenRect(Node* node, WebFocusType type) {
DCHECK(!frame_view->NeedsLayout()); DCHECK(!frame_view->NeedsLayout());
LayoutRect container_viewport_rect(frame_view->VisibleContentRect()); LayoutRect container_viewport_rect(
frame_view->LayoutViewportScrollableArea()->VisibleContentRect());
// We want to select a node if it is currently off screen, but will be // We want to select a node if it is currently off screen, but will be
// exposed after we scroll. Adjust the viewport to post-scrolling position. // exposed after we scroll. Adjust the viewport to post-scrolling position.
// If the container has overflow:hidden, we cannot scroll, so we do not pass // If the container has overflow:hidden, we cannot scroll, so we do not pass
...@@ -223,7 +224,8 @@ bool ScrollInDirection(LocalFrame* frame, WebFocusType type) { ...@@ -223,7 +224,8 @@ bool ScrollInDirection(LocalFrame* frame, WebFocusType type) {
return false; return false;
} }
frame->View()->ScrollBy(ScrollOffset(dx, dy), kUserScroll); frame->View()->LayoutViewportScrollableArea()->ScrollBy(
ScrollOffset(dx, dy), kUserScroll);
return true; return true;
} }
return false; return false;
...@@ -380,9 +382,11 @@ bool CanScrollInDirection(const LocalFrame* frame, WebFocusType type) { ...@@ -380,9 +382,11 @@ bool CanScrollInDirection(const LocalFrame* frame, WebFocusType type) {
if ((type == kWebFocusTypeUp || type == kWebFocusTypeDown) && if ((type == kWebFocusTypeUp || type == kWebFocusTypeDown) &&
kScrollbarAlwaysOff == vertical_mode) kScrollbarAlwaysOff == vertical_mode)
return false; return false;
LayoutSize size(frame->View()->ContentsSize()); ScrollableArea* scrollable_area =
LayoutSize offset(frame->View()->ScrollOffsetInt()); frame->View()->LayoutViewportScrollableArea();
LayoutRect rect(frame->View()->VisibleContentRect(kIncludeScrollbars)); LayoutSize size(scrollable_area->ContentsSize());
LayoutSize offset(scrollable_area->ScrollOffsetInt());
LayoutRect rect(scrollable_area->VisibleContentRect(kIncludeScrollbars));
switch (type) { switch (type) {
case kWebFocusTypeLeft: case kWebFocusTypeLeft:
...@@ -401,22 +405,9 @@ bool CanScrollInDirection(const LocalFrame* frame, WebFocusType type) { ...@@ -401,22 +405,9 @@ bool CanScrollInDirection(const LocalFrame* frame, WebFocusType type) {
static LayoutRect RectToAbsoluteCoordinates(LocalFrame* initial_frame, static LayoutRect RectToAbsoluteCoordinates(LocalFrame* initial_frame,
const LayoutRect& initial_rect) { const LayoutRect& initial_rect) {
LayoutRect rect = initial_rect; return LayoutRect(
for (Frame* frame = initial_frame; frame; frame = frame->Tree().Parent()) { initial_frame->View()->ContentsToRootFrame(initial_rect.Location()),
if (!frame->IsLocalFrame()) initial_rect.Size());
continue;
// FIXME: Spatial navigation is broken for OOPI.
Element* element = frame->DeprecatedLocalOwner();
if (element) {
do {
rect.Move(element->OffsetLeft(), element->OffsetTop());
LayoutObject* layout_object = element->GetLayoutObject();
element = layout_object ? layout_object->OffsetParent() : nullptr;
} while (element);
rect.Move((-ToLocalFrame(frame)->View()->ScrollOffsetInt()));
}
}
return rect;
} }
LayoutRect NodeRectInAbsoluteCoordinates(Node* node, bool ignore_border) { LayoutRect NodeRectInAbsoluteCoordinates(Node* node, bool ignore_border) {
...@@ -445,8 +436,11 @@ LayoutRect NodeRectInAbsoluteCoordinates(Node* node, bool ignore_border) { ...@@ -445,8 +436,11 @@ LayoutRect NodeRectInAbsoluteCoordinates(Node* node, bool ignore_border) {
} }
LayoutRect FrameRectInAbsoluteCoordinates(LocalFrame* frame) { LayoutRect FrameRectInAbsoluteCoordinates(LocalFrame* frame) {
return RectToAbsoluteCoordinates( ScrollableArea* scrollable_area =
frame, LayoutRect(frame->View()->VisibleContentRect())); frame->View()->LayoutViewportScrollableArea();
LayoutRect content_rect(scrollable_area->VisibleContentRect());
return LayoutRect(frame->View()->ContentsToRootFrame(LayoutPoint()),
content_rect.Size());
} }
// This method calculates the exitPoint from the startingRect and the entryPoint // 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