Spatial Navigation: issues with the node selection algorithm.
authorAdemar de Souza Reis Jr <ademar.reis@openbossa.org>
Mon, 22 Nov 2010 15:59:58 +0000 (12:59 -0300)
committerAdemar de Souza Reis Jr <ademar.reis@openbossa.org>
Mon, 22 Nov 2010 15:59:58 +0000 (12:59 -0300)
commita55b9748a5061297fc72984e623f5cb342378bad
treedc117b0d07d3189fa801a6b0fc3274d398a6d3e5
parentfcda7935a66d4fec886503fa666cb37379247cb5
Spatial Navigation: issues with the node selection algorithm.
https://bugs.webkit.org/show_bug.cgi?id=49382

Patch by Yael Aharon  <yael.aharon@nokia.com>, Chang Shu <chang.shu@nokia.com> on 2010-11-22
Reviewed by Antonio Gomes.

WebCore:

Modify the Spatial Navigation algorithm, to better handle initial focus and
navigation between frames.
The new algorithm takes the rect of the focused node as the startingRect,
instead of the node itself. That allows us to construct a virtual rect if
there is no focused node, or if it is off the screen.
The virtual rect is the edge of the container in the direction of the navigation.

With this patch, scrollable containers and frames will scroll regardless of weather
they have focusable content. Users will be able to use arrow keys to view all the
content of such a container. The only exception is if the container has style overflow:hidden.
We will not scroll in that case.

With this patch, we handle z-index and positioning so that if there are 2 overlapping focusable nodes,
we do a hit test and only the node on top can get focus.

hasOffScreenRect() was modified so that it can check if a node will be off-screen even after we scrolled
its parent container. We do not add the scrolling conditions for containers that have overflow:hidden
and cannot scroll.

calculateScrollbarModesForLayout is used to decide if a frame can scroll or not. We cannot rely on
the exsistance of the scrollbar, because it could be removed via the API, while the frame is still
allowed to scroll.

* page/FocusController.cpp:
(WebCore::updateFocusCandidateIfNeeded):
(WebCore::FocusController::findFocusCandidateInContainer):
(WebCore::FocusController::advanceFocusDirectionallyInContainer):
(WebCore::FocusController::advanceFocusDirectionally):
* page/FocusController.h:
* page/FrameView.h:
* page/SpatialNavigation.cpp:
(WebCore::FocusCandidate::FocusCandidate):
(WebCore::distanceDataForNode):
(WebCore::alignmentForRects):
(WebCore::areRectsMoreThanFullScreenApart):
(WebCore::isRectInDirection):
(WebCore::hasOffscreenRect):
(WebCore::scrollInDirection):
(WebCore::isScrollableContainerNode):
(WebCore::scrollableEnclosingBoxOrParentFrameForNodeInDirection):
(WebCore::canScrollInDirection):
(WebCore::rectToAbsoluteCoordinates):
(WebCore::nodeRectInAbsoluteCoordinates):
(WebCore::frameRectInAbsoluteCoordinates):
(WebCore::entryAndExitPointsForDirection):
(WebCore::canBeScrolledIntoView):
(WebCore::virtualRectForDirection):
* page/SpatialNavigation.h:

LayoutTests:

Replaced text in tests with images with fixed size to make them more cross platform and modified
test results to reflect that we can scroll container that do not include focusable content.

* fast/events/spatial-navigation/snav-clipped-overflowed-content-expected.txt:
* fast/events/spatial-navigation/snav-clipped-overflowed-content.html:
* fast/events/spatial-navigation/snav-div-scrollable-but-without-focusable-content-expected.txt:
* fast/events/spatial-navigation/snav-div-scrollable-but-without-focusable-content.html:
* fast/events/spatial-navigation/snav-iframe-no-focusable-content-expected.txt:
* fast/events/spatial-navigation/snav-iframe-no-focusable-content.html:
* fast/events/spatial-navigation/snav-iframe-no-scrollable-content-expected.txt:
* fast/events/spatial-navigation/snav-iframe-no-scrollable-content.html:
* fast/events/spatial-navigation/snav-iframe-with-offscreen-focusable-element-expected.txt:
* fast/events/spatial-navigation/snav-iframe-with-offscreen-focusable-element.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72522 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:

WebCore/page/FrameView.h
17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/spatial-navigation/snav-clipped-overflowed-content-expected.txt
LayoutTests/fast/events/spatial-navigation/snav-clipped-overflowed-content.html
LayoutTests/fast/events/spatial-navigation/snav-div-scrollable-but-without-focusable-content-expected.txt
LayoutTests/fast/events/spatial-navigation/snav-div-scrollable-but-without-focusable-content.html
LayoutTests/fast/events/spatial-navigation/snav-iframe-no-focusable-content-expected.txt
LayoutTests/fast/events/spatial-navigation/snav-iframe-no-focusable-content.html
LayoutTests/fast/events/spatial-navigation/snav-iframe-no-scrollable-content-expected.txt
LayoutTests/fast/events/spatial-navigation/snav-iframe-no-scrollable-content.html
LayoutTests/fast/events/spatial-navigation/snav-iframe-with-offscreen-focusable-element-expected.txt
LayoutTests/fast/events/spatial-navigation/snav-iframe-with-offscreen-focusable-element.html
WebCore/ChangeLog
WebCore/page/FocusController.cpp
WebCore/page/FocusController.h
WebCore/page/FrameView.h
WebCore/page/SpatialNavigation.cpp
WebCore/page/SpatialNavigation.h