Node* FocusController::nextFocusableNode(FocusNavigationScope scope, Node* start) { if (start) { int tabIndex = adjustedTabIndex(start); // If a node is excluded from the normal tabbing cycle, the next focusable node is determined by tree order if (tabIndex < 0) { for (Node* node = NodeTraversal::next(*start); node; node = NodeTraversal::next(*node)) { if (shouldVisit(node) && adjustedTabIndex(node) >= 0) return node; } } // First try to find a node with the same tabindex as start that comes after start in the scope. if (Node* winner = findNodeWithExactTabIndex(NodeTraversal::next(*start), tabIndex, FocusTypeForward)) return winner; if (!tabIndex) // We've reached the last node in the document with a tabindex of 0. This is the end of the tabbing order. return 0; } // Look for the first node in the scope that: // 1) has the lowest tabindex that is higher than start's tabindex (or 0, if start is null), and // 2) comes first in the scope, if there's a tie. if (Node* winner = nextNodeWithGreaterTabIndex(scope.rootNode(), start ? adjustedTabIndex(start) : 0)) return winner; // There are no nodes with a tabindex greater than start's tabindex, // so find the first node with a tabindex of 0. return findNodeWithExactTabIndex(scope.rootNode(), 0, FocusTypeForward); }
Node* FocusController::findNodeWithExactTabIndex(Node* start, int tabIndex, FocusType type) { // Search is inclusive of start for (Node* node = start; node; node = type == FocusTypeForward ? NodeTraversal::next(*node) : NodeTraversal::previous(*node)) { if (shouldVisit(node) && adjustedTabIndex(node) == tabIndex) return node; } return 0; }
static Node* previousNodeWithLowerTabIndex(Node* start, int tabIndex) { // Search is inclusive of start int winningTabIndex = 0; Node* winner = 0; for (Node* node = start; node; node = NodeTraversal::previous(*node)) { int currentTabIndex = adjustedTabIndex(node); if ((shouldVisit(node) || isNonKeyboardFocusableShadowHost(node)) && currentTabIndex < tabIndex && currentTabIndex > winningTabIndex) { winner = node; winningTabIndex = currentTabIndex; } } return winner; }
static Node* nextNodeWithGreaterTabIndex(Node* start, int tabIndex) { // Search is inclusive of start int winningTabIndex = std::numeric_limits<short>::max() + 1; Node* winner = 0; for (Node* node = start; node; node = NodeTraversal::next(*node)) { if (shouldVisit(node) && node->tabIndex() > tabIndex && node->tabIndex() < winningTabIndex) { winner = node; winningTabIndex = node->tabIndex(); } } return winner; }
bool TestRunner::visitEnter(TestSuite& suite) { if (m_context->shouldStop()) return false; if (!TestQualifier::visitEnter(suite)) return false; if (shouldVisit(currentPath())) return true; TestQualifier::visitLeave(suite); return false; }
bool TestRunner::visit(TestCase& test) { if (m_context->shouldStop()) return false; if (!shouldVisit(currentPath() + test.name())) return false; int rst = runTestCase(test, *m_context, logS()); if( 0 != rst ) m_failures++; m_tests++; // Always continue, regardless of test result, unless the context // object says otherwise. return !m_context->shouldStop(); }
Node* FocusController::previousFocusableNode(FocusNavigationScope scope, Node* start) { Node* last = 0; for (Node* node = scope.rootNode(); node; node = node->lastChild()) last = node; ASSERT(last); // First try to find the last node in the scope that comes before start and has the same tabindex as start. // If start is null, find the last node in the scope with a tabindex of 0. Node* startingNode; int startingTabIndex; if (start) { startingNode = NodeTraversal::previous(*start); startingTabIndex = adjustedTabIndex(start); } else { startingNode = last; startingTabIndex = 0; } // However, if a node is excluded from the normal tabbing cycle, the previous focusable node is determined by tree order if (startingTabIndex < 0) { for (Node* node = startingNode; node; node = NodeTraversal::previous(*node)) { if (shouldVisit(node) && adjustedTabIndex(node) >= 0) return node; } } if (Node* winner = findNodeWithExactTabIndex(startingNode, startingTabIndex, FocusTypeBackward)) return winner; // There are no nodes before start with the same tabindex as start, so look for a node that: // 1) has the highest non-zero tabindex (that is less than start's tabindex), and // 2) comes last in the scope, if there's a tie. startingTabIndex = (start && startingTabIndex) ? startingTabIndex : std::numeric_limits<short>::max(); return previousNodeWithLowerTabIndex(last, startingTabIndex); }