Changeset 73627 in webkit


Ignore:
Timestamp:
Dec 9, 2010 10:53:47 AM (13 years ago)
Author:
tonikitoo@webkit.org
Message:

2010-12-07 Antonio Gomes <agomes@rim.com>

Reviewed by Daniel Bates.

Spatial Navigation: code clean up
https://bugs.webkit.org/show_bug.cgi?id=50666

Patch unifies two FocusCandidate constructors, making caller sites
simpler. Now the special handling HTMLAreaElement gets is done within
the non default constructor (i.e. FocusCanditate(Node*, FocusDirection)).

No new tests needed.

  • page/FocusController.cpp: (WebCore::FocusController::findFocusCandidateInContainer):
  • page/SpatialNavigation.cpp: (WebCore::FocusCandidate::FocusCandidate):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r73626 r73627  
     12010-12-07  Antonio Gomes  <agomes@rim.com>
     2
     3        Reviewed by Daniel Bates.
     4
     5        Spatial Navigation: code clean up
     6        https://bugs.webkit.org/show_bug.cgi?id=50666
     7
     8        Patch unifies two FocusCandidate constructors, making caller sites
     9        simpler. Now the special handling HTMLAreaElement gets is done within
     10        the non default constructor (i.e. FocusCanditate(Node*, FocusDirection)).
     11
     12        No new tests needed.
     13
     14        * page/FocusController.cpp:
     15        (WebCore::FocusController::findFocusCandidateInContainer):
     16        * page/SpatialNavigation.cpp:
     17        (WebCore::FocusCandidate::FocusCandidate):
     18
    1192010-12-09  Philippe Normand  <pnormand@igalia.com>
    220
  • trunk/WebCore/page/FocusController.cpp

    r73452 r73627  
    479479            continue;
    480480
    481         if (node->hasTagName(areaTag)) {
    482             HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node);
    483             FocusCandidate candidate(area, direction);
    484             if (candidate.isNull())
    485                 continue;
    486 
    487             candidate.enclosingScrollableBox = container;
    488             updateFocusCandidateIfNeeded(direction, startingRect, candidate, closest);
     481        FocusCandidate candidate = FocusCandidate(node, direction);
     482        if (candidate.isNull())
    489483            continue;
    490         }
    491 
    492         if (!node->renderer())
    493             continue;
    494 
    495         FocusCandidate candidate(node, direction);
     484
    496485        candidate.enclosingScrollableBox = container;
    497486        updateFocusCandidateIfNeeded(direction, startingRect, candidate, closest);
  • trunk/WebCore/page/SpatialNavigation.cpp

    r73452 r73627  
    3737#include "HTMLImageElement.h"
    3838#include "HTMLMapElement.h"
     39#include "HTMLNames.h"
    3940#include "IntRect.h"
    4041#include "Node.h"
     
    5657
    5758FocusCandidate::FocusCandidate(Node* n, FocusDirection direction)
    58     : visibleNode(n)
    59     , focusableNode(n)
    60     , enclosingScrollableBox(0)
    61     , distance(maxDistance())
    62     , parentDistance(maxDistance())
    63     , alignment(None)
    64     , parentAlignment(None)
    65     , rect(nodeRectInAbsoluteCoordinates(n, true /* ignore border */))
    66     , isOffscreen(hasOffscreenRect(n))
    67     , isOffscreenAfterScrolling(hasOffscreenRect(n, direction))
    68 {
    69 }
    70 
    71 FocusCandidate::FocusCandidate(HTMLAreaElement* area, FocusDirection direction)
    7259    : visibleNode(0)
    7360    , focusableNode(0)
     
    8067    , isOffscreenAfterScrolling(true)
    8168{
    82     HTMLImageElement* image = area->imageElement();
    83     if (!image)
    84         return;
    85 
    86     focusableNode = area;
    87     visibleNode = image;
    88     rect = virtualRectForAreaElementAndDirection(direction, area);
    89     isOffscreen = hasOffscreenRect(image);
    90     isOffscreenAfterScrolling = hasOffscreenRect(image, direction);
     69    if (n->hasTagName(HTMLNames::areaTag)) {
     70        HTMLAreaElement* area = static_cast<HTMLAreaElement*>(n);
     71        HTMLImageElement* image = area->imageElement();
     72        if (!image || !image->renderer())
     73            return;
     74
     75        visibleNode = image;
     76        rect = virtualRectForAreaElementAndDirection(direction, area);
     77    } else {
     78        if (!n->renderer())
     79            return;
     80
     81        visibleNode = n;
     82        rect = nodeRectInAbsoluteCoordinates(n, true /* ignore border */);
     83    }
     84
     85    focusableNode = n;
     86    isOffscreen = hasOffscreenRect(visibleNode);
     87    isOffscreenAfterScrolling = hasOffscreenRect(visibleNode, direction);
    9188}
    9289
Note: See TracChangeset for help on using the changeset viewer.