MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / tabToNextElement

Method tabToNextElement

src/main/java/org/htmlunit/html/HtmlPage.java:1619–1648  ·  view source on GitHub ↗

Move the focus to the next element in the tab order. To determine the specified tab order, refer to HtmlPage#getTabbableElements() @return the element that has focus after calling this method

()

Source from the content-addressed store, hash-verified

1617 * @return the element that has focus after calling this method
1618 */
1619 public HtmlElement tabToNextElement() {
1620 final List<HtmlElement> elements = getTabbableElements();
1621 if (elements.isEmpty()) {
1622 setFocusedElement(null);
1623 return null;
1624 }
1625
1626 final HtmlElement elementToGiveFocus;
1627 final DomElement elementWithFocus = getFocusedElement();
1628 if (elementWithFocus == null) {
1629 elementToGiveFocus = elements.get(0);
1630 }
1631 else {
1632 final int index = elements.indexOf(elementWithFocus);
1633 if (index == -1) {
1634 // The element with focus isn't on this page
1635 elementToGiveFocus = elements.get(0);
1636 }
1637 else if (index == elements.size() - 1) {
1638 // if at last jump to start
1639 elementToGiveFocus = elements.get(0);
1640 }
1641 else {
1642 elementToGiveFocus = elements.get(index + 1);
1643 }
1644 }
1645
1646 setFocusedElement(elementToGiveFocus);
1647 return elementToGiveFocus;
1648 }
1649
1650 /**
1651 * Move the focus to the previous element in the tab order. To determine the specified tab

Callers 3

tabNextMethod · 0.95

Calls 7

getTabbableElementsMethod · 0.95
setFocusedElementMethod · 0.95
getFocusedElementMethod · 0.95
isEmptyMethod · 0.65
getMethod · 0.45
indexOfMethod · 0.45
sizeMethod · 0.45

Tested by 3

tabNextMethod · 0.76