Chromium Code Reviews| 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); |