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 ? InputDeviceCapabilities::firesTouchEvent
sSourceCapabilities() : |
872 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); | 872 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); |
873 if (eventResult == WebInputEventResult::NotHandled) | 873 if (eventResult == WebInputEventResult::NotHandled) |
874 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mev.event(),
hitTestResult), sourceCapabilities); | 874 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mev.event(),
hitTestResult), sourceCapabilities); |
875 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s
crollbar(); | 875 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s
crollbar(); |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 | 1494 |
1495 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler. | 1495 // 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) | 1496 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato
micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse
Event& mouseEvent) |
1497 { | 1497 { |
1498 ASSERT(mouseEventType == EventTypeNames::mousedown | 1498 ASSERT(mouseEventType == EventTypeNames::mousedown |
1499 || mouseEventType == EventTypeNames::mousemove | 1499 || mouseEventType == EventTypeNames::mousemove |
1500 || mouseEventType == EventTypeNames::mouseup); | 1500 || mouseEventType == EventTypeNames::mouseup); |
1501 | 1501 |
1502 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent
); | 1502 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent
); |
1503 | 1503 |
| 1504 if (mouseEvent.getSyntheticEventType() == PlatformMouseEvent::FromTouch) |
| 1505 return dispatchMouseEvent(mouseEventType, m_nodeUnderMouse, clickCount,
mouseEvent); |
| 1506 |
1504 return m_pointerEventManager.sendMousePointerEvent( | 1507 return m_pointerEventManager.sendMousePointerEvent( |
1505 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr, | 1508 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr, |
1506 lastNodeUnderMouse); | 1509 lastNodeUnderMouse); |
1507 } | 1510 } |
1508 | 1511 |
1509 void EventHandler::setClickNode(Node* node) | 1512 void EventHandler::setClickNode(Node* node) |
1510 { | 1513 { |
1511 m_clickNode = node; | 1514 m_clickNode = node; |
1512 } | 1515 } |
1513 | 1516 |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 eventType = PlatformEvent::MouseReleased; | 2089 eventType = PlatformEvent::MouseReleased; |
2087 | 2090 |
2088 PlatformMouseEvent mouseEvent(locationInRootFrame, globalPosition, | 2091 PlatformMouseEvent mouseEvent(locationInRootFrame, globalPosition, |
2089 RightButton, eventType, 1, | 2092 RightButton, eventType, 1, |
2090 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, | 2093 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, |
2091 WTF::monotonicallyIncreasingTime(), WebPointerProperties::PointerType::M
ouse); | 2094 WTF::monotonicallyIncreasingTime(), WebPointerProperties::PointerType::M
ouse); |
2092 | 2095 |
2093 return sendContextMenuEvent(mouseEvent, overrideTargetElement); | 2096 return sendContextMenuEvent(mouseEvent, overrideTargetElement); |
2094 } | 2097 } |
2095 | 2098 |
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() | 2099 void EventHandler::scheduleHoverStateUpdate() |
2130 { | 2100 { |
2131 if (!m_hoverTimer.isActive()) | 2101 if (!m_hoverTimer.isActive()) |
2132 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE); | 2102 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE); |
2133 } | 2103 } |
2134 | 2104 |
2135 void EventHandler::scheduleCursorUpdate() | 2105 void EventHandler::scheduleCursorUpdate() |
2136 { | 2106 { |
2137 // We only want one timer for the page, rather than each frame having it's o
wn timer | 2107 // 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). | 2108 // competing which eachother (since there's only one mouse cursor). |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2610 | 2580 |
2611 FrameHost* EventHandler::frameHost() const | 2581 FrameHost* EventHandler::frameHost() const |
2612 { | 2582 { |
2613 if (!m_frame->page()) | 2583 if (!m_frame->page()) |
2614 return nullptr; | 2584 return nullptr; |
2615 | 2585 |
2616 return &m_frame->page()->frameHost(); | 2586 return &m_frame->page()->frameHost(); |
2617 } | 2587 } |
2618 | 2588 |
2619 } // namespace blink | 2589 } // namespace blink |
OLD | NEW |