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

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

Issue 2389073002: Fix link's hover state if the link under scrollbar (Closed)
Patch Set: Merge patch-2467693002 to fix testcase failed in OSX Created 4 years, 1 month 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 3440 matching lines...) Expand 10 before | Expand all | Expand 10 after
3451 // lead to a premature layout() happening, which could show a flash of white. 3451 // lead to a premature layout() happening, which could show a flash of white.
3452 // See also the similar code in EventHandler::hitTestResultAtPoint. 3452 // See also the similar code in EventHandler::hitTestResultAtPoint.
3453 if (layoutViewItem().isNull() || !view() || !view()->didFirstLayout()) 3453 if (layoutViewItem().isNull() || !view() || !view()->didFirstLayout())
3454 return MouseEventWithHitTestResults(event, 3454 return MouseEventWithHitTestResults(event,
3455 HitTestResult(request, LayoutPoint())); 3455 HitTestResult(request, LayoutPoint()));
3456 3456
3457 HitTestResult result(request, documentPoint); 3457 HitTestResult result(request, documentPoint);
3458 layoutViewItem().hitTest(result); 3458 layoutViewItem().hitTest(result);
3459 3459
3460 if (!request.readOnly()) 3460 if (!request.readOnly())
3461 updateHoverActiveState(request, result.innerElement()); 3461 updateHoverActiveState(request, result.innerElement(), result.scrollbar());
3462 3462
3463 if (isHTMLCanvasElement(result.innerNode())) { 3463 if (isHTMLCanvasElement(result.innerNode())) {
3464 PlatformMouseEvent eventWithRegion = event; 3464 PlatformMouseEvent eventWithRegion = event;
3465 HitTestCanvasResult* hitTestCanvasResult = 3465 HitTestCanvasResult* hitTestCanvasResult =
3466 toHTMLCanvasElement(result.innerNode()) 3466 toHTMLCanvasElement(result.innerNode())
3467 ->getControlAndIdIfHitRegionExists(result.pointInInnerNodeFrame()); 3467 ->getControlAndIdIfHitRegionExists(result.pointInInnerNodeFrame());
3468 if (hitTestCanvasResult->getControl()) { 3468 if (hitTestCanvasResult->getControl()) {
3469 result.setInnerNode(hitTestCanvasResult->getControl()); 3469 result.setInnerNode(hitTestCanvasResult->getControl());
3470 } 3470 }
3471 eventWithRegion.setRegion(hitTestCanvasResult->getId()); 3471 eventWithRegion.setRegion(hitTestCanvasResult->getId());
(...skipping 2496 matching lines...) Expand 10 before | Expand all | Expand 10 after
5968 currObj2 = currObj2->hoverAncestor()) { 5968 currObj2 = currObj2->hoverAncestor()) {
5969 if (currObj1 == currObj2) 5969 if (currObj1 == currObj2)
5970 return currObj1; 5970 return currObj1;
5971 } 5971 }
5972 } 5972 }
5973 5973
5974 return 0; 5974 return 0;
5975 } 5975 }
5976 5976
5977 void Document::updateHoverActiveState(const HitTestRequest& request, 5977 void Document::updateHoverActiveState(const HitTestRequest& request,
5978 Element* innerElement) { 5978 Element* innerElement,
5979 bool hitScrollbar) {
5979 DCHECK(!request.readOnly()); 5980 DCHECK(!request.readOnly());
5980 5981
5981 if (request.active() && m_frame) 5982 if (request.active() && m_frame && !hitScrollbar)
5982 m_frame->eventHandler().notifyElementActivated(); 5983 m_frame->eventHandler().notifyElementActivated();
5983 5984
5984 Element* innerElementInDocument = innerElement; 5985 Element* innerElementInDocument = hitScrollbar ? nullptr : innerElement;
5985 while (innerElementInDocument && innerElementInDocument->document() != this) { 5986 while (innerElementInDocument && innerElementInDocument->document() != this) {
5986 innerElementInDocument->document().updateHoverActiveState( 5987 innerElementInDocument->document().updateHoverActiveState(
5987 request, innerElementInDocument); 5988 request, innerElementInDocument, hitScrollbar);
5988 innerElementInDocument = innerElementInDocument->document().localOwner(); 5989 innerElementInDocument = innerElementInDocument->document().localOwner();
5989 } 5990 }
5990 5991
5991 updateDistribution(); 5992 updateDistribution();
5992 Element* oldActiveElement = activeHoverElement(); 5993 Element* oldActiveElement = activeHoverElement();
5993 if (oldActiveElement && !request.active()) { 5994 if (oldActiveElement && (!request.active() || hitScrollbar)) {
5994 // The oldActiveElement layoutObject is null, dropped on :active by setting 5995 // The oldActiveElement layoutObject is null, dropped on :active by setting
5995 // display: none, for instance. We still need to clear the ActiveChain as 5996 // display: none, for instance. We still need to clear the ActiveChain as
5996 // the mouse is released. 5997 // the mouse is released.
5997 for (Node* node = oldActiveElement; node; 5998 for (Node* node = oldActiveElement; node;
5998 node = FlatTreeTraversal::parent(*node)) { 5999 node = FlatTreeTraversal::parent(*node)) {
5999 DCHECK(!node->isTextNode()); 6000 DCHECK(!node->isTextNode());
6000 node->setActive(false); 6001 node->setActive(false);
6001 m_userActionElements.setInActiveChain(node, false); 6002 m_userActionElements.setInActiveChain(node, false);
6002 } 6003 }
6003 setActiveHoverElement(nullptr); 6004 setActiveHoverElement(nullptr);
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
6477 } 6478 }
6478 6479
6479 void showLiveDocumentInstances() { 6480 void showLiveDocumentInstances() {
6480 WeakDocumentSet& set = liveDocumentSet(); 6481 WeakDocumentSet& set = liveDocumentSet();
6481 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6482 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6482 for (Document* document : set) 6483 for (Document* document : set)
6483 fprintf(stderr, "- Document %p URL: %s\n", document, 6484 fprintf(stderr, "- Document %p URL: %s\n", document,
6484 document->url().getString().utf8().data()); 6485 document->url().getString().utf8().data());
6485 } 6486 }
6486 #endif 6487 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/input/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698