| 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly; | 817 hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly; |
| 820 HitTestRequest request(hitType); | 818 HitTestRequest request(hitType); |
| 821 MouseEventWithHitTestResults mev = MouseEventWithHitTestResults( | 819 MouseEventWithHitTestResults mev = MouseEventWithHitTestResults( |
| 822 mouseEvent, HitTestResult(request, LayoutPoint())); | 820 mouseEvent, HitTestResult(request, LayoutPoint())); |
| 823 | 821 |
| 824 // We don't want to do a hit-test in forceLeave scenarios because there might | 822 // We don't want to do a hit-test in forceLeave scenarios because there might |
| 825 // actually be some other frame above this one at the specified co-ordinate. | 823 // actually be some other frame above this one at the specified co-ordinate. |
| 826 // So we must force the hit-test to fail, while still clearing hover/active | 824 // So we must force the hit-test to fail, while still clearing hover/active |
| 827 // state. | 825 // state. |
| 828 if (forceLeave) { | 826 if (forceLeave) { |
| 829 m_frame->document()->updateHoverActiveState(request, nullptr, nullptr); | 827 m_frame->document()->updateHoverActiveState(request, nullptr); |
| 830 } else { | 828 } else { |
| 831 mev = EventHandlingUtil::performMouseEventHitTest(m_frame, request, | 829 mev = EventHandlingUtil::performMouseEventHitTest(m_frame, request, |
| 832 mouseEvent); | 830 mouseEvent); |
| 833 } | 831 } |
| 834 | 832 |
| 835 if (hoveredNode) | 833 if (hoveredNode) |
| 836 *hoveredNode = mev.hitTestResult(); | 834 *hoveredNode = mev.hitTestResult(); |
| 837 | 835 |
| 838 Scrollbar* scrollbar = nullptr; | 836 Scrollbar* scrollbar = nullptr; |
| 839 | 837 |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 | 1494 |
| 1497 LocalFrame* oldHoverFrame = toLocalFrame(owner->contentFrame()); | 1495 LocalFrame* oldHoverFrame = toLocalFrame(owner->contentFrame()); |
| 1498 Document* doc = oldHoverFrame->document(); | 1496 Document* doc = oldHoverFrame->document(); |
| 1499 if (!doc) | 1497 if (!doc) |
| 1500 break; | 1498 break; |
| 1501 | 1499 |
| 1502 oldHoverNodeInCurDoc = doc->hoverNode(); | 1500 oldHoverNodeInCurDoc = doc->hoverNode(); |
| 1503 // If the old hovered frame is different from the new hovered frame. | 1501 // If the old hovered frame is different from the new hovered frame. |
| 1504 // we should clear the old hovered node from the old hovered frame. | 1502 // we should clear the old hovered node from the old hovered frame. |
| 1505 if (newHoverFrame != oldHoverFrame) | 1503 if (newHoverFrame != oldHoverFrame) |
| 1506 doc->updateHoverActiveState(request, nullptr, nullptr); | 1504 doc->updateHoverActiveState(request, nullptr); |
| 1507 } | 1505 } |
| 1508 } | 1506 } |
| 1509 | 1507 |
| 1510 // Recursively set the new active/hover states on every frame in the chain of | 1508 // Recursively set the new active/hover states on every frame in the chain of |
| 1511 // innerElement. | 1509 // innerElement. |
| 1512 m_frame->document()->updateHoverActiveState(request, innerElement, nullptr); | 1510 m_frame->document()->updateHoverActiveState(request, innerElement); |
| 1513 } | 1511 } |
| 1514 | 1512 |
| 1515 // Update the mouseover/mouseenter/mouseout/mouseleave events across all frames | 1513 // Update the mouseover/mouseenter/mouseout/mouseleave events across all frames |
| 1516 // for this gesture, before passing the targeted gesture event directly to a hit | 1514 // for this gesture, before passing the targeted gesture event directly to a hit |
| 1517 // frame. | 1515 // frame. |
| 1518 void EventHandler::updateGestureTargetNodeForMouseEvent( | 1516 void EventHandler::updateGestureTargetNodeForMouseEvent( |
| 1519 const GestureEventWithHitTestResults& targetedEvent) { | 1517 const GestureEventWithHitTestResults& targetedEvent) { |
| 1520 ASSERT(m_frame == m_frame->localFrameRoot()); | 1518 ASSERT(m_frame == m_frame->localFrameRoot()); |
| 1521 | 1519 |
| 1522 // Behaviour of this function is as follows: | 1520 // Behaviour of this function is as follows: |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1835 | 1833 |
| 1836 Node* targetNode = | 1834 Node* targetNode = |
| 1837 overrideTargetElement ? overrideTargetElement : doc->focusedElement(); | 1835 overrideTargetElement ? overrideTargetElement : doc->focusedElement(); |
| 1838 if (!targetNode) | 1836 if (!targetNode) |
| 1839 targetNode = doc; | 1837 targetNode = doc; |
| 1840 | 1838 |
| 1841 // Use the focused node as the target for hover and active. | 1839 // Use the focused node as the target for hover and active. |
| 1842 HitTestRequest request(HitTestRequest::Active); | 1840 HitTestRequest request(HitTestRequest::Active); |
| 1843 HitTestResult result(request, locationInRootFrame); | 1841 HitTestResult result(request, locationInRootFrame); |
| 1844 result.setInnerNode(targetNode); | 1842 result.setInnerNode(targetNode); |
| 1845 doc->updateHoverActiveState(request, result.innerElement(), | 1843 doc->updateHoverActiveState(request, result.innerElement()); |
| 1846 result.scrollbar()); | |
| 1847 | 1844 |
| 1848 // The contextmenu event is a mouse event even when invoked using the | 1845 // The contextmenu event is a mouse event even when invoked using the |
| 1849 // keyboard. This is required for web compatibility. | 1846 // keyboard. This is required for web compatibility. |
| 1850 WebInputEvent::Type eventType = WebInputEvent::MouseDown; | 1847 WebInputEvent::Type eventType = WebInputEvent::MouseDown; |
| 1851 if (m_frame->settings() && m_frame->settings()->getShowContextMenuOnMouseUp()) | 1848 if (m_frame->settings() && m_frame->settings()->getShowContextMenuOnMouseUp()) |
| 1852 eventType = WebInputEvent::MouseUp; | 1849 eventType = WebInputEvent::MouseUp; |
| 1853 | 1850 |
| 1854 WebMouseEvent mouseEvent( | 1851 WebMouseEvent mouseEvent( |
| 1855 eventType, | 1852 eventType, |
| 1856 WebFloatPoint(locationInRootFrame.x(), locationInRootFrame.y()), | 1853 WebFloatPoint(locationInRootFrame.x(), locationInRootFrame.y()), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 ASSERT(m_frame); | 1905 ASSERT(m_frame); |
| 1909 ASSERT(m_frame->document()); | 1906 ASSERT(m_frame->document()); |
| 1910 | 1907 |
| 1911 if (LayoutViewItem layoutItem = m_frame->contentLayoutItem()) { | 1908 if (LayoutViewItem layoutItem = m_frame->contentLayoutItem()) { |
| 1912 if (FrameView* view = m_frame->view()) { | 1909 if (FrameView* view = m_frame->view()) { |
| 1913 HitTestRequest request(HitTestRequest::Move); | 1910 HitTestRequest request(HitTestRequest::Move); |
| 1914 HitTestResult result(request, | 1911 HitTestResult result(request, |
| 1915 view->rootFrameToContents( | 1912 view->rootFrameToContents( |
| 1916 m_mouseEventManager->lastKnownMousePosition())); | 1913 m_mouseEventManager->lastKnownMousePosition())); |
| 1917 layoutItem.hitTest(result); | 1914 layoutItem.hitTest(result); |
| 1918 m_frame->document()->updateHoverActiveState( | 1915 m_frame->document()->updateHoverActiveState(request, |
| 1919 request, result.innerElement(), result.scrollbar()); | 1916 result.innerElement()); |
| 1920 } | 1917 } |
| 1921 } | 1918 } |
| 1922 } | 1919 } |
| 1923 | 1920 |
| 1924 void EventHandler::activeIntervalTimerFired(TimerBase*) { | 1921 void EventHandler::activeIntervalTimerFired(TimerBase*) { |
| 1925 TRACE_EVENT0("input", "EventHandler::activeIntervalTimerFired"); | 1922 TRACE_EVENT0("input", "EventHandler::activeIntervalTimerFired"); |
| 1926 | 1923 |
| 1927 if (m_frame && m_frame->document() && m_lastDeferredTapElement) { | 1924 if (m_frame && m_frame->document() && m_lastDeferredTapElement) { |
| 1928 // FIXME: Enable condition when http://crbug.com/226842 lands | 1925 // FIXME: Enable condition when http://crbug.com/226842 lands |
| 1929 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement() | 1926 // m_lastDeferredTapElement.get() == m_frame->document()->activeElement() |
| 1930 HitTestRequest request(HitTestRequest::TouchEvent | | 1927 HitTestRequest request(HitTestRequest::TouchEvent | |
| 1931 HitTestRequest::Release); | 1928 HitTestRequest::Release); |
| 1932 m_frame->document()->updateHoverActiveState( | 1929 m_frame->document()->updateHoverActiveState(request, |
| 1933 request, m_lastDeferredTapElement.get(), nullptr); | 1930 m_lastDeferredTapElement.get()); |
| 1934 } | 1931 } |
| 1935 m_lastDeferredTapElement = nullptr; | 1932 m_lastDeferredTapElement = nullptr; |
| 1936 } | 1933 } |
| 1937 | 1934 |
| 1938 void EventHandler::notifyElementActivated() { | 1935 void EventHandler::notifyElementActivated() { |
| 1939 // Since another element has been set to active, stop current timer and clear | 1936 // Since another element has been set to active, stop current timer and clear |
| 1940 // reference. | 1937 // reference. |
| 1941 m_activeIntervalTimer.stop(); | 1938 m_activeIntervalTimer.stop(); |
| 1942 m_lastDeferredTapElement = nullptr; | 1939 m_lastDeferredTapElement = nullptr; |
| 1943 } | 1940 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2086 MouseEventWithHitTestResults& mev, | 2083 MouseEventWithHitTestResults& mev, |
| 2087 LocalFrame* subframe) { | 2084 LocalFrame* subframe) { |
| 2088 WebInputEventResult result = | 2085 WebInputEventResult result = |
| 2089 subframe->eventHandler().handleMouseReleaseEvent(mev.event()); | 2086 subframe->eventHandler().handleMouseReleaseEvent(mev.event()); |
| 2090 if (result != WebInputEventResult::NotHandled) | 2087 if (result != WebInputEventResult::NotHandled) |
| 2091 return result; | 2088 return result; |
| 2092 return WebInputEventResult::HandledSystem; | 2089 return WebInputEventResult::HandledSystem; |
| 2093 } | 2090 } |
| 2094 | 2091 |
| 2095 } // namespace blink | 2092 } // namespace blink |
| OLD | NEW |