Changeset 74723 in webkit


Ignore:
Timestamp:
Dec 28, 2010 1:57:11 PM (13 years ago)
Author:
tonikitoo@webkit.org
Message:

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

Reviewed by Daniel Bates.

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

No new tests needed.

  • page/FocusController.cpp: (WebCore::updatFocusCandidateIfNeeded): Assert renderer() and isElementNode() now that we are bailing out earlier in both the FocusCandidate constructor and FocusController::findFocusCandidateInContainer().
  • page/SpatialNavigation.h: Swapped the parameters order in canScrollInDirection and virtualRectForAreaElementAndDirection functions. (WebCore::FocusController::findFocusCandidateInContainer): (WebCore::FocusController::advanceFocusDirectionallyInContainer): Adjusted call sites of canScrollInDirection(), and added an early return if !isElementNode(). (WebCore::FocusController::advanceFocusDirectionally): Adjusted call site of virtualRectForAreaElementAndDirection().
  • page/SpatialNavigation.cpp: (WebCore::FocusCandidate::FocusCandidate): Assert if node is not an Element node. (WebCore::isScrollableNode): Renamed from isScrollableContainerNode. (WebCore::scrollInDirection): Adjusted call site after function name change; (WebCore::scrollableEnclosingBoxOrParentFrameForNodeInDi:rection): Assert if node is a Document node. (WebCore::canScrollInDirection): Signature changed. (WebCore::canBeScrolledIntoView): Ditto. (WebCore::virtualRectForAreaElementAndDirection): Ditto.
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r74722 r74723  
     12010-12-20  Antonio Gomes  <agomes@rim.com>
     2
     3        Reviewed by Daniel Bates.
     4
     5        Spatial Navigation: code clean up (Part VI)
     6        https://bugs.webkit.org/show_bug.cgi?id=50666
     7
     8        No new tests needed.
     9
     10        * page/FocusController.cpp:
     11        (WebCore::updatFocusCandidateIfNeeded): Assert renderer() and
     12        isElementNode() now that we are bailing out earlier in both the
     13        FocusCandidate constructor and FocusController::findFocusCandidateInContainer().
     14        * page/SpatialNavigation.h: Swapped the parameters order in canScrollInDirection
     15        and virtualRectForAreaElementAndDirection functions.
     16        (WebCore::FocusController::findFocusCandidateInContainer):
     17        (WebCore::FocusController::advanceFocusDirectionallyInContainer): Adjusted callsites
     18        of canScrollInDirection(), and added an early return if !isElementNode().
     19        (WebCore::FocusController::advanceFocusDirectionally): Adjusted callsite of
     20        virtualRectForAreaElementAndDirection();
     21        * page/SpatialNavigation.cpp:
     22        (WebCore::FocusCandidate::FocusCandidate): Assert if node is not a element node;
     23        (WebCore::isScrollableNode): Renamed from isScrollableContainerNode;
     24        (WebCore::scrollInDirection): Adjusted callsite after function name change;
     25        (WebCore::scrollableEnclosingBoxOrParentFrameForNodeInDi:rection): Assert if node is
     26        a documentNode.
     27        (WebCore::canScrollInDirection): Signature changed.
     28        (WebCore::canBeScrolledIntoView): Ditto.
     29        (WebCore::virtualRectForAreaElementAndDirection): Ditto.
     30
    1312010-12-28  Adrienne Walker  <enne@google.com>
    232
  • trunk/WebCore/page/FocusController.cpp

    r74170 r74723  
    418418static void updateFocusCandidateIfNeeded(FocusDirection direction, const IntRect& startingRect, FocusCandidate& candidate, FocusCandidate& closest)
    419419{
    420     if (!candidate.visibleNode->isElementNode() || !candidate.visibleNode->renderer())
    421         return;
     420    ASSERT(candidate.visibleNode->isElementNode());
     421    ASSERT(candidate.visibleNode->renderer());
    422422
    423423    // Ignore iframes that don't have a src attribute
     
    473473
    474474    Node* node = container->firstChild();
    475     for (; node; node = (node->isFrameOwnerElement() || canScrollInDirection(direction, node)) ? node->traverseNextSibling(container) : node->traverseNextNode(container)) {
     475    for (; node; node = (node->isFrameOwnerElement() || canScrollInDirection(node, direction)) ? node->traverseNextSibling(container) : node->traverseNextNode(container)) {
    476476        if (node == focusedNode)
    477477            continue;
    478478
    479         if (!node->isKeyboardFocusable(event) && !node->isFrameOwnerElement() && !canScrollInDirection(direction, node))
     479        if (!node->isElementNode())
     480            continue;
     481
     482        if (!node->isKeyboardFocusable(event) && !node->isFrameOwnerElement() && !canScrollInDirection(node, direction))
    480483            continue;
    481484
     
    532535        return true;
    533536    }
    534     if (canScrollInDirection(direction, focusCandidate.visibleNode)) {
     537
     538    if (canScrollInDirection(focusCandidate.visibleNode, direction)) {
    535539        if (focusCandidate.isOffscreenAfterScrolling) {
    536540            scrollInDirection(focusCandidate.visibleNode, direction);
     
    579583            HTMLAreaElement* area = static_cast<HTMLAreaElement*>(focusedNode);
    580584            container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direction, area->imageElement());
    581             startingRect = virtualRectForAreaElementAndDirection(direction, area);
     585            startingRect = virtualRectForAreaElementAndDirection(area, direction);
    582586        }
    583587    }
  • trunk/WebCore/page/SpatialNavigation.cpp

    r74006 r74723  
    5353static IntRect rectToAbsoluteCoordinates(Frame* initialFrame, const IntRect&);
    5454static void entryAndExitPointsForDirection(FocusDirection direction, const IntRect& startingRect, const IntRect& potentialRect, IntPoint& exitPoint, IntPoint& entryPoint);
    55 static bool isScrollableContainerNode(const Node*);
     55static bool isScrollableNode(const Node*);
    5656
    5757FocusCandidate::FocusCandidate(Node* node, FocusDirection direction)
     
    6767{
    6868    ASSERT(node);
     69    ASSERT(node->isElementNode());
     70
    6971    if (node->hasTagName(HTMLNames::areaTag)) {
    7072        HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node);
     
    7476
    7577        visibleNode = image;
    76         rect = virtualRectForAreaElementAndDirection(direction, area);
     78        rect = virtualRectForAreaElementAndDirection(area, direction);
    7779    } else {
    7880        if (!node->renderer())
     
    337339    ASSERT(frame);
    338340
    339     if (frame && canScrollInDirection(direction, frame->document())) {
     341    if (frame && canScrollInDirection(frame->document(), direction)) {
    340342        int dx = 0;
    341343        int dy = 0;
     
    373375        return false;
    374376
    375     if (canScrollInDirection(direction, container)) {
     377    if (canScrollInDirection(container, direction)) {
    376378        int dx = 0;
    377379        int dy = 0;
     
    418420}
    419421
    420 bool isScrollableContainerNode(const Node* node)
    421 {
     422bool isScrollableNode(const Node* node)
     423{
     424    ASSERT(!node->isDocumentNode());
     425
    422426    if (!node)
    423427        return false;
    424428
    425     if (RenderObject* renderer = node->renderer()) {
    426         return (renderer->isBox() && toRenderBox(renderer)->canBeScrolledAndHasScrollableArea()
    427              && node->hasChildNodes() && !node->isDocumentNode());
    428     }
     429    if (RenderObject* renderer = node->renderer())
     430        return renderer->isBox() && toRenderBox(renderer)->canBeScrolledAndHasScrollableArea() && node->hasChildNodes();
    429431
    430432    return false;
     
    440442        else
    441443            parent = parent->parentNode();
    442     } while (parent && !canScrollInDirection(direction, parent) && !parent->isDocumentNode());
     444    } while (parent && !canScrollInDirection(parent, direction) && !parent->isDocumentNode());
    443445
    444446    return parent;
    445447}
    446448
    447 bool canScrollInDirection(FocusDirection direction, const Node* container)
     449bool canScrollInDirection(const Node* container, FocusDirection direction)
    448450{
    449451    ASSERT(container);
    450452    if (container->isDocumentNode())
    451         return canScrollInDirection(direction, static_cast<const Document*>(container)->frame());
    452 
    453     if (!isScrollableContainerNode(container))
     453        return canScrollInDirection(static_cast<const Document*>(container)->frame(), direction);
     454
     455    if (!isScrollableNode(container))
    454456        return false;
    455457
     
    469471}
    470472
    471 bool canScrollInDirection(FocusDirection direction, const Frame* frame)
     473bool canScrollInDirection(const Frame* frame, FocusDirection direction)
    472474{
    473475    if (!frame->view())
     
    660662        }
    661663        if (parentNode == candidate.enclosingScrollableBox)
    662             return canScrollInDirection(direction, parentNode);
     664            return canScrollInDirection(parentNode, direction);
    663665    }
    664666    return true;
     
    694696}
    695697
    696 IntRect virtualRectForAreaElementAndDirection(FocusDirection direction, HTMLAreaElement* area)
     698IntRect virtualRectForAreaElementAndDirection(HTMLAreaElement* area, FocusDirection direction)
    697699{
    698700    ASSERT(area);
  • trunk/WebCore/page/SpatialNavigation.h

    r74006 r74723  
    139139bool scrollInDirection(Frame*, FocusDirection);
    140140bool scrollInDirection(Node* container, FocusDirection);
    141 bool canScrollInDirection(FocusDirection, const Node* container);
    142 bool canScrollInDirection(FocusDirection, const Frame*);
     141bool canScrollInDirection(const Node* container, FocusDirection);
     142bool canScrollInDirection(const Frame*, FocusDirection);
    143143bool canBeScrolledIntoView(FocusDirection, const FocusCandidate&);
    144144void distanceDataForNode(FocusDirection, const FocusCandidate& current, FocusCandidate& candidate);
     
    147147IntRect frameRectInAbsoluteCoordinates(Frame*);
    148148IntRect virtualRectForDirection(FocusDirection, const IntRect& startingRect, int width = 0);
    149 IntRect virtualRectForAreaElementAndDirection(FocusDirection, HTMLAreaElement*);
     149IntRect virtualRectForAreaElementAndDirection(HTMLAreaElement*, FocusDirection);
    150150HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate&);
    151151
Note: See TracChangeset for help on using the changeset viewer.