[EFL] [DRT] Implement scheduleAsynchronousKeyDown.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Mar 2012 15:40:49 +0000 (15:40 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Mar 2012 15:40:49 +0000 (15:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79601

Patch by ChangSeok Oh <shivamidow@gmail.com> on 2012-03-13
Reviewed by Gustavo Noronha Silva.

Source/WebKit/efl:

Added a new API to deliver all mutations explicitly.

* WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
(DumpRenderTreeSupportEfl::deliverAllMutationsIfNecessary):
* WebCoreSupport/DumpRenderTreeSupportEfl.h:

Tools:

Extracted shareable code from keyDownCallback and then added createKeyEventInfo.
createKeyEventInfo creates a new structure KeyEventInfo that has keyName and modifiers
and is taken over to sendKeyDown.
Added sendKeyDown and sendAsynchronousKeyDown to evaluate keyDown event directly
and asynchronously. Eventually, sendAsynchronousKeyDown calls sendKeyDown.

* DumpRenderTree/efl/EventSender.cpp:
(KeyEventInfo::KeyEventInfo):
(KeyEventInfo):
(createKeyEventInfo):
(sendKeyDown):
(keyDownCallback):
(sendAsynchronousKeyDown):
(scheduleAsynchronousKeyDownCallback):

LayoutTests:

Removed following two skipped tests.
fast/mutation/end-of-task-delivery.html
fast/mutation/inline-event-listener.html

* platform/efl/Skipped:

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

LayoutTests/ChangeLog
LayoutTests/platform/efl/Skipped
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp
Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.h
Tools/ChangeLog
Tools/DumpRenderTree/efl/EventSender.cpp

index 0fca9f7..a29ab1d 100644 (file)
@@ -1,3 +1,16 @@
+2012-03-13  ChangSeok Oh  <shivamidow@gmail.com>
+
+        [EFL] [DRT] Implement scheduleAsynchronousKeyDown.
+        https://bugs.webkit.org/show_bug.cgi?id=79601
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Removed following two skipped tests.
+        fast/mutation/end-of-task-delivery.html
+        fast/mutation/inline-event-listener.html
+
+        * platform/efl/Skipped:
+
 2012-03-13  Stephen Chenney  <schenney@chromium.org>
 
         Crash in WebCore::GraphicsContext::paintingDisabled
index f7746d6..56d0815 100644 (file)
@@ -1229,11 +1229,6 @@ http/tests/globalhistory
 # PasteBoard::plainText() does not support file names.
 editing/pasteboard/drag-files-to-editable-element.html
 
-# Fails because MutationObservers are not notified at end-of-task
-# https://bugs.webkit.org/show_bug.cgi?id=78290
-fast/mutation/end-of-task-delivery.html
-fast/mutation/inline-event-listener.html
-
 # Fails because of the security policy of the user agent?
 # http://webkit.org/b/79604
 fast/mutation/database-callback-delivery.html
index d48ba51..2dd4184 100644 (file)
@@ -1,3 +1,16 @@
+2012-03-13  ChangSeok Oh  <shivamidow@gmail.com>
+
+        [EFL] [DRT] Implement scheduleAsynchronousKeyDown.
+        https://bugs.webkit.org/show_bug.cgi?id=79601
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Added a new API to deliver all mutations explicitly.
+
+        * WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
+        (DumpRenderTreeSupportEfl::deliverAllMutationsIfNecessary):
+        * WebCoreSupport/DumpRenderTreeSupportEfl.h:
+
 2012-03-13  JungJik Lee  <jungjik.lee@samsung.com>
 
         [EFL] Remove a duplicate allocation of matrix entry.
index fd3d6b5..8d14a18 100644 (file)
@@ -37,6 +37,7 @@
 #include <PrintContext.h>
 #include <RenderTreeAsText.h>
 #include <Settings.h>
+#include <WebKitMutationObserver.h>
 #include <bindings/js/GCController.h>
 #include <history/HistoryItem.h>
 #include <workers/WorkerThread.h>
@@ -405,3 +406,10 @@ void DumpRenderTreeSupportEfl::dumpConfigurationForViewport(Evas_Object* ewkView
     restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
     fprintf(stdout, "viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n", attributes.layoutSize.width(), attributes.layoutSize.height(), attributes.initialScale, attributes.minimumScale, attributes.maximumScale, attributes.userScalable);
 }
+
+void DumpRenderTreeSupportEfl::deliverAllMutationsIfNecessary()
+{
+#if ENABLE(MUTATION_OBSERVERS)
+    WebCore::WebKitMutationObserver::deliverAllMutations();
+#endif
+}
index 950a78d..7ffc335 100644 (file)
@@ -79,6 +79,8 @@ public:
     static void setMockScrollbarsEnabled(bool);
 
     static void dumpConfigurationForViewport(Evas_Object* ewkView, int deviceDPI, const WebCore::IntSize& deviceSize, const WebCore::IntSize& availableSize);
+
+    static void deliverAllMutationsIfNecessary();
 };
 
 #endif // DumpRenderTreeSupportEfl_h
index 2fef630..7ec2035 100644 (file)
@@ -1,3 +1,25 @@
+2012-03-13  ChangSeok Oh  <shivamidow@gmail.com>
+
+        [EFL] [DRT] Implement scheduleAsynchronousKeyDown.
+        https://bugs.webkit.org/show_bug.cgi?id=79601
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Extracted shareable code from keyDownCallback and then added createKeyEventInfo.
+        createKeyEventInfo creates a new structure KeyEventInfo that has keyName and modifiers
+        and is taken over to sendKeyDown.
+        Added sendKeyDown and sendAsynchronousKeyDown to evaluate keyDown event directly
+        and asynchronously. Eventually, sendAsynchronousKeyDown calls sendKeyDown.
+
+        * DumpRenderTree/efl/EventSender.cpp:
+        (KeyEventInfo::KeyEventInfo):
+        (KeyEventInfo):
+        (createKeyEventInfo):
+        (sendKeyDown):
+        (keyDownCallback):
+        (sendAsynchronousKeyDown):
+        (scheduleAsynchronousKeyDownCallback):
+
 2012-03-12  Ojan Vafai  <ojan@chromium.org>
 
         webkit-patch optimize-baselines sometimes creates a mac-future result
index 7a4ca30..5934d4c 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2009 Holger Hans Peter Freyther
  * Copyright (C) 2010 Igalia S.L.
  * Copyright (C) 2011 ProFUSION Embedded Systems
- * Copyright (C) 2011 Samsung Electronics
+ * Copyright (C) 2011, 2012 Samsung Electronics
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -103,6 +103,17 @@ enum ZoomEvent {
     ZoomOut
 };
 
+struct KeyEventInfo {
+    KeyEventInfo(const char* keyName, EvasKeyModifier modifiers)
+        : keyName(keyName)
+        , modifiers(modifiers)
+    {
+    }
+
+    const char* keyName;
+    EvasKeyModifier modifiers;
+};
+
 static void setEvasModifiers(Evas* evas, EvasKeyModifier modifiers)
 {
     static const char* modifierNames[] = { "Control", "Shift", "Alt", "Super" };
@@ -399,14 +410,13 @@ static const char* keyNameFromJSValue(JSStringRef character)
     return 0;
 }
 
-static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+static KeyEventInfo* createKeyEventInfo(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    Evas_Object* view = ewk_frame_view_get(browser->mainFrame());
-    if (!view)
-        return JSValueMakeUndefined(context);
+    if (!ewk_frame_view_get(browser->mainFrame()))
+        return 0;
 
     if (argumentCount < 1)
-        return JSValueMakeUndefined(context);
+        return 0;
 
     // handle location argument.
     int location = DomKeyLocationStandard;
@@ -415,25 +425,44 @@ static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JS
 
     JSRetainPtr<JSStringRef> character(Adopt, JSValueToStringCopy(context, arguments[0], exception));
     if (exception && *exception)
-        return JSValueMakeUndefined(context);
+        return 0;
 
-    // send the event
-    Evas* evas = evas_object_evas_get(view);
+    EvasKeyModifier modifiers = EvasKeyModifierNone;
     if (argumentCount >= 2)
-        setEvasModifiers(evas, modifiersFromJSValue(context, arguments[1]));
+        modifiers = modifiersFromJSValue(context, arguments[1]);
 
     const CString cCharacter = character.get()->ustring().utf8();
     const char* keyName = (location == DomKeyLocationNumpad) ? keyPadNameFromJSValue(character.get()) : keyNameFromJSValue(character.get());
-
     if (!keyName)
         keyName = cCharacter.data();
 
+    return new KeyEventInfo(keyName, modifiers);
+}
+
+static void sendKeyDown(Evas* evas, KeyEventInfo* keyEventInfo)
+{
+    if (!keyEventInfo)
+        return;
+
+    const char* keyName = keyEventInfo->keyName;
+    EvasKeyModifier modifiers = keyEventInfo->modifiers;
+
     DumpRenderTreeSupportEfl::layoutFrame(browser->mainFrame());
+
+    ASSERT(evas);
+    setEvasModifiers(evas, modifiers);
     evas_event_feed_key_down(evas, keyName, keyName, keyName, 0, 0, 0);
     evas_event_feed_key_up(evas, keyName, keyName, keyName, 0, 1, 0);
-
     setEvasModifiers(evas, EvasKeyModifierNone);
 
+    DumpRenderTreeSupportEfl::deliverAllMutationsIfNecessary();
+}
+
+static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    OwnPtr<KeyEventInfo> keyEventInfo = adoptPtr(createKeyEventInfo(context, argumentCount, arguments, exception));
+    sendKeyDown(evas_object_evas_get(browser->mainFrame()), keyEventInfo.get());
+
     return JSValueMakeUndefined(context);
 }
 
@@ -508,6 +537,20 @@ static JSValueRef zoomPageOutCallback(JSContextRef context, JSObjectRef function
     return JSValueMakeUndefined(context);
 }
 
+static Eina_Bool sendAsynchronousKeyDown(void* userData)
+{
+    OwnPtr<KeyEventInfo> keyEventInfo = adoptPtr(static_cast<KeyEventInfo*>(userData));
+    sendKeyDown(evas_object_evas_get(browser->mainFrame()), keyEventInfo.get());
+    return ECORE_CALLBACK_CANCEL;
+}
+
+static JSValueRef scheduleAsynchronousKeyDownCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    KeyEventInfo* keyEventInfo = createKeyEventInfo(context, argumentCount, arguments, exception);
+    ecore_idler_add(sendAsynchronousKeyDown, static_cast<void*>(keyEventInfo));
+    return JSValueMakeUndefined(context);
+}
+
 static JSStaticFunction staticFunctions[] = {
     { "mouseScrollBy", mouseScrollByCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "continuousMouseScrollBy", continuousMouseScrollByCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -516,6 +559,7 @@ static JSStaticFunction staticFunctions[] = {
     { "mouseMoveTo", mouseMoveToCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "keyDown", keyDownCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "scheduleAsynchronousClick", scheduleAsynchronousClickCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    { "scheduleAsynchronousKeyDown", scheduleAsynchronousKeyDownCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "scalePageBy", scalePageByCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "textZoomIn", textZoomInCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "textZoomOut", textZoomOutCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },