Changeset 57304 in webkit


Ignore:
Timestamp:
Apr 8, 2010 4:24:26 PM (14 years ago)
Author:
tonikitoo@webkit.org
Message:

Spatial Navigation: proper handle negative x or y coordinates https://bugs.webkit.org/show_bug.cgi?id=36773

Reviewed by Simon Fraser.
Patch by Antonio Gomes <tonikitoo@webkit.org>

WebCore:

In Spatial Navigation logic, during rect acquisition in renderRectRelativeToRootDocument,
sometimes negative x() or y() values are got, and the current algorithm bails out in
any of such cases.

However, when a node is in a scrollable content (content overflow <div>) and
this scrollable container scrolled up, element gets offscreen, and gets negative values
for y(), for example. In such cases, they are still valid to be used in Spatial Navigation
logic.

Test: fast/events/spatial-navigation/snav-offscreen-content.html

  • page/SpatialNavigation.cpp:

(WebCore::distanceDataForNode):
(WebCore::checkNegativeCoordsForNode):

LayoutTests:

  • fast/events/spatial-navigation/snav-offscreen-content-expected.txt: Added.
  • fast/events/spatial-navigation/snav-offscreen-content.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r57303 r57304  
     12010-03-29  Antonio Gomes  <tonikitoo@webkit.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Spatial Navigation: proper handle negative x or y coordinates
     6        https://bugs.webkit.org/show_bug.cgi?id=36773
     7
     8        * fast/events/spatial-navigation/snav-offscreen-content-expected.txt: Added.
     9        * fast/events/spatial-navigation/snav-offscreen-content.html: Added.
     10
    1112010-04-08  Csaba Osztrogonác  <ossy@webkit.org>
    212
  • trunk/WebCore/ChangeLog

    r57301 r57304  
     12010-03-29  Antonio Gomes  <tonikitoo@webkit.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Spatial Navigation: proper handle negative x or y coordinates
     6        https://bugs.webkit.org/show_bug.cgi?id=36773
     7
     8        In Spatial Navigation logic, during rect acquisition in renderRectRelativeToRootDocument,
     9        sometimes negative x() or y() values are got, and the current algorithm bails out in
     10        any of such cases.
     11
     12        However, when a node is in a scrollable content (content overflow <div>) and
     13        this scrollable container scrolled up, element gets offscreen, and gets negative values
     14        for y(), for example. In such cases, they are still valid to be used in Spatial Navigation
     15        logic.
     16
     17        Test: fast/events/spatial-navigation/snav-offscreen-content.html
     18
     19        * page/SpatialNavigation.cpp:
     20        (WebCore::distanceDataForNode):
     21        (WebCore::checkNegativeCoordsForNode):
     22
    1232010-04-08  Dumitru Daniliuc  <dumi@chromium.org>
    224
  • trunk/WebCore/page/SpatialNavigation.cpp

    r57061 r57304  
    4747static bool isRectInDirection(FocusDirection, const IntRect&, const IntRect&);
    4848static void deflateIfOverlapped(IntRect&, IntRect&);
     49static bool checkNegativeCoordsForNode(Node*, const IntRect&);
    4950
    5051void distanceDataForNode(FocusDirection direction, Node* start, FocusCandidate& candidate)
     
    6970    deflateIfOverlapped(curRect, targetRect);
    7071
     72    // If empty rects or negative width or height, bail out.
    7173    if (curRect.isEmpty() || targetRect.isEmpty()
    72         || targetRect.x() < 0 || targetRect.y() < 0) {
     74     || targetRect.width() <= 0 || targetRect.height() <= 0) {
     75        candidate.distance = maxDistance();
     76        return;
     77    }
     78
     79    // Negative coordinates can be used if node is scrolled up offscreen.
     80    if (!checkNegativeCoordsForNode(start, curRect)) {
     81        candidate.distance = maxDistance();
     82        return;
     83    }
     84
     85    if (!checkNegativeCoordsForNode(candidate.node, targetRect)) {
    7386        candidate.distance = maxDistance();
    7487        return;
     
    487500}
    488501
     502static bool checkNegativeCoordsForNode(Node* node, const IntRect& curRect)
     503{
     504    ASSERT(node || node->renderer());
     505
     506    if (curRect.x() > 0 && curRect.y() > 0)
     507        return true;
     508
     509    bool canBeScrolled = false;
     510
     511    RenderObject* renderer = node->renderer();
     512    for (; renderer; renderer = renderer->parent()) {
     513        if (renderer->isBox() && toRenderBox(renderer)->canBeScrolledAndHasScrollableArea()) {
     514            canBeScrolled = true;
     515            break;
     516        }
     517    }
     518
     519    return canBeScrolled;
     520}
     521
    489522} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.