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

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 2491953004: Reland of Fix link's hover state if the link under scrollbar (Closed)
Patch Set: Rebase 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) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // the first layout because until then, there is nothing shown on the screen - 270 // the first layout because until then, there is nothing shown on the screen -
271 // the user can't have intentionally clicked on something belonging to this 271 // the user can't have intentionally clicked on something belonging to this
272 // page. Furthermore, mousemove events before the first layout should not 272 // page. Furthermore, mousemove events before the first layout should not
273 // lead to a premature layout() happening, which could show a flash of white. 273 // lead to a premature layout() happening, which could show a flash of white.
274 // See also the similar code in Document::performMouseEventHitTest. 274 // See also the similar code in Document::performMouseEventHitTest.
275 if (m_frame->contentLayoutItem().isNull() || !m_frame->view() || 275 if (m_frame->contentLayoutItem().isNull() || !m_frame->view() ||
276 !m_frame->view()->didFirstLayout()) 276 !m_frame->view()->didFirstLayout())
277 return result; 277 return result;
278 278
279 m_frame->contentLayoutItem().hitTest(result); 279 m_frame->contentLayoutItem().hitTest(result);
280 if (!request.readOnly()) 280 if (!request.readOnly()) {
281 m_frame->document()->updateHoverActiveState(request, result.innerElement()); 281 m_frame->document()->updateHoverActiveState(request, result.innerElement(),
282 result.scrollbar());
283 }
282 284
283 return result; 285 return result;
284 } 286 }
285 287
286 void EventHandler::stopAutoscroll() { 288 void EventHandler::stopAutoscroll() {
287 m_scrollManager->stopAutoscroll(); 289 m_scrollManager->stopAutoscroll();
288 } 290 }
289 291
290 // TODO(bokan): This should be merged with logicalScroll assuming 292 // TODO(bokan): This should be merged with logicalScroll assuming
291 // defaultSpaceEventHandler's chaining scroll can be done crossing frames. 293 // defaultSpaceEventHandler's chaining scroll can be done crossing frames.
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 return grabCursor(); 523 return grabCursor();
522 case CURSOR_WEBKIT_GRABBING: 524 case CURSOR_WEBKIT_GRABBING:
523 return grabbingCursor(); 525 return grabbingCursor();
524 } 526 }
525 return pointerCursor(); 527 return pointerCursor();
526 } 528 }
527 529
528 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, 530 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result,
529 Node* node, 531 Node* node,
530 const Cursor& iBeam) { 532 const Cursor& iBeam) {
533 if (result.scrollbar()) {
534 return pointerCursor();
535 }
536
531 bool editable = (node && hasEditableStyle(*node)); 537 bool editable = (node && hasEditableStyle(*node));
532 538
533 const bool isOverLink = 539 const bool isOverLink =
534 !selectionController().mouseDownMayStartSelect() && result.isOverLink(); 540 !selectionController().mouseDownMayStartSelect() && result.isOverLink();
535 if (useHandCursor(node, isOverLink)) 541 if (useHandCursor(node, isOverLink))
536 return handCursor(); 542 return handCursor();
537 543
538 bool inResizer = false; 544 bool inResizer = false;
539 LayoutObject* layoutObject = node ? node->layoutObject() : nullptr; 545 LayoutObject* layoutObject = node ? node->layoutObject() : nullptr;
540 if (layoutObject && m_frame->view()) { 546 if (layoutObject && m_frame->view()) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly; 809 hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly;
804 HitTestRequest request(hitType); 810 HitTestRequest request(hitType);
805 MouseEventWithHitTestResults mev = MouseEventWithHitTestResults( 811 MouseEventWithHitTestResults mev = MouseEventWithHitTestResults(
806 mouseEvent, HitTestResult(request, LayoutPoint())); 812 mouseEvent, HitTestResult(request, LayoutPoint()));
807 813
808 // We don't want to do a hit-test in forceLeave scenarios because there might 814 // We don't want to do a hit-test in forceLeave scenarios because there might
809 // actually be some other frame above this one at the specified co-ordinate. 815 // actually be some other frame above this one at the specified co-ordinate.
810 // So we must force the hit-test to fail, while still clearing hover/active 816 // So we must force the hit-test to fail, while still clearing hover/active
811 // state. 817 // state.
812 if (forceLeave) { 818 if (forceLeave) {
813 m_frame->document()->updateHoverActiveState(request, 0); 819 m_frame->document()->updateHoverActiveState(request, nullptr, false);
814 } else { 820 } else {
815 mev = EventHandlingUtil::performMouseEventHitTest(m_frame, request, 821 mev = EventHandlingUtil::performMouseEventHitTest(m_frame, request,
816 mouseEvent); 822 mouseEvent);
817 } 823 }
818 824
819 if (hoveredNode) 825 if (hoveredNode)
820 *hoveredNode = mev.hitTestResult(); 826 *hoveredNode = mev.hitTestResult();
821 827
822 Scrollbar* scrollbar = nullptr; 828 Scrollbar* scrollbar = nullptr;
823 829
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 1523
1518 LocalFrame* oldHoverFrame = toLocalFrame(owner->contentFrame()); 1524 LocalFrame* oldHoverFrame = toLocalFrame(owner->contentFrame());
1519 Document* doc = oldHoverFrame->document(); 1525 Document* doc = oldHoverFrame->document();
1520 if (!doc) 1526 if (!doc)
1521 break; 1527 break;
1522 1528
1523 oldHoverNodeInCurDoc = doc->hoverNode(); 1529 oldHoverNodeInCurDoc = doc->hoverNode();
1524 // If the old hovered frame is different from the new hovered frame. 1530 // If the old hovered frame is different from the new hovered frame.
1525 // we should clear the old hovered node from the old hovered frame. 1531 // we should clear the old hovered node from the old hovered frame.
1526 if (newHoverFrame != oldHoverFrame) 1532 if (newHoverFrame != oldHoverFrame)
1527 doc->updateHoverActiveState(request, nullptr); 1533 doc->updateHoverActiveState(request, nullptr, false);
1528 } 1534 }
1529 } 1535 }
1530 1536
1531 // Recursively set the new active/hover states on every frame in the chain of 1537 // Recursively set the new active/hover states on every frame in the chain of
1532 // innerElement. 1538 // innerElement.
1533 m_frame->document()->updateHoverActiveState(request, innerElement); 1539 m_frame->document()->updateHoverActiveState(request, innerElement, false);
1534 } 1540 }
1535 1541
1536 // Update the mouseover/mouseenter/mouseout/mouseleave events across all frames 1542 // Update the mouseover/mouseenter/mouseout/mouseleave events across all frames
1537 // for this gesture, before passing the targeted gesture event directly to a hit 1543 // for this gesture, before passing the targeted gesture event directly to a hit
1538 // frame. 1544 // frame.
1539 void EventHandler::updateGestureTargetNodeForMouseEvent( 1545 void EventHandler::updateGestureTargetNodeForMouseEvent(
1540 const GestureEventWithHitTestResults& targetedEvent) { 1546 const GestureEventWithHitTestResults& targetedEvent) {
1541 ASSERT(m_frame == m_frame->localFrameRoot()); 1547 ASSERT(m_frame == m_frame->localFrameRoot());
1542 1548
1543 // Behaviour of this function is as follows: 1549 // Behaviour of this function is as follows:
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 1855
1850 Node* targetNode = 1856 Node* targetNode =
1851 overrideTargetElement ? overrideTargetElement : doc->focusedElement(); 1857 overrideTargetElement ? overrideTargetElement : doc->focusedElement();
1852 if (!targetNode) 1858 if (!targetNode)
1853 targetNode = doc; 1859 targetNode = doc;
1854 1860
1855 // Use the focused node as the target for hover and active. 1861 // Use the focused node as the target for hover and active.
1856 HitTestRequest request(HitTestRequest::Active); 1862 HitTestRequest request(HitTestRequest::Active);
1857 HitTestResult result(request, locationInRootFrame); 1863 HitTestResult result(request, locationInRootFrame);
1858 result.setInnerNode(targetNode); 1864 result.setInnerNode(targetNode);
1859 doc->updateHoverActiveState(request, result.innerElement()); 1865 doc->updateHoverActiveState(request, result.innerElement(),
1866 result.scrollbar());
1860 1867
1861 // The contextmenu event is a mouse event even when invoked using the 1868 // The contextmenu event is a mouse event even when invoked using the
1862 // keyboard. This is required for web compatibility. 1869 // keyboard. This is required for web compatibility.
1863 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; 1870 PlatformEvent::EventType eventType = PlatformEvent::MousePressed;
1864 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) 1871 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp())
1865 eventType = PlatformEvent::MouseReleased; 1872 eventType = PlatformEvent::MouseReleased;
1866 1873
1867 PlatformMouseEvent mouseEvent( 1874 PlatformMouseEvent mouseEvent(
1868 locationInRootFrame, globalPosition, 1875 locationInRootFrame, globalPosition,
1869 WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0, 1876 WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 ASSERT(m_frame); 1922 ASSERT(m_frame);
1916 ASSERT(m_frame->document()); 1923 ASSERT(m_frame->document());
1917 1924
1918 if (LayoutViewItem layoutItem = m_frame->contentLayoutItem()) { 1925 if (LayoutViewItem layoutItem = m_frame->contentLayoutItem()) {
1919 if (FrameView* view = m_frame->view()) { 1926 if (FrameView* view = m_frame->view()) {
1920 HitTestRequest request(HitTestRequest::Move); 1927 HitTestRequest request(HitTestRequest::Move);
1921 HitTestResult result(request, 1928 HitTestResult result(request,
1922 view->rootFrameToContents( 1929 view->rootFrameToContents(
1923 m_mouseEventManager->lastKnownMousePosition())); 1930 m_mouseEventManager->lastKnownMousePosition()));
1924 layoutItem.hitTest(result); 1931 layoutItem.hitTest(result);
1925 m_frame->document()->updateHoverActiveState(request, 1932 m_frame->document()->updateHoverActiveState(
1926 result.innerElement()); 1933 request, result.innerElement(), result.scrollbar());
1927 } 1934 }
1928 } 1935 }
1929 } 1936 }
1930 1937
1931 void EventHandler::activeIntervalTimerFired(TimerBase*) { 1938 void EventHandler::activeIntervalTimerFired(TimerBase*) {
1932 TRACE_EVENT0("input", "EventHandler::activeIntervalTimerFired"); 1939 TRACE_EVENT0("input", "EventHandler::activeIntervalTimerFired");
1933 m_activeIntervalTimer.stop(); 1940 m_activeIntervalTimer.stop();
1934 1941
1935 if (m_frame && m_frame->document() && m_lastDeferredTapElement) { 1942 if (m_frame && m_frame->document() && m_lastDeferredTapElement) {
1936 // FIXME: Enable condition when http://crbug.com/226842 lands 1943 // FIXME: Enable condition when http://crbug.com/226842 lands
1937 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement() 1944 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement()
1938 HitTestRequest request(HitTestRequest::TouchEvent | 1945 HitTestRequest request(HitTestRequest::TouchEvent |
1939 HitTestRequest::Release); 1946 HitTestRequest::Release);
1940 m_frame->document()->updateHoverActiveState(request, 1947 m_frame->document()->updateHoverActiveState(
1941 m_lastDeferredTapElement.get()); 1948 request, m_lastDeferredTapElement.get(), false);
1942 } 1949 }
1943 m_lastDeferredTapElement = nullptr; 1950 m_lastDeferredTapElement = nullptr;
1944 } 1951 }
1945 1952
1946 void EventHandler::notifyElementActivated() { 1953 void EventHandler::notifyElementActivated() {
1947 // Since another element has been set to active, stop current timer and clear 1954 // Since another element has been set to active, stop current timer and clear
1948 // reference. 1955 // reference.
1949 m_activeIntervalTimer.stop(); 1956 m_activeIntervalTimer.stop();
1950 m_lastDeferredTapElement = nullptr; 1957 m_lastDeferredTapElement = nullptr;
1951 } 1958 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 } 2106 }
2100 2107
2101 FrameHost* EventHandler::frameHost() const { 2108 FrameHost* EventHandler::frameHost() const {
2102 if (!m_frame->page()) 2109 if (!m_frame->page())
2103 return nullptr; 2110 return nullptr;
2104 2111
2105 return &m_frame->page()->frameHost(); 2112 return &m_frame->page()->frameHost();
2106 } 2113 }
2107 2114
2108 } // namespace blink 2115 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/page/ChromeClient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698