Commit 237c1ea4 authored by tonikitoo@webkit.org's avatar tonikitoo@webkit.org

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

        Reviewed by Daniel Bates.

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

        No new tests needed.

        * page/FocusController.cpp: Removed static declaration of updateFocusCandidateIfNeeded() from
        the top of FocusController.cpp, and added the 'static' keyword where the function is implemented;
        * page/SpatialNavigation.cpp: In FocusCandidate constructor, renamed 'n' to 'node', and added an assert to it;
        (WebCore::FocusCandidate::FocusCandidate):
        (WebCore::virtualRectForAreaElementAndDirection): Added an assert to 'node';
        * page/SpatialNavigation.h:I reordered the declaration of some methods in order to group related ones;
        Removed isScrollableContainerNode() function declaration since it is not used outside SpatialNavigation.cpp;
        And removed the declaration of isNodeDeepDescendantOfDocument() since it does not exist anymore.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b0a37b0b
2010-12-09 Antonio Gomes <agomes@rim.com>
Reviewed by Daniel Bates.
Spatial Navigation: code clean up (part II)
https://bugs.webkit.org/show_bug.cgi?id=50666
No new tests needed.
* page/FocusController.cpp: Removed static declaration of updateFocusCandidateIfNeeded() from
the top of FocusController.cpp, and added the 'static' keyword where the function is implemented;
* page/SpatialNavigation.cpp: In FocusCandidate constructor, renamed 'n' to 'node', and added an assert to it;
(WebCore::FocusCandidate::FocusCandidate):
(WebCore::virtualRectForAreaElementAndDirection): Added an assert to 'node';
* page/SpatialNavigation.h:I reordered the declaration of some methods in order to group related ones;
Removed isScrollableContainerNode() function declaration since it is not used outside SpatialNavigation.cpp;
And removed the declaration of isNodeDeepDescendantOfDocument() since it does not exist anymore.
2010-12-12 Philippe Normand <pnormand@igalia.com>
Reviewed by Xan Lopez.
......
......@@ -61,7 +61,6 @@ namespace WebCore {
using namespace HTMLNames;
using namespace std;
static void updateFocusCandidateIfNeeded(FocusDirection direction, const IntRect& startingRect, FocusCandidate& candidate, FocusCandidate& closest);
static inline void dispatchEventsOnWindowAndFocusedNode(Document* document, bool focused)
{
// If we have a focused node we should dispatch blur on it before we blur the window.
......@@ -414,7 +413,7 @@ void FocusController::setActive(bool active)
dispatchEventsOnWindowAndFocusedNode(m_focusedFrame->document(), active);
}
void updateFocusCandidateIfNeeded(FocusDirection direction, const IntRect& startingRect, FocusCandidate& candidate, FocusCandidate& closest)
static void updateFocusCandidateIfNeeded(FocusDirection direction, const IntRect& startingRect, FocusCandidate& candidate, FocusCandidate& closest)
{
if (!candidate.visibleNode->isElementNode() || !candidate.visibleNode->renderer())
return;
......
......@@ -51,11 +51,11 @@ static bool areRectsPartiallyAligned(FocusDirection, const IntRect&, const IntRe
static bool areRectsMoreThanFullScreenApart(FocusDirection direction, const IntRect& curRect, const IntRect& targetRect, const IntSize& viewSize);
static bool isRectInDirection(FocusDirection, const IntRect&, const IntRect&);
static void deflateIfOverlapped(IntRect&, IntRect&);
static IntRect rectToAbsoluteCoordinates(Frame* initialFrame, const IntRect& rect);
static IntRect rectToAbsoluteCoordinates(Frame* initialFrame, const IntRect&);
static void entryAndExitPointsForDirection(FocusDirection direction, const IntRect& startingRect, const IntRect& potentialRect, IntPoint& exitPoint, IntPoint& entryPoint);
static bool isScrollableContainerNode(const Node*);
FocusCandidate::FocusCandidate(Node* n, FocusDirection direction)
FocusCandidate::FocusCandidate(Node* node, FocusDirection direction)
: visibleNode(0)
, focusableNode(0)
, enclosingScrollableBox(0)
......@@ -66,8 +66,9 @@ FocusCandidate::FocusCandidate(Node* n, FocusDirection direction)
, isOffscreen(true)
, isOffscreenAfterScrolling(true)
{
if (n->hasTagName(HTMLNames::areaTag)) {
HTMLAreaElement* area = static_cast<HTMLAreaElement*>(n);
ASSERT(node);
if (node->hasTagName(HTMLNames::areaTag)) {
HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node);
HTMLImageElement* image = area->imageElement();
if (!image || !image->renderer())
return;
......@@ -75,14 +76,14 @@ FocusCandidate::FocusCandidate(Node* n, FocusDirection direction)
visibleNode = image;
rect = virtualRectForAreaElementAndDirection(direction, area);
} else {
if (!n->renderer())
if (!node->renderer())
return;
visibleNode = n;
rect = nodeRectInAbsoluteCoordinates(n, true /* ignore border */);
visibleNode = node;
rect = nodeRectInAbsoluteCoordinates(node, true /* ignore border */);
}
focusableNode = n;
focusableNode = node;
isOffscreen = hasOffscreenRect(visibleNode);
isOffscreenAfterScrolling = hasOffscreenRect(visibleNode, direction);
}
......@@ -693,6 +694,8 @@ IntRect virtualRectForDirection(FocusDirection direction, const IntRect& startin
IntRect virtualRectForAreaElementAndDirection(FocusDirection direction, HTMLAreaElement* area)
{
ASSERT(area);
ASSERT(area->imageElement());
// Area elements tend to overlap more than other focusable elements. We flatten the rect of the area elements
// to minimize the effect of overlapping areas.
IntRect rect = virtualRectForDirection(direction, rectToAbsoluteCoordinates(area->document()->frame(), area->getRect(area->imageElement()->renderer())), 1);
......
......@@ -133,18 +133,16 @@ struct FocusCandidate {
bool isOffscreenAfterScrolling;
};
bool hasOffscreenRect(Node*, FocusDirection direction = FocusDirectionNone);
bool scrollInDirection(Frame*, FocusDirection);
bool scrollInDirection(Node* container, FocusDirection);
bool hasOffscreenRect(Node*, FocusDirection direction = FocusDirectionNone);
bool isScrollableContainerNode(const Node*);
bool isNodeDeepDescendantOfDocument(Node*, Document*);
Node* scrollableEnclosingBoxOrParentFrameForNodeInDirection(FocusDirection, Node* node);
bool canScrollInDirection(FocusDirection, const Node* container);
bool canScrollInDirection(FocusDirection, const Frame*);
bool canBeScrolledIntoView(FocusDirection, const FocusCandidate&);
void distanceDataForNode(FocusDirection, FocusCandidate& current, FocusCandidate& candidate);
Node* scrollableEnclosingBoxOrParentFrameForNodeInDirection(FocusDirection, Node*);
IntRect nodeRectInAbsoluteCoordinates(Node*, bool ignoreBorder = false);
IntRect frameRectInAbsoluteCoordinates(Frame*);
void distanceDataForNode(FocusDirection, FocusCandidate& current, FocusCandidate& candidate);
bool canBeScrolledIntoView(FocusDirection, const FocusCandidate&);
IntRect virtualRectForDirection(FocusDirection, const IntRect& startingRect, int width = 0);
IntRect virtualRectForAreaElementAndDirection(FocusDirection, HTMLAreaElement*);
} // namspace WebCore
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment