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

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

Issue 2795143004: [selectors4] Implement :focus-within pseudo-class (Closed)
Patch Set: Rebased patch Created 3 years, 8 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 | « third_party/WebKit/Source/core/dom/ContainerNode.h ('k') | third_party/WebKit/Source/core/dom/Node.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « third_party/WebKit/Source/core/dom/ContainerNode.h ('k') | third_party/WebKit/Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698