| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nuanti Ltd. | 3 * Copyright (C) 2008 Nuanti Ltd. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 Node* FocusController::findFocusableNode(FocusDirection direction, FocusNavigati
onScope scope, Node* node) | 461 Node* FocusController::findFocusableNode(FocusDirection direction, FocusNavigati
onScope scope, Node* node) |
| 462 { | 462 { |
| 463 return (direction == FocusDirectionForward) | 463 return (direction == FocusDirectionForward) |
| 464 ? nextFocusableNode(scope, node) | 464 ? nextFocusableNode(scope, node) |
| 465 : previousFocusableNode(scope, node); | 465 : previousFocusableNode(scope, node); |
| 466 } | 466 } |
| 467 | 467 |
| 468 Node* FocusController::findNodeWithExactTabIndex(Node* start, int tabIndex, Focu
sDirection direction) | 468 Node* FocusController::findNodeWithExactTabIndex(Node* start, int tabIndex, Focu
sDirection direction) |
| 469 { | 469 { |
| 470 // Search is inclusive of start | 470 // Search is inclusive of start |
| 471 for (Node* node = start; node; node = direction == FocusDirectionForward ? N
odeTraversal::next(node) : NodeTraversal::previous(node)) { | 471 for (Node* node = start; node; node = direction == FocusDirectionForward ? N
odeTraversal::next(*node) : NodeTraversal::previous(node)) { |
| 472 if (shouldVisit(node) && adjustedTabIndex(node) == tabIndex) | 472 if (shouldVisit(node) && adjustedTabIndex(node) == tabIndex) |
| 473 return node; | 473 return node; |
| 474 } | 474 } |
| 475 return 0; | 475 return 0; |
| 476 } | 476 } |
| 477 | 477 |
| 478 static Node* nextNodeWithGreaterTabIndex(Node* start, int tabIndex) | 478 static Node* nextNodeWithGreaterTabIndex(Node* start, int tabIndex) |
| 479 { | 479 { |
| 480 // Search is inclusive of start | 480 // Search is inclusive of start |
| 481 int winningTabIndex = std::numeric_limits<short>::max() + 1; | 481 int winningTabIndex = std::numeric_limits<short>::max() + 1; |
| 482 Node* winner = 0; | 482 Node* winner = 0; |
| 483 for (Node* node = start; node; node = NodeTraversal::next(node)) { | 483 for (Node* node = start; node; node = NodeTraversal::next(*node)) { |
| 484 if (shouldVisit(node) && node->tabIndex() > tabIndex && node->tabIndex()
< winningTabIndex) { | 484 if (shouldVisit(node) && node->tabIndex() > tabIndex && node->tabIndex()
< winningTabIndex) { |
| 485 winner = node; | 485 winner = node; |
| 486 winningTabIndex = node->tabIndex(); | 486 winningTabIndex = node->tabIndex(); |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 | 489 |
| 490 return winner; | 490 return winner; |
| 491 } | 491 } |
| 492 | 492 |
| 493 static Node* previousNodeWithLowerTabIndex(Node* start, int tabIndex) | 493 static Node* previousNodeWithLowerTabIndex(Node* start, int tabIndex) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 504 } | 504 } |
| 505 return winner; | 505 return winner; |
| 506 } | 506 } |
| 507 | 507 |
| 508 Node* FocusController::nextFocusableNode(FocusNavigationScope scope, Node* start
) | 508 Node* FocusController::nextFocusableNode(FocusNavigationScope scope, Node* start
) |
| 509 { | 509 { |
| 510 if (start) { | 510 if (start) { |
| 511 int tabIndex = adjustedTabIndex(start); | 511 int tabIndex = adjustedTabIndex(start); |
| 512 // If a node is excluded from the normal tabbing cycle, the next focusab
le node is determined by tree order | 512 // If a node is excluded from the normal tabbing cycle, the next focusab
le node is determined by tree order |
| 513 if (tabIndex < 0) { | 513 if (tabIndex < 0) { |
| 514 for (Node* node = NodeTraversal::next(start); node; node = NodeTrave
rsal::next(node)) { | 514 for (Node* node = NodeTraversal::next(*start); node; node = NodeTrav
ersal::next(*node)) { |
| 515 if (shouldVisit(node) && adjustedTabIndex(node) >= 0) | 515 if (shouldVisit(node) && adjustedTabIndex(node) >= 0) |
| 516 return node; | 516 return node; |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 | 519 |
| 520 // First try to find a node with the same tabindex as start that comes a
fter start in the scope. | 520 // First try to find a node with the same tabindex as start that comes a
fter start in the scope. |
| 521 if (Node* winner = findNodeWithExactTabIndex(NodeTraversal::next(start),
tabIndex, FocusDirectionForward)) | 521 if (Node* winner = findNodeWithExactTabIndex(NodeTraversal::next(*start)
, tabIndex, FocusDirectionForward)) |
| 522 return winner; | 522 return winner; |
| 523 | 523 |
| 524 if (!tabIndex) | 524 if (!tabIndex) |
| 525 // We've reached the last node in the document with a tabindex of 0.
This is the end of the tabbing order. | 525 // We've reached the last node in the document with a tabindex of 0.
This is the end of the tabbing order. |
| 526 return 0; | 526 return 0; |
| 527 } | 527 } |
| 528 | 528 |
| 529 // Look for the first node in the scope that: | 529 // Look for the first node in the scope that: |
| 530 // 1) has the lowest tabindex that is higher than start's tabindex (or 0, if
start is null), and | 530 // 1) has the lowest tabindex that is higher than start's tabindex (or 0, if
start is null), and |
| 531 // 2) comes first in the scope, if there's a tie. | 531 // 2) comes first in the scope, if there's a tie. |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 Element* focusedElement = (focusedFrame() && focusedFrame()->document()) ? f
ocusedFrame()->document()->focusedElement() : 0; | 773 Element* focusedElement = (focusedFrame() && focusedFrame()->document()) ? f
ocusedFrame()->document()->focusedElement() : 0; |
| 774 | 774 |
| 775 Element* element = ElementTraversal::firstWithin(container); | 775 Element* element = ElementTraversal::firstWithin(container); |
| 776 FocusCandidate current; | 776 FocusCandidate current; |
| 777 current.rect = startingRect; | 777 current.rect = startingRect; |
| 778 current.focusableNode = focusedElement; | 778 current.focusableNode = focusedElement; |
| 779 current.visibleNode = focusedElement; | 779 current.visibleNode = focusedElement; |
| 780 | 780 |
| 781 for (; element; element = (element->isFrameOwnerElement() || canScrollInDire
ction(element, direction)) | 781 for (; element; element = (element->isFrameOwnerElement() || canScrollInDire
ction(element, direction)) |
| 782 ? ElementTraversal::nextSkippingChildren(element, container) | 782 ? ElementTraversal::nextSkippingChildren(element, container) |
| 783 : ElementTraversal::next(element, container)) { | 783 : ElementTraversal::next(*element, container)) { |
| 784 if (element == focusedElement) | 784 if (element == focusedElement) |
| 785 continue; | 785 continue; |
| 786 | 786 |
| 787 if (!element->isKeyboardFocusable() && !element->isFrameOwnerElement() &
& !canScrollInDirection(element, direction)) | 787 if (!element->isKeyboardFocusable() && !element->isFrameOwnerElement() &
& !canScrollInDirection(element, direction)) |
| 788 continue; | 788 continue; |
| 789 | 789 |
| 790 FocusCandidate candidate = FocusCandidate(element, direction); | 790 FocusCandidate candidate = FocusCandidate(element, direction); |
| 791 if (candidate.isNull()) | 791 if (candidate.isNull()) |
| 792 continue; | 792 continue; |
| 793 | 793 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); | 900 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); |
| 901 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direct
ion, container); | 901 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direct
ion, container); |
| 902 if (container && container->isDocumentNode()) | 902 if (container && container->isDocumentNode()) |
| 903 toDocument(container)->updateLayoutIgnorePendingStylesheets(); | 903 toDocument(container)->updateLayoutIgnorePendingStylesheets(); |
| 904 } while (!consumed && container); | 904 } while (!consumed && container); |
| 905 | 905 |
| 906 return consumed; | 906 return consumed; |
| 907 } | 907 } |
| 908 | 908 |
| 909 } // namespace WebCore | 909 } // namespace WebCore |
| OLD | NEW |