Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp

Issue 1932523003: Introduce NodeTraversal::ancestorsOf() and inclusiveAncestors() for range-based for loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-04-28T18:38:12 Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 1644
1645 // Try to find the first focusable node up the chain, which will, for 1645 // Try to find the first focusable node up the chain, which will, for
1646 // example, focus links if we have found text within the link. 1646 // example, focus links if we have found text within the link.
1647 Node* node = activeMatch->firstNode(); 1647 Node* node = activeMatch->firstNode();
1648 if (node && node->isInShadowTree()) { 1648 if (node && node->isInShadowTree()) {
1649 if (Node* host = node->shadowHost()) { 1649 if (Node* host = node->shadowHost()) {
1650 if (isHTMLInputElement(*host) || isHTMLTextAreaElement(*host)) 1650 if (isHTMLInputElement(*host) || isHTMLTextAreaElement(*host))
1651 node = host; 1651 node = host;
1652 } 1652 }
1653 } 1653 }
1654 for (; node; node = node->parentNode()) { 1654 if (node) {
1655 if (!node->isElementNode()) 1655 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) {
1656 continue; 1656 if (!runner.isElementNode())
1657 Element* element = toElement(node); 1657 continue;
1658 if (element->isFocusable()) { 1658 Element& element = toElement(runner);
1659 // Found a focusable parent node. Set the active match as the 1659 if (element.isFocusable()) {
1660 // selection and focus to the focusable node. 1660 // Found a focusable parent node. Set the active match as th e
1661 frame()->selection().setSelection(VisibleSelection(EphemeralRang e(activeMatch))); 1661 // selection and focus to the focusable node.
1662 frame()->document()->setFocusedElement(element, FocusParams(Sele ctionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); 1662 frame()->selection().setSelection(VisibleSelection(Ephemeral Range(activeMatch)));
1663 return; 1663 frame()->document()->setFocusedElement(&element, FocusParams (SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr));
1664 return;
1665 }
1664 } 1666 }
1665 } 1667 }
1666 1668
1667 // Iterate over all the nodes in the range until we find a focusable nod e. 1669 // Iterate over all the nodes in the range until we find a focusable nod e.
1668 // This, for example, sets focus to the first link if you search for 1670 // This, for example, sets focus to the first link if you search for
1669 // text and text that is within one or more links. 1671 // text and text that is within one or more links.
1670 node = activeMatch->firstNode(); 1672 node = activeMatch->firstNode();
1671 for (; node && node != activeMatch->pastLastNode(); node = NodeTraversal ::next(*node)) { 1673 for (; node && node != activeMatch->pastLastNode(); node = NodeTraversal ::next(*node)) {
1672 if (!node->isElementNode()) 1674 if (!node->isElementNode())
1673 continue; 1675 continue;
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 return WebSandboxFlags::None; 2112 return WebSandboxFlags::None;
2111 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); 2113 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( ));
2112 } 2114 }
2113 2115
2114 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) 2116 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags)
2115 { 2117 {
2116 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); 2118 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags));
2117 } 2119 }
2118 2120
2119 } // namespace blink 2121 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698