Changeset 135789 in webkit
- Timestamp:
- Nov 26, 2012, 4:56:30 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r135783 r135789 1 2012-11-26 Varun Jain <varunjain@chromium.org> 2 3 LongPress and LongTap gestures should start drag/drop and open context menu respectively. 4 https://bugs.webkit.org/show_bug.cgi?id=101545 5 6 Reviewed by Antonio Gomes. 7 8 For LongPress, we simulate drag by sending a mouse down and mouse drag 9 events. If a drag is not started (because maybe there is no draggable 10 element), then we show context menu instead (which is the current 11 behavior for LongPress). For LongTap, we use the existing functions that 12 LongPress uses to summon the context menu. LongPress initiated drag and 13 drop can be enabled/disabled by the platform using the Setting 14 touchDragDropEnabled which is disabled by default. 15 16 * fast/events/touch/gesture/context-menu-on-long-tap.html: Added. 17 * fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag.html: Added. 18 * platform/chromium/fast/events/touch/gesture/context-menu-on-long-tap-expected.txt: Added. 19 * platform/chromium/fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag-expected.txt: Added. 20 * touchadjustment/touch-links-longpress-expected.txt: 21 * touchadjustment/touch-links-longpress.html: 22 1 23 2012-11-26 Roger Fong <roger_fong@apple.com> 2 24 -
trunk/LayoutTests/touchadjustment/touch-links-longpress-expected.txt
r124642 r135789 1 Tests if a long press gesture on links will trigger a context menuwhen touch adjustment is used.1 Tests if a long press gesture on links will trigger a drag/drop when touch adjustment is used. 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". -
trunk/LayoutTests/touchadjustment/touch-links-longpress.html
r132929 r135789 2 2 <html> 3 3 <head> 4 <title>Touch Adjustment : Testing that a context menu will appearon a long press - bug 92914</title>4 <title>Touch Adjustment : Testing that a drag/drop will start on a long press - bug 92914</title> 5 5 <script src="../fast/js/resources/js-test-pre.js"></script> 6 6 <script src="resources/touchadjustment.js"></script> … … 32 32 }); 33 33 34 document.on contextmenu = function() { debug("PASS");}34 document.ondragstart = function(e) { debug("PASS"); e.preventDefault();} 35 35 36 36 function testLongPress(touchpoint) … … 90 90 { 91 91 if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestClickableNode) { 92 description('Tests if a long press gesture on links will trigger a context menu when touch adjustment is used.'); 92 testRunner.setTouchDragDropEnabled(true); 93 description('Tests if a long press gesture on links will trigger a drag/drop when touch adjustment is used.'); 93 94 testDirectTouches(); 94 95 testIndirectTouches(); -
trunk/Source/WebCore/ChangeLog
r135788 r135789 1 2012-11-26 Varun Jain <varunjain@chromium.org> 2 3 LongPress and LongTap gestures should start drag/drop and open context menu respectively. 4 https://bugs.webkit.org/show_bug.cgi?id=101545 5 6 Reviewed by Antonio Gomes. 7 8 For LongPress, we simulate drag by sending a mouse down and mouse drag 9 events. If a drag is not started (because maybe there is no draggable 10 element), then we show context menu instead (which is the current 11 behavior for LongPress). For LongTap, we use the existing functions that 12 LongPress uses to summon the context menu. LongPress initiated drag and 13 drop can be enabled/disabled by the platform using the Setting 14 touchDragDropEnabled which is disabled by default. 15 16 Tests: fast/events/touch/gesture/context-menu-on-long-tap.html 17 fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag.html 18 19 * page/EventHandler.cpp: 20 (WebCore::EventHandler::EventHandler): 21 (WebCore::EventHandler::clear): 22 (WebCore::EventHandler::handleMouseDraggedEvent): 23 (WebCore::EventHandler::handleGestureEvent): 24 (WebCore::EventHandler::handleGestureLongPress): 25 (WebCore::EventHandler::handleGestureLongTap): 26 (WebCore): 27 (WebCore::EventHandler::handleGestureForTextSelectionOrContextMenu): 28 (WebCore::EventHandler::adjustGesturePosition): 29 (WebCore::EventHandler::handleDrag): 30 * page/EventHandler.h: 31 (EventHandler): 32 * page/Settings.in: 33 1 34 2012-11-26 Andreas Kling <akling@apple.com> 2 35 -
trunk/Source/WebCore/page/EventHandler.cpp
r135650 r135789 349 349 , m_mouseMovedDurationRunningAverage(0) 350 350 , m_baseEventType(PlatformEvent::NoType) 351 , m_didStartDrag(false) 352 , m_didLongPressInvokeContextMenu(false) 351 353 { 352 354 } … … 402 404 m_mouseMovedDurationRunningAverage = 0; 403 405 m_baseEventType = PlatformEvent::NoType; 406 m_didStartDrag = false; 407 m_didLongPressInvokeContextMenu = false; 404 408 } 405 409 … … 712 716 bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& event) 713 717 { 714 if (handleDrag(event ))718 if (handleDrag(event, ShouldCheckDragHysteresis)) 715 719 return true; 716 720 … … 2597 2601 case PlatformEvent::GestureLongPress: 2598 2602 return handleGestureLongPress(gestureEvent); 2603 case PlatformEvent::GestureLongTap: 2604 return handleGestureLongTap(gestureEvent); 2599 2605 case PlatformEvent::GestureTwoFingerTap: 2600 2606 return handleGestureTwoFingerTap(gestureEvent); … … 2648 2654 bool EventHandler::handleGestureLongPress(const PlatformGestureEvent& gestureEvent) 2649 2655 { 2656 #if ENABLE(DRAG_SUPPORT) 2657 if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled()) { 2658 IntPoint adjustedPoint = gestureEvent.position(); 2659 #if ENABLE(TOUCH_ADJUSTMENT) 2660 adjustGesturePosition(gestureEvent, adjustedPoint); 2661 #endif 2662 PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosition(), LeftButton, PlatformEvent::MousePressed, 0, false, false, false, false, WTF::currentTime()); 2663 handleMousePressEvent(mouseDownEvent); 2664 PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosition(), LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, WTF::currentTime()); 2665 HitTestRequest request(HitTestRequest::ReadOnly); 2666 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragEvent); 2667 m_didStartDrag = false; 2668 handleDrag(mev, DontCheckDragHysteresis); 2669 if (m_didStartDrag) 2670 return true; 2671 } 2672 #endif 2650 2673 return handleGestureForTextSelectionOrContextMenu(gestureEvent); 2674 } 2675 2676 bool EventHandler::handleGestureLongTap(const PlatformGestureEvent& gestureEvent) 2677 { 2678 #if ENABLE(CONTEXT_MENUS) && !OS(ANDROID) 2679 if (!m_didLongPressInvokeContextMenu) 2680 return sendContextMenuEventForGesture(gestureEvent); 2681 #endif 2682 return false; 2651 2683 } 2652 2684 … … 2664 2696 #endif 2665 2697 #if ENABLE(CONTEXT_MENUS) 2698 m_didLongPressInvokeContextMenu = (gestureEvent.type() == PlatformEvent::GestureLongPress); 2666 2699 return sendContextMenuEventForGesture(gestureEvent); 2667 2700 #else … … 2761 2794 break; 2762 2795 case PlatformEvent::GestureLongPress: 2796 case PlatformEvent::GestureLongTap: 2763 2797 case PlatformEvent::GestureTwoFingerTap: 2764 2798 bestContextMenuNodeForTouchPoint(gestureEvent.position(), IntSize(gestureEvent.area().width() / 2, gestureEvent.area().height() / 2), adjustedPoint, targetNode); … … 3331 3365 } 3332 3366 3333 bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event )3367 bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDragHysteresis checkDragHysteresis) 3334 3368 { 3335 3369 if (event.event().button() != LeftButton || event.event().type() != PlatformEvent::MouseMoved) { … … 3410 3444 } 3411 3445 3412 if ( !dragHysteresisExceeded(event.event().position()))3446 if (checkDragHysteresis == ShouldCheckDragHysteresis && !dragHysteresisExceeded(event.event().position())) 3413 3447 return true; 3414 3448 … … 3461 3495 Page* page = m_frame->page(); 3462 3496 DragController* dragController = page ? page->dragController() : 0; 3463 bool startedDrag = dragController && dragController->startDrag(m_frame, dragState(), srcOp, event.event(), m_mouseDownPos);3497 m_didStartDrag = dragController && dragController->startDrag(m_frame, dragState(), srcOp, event.event(), m_mouseDownPos); 3464 3498 // In WebKit2 we could reenter this code and start another drag. 3465 3499 // On OS X this causes problems with the ownership of the pasteboard 3466 3500 // and the promised types. 3467 if ( startedDrag) {3501 if (m_didStartDrag) { 3468 3502 m_mouseDownMayStartDrag = false; 3469 3503 return true; -
trunk/Source/WebCore/page/EventHandler.h
r135414 r135789 92 92 enum HitTestScrollbars { ShouldHitTestScrollbars, DontHitTestScrollbars }; 93 93 enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace }; 94 enum CheckDragHysteresis { ShouldCheckDragHysteresis, DontCheckDragHysteresis }; 94 95 95 96 class EventHandler { … … 171 172 bool handleGestureTap(const PlatformGestureEvent&); 172 173 bool handleGestureLongPress(const PlatformGestureEvent&); 174 bool handleGestureLongTap(const PlatformGestureEvent&); 173 175 bool handleGestureTwoFingerTap(const PlatformGestureEvent&); 174 176 bool handleGestureScrollUpdate(const PlatformGestureEvent&); … … 308 310 void freeClipboard(); 309 311 310 bool handleDrag(const MouseEventWithHitTestResults& );312 bool handleDrag(const MouseEventWithHitTestResults&, CheckDragHysteresis); 311 313 #endif 312 314 bool handleMouseUp(const MouseEventWithHitTestResults&); … … 469 471 double m_mouseMovedDurationRunningAverage; 470 472 PlatformEvent::Type m_baseEventType; 473 bool m_didStartDrag; 474 bool m_didLongPressInvokeContextMenu; 471 475 }; 472 476 -
trunk/Source/WebCore/page/Settings.in
r135414 r135789 165 165 webSecurityEnabled initial=true 166 166 spatialNavigationEnabled initial=false 167 168 # This setting adds a means to enable/disable touch initiated drag & drop. If 169 # enabled, the user can initiate drag using long press. 170 touchDragDropEnabled initial=false -
trunk/Source/WebKit/chromium/ChangeLog
r135787 r135789 1 2012-11-26 Varun Jain <varunjain@chromium.org> 2 3 LongPress and LongTap gestures should start drag/drop and open context menu respectively. 4 https://bugs.webkit.org/show_bug.cgi?id=101545 5 6 Reviewed by Antonio Gomes. 7 8 For LongPress, we simulate drag by sending a mouse down and mouse drag 9 events. If a drag is not started (because maybe there is no draggable 10 element), then we show context menu instead (which is the current 11 behavior for LongPress). For LongTap, we use the existing functions that 12 LongPress uses to summon the context menu. LongPress initiated drag and 13 drop can be enabled/disabled by the platform using the Setting 14 touchDragDropEnabled which is disabled by default. 15 16 * public/WebSettings.h: 17 * src/WebSettingsImpl.cpp: 18 (WebKit::WebSettingsImpl::setTouchDragDropEnabled): 19 (WebKit): 20 * src/WebSettingsImpl.h: 21 (WebSettingsImpl): 22 1 23 2012-11-26 Yusuf Ozuysal <yusufo@google.com> 2 24 -
trunk/Source/WebKit/chromium/public/WebSettings.h
r135414 r135789 159 159 virtual void setTextAutosizingFontScaleFactor(float) = 0; 160 160 virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded() = 0; 161 virtual void setTouchDragDropEnabled(bool) = 0; 161 162 virtual void setUnifiedTextCheckerEnabled(bool) = 0; 162 163 virtual void setUserStyleSheetLocation(const WebURL&) = 0; -
trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp
r135414 r135789 347 347 } 348 348 349 void WebSettingsImpl::setTouchDragDropEnabled(bool enabled) 350 { 351 m_settings->setTouchDragDropEnabled(enabled); 352 } 353 349 354 void WebSettingsImpl::setOfflineWebApplicationCacheEnabled(bool enabled) 350 355 { -
trunk/Source/WebKit/chromium/src/WebSettingsImpl.h
r135414 r135789 154 154 virtual void setTextAutosizingFontScaleFactor(float); 155 155 virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded(); 156 virtual void setTouchDragDropEnabled(bool); 156 157 virtual void setUnifiedTextCheckerEnabled(bool); 157 158 virtual void setUserStyleSheetLocation(const WebURL&); -
trunk/Tools/ChangeLog
r135752 r135789 1 2012-11-26 Varun Jain <varunjain@chromium.org> 2 3 LongPress and LongTap gestures should start drag/drop and open context menu respectively. 4 https://bugs.webkit.org/show_bug.cgi?id=101545 5 6 Reviewed by Antonio Gomes. 7 8 For LongPress, we simulate drag by sending a mouse down and mouse drag 9 events. If a drag is not started (because maybe there is no draggable 10 element), then we show context menu instead (which is the current 11 behavior for LongPress). For LongTap, we use the existing functions that 12 LongPress uses to summon the context menu. LongPress initiated drag and 13 drop can be enabled/disabled by the platform using the Setting 14 touchDragDropEnabled which is disabled by default. 15 16 * DumpRenderTree/chromium/TestRunner/src/EventSender.cpp: 17 (WebTestRunner): 18 (WebTestRunner::EventSender::EventSender): 19 (WebTestRunner::EventSender::gestureLongTap): 20 (WebTestRunner::EventSender::gestureEvent): 21 * DumpRenderTree/chromium/TestRunner/src/EventSender.h: 22 (EventSender): 23 * DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp: 24 (WebTestRunner::TestRunner::TestRunner): 25 (WebTestRunner::TestRunner::setTouchDragDropEnabled): 26 (WebTestRunner): 27 * DumpRenderTree/chromium/TestRunner/src/TestRunner.h: 28 (TestRunner): 29 1 30 2012-11-26 Christophe Dumez <christophe.dumez@intel.com> 2 31 -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp
r135436 r135789 297 297 bindMethod("gestureTapCancel", &EventSender::gestureTapCancel); 298 298 bindMethod("gestureLongPress", &EventSender::gestureLongPress); 299 bindMethod("gestureLongTap", &EventSender::gestureLongTap); 299 300 bindMethod("gestureTwoFingerTap", &EventSender::gestureTwoFingerTap); 300 301 bindMethod("zoomPageIn", &EventSender::zoomPageIn); … … 1138 1139 } 1139 1140 1141 void EventSender::gestureLongTap(const CppArgumentList& arguments, CppVariant* result) 1142 { 1143 result->setNull(); 1144 gestureEvent(WebInputEvent::GestureLongTap, arguments); 1145 } 1146 1140 1147 void EventSender::gestureTwoFingerTap(const CppArgumentList& arguments, CppVariant* result) 1141 1148 { … … 1207 1214 event.y = point.y; 1208 1215 if (arguments.size() >= 4) { 1209 event.data.tapDown.width = static_cast<float>(arguments[2].toDouble()); 1210 event.data.tapDown.height = static_cast<float>(arguments[3].toDouble()); 1216 event.data.longPress.width = static_cast<float>(arguments[2].toDouble()); 1217 event.data.longPress.height = static_cast<float>(arguments[3].toDouble()); 1218 } 1219 break; 1220 case WebInputEvent::GestureLongTap: 1221 event.x = point.x; 1222 event.y = point.y; 1223 if (arguments.size() >= 4) { 1224 event.data.longPress.width = static_cast<float>(arguments[2].toDouble()); 1225 event.data.longPress.height = static_cast<float>(arguments[3].toDouble()); 1211 1226 } 1212 1227 break; -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h
r135436 r135789 112 112 void gestureTapCancel(const CppArgumentList&, CppVariant*); 113 113 void gestureLongPress(const CppArgumentList&, CppVariant*); 114 void gestureLongTap(const CppArgumentList&, CppVariant*); 114 115 void gestureTwoFingerTap(const CppArgumentList&, CppVariant*); 115 116 void gestureEvent(WebKit::WebInputEvent::Type, const CppArgumentList&); -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
r135184 r135789 99 99 bindMethod("setTextDirection", &TestRunner::setTextDirection); 100 100 bindMethod("textSurroundingNode", &TestRunner::textSurroundingNode); 101 bindMethod("setTouchDragDropEnabled", &TestRunner::setTouchDragDropEnabled); 101 102 102 103 // Properties. … … 665 666 } 666 667 668 void TestRunner::setTouchDragDropEnabled(const CppArgumentList& arguments, CppVariant* result) 669 { 670 result->setNull(); 671 if (arguments.size() != 1 || !arguments[0].isBool()) 672 return; 673 674 m_webView->settings()->setTouchDragDropEnabled(arguments[0].toBoolean()); 675 } 676 667 677 void TestRunner::workerThreadCount(CppVariant* result) 668 678 { -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h
r135184 r135789 148 148 // length to retrieve. 149 149 void textSurroundingNode(const CppArgumentList&, CppVariant*); 150 void setTouchDragDropEnabled(const CppArgumentList&, CppVariant*); 150 151 151 152 ///////////////////////////////////////////////////////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.