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

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-28T16:44:17 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
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 for (Node& runner : NodeTraversal::ancestorsOrSelfOf(node)) {
1655 if (!node->isElementNode()) 1655 if (!runner.isElementNode())
1656 continue; 1656 continue;
1657 Element* element = toElement(node); 1657 Element& element = toElement(runner);
1658 if (element->isFocusable()) { 1658 if (element.isFocusable()) {
1659 // Found a focusable parent node. Set the active match as the 1659 // Found a focusable parent node. Set the active match as the
1660 // selection and focus to the focusable node. 1660 // selection and focus to the focusable node.
1661 frame()->selection().setSelection(VisibleSelection(EphemeralRang e(activeMatch))); 1661 frame()->selection().setSelection(VisibleSelection(EphemeralRang e(activeMatch)));
1662 frame()->document()->setFocusedElement(element, FocusParams(Sele ctionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); 1662 frame()->document()->setFocusedElement(&element, FocusParams(Sel ectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr));
1663 return; 1663 return;
1664 } 1664 }
1665 } 1665 }
1666 1666
1667 // Iterate over all the nodes in the range until we find a focusable nod e. 1667 // 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 1668 // This, for example, sets focus to the first link if you search for
1669 // text and text that is within one or more links. 1669 // text and text that is within one or more links.
1670 node = activeMatch->firstNode(); 1670 node = activeMatch->firstNode();
1671 for (; node && node != activeMatch->pastLastNode(); node = NodeTraversal ::next(*node)) { 1671 for (; node && node != activeMatch->pastLastNode(); node = NodeTraversal ::next(*node)) {
1672 if (!node->isElementNode()) 1672 if (!node->isElementNode())
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 return WebSandboxFlags::None; 2110 return WebSandboxFlags::None;
2111 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); 2111 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( ));
2112 } 2112 }
2113 2113
2114 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) 2114 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags)
2115 { 2115 {
2116 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); 2116 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags));
2117 } 2117 }
2118 2118
2119 } // namespace blink 2119 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698