Index: third_party/WebKit/Source/core/dom/ContainerNode.cpp |
diff --git a/third_party/WebKit/Source/core/dom/ContainerNode.cpp b/third_party/WebKit/Source/core/dom/ContainerNode.cpp |
index 3de58c2b8b065a3bc08c1e1f237b27374c12ecc8..5b66c1f31e9eccb69e19d331c67170047c010f59 100644 |
--- a/third_party/WebKit/Source/core/dom/ContainerNode.cpp |
+++ b/third_party/WebKit/Source/core/dom/ContainerNode.cpp |
@@ -1044,7 +1044,9 @@ void ContainerNode::FocusWithinStateChanged() { |
ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoFocusWithin); |
} |
-void ContainerNode::SetFocused(bool received, WebFocusType focus_type) { |
+void ContainerNode::SetFocused(bool received, |
+ WebFocusType focus_type, |
+ Node* common_ancestor) { |
// 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. |
@@ -1070,7 +1072,7 @@ void ContainerNode::SetFocused(bool received, WebFocusType focus_type) { |
FocusStateChanged(); |
UpdateDistribution(); |
- for (ContainerNode* node = this; node; |
+ for (ContainerNode* node = this; node && node != common_ancestor; |
node = FlatTreeTraversal::Parent(*node)) { |
node->SetHasFocusWithin(received); |
node->FocusWithinStateChanged(); |