Changeset 72797 in webkit


Ignore:
Timestamp:
Nov 29, 2010 7:40:24 AM (13 years ago)
Author:
yael.aharon@nokia.com
Message:

Spatial Navigation: Store more information in FocusCandidate
https://bugs.webkit.org/show_bug.cgi?id=50153

Reviewed by Antonio Gomes.

More information should be stored in FocusCandidate, to avoid
recalculating it when running the spatial navigation algorithm.

No new tests, since this is code refactoring only.

  • page/FocusController.cpp:

(WebCore::updateFocusCandidateIfNeeded):
(WebCore::FocusController::findFocusCandidateInContainer):
(WebCore::FocusController::advanceFocusDirectionallyInContainer):

  • page/SpatialNavigation.cpp:

(WebCore::FocusCandidate::FocusCandidate):
(WebCore::canBeScrolledIntoView):

  • page/SpatialNavigation.h:

(WebCore::FocusCandidate::FocusCandidate):

Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r72796 r72797  
     12010-11-29  Yael Aharon  <yael.aharon@nokia.com>
     2
     3        Reviewed by Antonio Gomes.
     4
     5        Spatial Navigation: Store more information in FocusCandidate
     6        https://bugs.webkit.org/show_bug.cgi?id=50153
     7
     8        More information should be stored in FocusCandidate, to avoid
     9        recalculating it when running the spatial navigation algorithm.
     10
     11        No new tests, since this is code refactoring only.
     12
     13        * page/FocusController.cpp:
     14        (WebCore::updateFocusCandidateIfNeeded):
     15        (WebCore::FocusController::findFocusCandidateInContainer):
     16        (WebCore::FocusController::advanceFocusDirectionallyInContainer):
     17        * page/SpatialNavigation.cpp:
     18        (WebCore::FocusCandidate::FocusCandidate):
     19        (WebCore::canBeScrolledIntoView):
     20        * page/SpatialNavigation.h:
     21        (WebCore::FocusCandidate::FocusCandidate):
     22
    1232010-11-29  Dimitri Glazkov  <dglazkov@chromium.org>
    224
  • trunk/WebCore/page/FocusController.cpp

    r72596 r72797  
    423423
    424424    // Ignore off screen child nodes of containers that do not scroll (overflow:hidden)
    425     if (hasOffscreenRect(candidate.node) && !canBeScrolledIntoView(direction, candidate))
     425    if (candidate.isOffscreen && !canBeScrolledIntoView(direction, candidate))
    426426        return;
    427427
     
    432432        return;
    433433
    434     if (hasOffscreenRect(candidate.node, direction) && candidate.alignment < Full)
     434    if (candidate.isOffscreenAfterScrolling && candidate.alignment < Full)
    435435        return;
    436436
     
    440440    }
    441441
    442     IntRect intersectionRect = intersection(nodeRectInAbsoluteCoordinates(candidate.node, true), nodeRectInAbsoluteCoordinates(closest.node, true));
     442    IntRect intersectionRect = intersection(candidate.rect, closest.rect);
    443443    if (!intersectionRect.isEmpty()) {
    444444        // If 2 nodes are intersecting, do hit test to find which node in on top.
     
    480480            continue;
    481481
    482         FocusCandidate candidate(node);
     482        FocusCandidate candidate(node, direction);
    483483        candidate.enclosingScrollableBox = container;
    484484        updateFocusCandidateIfNeeded(direction, startingRect, candidate, closest);
     
    516516        ASSERT(frameElement->contentFrame());
    517517
    518         if (hasOffscreenRect(focusCandidate.node, direction)) {
     518        if (focusCandidate.isOffscreenAfterScrolling) {
    519519            scrollInDirection(focusCandidate.node->document(), direction);
    520520            return true;
     
    533533    }
    534534    if (canScrollInDirection(direction, focusCandidate.node)) {
    535         if (hasOffscreenRect(focusCandidate.node, direction)) {
     535        if (focusCandidate.isOffscreenAfterScrolling) {
    536536            scrollInDirection(focusCandidate.node, direction);
    537537            return true;
     
    544544        return advanceFocusDirectionallyInContainer(focusCandidate.node, startingRect, direction, event);
    545545    }
    546     if (hasOffscreenRect(focusCandidate.node, direction)) {
     546    if (focusCandidate.isOffscreenAfterScrolling) {
    547547        Node* container = focusCandidate.enclosingScrollableBox;
    548548        scrollInDirection(container, direction);
  • trunk/WebCore/page/SpatialNavigation.cpp

    r72596 r72797  
    5252
    5353
    54 FocusCandidate::FocusCandidate(Node* n)
     54FocusCandidate::FocusCandidate(Node* n, FocusDirection direction)
    5555    : node(n)
    5656    , enclosingScrollableBox(0)
     
    6060    , parentAlignment(None)
    6161    , rect(nodeRectInAbsoluteCoordinates(n, true /* ignore border */))
     62    , isOffscreen(hasOffscreenRect(n))
     63    , isOffscreenAfterScrolling(hasOffscreenRect(n, direction))
    6264{
    6365}
     
    623625bool canBeScrolledIntoView(FocusDirection direction, const FocusCandidate& candidate)
    624626{
    625     ASSERT(candidate.node && hasOffscreenRect(candidate.node));
     627    ASSERT(candidate.node && candidate.isOffscreen);
    626628    IntRect candidateRect = candidate.rect;
    627629    for (Node* parentNode = candidate.node->parent(); parentNode; parentNode = parentNode->parent()) {
  • trunk/WebCore/page/SpatialNavigation.h

    r72596 r72797  
    106106        , alignment(None)
    107107        , parentAlignment(None)
     108        , isOffscreen(true)
     109        , isOffscreenAfterScrolling(true)
    108110    {
    109111    }
    110112
    111     FocusCandidate(Node* n);
     113    FocusCandidate(Node* n, FocusDirection);
    112114    bool isNull() const { return !node; }
    113115    bool inScrollableContainer() const { return node && enclosingScrollableBox; }
     
    121123    RectsAlignment parentAlignment;
    122124    IntRect rect;
     125    bool isOffscreen;
     126    bool isOffscreenAfterScrolling;
    123127};
    124128
Note: See TracChangeset for help on using the changeset viewer.