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

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

Issue 2965603002: Update hover states when dragging the mouse into an element (Closed)
Patch Set: hover active chain Created 3 years, 5 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/LayoutTests/platform/win/editing/selection/drag-select-1-expected.png ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 49fc092b98dac85b94151d33315c4fa83057bbfb..16f0c9d5021decdcfe58eaf2664afa5f2514c4f9 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -6489,7 +6489,7 @@ void Document::UpdateHoverActiveState(const HitTestRequest& request,
bool allow_active_changes = !old_active_element && ActiveHoverElement();
// If the mouse is down and if this is a mouse move event, we want to restrict
- // changes in :hover/:active to only apply to elements that are in the :active
+ // changes in :active to only apply to elements that are in the :active
// chain that we froze at the time the mouse went down.
bool must_be_in_active_chain = request.Active() && request.Move();
@@ -6516,7 +6516,8 @@ void Document::UpdateHoverActiveState(const HitTestRequest& request,
}
HeapVector<Member<Element>, 32> elements_to_remove_from_chain;
- HeapVector<Member<Element>, 32> elements_to_add_to_chain;
+ HeapVector<Member<Element>, 32> elements_to_add_to_active_chain;
+ HeapVector<Member<Element>, 32> elements_to_add_to_hover_chain;
if (old_hover_element != new_hover_element) {
// The old hover path only needs to be cleared up to (and not including) the
@@ -6532,8 +6533,7 @@ void Document::UpdateHoverActiveState(const HitTestRequest& request,
if (old_hover_element && old_hover_element->isConnected()) {
for (Element* curr = old_hover_element; curr && curr != ancestor_element;
curr = FlatTreeTraversal::ParentElement(*curr)) {
- if (!must_be_in_active_chain || curr->InActiveChain())
- elements_to_remove_from_chain.push_back(curr);
+ elements_to_remove_from_chain.push_back(curr);
}
}
}
@@ -6541,8 +6541,9 @@ void Document::UpdateHoverActiveState(const HitTestRequest& request,
// Now set the hover state for our new object up to the root.
for (Element* curr = new_hover_element; curr;
curr = FlatTreeTraversal::ParentElement(*curr)) {
+ elements_to_add_to_hover_chain.push_back(curr);
Navid Zolghadr 2017/07/04 17:51:59 Do we need a check like old_hover_element != new_h
if (!must_be_in_active_chain || curr->InActiveChain())
- elements_to_add_to_chain.push_back(curr);
+ elements_to_add_to_active_chain.push_back(curr);
}
if (allow_hover_changes) {
@@ -6550,14 +6551,17 @@ void Document::UpdateHoverActiveState(const HitTestRequest& request,
element->SetHovered(false);
}
+ // Elements past the common ancestor do not change hover state, but might
+ // change active state.
+ for (Element* element : elements_to_add_to_active_chain) {
+ if (allow_active_changes)
+ element->SetActive(true);
+ }
+
bool saw_common_ancestor = false;
- for (Element* element : elements_to_add_to_chain) {
- // Elements past the common ancestor do not change hover state, but might
- // change active state.
+ for (Element* element : elements_to_add_to_hover_chain) {
if (element == ancestor_element)
saw_common_ancestor = true;
- if (allow_active_changes)
- element->SetActive(true);
if (allow_hover_changes &&
(!saw_common_ancestor || element == hover_element_))
element->SetHovered(true);
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/editing/selection/drag-select-1-expected.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698