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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 4036 matching lines...) Expand 10 before | Expand all | Expand 10 after
4047 if (NodeChildRemovalTracker::IsBeingRemoved(new_focused_element)) 4047 if (NodeChildRemovalTracker::IsBeingRemoved(new_focused_element))
4048 return true; 4048 return true;
4049 4049
4050 if (focused_element_ == new_focused_element) 4050 if (focused_element_ == new_focused_element)
4051 return true; 4051 return true;
4052 4052
4053 bool focus_change_blocked = false; 4053 bool focus_change_blocked = false;
4054 Element* old_focused_element = focused_element_; 4054 Element* old_focused_element = focused_element_;
4055 focused_element_ = nullptr; 4055 focused_element_ = nullptr;
4056 4056
4057 UpdateDistribution();
4058 Node* ancestor = (old_focused_element && old_focused_element->isConnected() &&
4059 new_focused_element)
4060 ? FlatTreeTraversal::CommonAncestor(*old_focused_element,
4061 *new_focused_element)
4062 : nullptr;
4063
4057 // Remove focus from the existing focus node (if any) 4064 // Remove focus from the existing focus node (if any)
4058 if (old_focused_element) { 4065 if (old_focused_element) {
4059 old_focused_element->SetFocused(false, params.type); 4066 old_focused_element->SetFocused(false, params.type);
4067 old_focused_element->SetHasFocusWithinUpToAncestor(false, ancestor);
4060 4068
4061 // Dispatch the blur event and let the node do any other blur related 4069 // Dispatch the blur event and let the node do any other blur related
4062 // activities (important for text fields) 4070 // activities (important for text fields)
4063 // If page lost focus, blur event will have already been dispatched 4071 // If page lost focus, blur event will have already been dispatched
4064 if (GetPage() && (GetPage()->GetFocusController().IsFocused())) { 4072 if (GetPage() && (GetPage()->GetFocusController().IsFocused())) {
4065 old_focused_element->DispatchBlurEvent(new_focused_element, params.type, 4073 old_focused_element->DispatchBlurEvent(new_focused_element, params.type,
4066 params.source_capabilities); 4074 params.source_capabilities);
4067 if (focused_element_) { 4075 if (focused_element_) {
4068 // handler shifted focus 4076 // handler shifted focus
4069 focus_change_blocked = true; 4077 focus_change_blocked = true;
(...skipping 27 matching lines...) Expand all
4097 !AcceptsEditingFocus(*new_focused_element)) { 4105 !AcceptsEditingFocus(*new_focused_element)) {
4098 // delegate blocks focus change 4106 // delegate blocks focus change
4099 focus_change_blocked = true; 4107 focus_change_blocked = true;
4100 goto SetFocusedElementDone; 4108 goto SetFocusedElementDone;
4101 } 4109 }
4102 // Set focus on the new node 4110 // Set focus on the new node
4103 focused_element_ = new_focused_element; 4111 focused_element_ = new_focused_element;
4104 SetSequentialFocusNavigationStartingPoint(focused_element_.Get()); 4112 SetSequentialFocusNavigationStartingPoint(focused_element_.Get());
4105 4113
4106 focused_element_->SetFocused(true, params.type); 4114 focused_element_->SetFocused(true, params.type);
4115 focused_element_->SetHasFocusWithinUpToAncestor(true, ancestor);
4116
4107 // Element::setFocused for frames can dispatch events. 4117 // Element::setFocused for frames can dispatch events.
4108 if (focused_element_ != new_focused_element) { 4118 if (focused_element_ != new_focused_element) {
4109 focus_change_blocked = true; 4119 focus_change_blocked = true;
4110 goto SetFocusedElementDone; 4120 goto SetFocusedElementDone;
4111 } 4121 }
4112 CancelFocusAppearanceUpdate(); 4122 CancelFocusAppearanceUpdate();
4113 focused_element_->UpdateFocusAppearance(params.selection_behavior); 4123 focused_element_->UpdateFocusAppearance(params.selection_behavior);
4114 4124
4115 // Dispatch the focus event and let the node do any other focus related 4125 // Dispatch the focus event and let the node do any other focus related
4116 // activities (important for text fields) 4126 // activities (important for text fields)
(...skipping 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after
6652 } 6662 }
6653 6663
6654 void showLiveDocumentInstances() { 6664 void showLiveDocumentInstances() {
6655 WeakDocumentSet& set = liveDocumentSet(); 6665 WeakDocumentSet& set = liveDocumentSet();
6656 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6666 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6657 for (blink::Document* document : set) 6667 for (blink::Document* document : set)
6658 fprintf(stderr, "- Document %p URL: %s\n", document, 6668 fprintf(stderr, "- Document %p URL: %s\n", document,
6659 document->Url().GetString().Utf8().Data()); 6669 document->Url().GetString().Utf8().Data());
6660 } 6670 }
6661 #endif 6671 #endif
OLDNEW
« 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