diff options
author | commit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2012-11-27 00:56:30 +0000 |
---|---|---|
committer | commit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2012-11-27 00:56:30 +0000 |
commit | 9032e73157be5e6cd1e27d745b864e20db231fe2 (patch) | |
tree | f556691a81c4c8fa72a907d9f8a20346e6a050e6 /third_party/WebKit | |
parent | f3a55e62aa7ba975fa39f7b544ffe95af7b3d4a6 (diff) | |
download | chromium_src-9032e73157be5e6cd1e27d745b864e20db231fe2.zip chromium_src-9032e73157be5e6cd1e27d745b864e20db231fe2.tar.gz chromium_src-9032e73157be5e6cd1e27d745b864e20db231fe2.tar.bz2 |
LongPress and LongTap gestures should start drag/drop and open context menu respectively.
https://bugs.webkit.org/show_bug.cgi?id=101545
Patch by Varun Jain <varunjain@chromium.org> on 2012-11-26
Reviewed by Antonio Gomes.
For LongPress, we simulate drag by sending a mouse down and mouse drag
events. If a drag is not started (because maybe there is no draggable
element), then we show context menu instead (which is the current
behavior for LongPress). For LongTap, we use the existing functions that
LongPress uses to summon the context menu. LongPress initiated drag and
drop can be enabled/disabled by the platform using the Setting
touchDragDropEnabled which is disabled by default.
Source/WebCore:
Tests: fast/events/touch/gesture/context-menu-on-long-tap.html
fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag.html
* page/EventHandler.cpp:
(WebCore::EventHandler::EventHandler):
(WebCore::EventHandler::clear):
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::handleGestureEvent):
(WebCore::EventHandler::handleGestureLongPress):
(WebCore::EventHandler::handleGestureLongTap):
(WebCore):
(WebCore::EventHandler::handleGestureForTextSelectionOrContextMenu):
(WebCore::EventHandler::adjustGesturePosition):
(WebCore::EventHandler::handleDrag):
* page/EventHandler.h:
(EventHandler):
* page/Settings.in:
Source/WebKit/chromium:
* public/WebSettings.h:
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setTouchDragDropEnabled):
(WebKit):
* src/WebSettingsImpl.h:
(WebSettingsImpl):
Tools:
* DumpRenderTree/chromium/TestRunner/src/EventSender.cpp:
(WebTestRunner):
(WebTestRunner::EventSender::EventSender):
(WebTestRunner::EventSender::gestureLongTap):
(WebTestRunner::EventSender::gestureEvent):
* DumpRenderTree/chromium/TestRunner/src/EventSender.h:
(EventSender):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
(WebTestRunner::TestRunner::TestRunner):
(WebTestRunner::TestRunner::setTouchDragDropEnabled):
(WebTestRunner):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
(TestRunner):
LayoutTests:
* fast/events/touch/gesture/context-menu-on-long-tap.html: Added.
* fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag.html: Added.
* platform/chromium/fast/events/touch/gesture/context-menu-on-long-tap-expected.txt: Added.
* platform/chromium/fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag-expected.txt: Added.
* touchadjustment/touch-links-longpress-expected.txt:
* touchadjustment/touch-links-longpress.html:
git-svn-id: svn://svn.chromium.org/blink/trunk@135789 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit')
20 files changed, 277 insertions, 12 deletions
diff --git a/third_party/WebKit/LayoutTests/ChangeLog b/third_party/WebKit/LayoutTests/ChangeLog index 6f8726b..98e9668 100644 --- a/third_party/WebKit/LayoutTests/ChangeLog +++ b/third_party/WebKit/LayoutTests/ChangeLog @@ -1,3 +1,25 @@ +2012-11-26 Varun Jain <varunjain@chromium.org> + + LongPress and LongTap gestures should start drag/drop and open context menu respectively. + https://bugs.webkit.org/show_bug.cgi?id=101545 + + Reviewed by Antonio Gomes. + + For LongPress, we simulate drag by sending a mouse down and mouse drag + events. If a drag is not started (because maybe there is no draggable + element), then we show context menu instead (which is the current + behavior for LongPress). For LongTap, we use the existing functions that + LongPress uses to summon the context menu. LongPress initiated drag and + drop can be enabled/disabled by the platform using the Setting + touchDragDropEnabled which is disabled by default. + + * fast/events/touch/gesture/context-menu-on-long-tap.html: Added. + * fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag.html: Added. + * platform/chromium/fast/events/touch/gesture/context-menu-on-long-tap-expected.txt: Added. + * platform/chromium/fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag-expected.txt: Added. + * touchadjustment/touch-links-longpress-expected.txt: + * touchadjustment/touch-links-longpress.html: + 2012-11-26 Roger Fong <roger_fong@apple.com> Unreviewed. Skipping some compositing/tiling tests on Windows because tiled backing is not supported. diff --git a/third_party/WebKit/LayoutTests/fast/events/touch/gesture/context-menu-on-long-tap.html b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/context-menu-on-long-tap.html new file mode 100644 index 0000000..48b62bd --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/context-menu-on-long-tap.html @@ -0,0 +1,34 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<script src="../../../js/resources/js-test-pre.js"></script> +</head> +<body onload="test()"> +<p>This test checks that the context menu is shown on long tap gesture.</p> +<div id="text">Testing</div> +<div id="result">FAIL</div> +<script> +function test() +{ + if (window.testRunner) + testRunner.dumpAsText(); + + document.oncontextmenu = function() { document.getElementById("result").innerHTML = "PASS"; } + + var text = document.getElementById("text"); + + var x = text.offsetParent.offsetLeft + text.offsetLeft + 4; + var y = text.offsetParent.offsetTop + text.offsetTop + text.offsetHeight / 2; + + if (!window.eventSender) + return; + if (eventSender.gestureLongTap) { + eventSender.gestureLongTap(x, y); + } else { + debug("gestureLongTap not implemented by this platform"); + return; + } +} +</script> +</body> +</html> diff --git a/third_party/WebKit/LayoutTests/fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag.html b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag.html new file mode 100644 index 0000000..6a4433c4 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag.html @@ -0,0 +1,39 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<script src="../../../js/resources/js-test-pre.js"></script> +</head> +<body onload="test()"> +<p>This test checks that a long press gesture on a draggable element starts a drag/drop session.</p> +<div id="text">Testing</div> +<div id="result">FAIL</div> +<div id="draggableDiv" draggable='true'>Drag me</div> +<script> +function test() +{ + if (window.testRunner) + testRunner.dumpAsText(); + + if (testRunner.setTouchDragDropEnabled) + testRunner.setTouchDragDropEnabled(true); + + document.ondragstart = function() { document.getElementById("result").innerHTML = "PASS"; } + + var dragableDiv = document.getElementById("draggableDiv"); + + var x = draggableDiv.offsetParent.offsetLeft + draggableDiv.offsetLeft + 4; + var y = draggableDiv.offsetParent.offsetTop + draggableDiv.offsetTop + draggableDiv.offsetHeight / 2; + + if (!window.eventSender) + return; + if (eventSender.gestureLongPress) { + eventSender.gestureLongPress(x, y); + eventSender.mouseUp(); + } else { + debug("gestureLongPress not implemented by this platform"); + return; + } +} +</script> +</body> +</html> diff --git a/third_party/WebKit/LayoutTests/platform/chromium/fast/events/touch/gesture/context-menu-on-long-tap-expected.txt b/third_party/WebKit/LayoutTests/platform/chromium/fast/events/touch/gesture/context-menu-on-long-tap-expected.txt new file mode 100644 index 0000000..d75735f --- /dev/null +++ b/third_party/WebKit/LayoutTests/platform/chromium/fast/events/touch/gesture/context-menu-on-long-tap-expected.txt @@ -0,0 +1,4 @@ +This test checks that the context menu is shown on long tap gesture. + +Testing +PASS diff --git a/third_party/WebKit/LayoutTests/platform/chromium/fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag-expected.txt b/third_party/WebKit/LayoutTests/platform/chromium/fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag-expected.txt new file mode 100644 index 0000000..c52a45e --- /dev/null +++ b/third_party/WebKit/LayoutTests/platform/chromium/fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag-expected.txt @@ -0,0 +1,5 @@ +This test checks that a long press gesture on a draggable element starts a drag/drop session. + +Testing +PASS +Drag me diff --git a/third_party/WebKit/LayoutTests/touchadjustment/touch-links-longpress-expected.txt b/third_party/WebKit/LayoutTests/touchadjustment/touch-links-longpress-expected.txt index 1951f97..c22036c 100644 --- a/third_party/WebKit/LayoutTests/touchadjustment/touch-links-longpress-expected.txt +++ b/third_party/WebKit/LayoutTests/touchadjustment/touch-links-longpress-expected.txt @@ -1,4 +1,4 @@ -Tests if a long press gesture on links will trigger a context menu when touch adjustment is used. +Tests if a long press gesture on links will trigger a drag/drop when touch adjustment is used. On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". diff --git a/third_party/WebKit/LayoutTests/touchadjustment/touch-links-longpress.html b/third_party/WebKit/LayoutTests/touchadjustment/touch-links-longpress.html index dca907b..fda9c66 100644 --- a/third_party/WebKit/LayoutTests/touchadjustment/touch-links-longpress.html +++ b/third_party/WebKit/LayoutTests/touchadjustment/touch-links-longpress.html @@ -1,7 +1,7 @@ <!DOCTYPE html> <html> <head> - <title>Touch Adjustment : Testing that a context menu will appear on a long press - bug 92914</title> + <title>Touch Adjustment : Testing that a drag/drop will start on a long press - bug 92914</title> <script src="../fast/js/resources/js-test-pre.js"></script> <script src="resources/touchadjustment.js"></script> <style> @@ -31,7 +31,7 @@ e[a] = document.getElementById(a); }); - document.oncontextmenu = function() { debug("PASS"); } + document.ondragstart = function(e) { debug("PASS"); e.preventDefault();} function testLongPress(touchpoint) { @@ -89,7 +89,8 @@ function runTests() { if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestClickableNode) { - description('Tests if a long press gesture on links will trigger a context menu when touch adjustment is used.'); + testRunner.setTouchDragDropEnabled(true); + description('Tests if a long press gesture on links will trigger a drag/drop when touch adjustment is used.'); testDirectTouches(); testIndirectTouches(); e.sandbox.style.display = 'none'; diff --git a/third_party/WebKit/Source/WebCore/ChangeLog b/third_party/WebKit/Source/WebCore/ChangeLog index d325ab2..931fd6c 100644 --- a/third_party/WebKit/Source/WebCore/ChangeLog +++ b/third_party/WebKit/Source/WebCore/ChangeLog @@ -1,3 +1,36 @@ +2012-11-26 Varun Jain <varunjain@chromium.org> + + LongPress and LongTap gestures should start drag/drop and open context menu respectively. + https://bugs.webkit.org/show_bug.cgi?id=101545 + + Reviewed by Antonio Gomes. + + For LongPress, we simulate drag by sending a mouse down and mouse drag + events. If a drag is not started (because maybe there is no draggable + element), then we show context menu instead (which is the current + behavior for LongPress). For LongTap, we use the existing functions that + LongPress uses to summon the context menu. LongPress initiated drag and + drop can be enabled/disabled by the platform using the Setting + touchDragDropEnabled which is disabled by default. + + Tests: fast/events/touch/gesture/context-menu-on-long-tap.html + fast/events/touch/gesture/long-press-on-draggable-element-triggers-drag.html + + * page/EventHandler.cpp: + (WebCore::EventHandler::EventHandler): + (WebCore::EventHandler::clear): + (WebCore::EventHandler::handleMouseDraggedEvent): + (WebCore::EventHandler::handleGestureEvent): + (WebCore::EventHandler::handleGestureLongPress): + (WebCore::EventHandler::handleGestureLongTap): + (WebCore): + (WebCore::EventHandler::handleGestureForTextSelectionOrContextMenu): + (WebCore::EventHandler::adjustGesturePosition): + (WebCore::EventHandler::handleDrag): + * page/EventHandler.h: + (EventHandler): + * page/Settings.in: + 2012-11-26 Andreas Kling <akling@apple.com> RenderStyle: Move 'list-style-image' to rare inherited data. diff --git a/third_party/WebKit/Source/WebCore/page/EventHandler.cpp b/third_party/WebKit/Source/WebCore/page/EventHandler.cpp index 8705af6..a213178 100644 --- a/third_party/WebKit/Source/WebCore/page/EventHandler.cpp +++ b/third_party/WebKit/Source/WebCore/page/EventHandler.cpp @@ -348,6 +348,8 @@ EventHandler::EventHandler(Frame* frame) #endif , m_mouseMovedDurationRunningAverage(0) , m_baseEventType(PlatformEvent::NoType) + , m_didStartDrag(false) + , m_didLongPressInvokeContextMenu(false) { } @@ -401,6 +403,8 @@ void EventHandler::clear() #endif m_mouseMovedDurationRunningAverage = 0; m_baseEventType = PlatformEvent::NoType; + m_didStartDrag = false; + m_didLongPressInvokeContextMenu = false; } void EventHandler::nodeWillBeRemoved(Node* nodeToBeRemoved) @@ -711,7 +715,7 @@ static bool canAutoscroll(RenderObject* renderer) #if ENABLE(DRAG_SUPPORT) bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& event) { - if (handleDrag(event)) + if (handleDrag(event, ShouldCheckDragHysteresis)) return true; if (!m_mousePressed) @@ -2596,6 +2600,8 @@ bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) return handleGestureTapDown(); case PlatformEvent::GestureLongPress: return handleGestureLongPress(gestureEvent); + case PlatformEvent::GestureLongTap: + return handleGestureLongTap(gestureEvent); case PlatformEvent::GestureTwoFingerTap: return handleGestureTwoFingerTap(gestureEvent); case PlatformEvent::GestureScrollEnd: @@ -2647,9 +2653,35 @@ bool EventHandler::handleGestureTap(const PlatformGestureEvent& gestureEvent) bool EventHandler::handleGestureLongPress(const PlatformGestureEvent& gestureEvent) { +#if ENABLE(DRAG_SUPPORT) + if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled()) { + IntPoint adjustedPoint = gestureEvent.position(); +#if ENABLE(TOUCH_ADJUSTMENT) + adjustGesturePosition(gestureEvent, adjustedPoint); +#endif + PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosition(), LeftButton, PlatformEvent::MousePressed, 0, false, false, false, false, WTF::currentTime()); + handleMousePressEvent(mouseDownEvent); + PlatformMouseEvent mouseDragEvent(adjustedPoint, gestureEvent.globalPosition(), LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, WTF::currentTime()); + HitTestRequest request(HitTestRequest::ReadOnly); + MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDragEvent); + m_didStartDrag = false; + handleDrag(mev, DontCheckDragHysteresis); + if (m_didStartDrag) + return true; + } +#endif return handleGestureForTextSelectionOrContextMenu(gestureEvent); } +bool EventHandler::handleGestureLongTap(const PlatformGestureEvent& gestureEvent) +{ +#if ENABLE(CONTEXT_MENUS) && !OS(ANDROID) + if (!m_didLongPressInvokeContextMenu) + return sendContextMenuEventForGesture(gestureEvent); +#endif + return false; +} + bool EventHandler::handleGestureForTextSelectionOrContextMenu(const PlatformGestureEvent& gestureEvent) { #if OS(ANDROID) @@ -2663,6 +2695,7 @@ bool EventHandler::handleGestureForTextSelectionOrContextMenu(const PlatformGest } #endif #if ENABLE(CONTEXT_MENUS) + m_didLongPressInvokeContextMenu = (gestureEvent.type() == PlatformEvent::GestureLongPress); return sendContextMenuEventForGesture(gestureEvent); #else return false; @@ -2760,6 +2793,7 @@ bool EventHandler::adjustGesturePosition(const PlatformGestureEvent& gestureEven bestClickableNodeForTouchPoint(gestureEvent.position(), IntSize(gestureEvent.area().width() / 2, gestureEvent.area().height() / 2), adjustedPoint, targetNode); break; case PlatformEvent::GestureLongPress: + case PlatformEvent::GestureLongTap: case PlatformEvent::GestureTwoFingerTap: bestContextMenuNodeForTouchPoint(gestureEvent.position(), IntSize(gestureEvent.area().width() / 2, gestureEvent.area().height() / 2), adjustedPoint, targetNode); break; @@ -3330,7 +3364,7 @@ static bool ExactlyOneBitSet(DragSourceAction n) return n && !(n & (n - 1)); } -bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event) +bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDragHysteresis checkDragHysteresis) { if (event.event().button() != LeftButton || event.event().type() != PlatformEvent::MouseMoved) { // If we allowed the other side of the bridge to handle a drag @@ -3409,7 +3443,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event) view->setCursor(pointerCursor()); } - if (!dragHysteresisExceeded(event.event().position())) + if (checkDragHysteresis == ShouldCheckDragHysteresis && !dragHysteresisExceeded(event.event().position())) return true; // Once we're past the hysteresis point, we don't want to treat this gesture as a click @@ -3460,11 +3494,11 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event) if (m_mouseDownMayStartDrag) { Page* page = m_frame->page(); DragController* dragController = page ? page->dragController() : 0; - bool startedDrag = dragController && dragController->startDrag(m_frame, dragState(), srcOp, event.event(), m_mouseDownPos); + m_didStartDrag = dragController && dragController->startDrag(m_frame, dragState(), srcOp, event.event(), m_mouseDownPos); // In WebKit2 we could reenter this code and start another drag. // On OS X this causes problems with the ownership of the pasteboard // and the promised types. - if (startedDrag) { + if (m_didStartDrag) { m_mouseDownMayStartDrag = false; return true; } diff --git a/third_party/WebKit/Source/WebCore/page/EventHandler.h b/third_party/WebKit/Source/WebCore/page/EventHandler.h index fcbcd61..c15898a 100644 --- a/third_party/WebKit/Source/WebCore/page/EventHandler.h +++ b/third_party/WebKit/Source/WebCore/page/EventHandler.h @@ -91,6 +91,7 @@ extern const int GeneralDragHysteresis; enum HitTestScrollbars { ShouldHitTestScrollbars, DontHitTestScrollbars }; enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace }; +enum CheckDragHysteresis { ShouldCheckDragHysteresis, DontCheckDragHysteresis }; class EventHandler { WTF_MAKE_NONCOPYABLE(EventHandler); @@ -170,6 +171,7 @@ public: bool handleGestureEvent(const PlatformGestureEvent&); bool handleGestureTap(const PlatformGestureEvent&); bool handleGestureLongPress(const PlatformGestureEvent&); + bool handleGestureLongTap(const PlatformGestureEvent&); bool handleGestureTwoFingerTap(const PlatformGestureEvent&); bool handleGestureScrollUpdate(const PlatformGestureEvent&); bool isScrollbarHandlingGestures() const; @@ -307,7 +309,7 @@ private: void freeClipboard(); - bool handleDrag(const MouseEventWithHitTestResults&); + bool handleDrag(const MouseEventWithHitTestResults&, CheckDragHysteresis); #endif bool handleMouseUp(const MouseEventWithHitTestResults&); #if ENABLE(DRAG_SUPPORT) @@ -468,6 +470,8 @@ private: double m_mouseMovedDurationRunningAverage; PlatformEvent::Type m_baseEventType; + bool m_didStartDrag; + bool m_didLongPressInvokeContextMenu; }; } // namespace WebCore diff --git a/third_party/WebKit/Source/WebCore/page/Settings.in b/third_party/WebKit/Source/WebCore/page/Settings.in index 88d51c4..126630c 100644 --- a/third_party/WebKit/Source/WebCore/page/Settings.in +++ b/third_party/WebKit/Source/WebCore/page/Settings.in @@ -164,3 +164,7 @@ frameFlatteningEnabled initial=false allowCustomScrollbarInMainFrame initial=true webSecurityEnabled initial=true spatialNavigationEnabled initial=false + +# This setting adds a means to enable/disable touch initiated drag & drop. If +# enabled, the user can initiate drag using long press. +touchDragDropEnabled initial=false diff --git a/third_party/WebKit/Source/WebKit/chromium/ChangeLog b/third_party/WebKit/Source/WebKit/chromium/ChangeLog index 677e0b9..8496fca 100644 --- a/third_party/WebKit/Source/WebKit/chromium/ChangeLog +++ b/third_party/WebKit/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,25 @@ +2012-11-26 Varun Jain <varunjain@chromium.org> + + LongPress and LongTap gestures should start drag/drop and open context menu respectively. + https://bugs.webkit.org/show_bug.cgi?id=101545 + + Reviewed by Antonio Gomes. + + For LongPress, we simulate drag by sending a mouse down and mouse drag + events. If a drag is not started (because maybe there is no draggable + element), then we show context menu instead (which is the current + behavior for LongPress). For LongTap, we use the existing functions that + LongPress uses to summon the context menu. LongPress initiated drag and + drop can be enabled/disabled by the platform using the Setting + touchDragDropEnabled which is disabled by default. + + * public/WebSettings.h: + * src/WebSettingsImpl.cpp: + (WebKit::WebSettingsImpl::setTouchDragDropEnabled): + (WebKit): + * src/WebSettingsImpl.h: + (WebSettingsImpl): + 2012-11-26 Yusuf Ozuysal <yusufo@google.com> Add hasTouchEventhandlersAt to WebView API diff --git a/third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h b/third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h index 2d356fa..4c9d0cc 100644 --- a/third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h +++ b/third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h @@ -158,6 +158,7 @@ public: virtual void setTextAutosizingEnabled(bool) = 0; virtual void setTextAutosizingFontScaleFactor(float) = 0; virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded() = 0; + virtual void setTouchDragDropEnabled(bool) = 0; virtual void setUnifiedTextCheckerEnabled(bool) = 0; virtual void setUserStyleSheetLocation(const WebURL&) = 0; virtual void setUsesEncodingDetector(bool) = 0; diff --git a/third_party/WebKit/Source/WebKit/chromium/src/WebSettingsImpl.cpp b/third_party/WebKit/Source/WebKit/chromium/src/WebSettingsImpl.cpp index 20fcc1b..164880a 100644 --- a/third_party/WebKit/Source/WebKit/chromium/src/WebSettingsImpl.cpp +++ b/third_party/WebKit/Source/WebKit/chromium/src/WebSettingsImpl.cpp @@ -346,6 +346,11 @@ void WebSettingsImpl::setTextDirectionSubmenuInclusionBehaviorNeverIncluded() m_settings->setTextDirectionSubmenuInclusionBehavior(WebCore::TextDirectionSubmenuNeverIncluded); } +void WebSettingsImpl::setTouchDragDropEnabled(bool enabled) +{ + m_settings->setTouchDragDropEnabled(enabled); +} + void WebSettingsImpl::setOfflineWebApplicationCacheEnabled(bool enabled) { m_settings->setOfflineWebApplicationCacheEnabled(enabled); diff --git a/third_party/WebKit/Source/WebKit/chromium/src/WebSettingsImpl.h b/third_party/WebKit/Source/WebKit/chromium/src/WebSettingsImpl.h index 98520ea..ab92562 100644 --- a/third_party/WebKit/Source/WebKit/chromium/src/WebSettingsImpl.h +++ b/third_party/WebKit/Source/WebKit/chromium/src/WebSettingsImpl.h @@ -153,6 +153,7 @@ public: virtual void setTextAutosizingEnabled(bool); virtual void setTextAutosizingFontScaleFactor(float); virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded(); + virtual void setTouchDragDropEnabled(bool); virtual void setUnifiedTextCheckerEnabled(bool); virtual void setUserStyleSheetLocation(const WebURL&); virtual void setUsesEncodingDetector(bool); diff --git a/third_party/WebKit/Tools/ChangeLog b/third_party/WebKit/Tools/ChangeLog index 76cf78b..4ed0253 100644 --- a/third_party/WebKit/Tools/ChangeLog +++ b/third_party/WebKit/Tools/ChangeLog @@ -1,3 +1,32 @@ +2012-11-26 Varun Jain <varunjain@chromium.org> + + LongPress and LongTap gestures should start drag/drop and open context menu respectively. + https://bugs.webkit.org/show_bug.cgi?id=101545 + + Reviewed by Antonio Gomes. + + For LongPress, we simulate drag by sending a mouse down and mouse drag + events. If a drag is not started (because maybe there is no draggable + element), then we show context menu instead (which is the current + behavior for LongPress). For LongTap, we use the existing functions that + LongPress uses to summon the context menu. LongPress initiated drag and + drop can be enabled/disabled by the platform using the Setting + touchDragDropEnabled which is disabled by default. + + * DumpRenderTree/chromium/TestRunner/src/EventSender.cpp: + (WebTestRunner): + (WebTestRunner::EventSender::EventSender): + (WebTestRunner::EventSender::gestureLongTap): + (WebTestRunner::EventSender::gestureEvent): + * DumpRenderTree/chromium/TestRunner/src/EventSender.h: + (EventSender): + * DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp: + (WebTestRunner::TestRunner::TestRunner): + (WebTestRunner::TestRunner::setTouchDragDropEnabled): + (WebTestRunner): + * DumpRenderTree/chromium/TestRunner/src/TestRunner.h: + (TestRunner): + 2012-11-26 Christophe Dumez <christophe.dumez@intel.com> [EFL][WK2] Add setting to enable / disable HTML5 local storage functionality diff --git a/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp b/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp index 171e25d..773a56b 100644 --- a/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp +++ b/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp @@ -296,6 +296,7 @@ EventSender::EventSender() bindMethod("gestureTapDown", &EventSender::gestureTapDown); bindMethod("gestureTapCancel", &EventSender::gestureTapCancel); bindMethod("gestureLongPress", &EventSender::gestureLongPress); + bindMethod("gestureLongTap", &EventSender::gestureLongTap); bindMethod("gestureTwoFingerTap", &EventSender::gestureTwoFingerTap); bindMethod("zoomPageIn", &EventSender::zoomPageIn); bindMethod("zoomPageOut", &EventSender::zoomPageOut); @@ -1137,6 +1138,12 @@ void EventSender::gestureLongPress(const CppArgumentList& arguments, CppVariant* gestureEvent(WebInputEvent::GestureLongPress, arguments); } +void EventSender::gestureLongTap(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + gestureEvent(WebInputEvent::GestureLongTap, arguments); +} + void EventSender::gestureTwoFingerTap(const CppArgumentList& arguments, CppVariant* result) { result->setNull(); @@ -1206,8 +1213,16 @@ void EventSender::gestureEvent(WebInputEvent::Type type, const CppArgumentList& event.x = point.x; event.y = point.y; if (arguments.size() >= 4) { - event.data.tapDown.width = static_cast<float>(arguments[2].toDouble()); - event.data.tapDown.height = static_cast<float>(arguments[3].toDouble()); + event.data.longPress.width = static_cast<float>(arguments[2].toDouble()); + event.data.longPress.height = static_cast<float>(arguments[3].toDouble()); + } + break; + case WebInputEvent::GestureLongTap: + event.x = point.x; + event.y = point.y; + if (arguments.size() >= 4) { + event.data.longPress.width = static_cast<float>(arguments[2].toDouble()); + event.data.longPress.height = static_cast<float>(arguments[3].toDouble()); } break; case WebInputEvent::GestureTwoFingerTap: diff --git a/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h b/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h index c5d742b..b1da684 100644 --- a/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h +++ b/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h @@ -111,6 +111,7 @@ public: void gestureTapDown(const CppArgumentList&, CppVariant*); void gestureTapCancel(const CppArgumentList&, CppVariant*); void gestureLongPress(const CppArgumentList&, CppVariant*); + void gestureLongTap(const CppArgumentList&, CppVariant*); void gestureTwoFingerTap(const CppArgumentList&, CppVariant*); void gestureEvent(WebKit::WebInputEvent::Type, const CppArgumentList&); diff --git a/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp b/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp index 3707892..8aa817a 100644 --- a/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp +++ b/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp @@ -98,6 +98,7 @@ TestRunner::TestRunner() bindMethod("setPageVisibility", &TestRunner::setPageVisibility); bindMethod("setTextDirection", &TestRunner::setTextDirection); bindMethod("textSurroundingNode", &TestRunner::textSurroundingNode); + bindMethod("setTouchDragDropEnabled", &TestRunner::setTouchDragDropEnabled); // Properties. bindProperty("workerThreadCount", &TestRunner::workerThreadCount); @@ -664,6 +665,15 @@ void TestRunner::textSurroundingNode(const CppArgumentList& arguments, CppVarian result->set(surroundingText.textContent().utf8()); } +void TestRunner::setTouchDragDropEnabled(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + if (arguments.size() != 1 || !arguments[0].isBool()) + return; + + m_webView->settings()->setTouchDragDropEnabled(arguments[0].toBoolean()); +} + void TestRunner::workerThreadCount(CppVariant* result) { result->set(static_cast<int>(WebWorkerInfo::dedicatedWorkerCount())); diff --git a/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h b/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h index f9e9f7a..4691e55 100644 --- a/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h +++ b/third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h @@ -147,6 +147,7 @@ private: // point coordinates relative to the node and the fourth the maximum text // length to retrieve. void textSurroundingNode(const CppArgumentList&, CppVariant*); + void setTouchDragDropEnabled(const CppArgumentList&, CppVariant*); /////////////////////////////////////////////////////////////////////////// // Properties |