Changeset 74723 in webkit
- Timestamp:
- Dec 28, 2010 1:57:11 PM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r74722 r74723 1 2010-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 1 31 2010-12-28 Adrienne Walker <enne@google.com> 2 32 -
trunk/WebCore/page/FocusController.cpp
r74170 r74723 418 418 static void updateFocusCandidateIfNeeded(FocusDirection direction, const IntRect& startingRect, FocusCandidate& candidate, FocusCandidate& closest) 419 419 { 420 if (!candidate.visibleNode->isElementNode() || !candidate.visibleNode->renderer())421 return;420 ASSERT(candidate.visibleNode->isElementNode()); 421 ASSERT(candidate.visibleNode->renderer()); 422 422 423 423 // Ignore iframes that don't have a src attribute … … 473 473 474 474 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)) { 476 476 if (node == focusedNode) 477 477 continue; 478 478 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)) 480 483 continue; 481 484 … … 532 535 return true; 533 536 } 534 if (canScrollInDirection(direction, focusCandidate.visibleNode)) { 537 538 if (canScrollInDirection(focusCandidate.visibleNode, direction)) { 535 539 if (focusCandidate.isOffscreenAfterScrolling) { 536 540 scrollInDirection(focusCandidate.visibleNode, direction); … … 579 583 HTMLAreaElement* area = static_cast<HTMLAreaElement*>(focusedNode); 580 584 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direction, area->imageElement()); 581 startingRect = virtualRectForAreaElementAndDirection( direction, area);585 startingRect = virtualRectForAreaElementAndDirection(area, direction); 582 586 } 583 587 } -
trunk/WebCore/page/SpatialNavigation.cpp
r74006 r74723 53 53 static IntRect rectToAbsoluteCoordinates(Frame* initialFrame, const IntRect&); 54 54 static void entryAndExitPointsForDirection(FocusDirection direction, const IntRect& startingRect, const IntRect& potentialRect, IntPoint& exitPoint, IntPoint& entryPoint); 55 static bool isScrollable ContainerNode(const Node*);55 static bool isScrollableNode(const Node*); 56 56 57 57 FocusCandidate::FocusCandidate(Node* node, FocusDirection direction) … … 67 67 { 68 68 ASSERT(node); 69 ASSERT(node->isElementNode()); 70 69 71 if (node->hasTagName(HTMLNames::areaTag)) { 70 72 HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node); … … 74 76 75 77 visibleNode = image; 76 rect = virtualRectForAreaElementAndDirection( direction, area);78 rect = virtualRectForAreaElementAndDirection(area, direction); 77 79 } else { 78 80 if (!node->renderer()) … … 337 339 ASSERT(frame); 338 340 339 if (frame && canScrollInDirection( direction, frame->document())) {341 if (frame && canScrollInDirection(frame->document(), direction)) { 340 342 int dx = 0; 341 343 int dy = 0; … … 373 375 return false; 374 376 375 if (canScrollInDirection( direction, container)) {377 if (canScrollInDirection(container, direction)) { 376 378 int dx = 0; 377 379 int dy = 0; … … 418 420 } 419 421 420 bool isScrollableContainerNode(const Node* node) 421 { 422 bool isScrollableNode(const Node* node) 423 { 424 ASSERT(!node->isDocumentNode()); 425 422 426 if (!node) 423 427 return false; 424 428 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(); 429 431 430 432 return false; … … 440 442 else 441 443 parent = parent->parentNode(); 442 } while (parent && !canScrollInDirection( direction, parent) && !parent->isDocumentNode());444 } while (parent && !canScrollInDirection(parent, direction) && !parent->isDocumentNode()); 443 445 444 446 return parent; 445 447 } 446 448 447 bool canScrollInDirection( FocusDirection direction, const Node* container)449 bool canScrollInDirection(const Node* container, FocusDirection direction) 448 450 { 449 451 ASSERT(container); 450 452 if (container->isDocumentNode()) 451 return canScrollInDirection( direction, static_cast<const Document*>(container)->frame());452 453 if (!isScrollable ContainerNode(container))453 return canScrollInDirection(static_cast<const Document*>(container)->frame(), direction); 454 455 if (!isScrollableNode(container)) 454 456 return false; 455 457 … … 469 471 } 470 472 471 bool canScrollInDirection( FocusDirection direction, const Frame* frame)473 bool canScrollInDirection(const Frame* frame, FocusDirection direction) 472 474 { 473 475 if (!frame->view()) … … 660 662 } 661 663 if (parentNode == candidate.enclosingScrollableBox) 662 return canScrollInDirection( direction, parentNode);664 return canScrollInDirection(parentNode, direction); 663 665 } 664 666 return true; … … 694 696 } 695 697 696 IntRect virtualRectForAreaElementAndDirection( FocusDirection direction, HTMLAreaElement* area)698 IntRect virtualRectForAreaElementAndDirection(HTMLAreaElement* area, FocusDirection direction) 697 699 { 698 700 ASSERT(area); -
trunk/WebCore/page/SpatialNavigation.h
r74006 r74723 139 139 bool scrollInDirection(Frame*, FocusDirection); 140 140 bool scrollInDirection(Node* container, FocusDirection); 141 bool canScrollInDirection( FocusDirection, const Node* container);142 bool canScrollInDirection( FocusDirection, const Frame*);141 bool canScrollInDirection(const Node* container, FocusDirection); 142 bool canScrollInDirection(const Frame*, FocusDirection); 143 143 bool canBeScrolledIntoView(FocusDirection, const FocusCandidate&); 144 144 void distanceDataForNode(FocusDirection, const FocusCandidate& current, FocusCandidate& candidate); … … 147 147 IntRect frameRectInAbsoluteCoordinates(Frame*); 148 148 IntRect virtualRectForDirection(FocusDirection, const IntRect& startingRect, int width = 0); 149 IntRect virtualRectForAreaElementAndDirection( FocusDirection, HTMLAreaElement*);149 IntRect virtualRectForAreaElementAndDirection(HTMLAreaElement*, FocusDirection); 150 150 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate&); 151 151
Note: See TracChangeset
for help on using the changeset viewer.