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