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 f9e5f7dbb686d586f92db52d6bb2f27309d28169..3de58c2b8b065a3bc08c1e1f237b27374c12ecc8 100644 |
--- a/third_party/WebKit/Source/core/dom/ContainerNode.cpp |
+++ b/third_party/WebKit/Source/core/dom/ContainerNode.cpp |
@@ -1025,6 +1025,23 @@ void ContainerNode::FocusStateChanged() { |
LayoutTheme::GetTheme().ControlStateChanged(*GetLayoutObject(), |
kFocusControlState); |
+ FocusWithinStateChanged(); |
+} |
+ |
+void ContainerNode::FocusWithinStateChanged() { |
+ if (GetComputedStyle() && GetComputedStyle()->AffectedByFocusWithin()) { |
+ StyleChangeType change_type = |
+ GetComputedStyle()->HasPseudoStyle(kPseudoIdFirstLetter) |
+ ? kSubtreeStyleChange |
+ : kLocalStyleChange; |
+ SetNeedsStyleRecalc(change_type, |
+ StyleChangeReasonForTracing::CreateWithExtraData( |
+ StyleChangeReason::kPseudoClass, |
+ StyleChangeExtraData::g_focus_within)); |
+ } |
+ if (IsElementNode() && |
+ ToElement(this)->ChildrenOrSiblingsAffectedByFocusWithin()) |
+ ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoFocusWithin); |
} |
void ContainerNode::SetFocused(bool received, WebFocusType focus_type) { |
@@ -1052,6 +1069,13 @@ void ContainerNode::SetFocused(bool received, WebFocusType focus_type) { |
FocusStateChanged(); |
+ UpdateDistribution(); |
+ for (ContainerNode* node = this; node; |
+ node = FlatTreeTraversal::Parent(*node)) { |
+ node->SetHasFocusWithin(received); |
+ node->FocusWithinStateChanged(); |
+ } |
+ |
if (GetLayoutObject() || received) |
return; |
@@ -1064,6 +1088,16 @@ void ContainerNode::SetFocused(bool received, WebFocusType focus_type) { |
kLocalStyleChange, |
StyleChangeReasonForTracing::CreateWithExtraData( |
StyleChangeReason::kPseudoClass, StyleChangeExtraData::g_focus)); |
+ |
+ if (IsElementNode() && |
+ ToElement(this)->ChildrenOrSiblingsAffectedByFocusWithin()) { |
+ ToElement(this)->PseudoStateChanged(CSSSelector::kPseudoFocusWithin); |
+ } else { |
+ SetNeedsStyleRecalc(kLocalStyleChange, |
+ StyleChangeReasonForTracing::CreateWithExtraData( |
+ StyleChangeReason::kPseudoClass, |
+ StyleChangeExtraData::g_focus_within)); |
+ } |
} |
void ContainerNode::SetActive(bool down) { |