OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. |
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
855 FrameView* view = m_frame->view(); | 855 FrameView* view = m_frame->view(); |
856 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l ayoutObject()->enclosingLayer() : nullptr; | 856 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l ayoutObject()->enclosingLayer() : nullptr; |
857 IntPoint p = view->rootFrameToContents(mouseEvent.position()); | 857 IntPoint p = view->rootFrameToContents(mouseEvent.position()); |
858 if (layer && layer->getScrollableArea() && layer->getScrollableArea()->i sPointInResizeControl(p, ResizerForPointer)) { | 858 if (layer && layer->getScrollableArea() && layer->getScrollableArea()->i sPointInResizeControl(p, ResizerForPointer)) { |
859 m_scrollManager.setResizeScrollableArea(layer, p); | 859 m_scrollManager.setResizeScrollableArea(layer, p); |
860 return WebInputEventResult::HandledSystem; | 860 return WebInputEventResult::HandledSystem; |
861 } | 861 } |
862 } | 862 } |
863 | 863 |
864 // m_selectionInitiationState is initialized after dispatching mousedown | 864 // m_selectionInitiationState is initialized after dispatching mousedown |
865 // event in order not to keep the selection by DOM APIs Because we can't | 865 // event in order not to keep the selection by DOM APIs because we can't |
866 // give the user the chance to handle the selection by user action like | 866 // give the user the chance to handle the selection by user action like |
867 // dragging if we keep the selection in case of mousedown. FireFox also has | 867 // dragging if we keep the selection in case of mousedown. FireFox also has |
868 // the same behavior and it's more compatible with other browsers. | 868 // the same behavior and it's more compatible with other browsers. |
869 selectionController().initializeSelectionState(); | 869 selectionController().initializeSelectionState(); |
870 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly); | 870 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly); |
871 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventTy pe() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEvent sSourceCapabilities() : | 871 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventTy pe() == PlatformMouseEvent::FromTouch |
dtapuska
2016/07/20 16:26:08
Is this "git cl format" doing the formatting chang
mustaq
2016/07/20 16:36:44
Done.
| |
872 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); | 872 ? InputDeviceCapabilities::firesTouchEventsSourceCapabilities() |
873 : InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); | |
873 if (eventResult == WebInputEventResult::NotHandled) | 874 if (eventResult == WebInputEventResult::NotHandled) |
874 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mev.event(), hitTestResult), sourceCapabilities); | 875 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mev.event(), hitTestResult), sourceCapabilities); |
875 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar(); | 876 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar(); |
876 | 877 |
877 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults | 878 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults |
878 // in case the scrollbar widget was destroyed when the mouse event was handl ed. | 879 // in case the scrollbar widget was destroyed when the mouse event was handl ed. |
879 if (mev.scrollbar()) { | 880 if (mev.scrollbar()) { |
880 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); | 881 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); |
881 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); | 882 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); |
882 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); | 883 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1486 { | 1487 { |
1487 m_pointerEventManager.releasePointerCapture(pointerId, target); | 1488 m_pointerEventManager.releasePointerCapture(pointerId, target); |
1488 } | 1489 } |
1489 | 1490 |
1490 void EventHandler::elementRemoved(EventTarget* target) | 1491 void EventHandler::elementRemoved(EventTarget* target) |
1491 { | 1492 { |
1492 m_pointerEventManager.elementRemoved(target); | 1493 m_pointerEventManager.elementRemoved(target); |
1493 } | 1494 } |
1494 | 1495 |
1495 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler. | 1496 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler. |
1496 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse Event& mouseEvent) | 1497 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents( |
dtapuska
2016/07/20 16:26:08
ditto
mustaq
2016/07/20 16:36:44
Done.
| |
1498 const AtomicString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent) | |
1497 { | 1499 { |
1498 ASSERT(mouseEventType == EventTypeNames::mousedown | 1500 ASSERT(mouseEventType == EventTypeNames::mousedown |
1499 || mouseEventType == EventTypeNames::mousemove | 1501 || mouseEventType == EventTypeNames::mousemove |
1500 || mouseEventType == EventTypeNames::mouseup); | 1502 || mouseEventType == EventTypeNames::mouseup); |
1501 | 1503 |
1502 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent ); | 1504 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent ); |
1503 | 1505 |
1506 if (mouseEvent.getSyntheticEventType() == PlatformMouseEvent::FromTouch) { | |
dtapuska
2016/07/20 16:26:08
braces not needed
mustaq
2016/07/20 16:36:44
Done.
| |
1507 return dispatchMouseEvent(mouseEventType, m_nodeUnderMouse, clickCount, mouseEvent); | |
1508 } | |
1509 | |
1504 return m_pointerEventManager.sendMousePointerEvent( | 1510 return m_pointerEventManager.sendMousePointerEvent( |
1505 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr, | 1511 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr, |
1506 lastNodeUnderMouse); | 1512 lastNodeUnderMouse); |
1507 } | 1513 } |
1508 | 1514 |
1509 void EventHandler::setClickNode(Node* node) | 1515 void EventHandler::setClickNode(Node* node) |
1510 { | 1516 { |
1511 m_clickNode = node; | 1517 m_clickNode = node; |
1512 } | 1518 } |
1513 | 1519 |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2086 eventType = PlatformEvent::MouseReleased; | 2092 eventType = PlatformEvent::MouseReleased; |
2087 | 2093 |
2088 PlatformMouseEvent mouseEvent(locationInRootFrame, globalPosition, | 2094 PlatformMouseEvent mouseEvent(locationInRootFrame, globalPosition, |
2089 RightButton, eventType, 1, | 2095 RightButton, eventType, 1, |
2090 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, | 2096 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, |
2091 WTF::monotonicallyIncreasingTime(), WebPointerProperties::PointerType::M ouse); | 2097 WTF::monotonicallyIncreasingTime(), WebPointerProperties::PointerType::M ouse); |
2092 | 2098 |
2093 return sendContextMenuEvent(mouseEvent, overrideTargetElement); | 2099 return sendContextMenuEvent(mouseEvent, overrideTargetElement); |
2094 } | 2100 } |
2095 | 2101 |
2096 WebInputEventResult EventHandler::sendContextMenuEventForGesture(const GestureEv entWithHitTestResults& targetedEvent) | |
2097 { | |
2098 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | |
2099 unsigned modifiers = gestureEvent.getModifiers(); | |
2100 | |
2101 // Send MouseMoved event prior to handling (https://crbug.com/485290). | |
2102 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(), | |
2103 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, | |
2104 static_cast<PlatformEvent::Modifiers>(modifiers), | |
2105 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse); | |
2106 dispatchMouseEvent(EventTypeNames::mousemove, targetedEvent.hitTestResult(). innerNode(), 0, fakeMouseMove); | |
2107 | |
2108 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; | |
2109 | |
2110 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) | |
2111 eventType = PlatformEvent::MouseReleased; | |
2112 | |
2113 // Always set right button down as we are sending mousedown event regardless | |
2114 modifiers |= PlatformEvent::RightButtonDown; | |
2115 | |
2116 // TODO(crbug.com/579564): Maybe we should not send mouse down at all | |
2117 PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEven t.event().globalPosition(), RightButton, eventType, 1, | |
2118 static_cast<PlatformEvent::Modifiers>(modifiers), | |
2119 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), WebPo interProperties::PointerType::Mouse); | |
2120 // To simulate right-click behavior, we send a right mouse down and then | |
2121 // context menu event. | |
2122 // FIXME: Send HitTestResults to avoid redundant hit tests. | |
2123 handleMousePressEvent(mouseEvent); | |
2124 return sendContextMenuEvent(mouseEvent); | |
2125 // We do not need to send a corresponding mouse release because in case of | |
2126 // right-click, the context menu takes capture and consumes all events. | |
2127 } | |
2128 | |
2129 void EventHandler::scheduleHoverStateUpdate() | 2102 void EventHandler::scheduleHoverStateUpdate() |
2130 { | 2103 { |
2131 if (!m_hoverTimer.isActive()) | 2104 if (!m_hoverTimer.isActive()) |
2132 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE); | 2105 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE); |
2133 } | 2106 } |
2134 | 2107 |
2135 void EventHandler::scheduleCursorUpdate() | 2108 void EventHandler::scheduleCursorUpdate() |
2136 { | 2109 { |
2137 // We only want one timer for the page, rather than each frame having it's o wn timer | 2110 // We only want one timer for the page, rather than each frame having it's o wn timer |
2138 // competing which eachother (since there's only one mouse cursor). | 2111 // competing which eachother (since there's only one mouse cursor). |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2610 | 2583 |
2611 FrameHost* EventHandler::frameHost() const | 2584 FrameHost* EventHandler::frameHost() const |
2612 { | 2585 { |
2613 if (!m_frame->page()) | 2586 if (!m_frame->page()) |
2614 return nullptr; | 2587 return nullptr; |
2615 | 2588 |
2616 return &m_frame->page()->frameHost(); | 2589 return &m_frame->page()->frameHost(); |
2617 } | 2590 } |
2618 | 2591 |
2619 } // namespace blink | 2592 } // namespace blink |
OLD | NEW |