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

        Reviewed by Daniel Bates.

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

        Avoid calling canScrollInDirection more than necessary.

        No new tests needed.

        * page/FocusController.cpp:
        (WebCore::FocusController::advanceFocusDirectionallyInContainer): Moved the call to canScrollInDirection()
        to within the scrollInDirection().
        * page/SpatialNavigation.cpp: Removed the assertion to canScrollingDirection function.
        (WebCore::scrollInDirection):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74004 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/page/SpatialNavigation.cpp b/WebCore/page/SpatialNavigation.cpp
index 0cd86e0..5d12f72 100644
--- a/WebCore/page/SpatialNavigation.cpp
+++ b/WebCore/page/SpatialNavigation.cpp
@@ -334,7 +334,7 @@
 
 bool scrollInDirection(Frame* frame, FocusDirection direction)
 {
-    ASSERT(frame && canScrollInDirection(direction, frame->document()));
+    ASSERT(frame);
 
     if (frame && canScrollInDirection(direction, frame->document())) {
         int dx = 0;
@@ -365,13 +365,14 @@
 
 bool scrollInDirection(Node* container, FocusDirection direction)
 {
+    ASSERT(container);
     if (container->isDocumentNode())
         return scrollInDirection(static_cast<Document*>(container)->frame(), direction);
 
     if (!container->renderBox())
         return false;
 
-    if (container && canScrollInDirection(direction, container)) {
+    if (canScrollInDirection(direction, container)) {
         int dx = 0;
         int dy = 0;
         switch (direction) {
@@ -397,6 +398,7 @@
         container->renderBox()->enclosingLayer()->scrollByRecursively(dx, dy);
         return true;
     }
+
     return false;
 }