| OLD | NEW |
| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 // the first layout because until then, there is nothing shown on the screen - | 271 // the first layout because until then, there is nothing shown on the screen - |
| 272 // the user can't have intentionally clicked on something belonging to this | 272 // the user can't have intentionally clicked on something belonging to this |
| 273 // page. Furthermore, mousemove events before the first layout should not | 273 // page. Furthermore, mousemove events before the first layout should not |
| 274 // lead to a premature layout() happening, which could show a flash of white. | 274 // lead to a premature layout() happening, which could show a flash of white. |
| 275 // See also the similar code in Document::performMouseEventHitTest. | 275 // See also the similar code in Document::performMouseEventHitTest. |
| 276 if (m_frame->contentLayoutItem().isNull() || !m_frame->view() || | 276 if (m_frame->contentLayoutItem().isNull() || !m_frame->view() || |
| 277 !m_frame->view()->didFirstLayout()) | 277 !m_frame->view()->didFirstLayout()) |
| 278 return result; | 278 return result; |
| 279 | 279 |
| 280 m_frame->contentLayoutItem().hitTest(result); | 280 m_frame->contentLayoutItem().hitTest(result); |
| 281 if (!request.readOnly()) { | 281 if (!request.readOnly()) |
| 282 m_frame->document()->updateHoverActiveState(request, result.innerElement(), | 282 m_frame->document()->updateHoverActiveState(request, result.innerElement()); |
| 283 result.scrollbar()); | |
| 284 } | |
| 285 | 283 |
| 286 return result; | 284 return result; |
| 287 } | 285 } |
| 288 | 286 |
| 289 void EventHandler::stopAutoscroll() { | 287 void EventHandler::stopAutoscroll() { |
| 290 m_scrollManager->stopAutoscroll(); | 288 m_scrollManager->stopAutoscroll(); |
| 291 } | 289 } |
| 292 | 290 |
| 293 // TODO(bokan): This should be merged with logicalScroll assuming | 291 // TODO(bokan): This should be merged with logicalScroll assuming |
| 294 // defaultSpaceEventHandler's chaining scroll can be done crossing frames. | 292 // defaultSpaceEventHandler's chaining scroll can be done crossing frames. |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 return grabCursor(); | 522 return grabCursor(); |
| 525 case CURSOR_WEBKIT_GRABBING: | 523 case CURSOR_WEBKIT_GRABBING: |
| 526 return grabbingCursor(); | 524 return grabbingCursor(); |
| 527 } | 525 } |
| 528 return pointerCursor(); | 526 return pointerCursor(); |
| 529 } | 527 } |
| 530 | 528 |
| 531 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, | 529 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, |
| 532 Node* node, | 530 Node* node, |
| 533 const Cursor& iBeam) { | 531 const Cursor& iBeam) { |
| 534 if (result.scrollbar()) { | |
| 535 return pointerCursor(); | |
| 536 } | |
| 537 | |
| 538 bool editable = (node && hasEditableStyle(*node)); | 532 bool editable = (node && hasEditableStyle(*node)); |
| 539 | 533 |
| 540 const bool isOverLink = | 534 const bool isOverLink = |
| 541 !selectionController().mouseDownMayStartSelect() && result.isOverLink(); | 535 !selectionController().mouseDownMayStartSelect() && result.isOverLink(); |
| 542 if (useHandCursor(node, isOverLink)) | 536 if (useHandCursor(node, isOverLink)) |
| 543 return handCursor(); | 537 return handCursor(); |
| 544 | 538 |
| 545 bool inResizer = false; | 539 bool inResizer = false; |
| 546 LayoutObject* layoutObject = node ? node->layoutObject() : nullptr; | 540 LayoutObject* layoutObject = node ? node->layoutObject() : nullptr; |
| 547 if (layoutObject && m_frame->view()) { | 541 if (layoutObject && m_frame->view()) { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly; | 804 hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly; |
| 811 HitTestRequest request(hitType); | 805 HitTestRequest request(hitType); |
| 812 MouseEventWithHitTestResults mev = MouseEventWithHitTestResults( | 806 MouseEventWithHitTestResults mev = MouseEventWithHitTestResults( |
| 813 mouseEvent, HitTestResult(request, LayoutPoint())); | 807 mouseEvent, HitTestResult(request, LayoutPoint())); |
| 814 | 808 |
| 815 // We don't want to do a hit-test in forceLeave scenarios because there might | 809 // We don't want to do a hit-test in forceLeave scenarios because there might |
| 816 // actually be some other frame above this one at the specified co-ordinate. | 810 // actually be some other frame above this one at the specified co-ordinate. |
| 817 // So we must force the hit-test to fail, while still clearing hover/active | 811 // So we must force the hit-test to fail, while still clearing hover/active |
| 818 // state. | 812 // state. |
| 819 if (forceLeave) { | 813 if (forceLeave) { |
| 820 m_frame->document()->updateHoverActiveState(request, nullptr, false); | 814 m_frame->document()->updateHoverActiveState(request, 0); |
| 821 } else { | 815 } else { |
| 822 mev = EventHandlingUtil::performMouseEventHitTest(m_frame, request, | 816 mev = EventHandlingUtil::performMouseEventHitTest(m_frame, request, |
| 823 mouseEvent); | 817 mouseEvent); |
| 824 } | 818 } |
| 825 | 819 |
| 826 if (hoveredNode) | 820 if (hoveredNode) |
| 827 *hoveredNode = mev.hitTestResult(); | 821 *hoveredNode = mev.hitTestResult(); |
| 828 | 822 |
| 829 Scrollbar* scrollbar = nullptr; | 823 Scrollbar* scrollbar = nullptr; |
| 830 | 824 |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 | 1518 |
| 1525 LocalFrame* oldHoverFrame = toLocalFrame(owner->contentFrame()); | 1519 LocalFrame* oldHoverFrame = toLocalFrame(owner->contentFrame()); |
| 1526 Document* doc = oldHoverFrame->document(); | 1520 Document* doc = oldHoverFrame->document(); |
| 1527 if (!doc) | 1521 if (!doc) |
| 1528 break; | 1522 break; |
| 1529 | 1523 |
| 1530 oldHoverNodeInCurDoc = doc->hoverNode(); | 1524 oldHoverNodeInCurDoc = doc->hoverNode(); |
| 1531 // If the old hovered frame is different from the new hovered frame. | 1525 // If the old hovered frame is different from the new hovered frame. |
| 1532 // we should clear the old hovered node from the old hovered frame. | 1526 // we should clear the old hovered node from the old hovered frame. |
| 1533 if (newHoverFrame != oldHoverFrame) | 1527 if (newHoverFrame != oldHoverFrame) |
| 1534 doc->updateHoverActiveState(request, nullptr, false); | 1528 doc->updateHoverActiveState(request, nullptr); |
| 1535 } | 1529 } |
| 1536 } | 1530 } |
| 1537 | 1531 |
| 1538 // Recursively set the new active/hover states on every frame in the chain of | 1532 // Recursively set the new active/hover states on every frame in the chain of |
| 1539 // innerElement. | 1533 // innerElement. |
| 1540 m_frame->document()->updateHoverActiveState(request, innerElement, false); | 1534 m_frame->document()->updateHoverActiveState(request, innerElement); |
| 1541 } | 1535 } |
| 1542 | 1536 |
| 1543 // Update the mouseover/mouseenter/mouseout/mouseleave events across all frames | 1537 // Update the mouseover/mouseenter/mouseout/mouseleave events across all frames |
| 1544 // for this gesture, before passing the targeted gesture event directly to a hit | 1538 // for this gesture, before passing the targeted gesture event directly to a hit |
| 1545 // frame. | 1539 // frame. |
| 1546 void EventHandler::updateGestureTargetNodeForMouseEvent( | 1540 void EventHandler::updateGestureTargetNodeForMouseEvent( |
| 1547 const GestureEventWithHitTestResults& targetedEvent) { | 1541 const GestureEventWithHitTestResults& targetedEvent) { |
| 1548 ASSERT(m_frame == m_frame->localFrameRoot()); | 1542 ASSERT(m_frame == m_frame->localFrameRoot()); |
| 1549 | 1543 |
| 1550 // Behaviour of this function is as follows: | 1544 // Behaviour of this function is as follows: |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 | 1850 |
| 1857 Node* targetNode = | 1851 Node* targetNode = |
| 1858 overrideTargetElement ? overrideTargetElement : doc->focusedElement(); | 1852 overrideTargetElement ? overrideTargetElement : doc->focusedElement(); |
| 1859 if (!targetNode) | 1853 if (!targetNode) |
| 1860 targetNode = doc; | 1854 targetNode = doc; |
| 1861 | 1855 |
| 1862 // Use the focused node as the target for hover and active. | 1856 // Use the focused node as the target for hover and active. |
| 1863 HitTestRequest request(HitTestRequest::Active); | 1857 HitTestRequest request(HitTestRequest::Active); |
| 1864 HitTestResult result(request, locationInRootFrame); | 1858 HitTestResult result(request, locationInRootFrame); |
| 1865 result.setInnerNode(targetNode); | 1859 result.setInnerNode(targetNode); |
| 1866 doc->updateHoverActiveState(request, result.innerElement(), | 1860 doc->updateHoverActiveState(request, result.innerElement()); |
| 1867 result.scrollbar()); | |
| 1868 | 1861 |
| 1869 // The contextmenu event is a mouse event even when invoked using the | 1862 // The contextmenu event is a mouse event even when invoked using the |
| 1870 // keyboard. This is required for web compatibility. | 1863 // keyboard. This is required for web compatibility. |
| 1871 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; | 1864 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; |
| 1872 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) | 1865 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) |
| 1873 eventType = PlatformEvent::MouseReleased; | 1866 eventType = PlatformEvent::MouseReleased; |
| 1874 | 1867 |
| 1875 PlatformMouseEvent mouseEvent( | 1868 PlatformMouseEvent mouseEvent( |
| 1876 locationInRootFrame, globalPosition, | 1869 locationInRootFrame, globalPosition, |
| 1877 WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0, | 1870 WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1923 ASSERT(m_frame); | 1916 ASSERT(m_frame); |
| 1924 ASSERT(m_frame->document()); | 1917 ASSERT(m_frame->document()); |
| 1925 | 1918 |
| 1926 if (LayoutViewItem layoutItem = m_frame->contentLayoutItem()) { | 1919 if (LayoutViewItem layoutItem = m_frame->contentLayoutItem()) { |
| 1927 if (FrameView* view = m_frame->view()) { | 1920 if (FrameView* view = m_frame->view()) { |
| 1928 HitTestRequest request(HitTestRequest::Move); | 1921 HitTestRequest request(HitTestRequest::Move); |
| 1929 HitTestResult result(request, | 1922 HitTestResult result(request, |
| 1930 view->rootFrameToContents( | 1923 view->rootFrameToContents( |
| 1931 m_mouseEventManager->lastKnownMousePosition())); | 1924 m_mouseEventManager->lastKnownMousePosition())); |
| 1932 layoutItem.hitTest(result); | 1925 layoutItem.hitTest(result); |
| 1933 m_frame->document()->updateHoverActiveState( | 1926 m_frame->document()->updateHoverActiveState(request, |
| 1934 request, result.innerElement(), result.scrollbar()); | 1927 result.innerElement()); |
| 1935 } | 1928 } |
| 1936 } | 1929 } |
| 1937 } | 1930 } |
| 1938 | 1931 |
| 1939 void EventHandler::activeIntervalTimerFired(TimerBase*) { | 1932 void EventHandler::activeIntervalTimerFired(TimerBase*) { |
| 1940 TRACE_EVENT0("input", "EventHandler::activeIntervalTimerFired"); | 1933 TRACE_EVENT0("input", "EventHandler::activeIntervalTimerFired"); |
| 1941 m_activeIntervalTimer.stop(); | 1934 m_activeIntervalTimer.stop(); |
| 1942 | 1935 |
| 1943 if (m_frame && m_frame->document() && m_lastDeferredTapElement) { | 1936 if (m_frame && m_frame->document() && m_lastDeferredTapElement) { |
| 1944 // FIXME: Enable condition when http://crbug.com/226842 lands | 1937 // FIXME: Enable condition when http://crbug.com/226842 lands |
| 1945 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement() | 1938 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement() |
| 1946 HitTestRequest request(HitTestRequest::TouchEvent | | 1939 HitTestRequest request(HitTestRequest::TouchEvent | |
| 1947 HitTestRequest::Release); | 1940 HitTestRequest::Release); |
| 1948 m_frame->document()->updateHoverActiveState( | 1941 m_frame->document()->updateHoverActiveState(request, |
| 1949 request, m_lastDeferredTapElement.get(), false); | 1942 m_lastDeferredTapElement.get()); |
| 1950 } | 1943 } |
| 1951 m_lastDeferredTapElement = nullptr; | 1944 m_lastDeferredTapElement = nullptr; |
| 1952 } | 1945 } |
| 1953 | 1946 |
| 1954 void EventHandler::notifyElementActivated() { | 1947 void EventHandler::notifyElementActivated() { |
| 1955 // Since another element has been set to active, stop current timer and clear | 1948 // Since another element has been set to active, stop current timer and clear |
| 1956 // reference. | 1949 // reference. |
| 1957 m_activeIntervalTimer.stop(); | 1950 m_activeIntervalTimer.stop(); |
| 1958 m_lastDeferredTapElement = nullptr; | 1951 m_lastDeferredTapElement = nullptr; |
| 1959 } | 1952 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2093 } | 2086 } |
| 2094 | 2087 |
| 2095 FrameHost* EventHandler::frameHost() const { | 2088 FrameHost* EventHandler::frameHost() const { |
| 2096 if (!m_frame->page()) | 2089 if (!m_frame->page()) |
| 2097 return nullptr; | 2090 return nullptr; |
| 2098 | 2091 |
| 2099 return &m_frame->page()->frameHost(); | 2092 return &m_frame->page()->frameHost(); |
| 2100 } | 2093 } |
| 2101 | 2094 |
| 2102 } // namespace blink | 2095 } // namespace blink |
| OLD | NEW |