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

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

Issue 2821303005: [selectors4] Use common ancestor strategy for :focus-within (Closed)
Patch Set: Use EXPECT_EQ instead of ASSERT_EQ 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
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index a289edaa1ac1bf3457005f872c137db1c0c054f4..c79f3775d511140651a4298a109dcac17ca298c4 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -4054,9 +4054,17 @@ bool Document::SetFocusedElement(Element* prp_new_focused_element,
Element* old_focused_element = focused_element_;
focused_element_ = nullptr;
+ UpdateDistribution();
+ Node* ancestor = (old_focused_element && old_focused_element->isConnected() &&
+ new_focused_element)
+ ? FlatTreeTraversal::CommonAncestor(*old_focused_element,
+ *new_focused_element)
+ : nullptr;
+
// Remove focus from the existing focus node (if any)
if (old_focused_element) {
old_focused_element->SetFocused(false, params.type);
+ old_focused_element->SetHasFocusWithinUpToAncestor(false, ancestor);
// Dispatch the blur event and let the node do any other blur related
// activities (important for text fields)
@@ -4104,6 +4112,8 @@ bool Document::SetFocusedElement(Element* prp_new_focused_element,
SetSequentialFocusNavigationStartingPoint(focused_element_.Get());
focused_element_->SetFocused(true, params.type);
+ focused_element_->SetHasFocusWithinUpToAncestor(true, ancestor);
+
// Element::setFocused for frames can dispatch events.
if (focused_element_ != new_focused_element) {
focus_change_blocked = true;
« no previous file with comments | « third_party/WebKit/Source/core/dom/ContainerNode.cpp ('k') | third_party/WebKit/Source/core/page/FocusController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698