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

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

Issue 1177673005: Implement ShadowRoot.delegatesFocus 4/4 (match CSS :focus for shadow host) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix for comments, add a layout test 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
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index f399213a53970bcd7f8a6b467d8ce43cac065ba5..b709a75b3be82927d8aafce0084aea0184e5c589 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -1084,6 +1084,19 @@ void ContainerNode::focusStateChanged()
void ContainerNode::setFocus(bool received)
{
+ // Recurse up author shadow trees to mark shadow hosts if it matches :focus.
+ // TODO(kochi): Handle UA shadows which marks multiple nodes as focused such as
+ // <input type="date"> the same way as author shadow.
+ if (isInShadowTree() && shadowHost()->shadowRoot())
hayato 2015/06/12 07:59:29 How about this? The intention would becomes more c
kochi 2015/06/12 08:21:35 Adopted your first suggestion.
+ shadowHost()->setFocus(received);
+
+ // If this is an author shadow host and indirectly focused (has focused element within
+ // its shadow root), update focus.
+ if (isElementNode() && document().focusedElement() && document().focusedElement() != this) {
+ if (toElement(this)->shadowRoot())
+ received = received && toElement(this)->shadowRoot()->delegatesFocus();
+ }
+
if (focused() == received)
return;

Powered by Google App Engine
This is Rietveld 408576698