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

Unified Diff: Source/core/dom/Element.cpp

Issue 1177673004: Implement ShadowRoot.delegatesFocus 3/4 (Slide focus on focus() method) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/dom/shadow/focus-method-with-delegatesFocus-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 590d95151d0a81b4a84705bf47fcc8d2ecf9d2ad..6cd59d0bb0f764274278a7c1d0626b139bed38d0 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -2193,6 +2193,18 @@ void Element::focus(bool restorePreviousSelection, WebFocusType type)
if (!isFocusable())
return;
+ if (shadowRoot() && shadowRoot()->delegatesFocus()) {
+ if (containsIncludingShadowDOM(document().focusedElement()))
+ return;
+
+ // Slide the focus to its inner node.
+ Node* next = document().page()->focusController().findFocusableNode(WebFocusTypeForward, *this);
+ if (next && next->isElementNode() && containsIncludingShadowDOM(next)) {
+ toElement(next)->focus(false, WebFocusTypeForward);
+ return;
+ }
+ }
+
RefPtrWillBeRawPtr<Node> protect(this);
if (!document().page()->focusController().setFocusedElement(this, document().frame(), type))
return;
« no previous file with comments | « LayoutTests/fast/dom/shadow/focus-method-with-delegatesFocus-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698