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 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2469 PlatformMouseEvent fakeMouseUp(adjustedPoint, gestureEvent.globalPosition(), | 2469 PlatformMouseEvent fakeMouseUp(adjustedPoint, gestureEvent.globalPosition(), |
2470 LeftButton, PlatformEvent::MouseReleased, tapCount, | 2470 LeftButton, PlatformEvent::MouseReleased, tapCount, |
2471 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp()); | 2471 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp()); |
2472 defaultPrevented |= handleMouseReleaseEvent(fakeMouseUp); | 2472 defaultPrevented |= handleMouseReleaseEvent(fakeMouseUp); |
2473 | 2473 |
2474 return defaultPrevented; | 2474 return defaultPrevented; |
2475 } | 2475 } |
2476 | 2476 |
2477 bool EventHandler::handleGestureLongPress(const PlatformGestureEvent& gestureEve nt) | 2477 bool EventHandler::handleGestureLongPress(const PlatformGestureEvent& gestureEve nt) |
2478 { | 2478 { |
2479 IntPoint adjustedPoint = gestureEvent.position(); | |
2480 #if ENABLE(TOUCH_ADJUSTMENT) | |
2481 adjustGesturePosition(gestureEvent, adjustedPoint); | |
2482 #endif | |
2483 PlatformMouseEvent mouseDown(adjustedPoint, gestureEvent.globalPosition(), L eftButton, PlatformEvent::MousePressed, 1, | |
2484 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp()); | |
2485 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowSh adowContent); | |
hayato
2013/04/17 04:51:03
Could we remove DisallowShadowContent from this Hi
varunjain
2013/04/17 17:45:36
I am not sure but wouldnt DisallowShadowContent st
| |
2486 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDown); | |
2487 RefPtr<Frame> subframe = subframeForHitTestResult(mev); | |
2488 if (subframe && subframe->eventHandler()->handleGestureLongPress(gestureEven t)) | |
2489 return true; | |
2490 | |
2491 m_didLongPressInvokeContextMenu = true; | |
2479 if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_ frame->view()) { | 2492 if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_ frame->view()) { |
2480 IntPoint adjustedPoint = gestureEvent.position(); | |
2481 #if ENABLE(TOUCH_ADJUSTMENT) | |
2482 adjustGesturePosition(gestureEvent, adjustedPoint); | |
2483 #endif | |
2484 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MouseMoved, 1, | 2493 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MouseMoved, 1, |
2485 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey (), gestureEvent.metaKey(), WTF::currentTime()); | 2494 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey (), gestureEvent.metaKey(), WTF::currentTime()); |
2486 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Disall owShadowContent); | 2495 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Disall owShadowContent); |
2487 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE vent); | 2496 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragE vent); |
2488 m_didStartDrag = false; | 2497 m_didStartDrag = false; |
2489 RefPtr<Frame> subframe = subframeForHitTestResult(mev); | |
2490 if (subframe && subframe->eventHandler()->handleGestureLongPress(gesture Event)) | |
2491 return true; | |
2492 m_mouseDownMayStartDrag = true; | 2498 m_mouseDownMayStartDrag = true; |
2493 dragState().m_dragSrc = 0; | 2499 dragState().m_dragSrc = 0; |
2494 m_mouseDownPos = m_frame->view()->windowToContents(mouseDragEvent.positi on()); | 2500 m_mouseDownPos = m_frame->view()->windowToContents(mouseDragEvent.positi on()); |
2495 handleDrag(mev, DontCheckDragHysteresis); | 2501 handleDrag(mev, DontCheckDragHysteresis); |
2496 if (m_didStartDrag) | 2502 if (m_didStartDrag) { |
2503 m_didLongPressInvokeContextMenu = false; | |
2497 return true; | 2504 return true; |
2505 } | |
2498 } | 2506 } |
2499 return handleGestureForTextSelectionOrContextMenu(gestureEvent); | 2507 bool shouldLongPressSelectWord = m_frame->settings() && m_frame->settings()- >touchEditingEnabled(); |
hayato
2013/04/17 04:51:03
Line 2507 to 2510 could be merged into #IF .. #ELS
varunjain
2013/04/17 17:45:36
Done.
| |
2500 } | 2508 #if OS(ANDROID) |
2501 | 2509 shouldLongPressSelectWord = true; |
2502 bool EventHandler::handleGestureLongTap(const PlatformGestureEvent& gestureEvent ) | |
2503 { | |
2504 #if ENABLE(CONTEXT_MENUS) && !OS(ANDROID) | |
2505 if (!m_didLongPressInvokeContextMenu) | |
2506 return sendContextMenuEventForGesture(gestureEvent); | |
2507 #endif | 2510 #endif |
2508 return false; | 2511 if (shouldLongPressSelectWord) { |
2509 } | 2512 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.pos ition()); |
2510 | 2513 HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest:: ReadOnly | HitTestRequest::Active); |
2511 bool EventHandler::handleGestureForTextSelectionOrContextMenu(const PlatformGest ureEvent& gestureEvent) | 2514 Node* innerNode = result.targetNode(); |
2512 { | 2515 if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable() | | innerNode->isTextNode())) { |
2513 #if OS(ANDROID) | 2516 selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitespac e); |
2514 IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.posit ion()); | 2517 if (m_frame->selection()->isRange()) |
2515 HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::Re adOnly | HitTestRequest::Active); | 2518 return true; |
2516 Node* innerNode = result.targetNode(); | 2519 } |
2517 if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable() || innerNode->isTextNode())) { | |
2518 selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitespace) ; | |
2519 if (m_frame->selection()->isRange()) | |
2520 return true; | |
2521 } | 2520 } |
2522 #endif | |
2523 #if ENABLE(CONTEXT_MENUS) | 2521 #if ENABLE(CONTEXT_MENUS) |
2524 m_didLongPressInvokeContextMenu = (gestureEvent.type() == PlatformEvent::Ges tureLongPress); | |
2525 return sendContextMenuEventForGesture(gestureEvent); | 2522 return sendContextMenuEventForGesture(gestureEvent); |
2526 #else | 2523 #else |
2527 return false; | 2524 return false; |
2528 #endif | 2525 #endif |
2529 } | 2526 } |
2530 | 2527 |
2528 bool EventHandler::handleGestureLongTap(const PlatformGestureEvent& gestureEvent ) | |
hayato
2013/04/17 04:51:03
It's optional, but looks like we can share some of
varunjain
2013/04/17 17:45:36
Done.
| |
2529 { | |
2530 IntPoint adjustedPoint = gestureEvent.position(); | |
2531 #if ENABLE(TOUCH_ADJUSTMENT) | |
2532 adjustGesturePosition(gestureEvent, adjustedPoint); | |
2533 #endif | |
2534 PlatformMouseEvent mouseDown(adjustedPoint, gestureEvent.globalPosition(), L eftButton, PlatformEvent::MousePressed, 1, | |
2535 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp()); | |
2536 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowSh adowContent); | |
2537 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDown); | |
2538 RefPtr<Frame> subframe = subframeForHitTestResult(mev); | |
2539 if (subframe && subframe->eventHandler()->handleGestureLongTap(gestureEvent) ) | |
2540 return true; | |
2541 #if ENABLE(CONTEXT_MENUS) && !OS(ANDROID) | |
2542 if (!m_didLongPressInvokeContextMenu) | |
2543 return sendContextMenuEventForGesture(gestureEvent); | |
2544 m_didLongPressInvokeContextMenu = true; | |
2545 #endif | |
2546 return false; | |
2547 } | |
2548 | |
2531 bool EventHandler::handleGestureTwoFingerTap(const PlatformGestureEvent& gesture Event) | 2549 bool EventHandler::handleGestureTwoFingerTap(const PlatformGestureEvent& gesture Event) |
2532 { | 2550 { |
2533 return handleGestureForTextSelectionOrContextMenu(gestureEvent); | 2551 return sendContextMenuEventForGesture(gestureEvent); |
2534 } | 2552 } |
2535 | 2553 |
2536 bool EventHandler::passGestureEventToWidget(const PlatformGestureEvent& gestureE vent, Widget* widget) | 2554 bool EventHandler::passGestureEventToWidget(const PlatformGestureEvent& gestureE vent, Widget* widget) |
2537 { | 2555 { |
2538 if (!widget) | 2556 if (!widget) |
2539 return false; | 2557 return false; |
2540 | 2558 |
2541 if (!widget->isFrameView()) | 2559 if (!widget->isFrameView()) |
2542 return false; | 2560 return false; |
2543 | 2561 |
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3919 #endif | 3937 #endif |
3920 | 3938 |
3921 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) | 3939 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) |
3922 { | 3940 { |
3923 m_mousePositionIsUnknown = false; | 3941 m_mousePositionIsUnknown = false; |
3924 m_lastKnownMousePosition = event.position(); | 3942 m_lastKnownMousePosition = event.position(); |
3925 m_lastKnownMouseGlobalPosition = event.globalPosition(); | 3943 m_lastKnownMouseGlobalPosition = event.globalPosition(); |
3926 } | 3944 } |
3927 | 3945 |
3928 } // namespace WebCore | 3946 } // namespace WebCore |
OLD | NEW |