[EFL][DRT] EventSender needs implementation of leapForward function
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 May 2012 23:21:43 +0000 (23:21 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 May 2012 23:21:43 +0000 (23:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83486

Patch by Alexander Shalamov <alexander.shalamov@intel.com> on 2012-05-08
Reviewed by Eric Seidel.

Tools:

Implemented leapForward function in Efl's DRT. This function is required
to delay and queue event execution and simulate real user behavior.

* DumpRenderTree/efl/EventSender.cpp:
(DelayedEvent):
(MouseEventInfo::MouseEventInfo):
(MouseEventInfo):
(sendClick):
(mouseDownCallback):
(mouseUpCallback):
(mouseMoveToCallback):
(leapForwardCallback):
(mouseScrollByCallback):
(feedOrQueueMouseEvent):
(feedMouseEvent):
(feedQueuedMouseEvents):

LayoutTests:

Unskipping few tests that were failing due to the missing leapForward function
Added EFL specific test result, since EFL doesnt support 2D wheel events

* platform/efl/Skipped:
* platform/efl/fast/events/platform-wheelevent-in-scrolling-div-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@116464 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/efl/Skipped
LayoutTests/platform/efl/fast/events/platform-wheelevent-in-scrolling-div-expected.txt [new file with mode: 0644]
Tools/ChangeLog
Tools/DumpRenderTree/efl/EventSender.cpp

index f532acb..26cde72 100644 (file)
@@ -1,3 +1,16 @@
+2012-05-08  Alexander Shalamov  <alexander.shalamov@intel.com>
+
+        [EFL][DRT] EventSender needs implementation of leapForward function
+        https://bugs.webkit.org/show_bug.cgi?id=83486
+
+        Reviewed by Eric Seidel.
+
+        Unskipping few tests that were failing due to the missing leapForward function
+        Added EFL specific test result, since EFL doesnt support 2D wheel events
+
+        * platform/efl/Skipped:
+        * platform/efl/fast/events/platform-wheelevent-in-scrolling-div-expected.txt: Added.
+
 2012-05-08  Oliver Hunt  <oliver@apple.com>
 
         Add mac results for new tests following http://trac.webkit.org/changeset/116438.
index 4fe6852..1e54431 100644 (file)
@@ -9,10 +9,6 @@ fast/dom/icon-url-property.html
 # EFL's EventSender does not implement dumpFilenameBeingDragged
 fast/events/drag-image-filename.html
 
-# EFL's EventSender does not correctly send a single wheel event when mouseScrollBy is called with both x and y not-null
-fast/events/platform-wheelevent-in-scrolling-div.html
-fast/events/remove-child-onscroll.html
-
 # EFL's EventSender does not implement continuousMouseScrollBy yet
 fast/events/continuous-platform-wheelevent-in-scrolling-div.html
 fast/events/wheelevent-direction-inverted-from-device.html
@@ -67,7 +63,7 @@ http/tests/security/clipboard/clipboard-file-access.html
 # EFL's EventSender does not implement addTouchPoint, clearTouchPoints, touchStart and other touch-related callbacks
 fast/events/touch
 
-# EFL's EventSender does not implement leapForward yet
+# EFL's port requires implementation of ClipboardEfl and DragClientEfl classes in order to suppport drag n drop functionality
 fast/events/drag-and-drop-subframe-dataTransfer.html
 editing/pasteboard/4947130.html
 editing/pasteboard/dataTransfer-setData-getData.html
@@ -89,7 +85,6 @@ editing/pasteboard/subframe-dragndrop-1.html
 editing/selection/4895428-1.html
 editing/selection/4895428-4.html
 editing/selection/5333725.html
-editing/selection/caret-bidi-first-and-last-letters.html
 editing/selection/caret-ltr-2-left.html
 editing/selection/caret-ltr-2.html
 editing/selection/caret-ltr-right.html
@@ -99,8 +94,6 @@ editing/selection/caret-rtl-2.html
 editing/selection/caret-rtl-right.html
 editing/selection/caret-rtl.html
 editing/selection/click-before-and-after-table.html
-editing/selection/click-below-rtl-text.html
-editing/selection/click-left-of-rtl-wrapping-text.html
 editing/selection/contains-boundaries.html
 editing/selection/crash-on-drag-with-mutation-events.html
 editing/selection/directionality-after-undo-replace.html
@@ -111,17 +104,10 @@ editing/selection/drag-to-contenteditable-iframe.html
 editing/selection/extend-over-file-input-by-drag-crash.html
 editing/selection/extend-selection-after-double-click.html
 editing/selection/fake-drag.html
-editing/selection/hit-test-on-text-with-line-height.html
-editing/selection/rtl-move-selection-right-left.html
-editing/selection/select-across-readonly-input-1.html
 editing/selection/select-across-readonly-input-2.html
 editing/selection/select-across-readonly-input-3.html
 editing/selection/select-across-readonly-input-4.html
 editing/selection/select-across-readonly-input-5.html
-editing/selection/select-out-of-editable.html
-editing/selection/select-out-of-floated-contenteditable.html
-editing/selection/select-out-of-floated-input.html
-editing/selection/select-out-of-floated-textarea.html
 fast/block/positioning/hittest-on-relative-positioned-children.html
 fast/events/5056619.html
 fast/events/bogus-dropEffect-effectAllowed.html
@@ -138,33 +124,23 @@ fast/events/dropzone-001.html
 fast/events/dropzone-002.html
 fast/events/dropzone-003.html
 fast/events/dropzone-005.html
-fast/events/fire-mousedown-while-pressing-mouse-button.html
-fast/events/frame-click-focus.html
 fast/events/ondragenter.html
 fast/events/ondrop-text-html.html
-fast/events/popup-blocking-timers.html
-fast/events/remove-target-in-mouseup-deep.html
-fast/events/remove-target-in-mouseup-insertback.html
-fast/events/remove-target-in-mouseup-twice.html
-fast/events/remove-target-in-mouseup.html
 fast/events/selectstart-by-double-triple-clicks.html
 fast/events/selectstart-by-drag.html
-fast/events/selectstart-by-single-click-with-shift.html
 fast/events/standalone-image-drag-to-editable.html
 fast/events/touch/touch-gesture-click.html
 fast/events/zoom-dblclick.html
 fast/forms/drag-into-textarea.html
 fast/forms/drag-out-of-textarea.html
-fast/forms/file/file-input-hit-test.html
 fast/forms/focus-change-on-keypress.html
 fast/forms/search-cancel-button-mouseup.html
 fast/forms/search-disabled-readonly.html
 fast/forms/textfield-drag-into-disabled.html
-fast/forms/type-after-focus-rule-shrink-width.html
-fast/frames/frame-inherit-noresize-from-frameset.html
 fast/frames/frame-programmatic-noresize.html
 fast/frames/frame-with-noresize-can-be-resized-after-removal-of-noresize.html
 fast/frames/frame-with-noresize-can-be-resized-after-setting-noResize-to-false.html
+fast/forms/type-after-focus-rule-shrink-width.html
 fast/lists/drag-into-marker.html
 fast/table/click-near-anonymous-table.html
 fast/text/offsetForPosition-complex-fallback.html
diff --git a/LayoutTests/platform/efl/fast/events/platform-wheelevent-in-scrolling-div-expected.txt b/LayoutTests/platform/efl/fast/events/platform-wheelevent-in-scrolling-div-expected.txt
new file mode 100644 (file)
index 0000000..c5127af
--- /dev/null
@@ -0,0 +1,9 @@
+FAIL event.wheelDeltaY should be -600. Was 0.
+PASS event.wheelDeltaX is window.expectedScrollLeft*-120
+PASS event.wheelDelta is window.expectedScrollLeft*-120
+PASS event.wheelDeltaY is window.expectedScrollTop*-120
+FAIL event.wheelDeltaX should be -360. Was 0.
+PASS event.wheelDelta is window.expectedScrollTop*-120
+PASS div.scrollTop is window.expectedScrollTop*window.pixelsPerWheelTick
+PASS div.scrollLeft is window.expectedScrollLeft*window.pixelsPerWheelTick
+
index 86f5708..9577f73 100644 (file)
@@ -1,3 +1,27 @@
+2012-05-08  Alexander Shalamov  <alexander.shalamov@intel.com>
+
+        [EFL][DRT] EventSender needs implementation of leapForward function
+        https://bugs.webkit.org/show_bug.cgi?id=83486
+
+        Reviewed by Eric Seidel.
+
+        Implemented leapForward function in Efl's DRT. This function is required
+        to delay and queue event execution and simulate real user behavior.
+
+        * DumpRenderTree/efl/EventSender.cpp:
+        (DelayedEvent):
+        (MouseEventInfo::MouseEventInfo):
+        (MouseEventInfo):
+        (sendClick):
+        (mouseDownCallback):
+        (mouseUpCallback):
+        (mouseMoveToCallback):
+        (leapForwardCallback):
+        (mouseScrollByCallback):
+        (feedOrQueueMouseEvent):
+        (feedMouseEvent):
+        (feedQueuedMouseEvents):
+
 2012-05-08  Ryuan Choi  <ryuan.choi@samsung.com>
 
         [EFL][DRT] WebKit/DRT should not paint webview for the pixel tests.
index 2bed5c9..1b9a452 100644 (file)
@@ -103,6 +103,11 @@ enum ZoomEvent {
     ZoomOut
 };
 
+enum EventQueueStrategy {
+    FeedQueuedEvents,
+    DoNotFeedQueuedEvents
+};
+
 struct KeyEventInfo {
     KeyEventInfo(const CString& keyName, EvasKeyModifier modifiers)
         : keyName(keyName)
@@ -114,6 +119,45 @@ struct KeyEventInfo {
     EvasKeyModifier modifiers;
 };
 
+struct MouseEventInfo {
+    MouseEventInfo(EvasMouseEvent event, EvasKeyModifier modifiers = EvasKeyModifierNone, EvasMouseButton button = EvasMouseButtonNone, int horizontalDelta = 0, int verticalDelta = 0)
+        : event(event)
+        , modifiers(modifiers)
+        , button(button)
+        , horizontalDelta(horizontalDelta)
+        , verticalDelta(verticalDelta)
+    {
+    }
+
+    EvasMouseEvent event;
+    EvasKeyModifier modifiers;
+    EvasMouseButton button;
+    int horizontalDelta;
+    int verticalDelta;
+};
+
+struct DelayedEvent {
+    DelayedEvent(MouseEventInfo* eventInfo, ulong delay = 0)
+        : eventInfo(eventInfo)
+        , delay(delay)
+    {
+    }
+
+    MouseEventInfo* eventInfo;
+    ulong delay;
+};
+
+WTF::Vector<DelayedEvent>& delayedEventQueue()
+{
+    DEFINE_STATIC_LOCAL(WTF::Vector<DelayedEvent>, staticDelayedEventQueue, ());
+    return staticDelayedEventQueue;
+}
+
+
+static void feedOrQueueMouseEvent(MouseEventInfo*, EventQueueStrategy);
+static void feedMouseEvent(MouseEventInfo*);
+static void feedQueuedMouseEvents();
+
 static void setEvasModifiers(Evas* evas, EvasKeyModifier modifiers)
 {
     static const char* modifierNames[] = { "Control", "Shift", "Alt", "Super" };
@@ -141,43 +185,10 @@ static EvasMouseButton translateMouseButtonNumber(int eventSenderButtonNumber)
     return EvasMouseButtonLeft;
 }
 
-static void sendMouseEvent(Evas* evas, EvasMouseEvent event, int buttonNumber, EvasKeyModifier modifiers)
-{
-    unsigned timeStamp = 0;
-
-    DumpRenderTreeSupportEfl::layoutFrame(browser->mainFrame());
-
-    setEvasModifiers(evas, modifiers);
-    if (event & EvasMouseEventMove)
-        evas_event_feed_mouse_move(evas, gLastMousePositionX, gLastMousePositionY, timeStamp++, 0);
-    if (event & EvasMouseEventDown) {
-        unsigned flags = 0;
-        if (gClickCount == 2)
-            flags |= EVAS_BUTTON_DOUBLE_CLICK;
-        else if (gClickCount == 3)
-            flags |= EVAS_BUTTON_TRIPLE_CLICK;
-
-        evas_event_feed_mouse_down(evas, buttonNumber, static_cast<Evas_Button_Flags>(flags), timeStamp++, 0);
-    }
-    if (event & EvasMouseEventUp)
-        evas_event_feed_mouse_up(evas, buttonNumber, EVAS_BUTTON_NONE, timeStamp++, 0);
-
-    const bool horizontal = !!(event & EvasMouseEventScrollLeft | event & EvasMouseEventScrollRight);
-    const bool vertical = !!(event & EvasMouseEventScrollUp | event & EvasMouseEventScrollDown);
-    if (vertical && horizontal) {
-        evas_event_feed_mouse_wheel(evas, 0, (event & EvasMouseEventScrollUp) ? 10 : -10, timeStamp, 0);
-        evas_event_feed_mouse_wheel(evas, 1, (event & EvasMouseEventScrollLeft) ? 10 : -10, timeStamp, 0);
-    } else if (vertical)
-        evas_event_feed_mouse_wheel(evas, 0, (event & EvasMouseEventScrollUp) ? 10 : -10, timeStamp, 0);
-    else if (horizontal)
-        evas_event_feed_mouse_wheel(evas, 1, (event & EvasMouseEventScrollLeft) ? 10 : -10, timeStamp, 0);
-
-    setEvasModifiers(evas, EvasKeyModifierNone);
-}
-
 static Eina_Bool sendClick(void*)
 {
-    sendMouseEvent(evas_object_evas_get(browser->mainFrame()), EvasMouseEventClick, EvasMouseButtonLeft, EvasKeyModifierNone);
+    MouseEventInfo* eventInfo = new MouseEventInfo(EvasMouseEventClick, EvasKeyModifierNone, EvasMouseButtonLeft);
+    feedOrQueueMouseEvent(eventInfo, FeedQueuedEvents);
     return ECORE_CALLBACK_CANCEL;
 }
 
@@ -249,8 +260,8 @@ static JSValueRef mouseDownCallback(JSContextRef context, JSObjectRef function,
     updateClickCount(button);
 
     EvasKeyModifier modifiers = argumentCount >= 2 ? modifiersFromJSValue(context, arguments[1]) : EvasKeyModifierNone;
-    sendMouseEvent(evas_object_evas_get(browser->mainFrame()), EvasMouseEventDown, button, modifiers);
-
+    MouseEventInfo* eventInfo = new MouseEventInfo(EvasMouseEventDown, modifiers, static_cast<EvasMouseButton>(button));
+    feedOrQueueMouseEvent(eventInfo, FeedQueuedEvents);
     gButtonCurrentlyDown = button;
     return JSValueMakeUndefined(context);
 }
@@ -271,7 +282,8 @@ static JSValueRef mouseUpCallback(JSContextRef context, JSObjectRef function, JS
     gButtonCurrentlyDown = 0;
 
     EvasKeyModifier modifiers = argumentCount >= 2 ? modifiersFromJSValue(context, arguments[1]) : EvasKeyModifierNone;
-    sendMouseEvent(evas_object_evas_get(browser->mainFrame()), EvasMouseEventUp, translateMouseButtonNumber(button), modifiers);
+    MouseEventInfo* eventInfo = new MouseEventInfo(EvasMouseEventUp, modifiers, translateMouseButtonNumber(button));
+    feedOrQueueMouseEvent(eventInfo, FeedQueuedEvents);
     return JSValueMakeUndefined(context);
 }
 
@@ -287,7 +299,22 @@ static JSValueRef mouseMoveToCallback(JSContextRef context, JSObjectRef function
     if (exception && *exception)
         return JSValueMakeUndefined(context);
 
-    sendMouseEvent(evas_object_evas_get(browser->mainFrame()), EvasMouseEventMove, EvasMouseButtonNone, EvasKeyModifierNone);
+    MouseEventInfo* eventInfo = new MouseEventInfo(EvasMouseEventMove);
+    feedOrQueueMouseEvent(eventInfo, DoNotFeedQueuedEvents);
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef leapForwardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount > 0) {
+        const ulong leapForwardDelay = JSValueToNumber(context, arguments[0], exception);
+        if (delayedEventQueue().isEmpty())
+            delayedEventQueue().append(DelayedEvent(0, leapForwardDelay));
+        else
+            delayedEventQueue().last().delay = leapForwardDelay;
+        gTimeOffset += leapForwardDelay;
+    }
+
     return JSValueMakeUndefined(context);
 }
 
@@ -313,14 +340,17 @@ static JSValueRef mouseScrollByCallback(JSContextRef context, JSObjectRef functi
     if (argumentCount < 2)
         return JSValueMakeUndefined(context);
 
-    const int horizontal = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
+    // We need to invert scrolling values since in EFL negative z value means that
+    // canvas is scrolling down
+    const int horizontal = -(static_cast<int>(JSValueToNumber(context, arguments[0], exception)));
     if (exception && *exception)
         return JSValueMakeUndefined(context);
-    const int vertical = static_cast<int>(JSValueToNumber(context, arguments[1], exception));
+    const int vertical = -(static_cast<int>(JSValueToNumber(context, arguments[1], exception)));
     if (exception && *exception)
         return JSValueMakeUndefined(context);
 
-    sendMouseEvent(evas_object_evas_get(browser->mainFrame()), evasMouseEventFromHorizontalAndVerticalOffsets(horizontal, vertical), EvasMouseButtonNone, EvasKeyModifierNone);
+    MouseEventInfo* eventInfo = new MouseEventInfo(evasMouseEventFromHorizontalAndVerticalOffsets(horizontal, vertical), EvasKeyModifierNone, EvasMouseButtonNone, horizontal, vertical);
+    feedOrQueueMouseEvent(eventInfo, FeedQueuedEvents);
     return JSValueMakeUndefined(context);
 }
 
@@ -562,6 +592,7 @@ static JSStaticFunction staticFunctions[] = {
     { "mouseDown", mouseDownCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "mouseUp", mouseUpCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "mouseMoveTo", mouseMoveToCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    { "leapForward", leapForwardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "keyDown", keyDownCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "scheduleAsynchronousClick", scheduleAsynchronousClickCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "scheduleAsynchronousKeyDown", scheduleAsynchronousKeyDownCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -615,3 +646,68 @@ JSObjectRef makeEventSender(JSContextRef context, bool isTopFrame)
 
     return JSObjectMake(context, getClass(context), 0);
 }
+
+static void feedOrQueueMouseEvent(MouseEventInfo* eventInfo, EventQueueStrategy strategy)
+{
+    if (!delayedEventQueue().isEmpty()) {
+        if (delayedEventQueue().last().eventInfo)
+            delayedEventQueue().last().eventInfo = eventInfo;
+        else
+            delayedEventQueue().append(DelayedEvent(eventInfo));
+
+        if (strategy == FeedQueuedEvents)
+            feedQueuedMouseEvents();
+    } else
+        feedMouseEvent(eventInfo);
+}
+
+static void feedMouseEvent(MouseEventInfo* eventInfo)
+{
+    if (!eventInfo)
+        return;
+
+    unsigned timeStamp = 0;
+    Evas_Object* mainFrame = browser->mainFrame();
+    Evas* evas = evas_object_evas_get(mainFrame);
+    DumpRenderTreeSupportEfl::layoutFrame(mainFrame);
+    EvasMouseEvent event = eventInfo->event;
+
+    setEvasModifiers(evas, eventInfo->modifiers);
+
+    Evas_Button_Flags flags = EVAS_BUTTON_NONE;
+
+    // FIXME: We need to pass additional information with our events, so that
+    // we could construct correct PlatformWheelEvent. At the moment, max number
+    // of clicks is 3
+    if (gClickCount == 3)
+        flags = EVAS_BUTTON_TRIPLE_CLICK;
+    else if (gClickCount == 2)
+        flags = EVAS_BUTTON_DOUBLE_CLICK;
+
+    if (event & EvasMouseEventMove)
+        evas_event_feed_mouse_move(evas, gLastMousePositionX, gLastMousePositionY, timeStamp++, 0);
+    if (event & EvasMouseEventDown)
+        evas_event_feed_mouse_down(evas, eventInfo->button, flags, timeStamp++, 0);
+    if (event & EvasMouseEventUp)
+        evas_event_feed_mouse_up(evas, eventInfo->button, flags, timeStamp++, 0);
+    if (event & EvasMouseEventScrollLeft | event & EvasMouseEventScrollRight)
+        evas_event_feed_mouse_wheel(evas, 1, eventInfo->horizontalDelta, timeStamp, 0);
+    if (event & EvasMouseEventScrollUp | event & EvasMouseEventScrollDown)
+        evas_event_feed_mouse_wheel(evas, 0, eventInfo->verticalDelta, timeStamp, 0);
+
+    setEvasModifiers(evas, EvasKeyModifierNone);
+
+    delete eventInfo;
+}
+
+static void feedQueuedMouseEvents()
+{
+    WTF::Vector<DelayedEvent>::const_iterator it = delayedEventQueue().begin();
+    for (; it != delayedEventQueue().end(); it++) {
+        DelayedEvent delayedEvent = *it;
+        if (delayedEvent.delay)
+            usleep(delayedEvent.delay * 1000);
+        feedMouseEvent(delayedEvent.eventInfo);
+    }
+    delayedEventQueue().clear();
+}