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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2668133003: Change hover element to scrollbar's parent when hit test contains scrollbar (Closed)
Patch Set: add test Created 3 years, 10 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 6070 matching lines...) Expand 10 before | Expand all | Expand 10 after
6081 } 6081 }
6082 6082
6083 return 0; 6083 return 0;
6084 } 6084 }
6085 6085
6086 void Document::updateHoverActiveState(const HitTestRequest& request, 6086 void Document::updateHoverActiveState(const HitTestRequest& request,
6087 Element* innerElement, 6087 Element* innerElement,
6088 Scrollbar* hitScrollbar) { 6088 Scrollbar* hitScrollbar) {
6089 DCHECK(!request.readOnly()); 6089 DCHECK(!request.readOnly());
6090 6090
6091 // Only cancel hover state when hitting native scrollbar because custom 6091 if (request.active() && m_frame)
6092 // scrollbar's style depends on the owner element's hover state.
6093 bool hitNativeScrollbar = hitScrollbar && !hitScrollbar->isCustomScrollbar();
6094
6095 if (request.active() && m_frame && !hitNativeScrollbar)
6096 m_frame->eventHandler().notifyElementActivated(); 6092 m_frame->eventHandler().notifyElementActivated();
6097 6093
6098 Element* innerElementInDocument = hitNativeScrollbar ? nullptr : innerElement; 6094 Element* innerElementInDocument = hitScrollbar ? nullptr : innerElement;
6095 // Replace the innerElementInDocument to be srollbar's parent when hit
6096 // scrollbar
6097 if (hitScrollbar) {
6098 ScrollableArea* scrollableArea = hitScrollbar->getScrollableArea();
6099 if (scrollableArea && scrollableArea->layoutBox() &&
6100 scrollableArea->layoutBox()->node() &&
6101 scrollableArea->layoutBox()->node()->isElementNode()) {
6102 innerElementInDocument =
bokan 2017/02/02 23:29:26 You've confirmed that this preserves the hover eff
chaopeng 2017/02/03 01:12:05 Yes, the customer scrollbar issue is also cause by
6103 toElement(hitScrollbar->getScrollableArea()->layoutBox()->node());
6104 }
6105 }
6106
6099 while (innerElementInDocument && innerElementInDocument->document() != this) { 6107 while (innerElementInDocument && innerElementInDocument->document() != this) {
6100 innerElementInDocument->document().updateHoverActiveState( 6108 innerElementInDocument->document().updateHoverActiveState(
6101 request, innerElementInDocument, hitScrollbar); 6109 request, innerElementInDocument, hitScrollbar);
6102 innerElementInDocument = innerElementInDocument->document().localOwner(); 6110 innerElementInDocument = innerElementInDocument->document().localOwner();
6103 } 6111 }
6104 6112
6105 updateDistribution(); 6113 updateDistribution();
6106 Element* oldActiveElement = activeHoverElement(); 6114 Element* oldActiveElement = activeHoverElement();
6107 if (oldActiveElement && (!request.active() || hitNativeScrollbar)) { 6115 if (oldActiveElement && !request.active()) {
6108 // The oldActiveElement layoutObject is null, dropped on :active by setting 6116 // The oldActiveElement layoutObject is null, dropped on :active by setting
6109 // display: none, for instance. We still need to clear the ActiveChain as 6117 // display: none, for instance. We still need to clear the ActiveChain as
6110 // the mouse is released. 6118 // the mouse is released.
6111 for (Node* node = oldActiveElement; node; 6119 for (Node* node = oldActiveElement; node;
6112 node = FlatTreeTraversal::parent(*node)) { 6120 node = FlatTreeTraversal::parent(*node)) {
6113 DCHECK(!node->isTextNode()); 6121 DCHECK(!node->isTextNode());
6114 node->setActive(false); 6122 node->setActive(false);
6115 m_userActionElements.setInActiveChain(node, false); 6123 m_userActionElements.setInActiveChain(node, false);
6116 } 6124 }
6117 setActiveHoverElement(nullptr); 6125 setActiveHoverElement(nullptr);
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
6569 } 6577 }
6570 6578
6571 void showLiveDocumentInstances() { 6579 void showLiveDocumentInstances() {
6572 WeakDocumentSet& set = liveDocumentSet(); 6580 WeakDocumentSet& set = liveDocumentSet();
6573 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6581 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6574 for (blink::Document* document : set) 6582 for (blink::Document* document : set)
6575 fprintf(stderr, "- Document %p URL: %s\n", document, 6583 fprintf(stderr, "- Document %p URL: %s\n", document,
6576 document->url().getString().utf8().data()); 6584 document->url().getString().utf8().data());
6577 } 6585 }
6578 #endif 6586 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698