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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 int tabIndex = adjustedTabIndex(start); | 575 int tabIndex = adjustedTabIndex(start); |
576 // If a node is excluded from the normal tabbing cycle, the next focusab le node is determined by tree order | 576 // If a node is excluded from the normal tabbing cycle, the next focusab le node is determined by tree order |
577 if (tabIndex < 0) { | 577 if (tabIndex < 0) { |
578 for (Node* node = NodeTraversal::next(*start); node; node = NodeTrav ersal::next(*node)) { | 578 for (Node* node = NodeTraversal::next(*start); node; node = NodeTrav ersal::next(*node)) { |
579 if (shouldVisit(node) && adjustedTabIndex(node) >= 0) | 579 if (shouldVisit(node) && adjustedTabIndex(node) >= 0) |
580 return node; | 580 return node; |
581 } | 581 } |
582 } | 582 } |
583 | 583 |
584 // First try to find a node with the same tabindex as start that comes a fter start in the scope. | 584 // First try to find a node with the same tabindex as start that comes a fter start in the scope. |
585 if (Node* winner = findNodeWithExactTabIndex(NodeTraversal::next(*start) , tabIndex, FocusTypeForward)) | 585 if (tabIndex >= 0) { |
hayato
2014/08/26 07:34:56
You can use `else` here rather than repeating `if`
| |
586 return winner; | 586 if (Node* winner = findNodeWithExactTabIndex(NodeTraversal::next(*st art), tabIndex, FocusTypeForward)) |
587 | 587 return winner; |
588 } | |
588 if (!tabIndex) | 589 if (!tabIndex) |
589 // We've reached the last node in the document with a tabindex of 0. This is the end of the tabbing order. | 590 // We've reached the last node in the document with a tabindex of 0. This is the end of the tabbing order. |
590 return 0; | 591 return 0; |
591 } | 592 } |
592 | 593 |
593 // Look for the first node in the scope that: | 594 // Look for the first node in the scope that: |
594 // 1) has the lowest tabindex that is higher than start's tabindex (or 0, if start is null), and | 595 // 1) has the lowest tabindex that is higher than start's tabindex (or 0, if start is null), and |
595 // 2) comes first in the scope, if there's a tie. | 596 // 2) comes first in the scope, if there's a tie. |
596 if (Node* winner = nextNodeWithGreaterTabIndex(scope.rootNode(), start ? adj ustedTabIndex(start) : 0)) | 597 if (Node* winner = nextNodeWithGreaterTabIndex(scope.rootNode(), start ? adj ustedTabIndex(start) : 0)) |
597 return winner; | 598 return winner; |
(...skipping 23 matching lines...) Expand all Loading... | |
621 } | 622 } |
622 | 623 |
623 // However, if a node is excluded from the normal tabbing cycle, the previou s focusable node is determined by tree order | 624 // However, if a node is excluded from the normal tabbing cycle, the previou s focusable node is determined by tree order |
624 if (startingTabIndex < 0) { | 625 if (startingTabIndex < 0) { |
625 for (Node* node = startingNode; node; node = NodeTraversal::previous(*no de)) { | 626 for (Node* node = startingNode; node; node = NodeTraversal::previous(*no de)) { |
626 if (shouldVisit(node) && adjustedTabIndex(node) >= 0) | 627 if (shouldVisit(node) && adjustedTabIndex(node) >= 0) |
627 return node; | 628 return node; |
628 } | 629 } |
629 } | 630 } |
630 | 631 |
631 if (Node* winner = findNodeWithExactTabIndex(startingNode, startingTabIndex, FocusTypeBackward)) | 632 if (startingTabIndex >= 0) { |
hayato
2014/08/26 07:34:56
Ditto.
| |
632 return winner; | 633 if (Node* winner = findNodeWithExactTabIndex(startingNode, startingTabIn dex, FocusTypeBackward)) |
634 return winner; | |
635 } | |
633 | 636 |
634 // There are no nodes before start with the same tabindex as start, so look for a node that: | 637 // There are no nodes before start with the same tabindex as start, so look for a node that: |
635 // 1) has the highest non-zero tabindex (that is less than start's tabindex) , and | 638 // 1) has the highest non-zero tabindex (that is less than start's tabindex) , and |
636 // 2) comes last in the scope, if there's a tie. | 639 // 2) comes last in the scope, if there's a tie. |
637 startingTabIndex = (start && startingTabIndex) ? startingTabIndex : std::num eric_limits<short>::max(); | 640 startingTabIndex = (start && startingTabIndex) ? startingTabIndex : std::num eric_limits<short>::max(); |
638 return previousNodeWithLowerTabIndex(last, startingTabIndex); | 641 return previousNodeWithLowerTabIndex(last, startingTabIndex); |
639 } | 642 } |
640 | 643 |
641 static bool relinquishesEditingFocus(Node *node) | 644 static bool relinquishesEditingFocus(Node *node) |
642 { | 645 { |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
919 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); | 922 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); |
920 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container); | 923 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container); |
921 if (container && container->isDocumentNode()) | 924 if (container && container->isDocumentNode()) |
922 toDocument(container)->updateLayoutIgnorePendingStylesheets(); | 925 toDocument(container)->updateLayoutIgnorePendingStylesheets(); |
923 } while (!consumed && container); | 926 } while (!consumed && container); |
924 | 927 |
925 return consumed; | 928 return consumed; |
926 } | 929 } |
927 | 930 |
928 } // namespace blink | 931 } // namespace blink |
OLD | NEW |