| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 , m_hoverTimer(this, &EventHandler::hoverTimerFired) | 184 , m_hoverTimer(this, &EventHandler::hoverTimerFired) |
| 185 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) | 185 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) |
| 186 , m_mouseDownMayStartAutoscroll(false) | 186 , m_mouseDownMayStartAutoscroll(false) |
| 187 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) | 187 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) |
| 188 , m_svgPan(false) | 188 , m_svgPan(false) |
| 189 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 189 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
| 190 , m_clickCount(0) | 190 , m_clickCount(0) |
| 191 , m_shouldOnlyFireDragOverEvent(false) | 191 , m_shouldOnlyFireDragOverEvent(false) |
| 192 , m_mousePositionIsUnknown(true) | 192 , m_mousePositionIsUnknown(true) |
| 193 , m_mouseDownTimestamp(0) | 193 , m_mouseDownTimestamp(0) |
| 194 , m_pointerEventManager(frame) | 194 , m_pointerEventManager(new PointerEventManager(frame)) |
| 195 , m_scrollManager(frame) | 195 , m_scrollManager(frame) |
| 196 , m_keyboardEventManager(frame, &m_scrollManager) | 196 , m_keyboardEventManager(frame, &m_scrollManager) |
| 197 , m_gestureManager(frame, &m_scrollManager, &m_pointerEventManager, m_select
ionController) | 197 , m_gestureManager(frame, &m_scrollManager, m_pointerEventManager, m_selecti
onController) |
| 198 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 198 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 199 { | 199 { |
| 200 } | 200 } |
| 201 | 201 |
| 202 EventHandler::~EventHandler() | 202 EventHandler::~EventHandler() |
| 203 { | 203 { |
| 204 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); | 204 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); |
| 205 } | 205 } |
| 206 | 206 |
| 207 DEFINE_TRACE(EventHandler) | 207 DEFINE_TRACE(EventHandler) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 m_dragTarget = nullptr; | 244 m_dragTarget = nullptr; |
| 245 m_shouldOnlyFireDragOverEvent = false; | 245 m_shouldOnlyFireDragOverEvent = false; |
| 246 m_mousePositionIsUnknown = true; | 246 m_mousePositionIsUnknown = true; |
| 247 m_lastKnownMousePosition = IntPoint(); | 247 m_lastKnownMousePosition = IntPoint(); |
| 248 m_lastKnownMouseGlobalPosition = IntPoint(); | 248 m_lastKnownMouseGlobalPosition = IntPoint(); |
| 249 m_lastMouseDownUserGestureToken.clear(); | 249 m_lastMouseDownUserGestureToken.clear(); |
| 250 m_mousePressNode = nullptr; | 250 m_mousePressNode = nullptr; |
| 251 m_mousePressed = false; | 251 m_mousePressed = false; |
| 252 m_capturesDragging = false; | 252 m_capturesDragging = false; |
| 253 m_capturingMouseEventsNode = nullptr; | 253 m_capturingMouseEventsNode = nullptr; |
| 254 m_pointerEventManager.clear(); | 254 m_pointerEventManager->clear(); |
| 255 m_scrollManager.clear(); | 255 m_scrollManager.clear(); |
| 256 m_gestureManager.clear(); | 256 m_gestureManager.clear(); |
| 257 m_mouseDownMayStartDrag = false; | 257 m_mouseDownMayStartDrag = false; |
| 258 m_lastDeferredTapElement = nullptr; | 258 m_lastDeferredTapElement = nullptr; |
| 259 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 259 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
| 260 m_mouseDownMayStartAutoscroll = false; | 260 m_mouseDownMayStartAutoscroll = false; |
| 261 m_svgPan = false; | 261 m_svgPan = false; |
| 262 m_mouseDownPos = IntPoint(); | 262 m_mouseDownPos = IntPoint(); |
| 263 m_mouseDownTimestamp = 0; | 263 m_mouseDownTimestamp = 0; |
| 264 m_dragStartPos = LayoutPoint(); | 264 m_dragStartPos = LayoutPoint(); |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 hitType |= HitTestRequest::Active; | 1004 hitType |= HitTestRequest::Active; |
| 1005 } else if (onlyUpdateScrollbars) { | 1005 } else if (onlyUpdateScrollbars) { |
| 1006 // Mouse events should be treated as "read-only" if we're updating only
scrollbars. This | 1006 // Mouse events should be treated as "read-only" if we're updating only
scrollbars. This |
| 1007 // means that :hover and :active freeze in the state they were in, rathe
r than updating | 1007 // means that :hover and :active freeze in the state they were in, rathe
r than updating |
| 1008 // for nodes the mouse moves while the window is not key (which will be
the case if | 1008 // for nodes the mouse moves while the window is not key (which will be
the case if |
| 1009 // onlyUpdateScrollbars is true). | 1009 // onlyUpdateScrollbars is true). |
| 1010 hitType |= HitTestRequest::ReadOnly; | 1010 hitType |= HitTestRequest::ReadOnly; |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 // Treat any mouse move events as readonly if the user is currently touching
the screen. | 1013 // Treat any mouse move events as readonly if the user is currently touching
the screen. |
| 1014 if (m_pointerEventManager.isAnyTouchActive()) | 1014 if (m_pointerEventManager->isAnyTouchActive()) |
| 1015 hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly; | 1015 hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly; |
| 1016 HitTestRequest request(hitType); | 1016 HitTestRequest request(hitType); |
| 1017 MouseEventWithHitTestResults mev = MouseEventWithHitTestResults(mouseEvent,
HitTestResult(request, LayoutPoint())); | 1017 MouseEventWithHitTestResults mev = MouseEventWithHitTestResults(mouseEvent,
HitTestResult(request, LayoutPoint())); |
| 1018 | 1018 |
| 1019 // We don't want to do a hit-test in forceLeave scenarios because there migh
t actually be some other frame above this one at the specified co-ordinate. | 1019 // We don't want to do a hit-test in forceLeave scenarios because there migh
t actually be some other frame above this one at the specified co-ordinate. |
| 1020 // So we must force the hit-test to fail, while still clearing hover/active
state. | 1020 // So we must force the hit-test to fail, while still clearing hover/active
state. |
| 1021 if (forceLeave) | 1021 if (forceLeave) |
| 1022 m_frame->document()->updateHoverActiveState(request, 0); | 1022 m_frame->document()->updateHoverActiveState(request, 0); |
| 1023 else | 1023 else |
| 1024 mev = prepareMouseEvent(request, mouseEvent); | 1024 mev = prepareMouseEvent(request, mouseEvent); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 m_lastScrollbarUnderMouse = nullptr; | 1450 m_lastScrollbarUnderMouse = nullptr; |
| 1451 } | 1451 } |
| 1452 | 1452 |
| 1453 return lastNodeUnderMouse; | 1453 return lastNodeUnderMouse; |
| 1454 } | 1454 } |
| 1455 | 1455 |
| 1456 void EventHandler::updateMouseEventTargetNodeAndSendEvents(Node* targetNode, | 1456 void EventHandler::updateMouseEventTargetNodeAndSendEvents(Node* targetNode, |
| 1457 const PlatformMouseEvent& mouseEvent, bool isFrameBoundaryTransition) | 1457 const PlatformMouseEvent& mouseEvent, bool isFrameBoundaryTransition) |
| 1458 { | 1458 { |
| 1459 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent
); | 1459 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent
); |
| 1460 m_pointerEventManager.sendMouseAndPossiblyPointerBoundaryEvents( | 1460 m_pointerEventManager->sendMouseAndPossiblyPointerBoundaryEvents( |
| 1461 lastNodeUnderMouse, m_nodeUnderMouse, mouseEvent, | 1461 lastNodeUnderMouse, m_nodeUnderMouse, mouseEvent, |
| 1462 isFrameBoundaryTransition); | 1462 isFrameBoundaryTransition); |
| 1463 } | 1463 } |
| 1464 | 1464 |
| 1465 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy
pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent) | 1465 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy
pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent) |
| 1466 { | 1466 { |
| 1467 updateMouseEventTargetNodeAndSendEvents(targetNode, mouseEvent); | 1467 updateMouseEventTargetNodeAndSendEvents(targetNode, mouseEvent); |
| 1468 if (!m_nodeUnderMouse) | 1468 if (!m_nodeUnderMouse) |
| 1469 return WebInputEventResult::NotHandled; | 1469 return WebInputEventResult::NotHandled; |
| 1470 | 1470 |
| 1471 MouseEvent* event = MouseEvent::create(eventType, m_nodeUnderMouse->document
().domWindow(), mouseEvent, clickCount, nullptr); | 1471 MouseEvent* event = MouseEvent::create(eventType, m_nodeUnderMouse->document
().domWindow(), mouseEvent, clickCount, nullptr); |
| 1472 return toWebInputEventResult(m_nodeUnderMouse->dispatchEvent(event)); | 1472 return toWebInputEventResult(m_nodeUnderMouse->dispatchEvent(event)); |
| 1473 } | 1473 } |
| 1474 | 1474 |
| 1475 bool EventHandler::isPointerEventActive(int pointerId) | 1475 bool EventHandler::isPointerEventActive(int pointerId) |
| 1476 { | 1476 { |
| 1477 return m_pointerEventManager.isActive(pointerId); | 1477 return m_pointerEventManager->isActive(pointerId); |
| 1478 } | 1478 } |
| 1479 | 1479 |
| 1480 void EventHandler::setPointerCapture(int pointerId, EventTarget* target) | 1480 void EventHandler::setPointerCapture(int pointerId, EventTarget* target) |
| 1481 { | 1481 { |
| 1482 // TODO(crbug.com/591387): This functionality should be per page not per fra
me. | 1482 // TODO(crbug.com/591387): This functionality should be per page not per fra
me. |
| 1483 m_pointerEventManager.setPointerCapture(pointerId, target); | 1483 m_pointerEventManager->setPointerCapture(pointerId, target); |
| 1484 } | 1484 } |
| 1485 | 1485 |
| 1486 void EventHandler::releasePointerCapture(int pointerId, EventTarget* target) | 1486 void EventHandler::releasePointerCapture(int pointerId, EventTarget* target) |
| 1487 { | 1487 { |
| 1488 m_pointerEventManager.releasePointerCapture(pointerId, target); | 1488 m_pointerEventManager->releasePointerCapture(pointerId, target); |
| 1489 } | 1489 } |
| 1490 | 1490 |
| 1491 void EventHandler::elementRemoved(EventTarget* target) | 1491 void EventHandler::elementRemoved(EventTarget* target) |
| 1492 { | 1492 { |
| 1493 m_pointerEventManager.elementRemoved(target); | 1493 m_pointerEventManager->elementRemoved(target); |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler. | 1496 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler. |
| 1497 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato
micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse
Event& mouseEvent) | 1497 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato
micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse
Event& mouseEvent) |
| 1498 { | 1498 { |
| 1499 ASSERT(mouseEventType == EventTypeNames::mousedown | 1499 ASSERT(mouseEventType == EventTypeNames::mousedown |
| 1500 || mouseEventType == EventTypeNames::mousemove | 1500 || mouseEventType == EventTypeNames::mousemove |
| 1501 || mouseEventType == EventTypeNames::mouseup); | 1501 || mouseEventType == EventTypeNames::mouseup); |
| 1502 | 1502 |
| 1503 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent
); | 1503 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent
); |
| 1504 | 1504 |
| 1505 return m_pointerEventManager.sendMousePointerEvent( | 1505 return m_pointerEventManager->sendMousePointerEvent( |
| 1506 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr, | 1506 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr, |
| 1507 lastNodeUnderMouse); | 1507 lastNodeUnderMouse); |
| 1508 } | 1508 } |
| 1509 | 1509 |
| 1510 void EventHandler::setClickNode(Node* node) | 1510 void EventHandler::setClickNode(Node* node) |
| 1511 { | 1511 { |
| 1512 m_clickNode = node; | 1512 m_clickNode = node; |
| 1513 } | 1513 } |
| 1514 | 1514 |
| 1515 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe
sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities) | 1515 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe
sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities) |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2552 if (!rect.contains(roundedIntPoint(point))) | 2552 if (!rect.contains(roundedIntPoint(point))) |
| 2553 return result; | 2553 return result; |
| 2554 } | 2554 } |
| 2555 frame->contentLayoutItem().hitTest(result); | 2555 frame->contentLayoutItem().hitTest(result); |
| 2556 return result; | 2556 return result; |
| 2557 } | 2557 } |
| 2558 | 2558 |
| 2559 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
nt) | 2559 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
nt) |
| 2560 { | 2560 { |
| 2561 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); | 2561 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); |
| 2562 return m_pointerEventManager.handleTouchEvents(event); | 2562 return m_pointerEventManager->handleTouchEvents(event); |
| 2563 } | 2563 } |
| 2564 | 2564 |
| 2565 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) | 2565 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) |
| 2566 { | 2566 { |
| 2567 m_mousePositionIsUnknown = false; | 2567 m_mousePositionIsUnknown = false; |
| 2568 m_lastKnownMousePosition = event.position(); | 2568 m_lastKnownMousePosition = event.position(); |
| 2569 m_lastKnownMouseGlobalPosition = event.globalPosition(); | 2569 m_lastKnownMouseGlobalPosition = event.globalPosition(); |
| 2570 } | 2570 } |
| 2571 | 2571 |
| 2572 WebInputEventResult EventHandler::passMousePressEventToSubframe(MouseEventWithHi
tTestResults& mev, LocalFrame* subframe) | 2572 WebInputEventResult EventHandler::passMousePressEventToSubframe(MouseEventWithHi
tTestResults& mev, LocalFrame* subframe) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2611 | 2611 |
| 2612 FrameHost* EventHandler::frameHost() const | 2612 FrameHost* EventHandler::frameHost() const |
| 2613 { | 2613 { |
| 2614 if (!m_frame->page()) | 2614 if (!m_frame->page()) |
| 2615 return nullptr; | 2615 return nullptr; |
| 2616 | 2616 |
| 2617 return &m_frame->page()->frameHost(); | 2617 return &m_frame->page()->frameHost(); |
| 2618 } | 2618 } |
| 2619 | 2619 |
| 2620 } // namespace blink | 2620 } // namespace blink |
| OLD | NEW |