[Gtk] Implement textInputController.doCommand
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2011 17:40:14 +0000 (17:40 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2011 17:40:14 +0000 (17:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=66496

Patch by Kaustubh Atrawalkar <kaustubh@motorola.com> on 2011-09-28
Reviewed by Martin Robinson.

Source/WebKit/gtk:

* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::doCommand): Function definition for doCommand
callback. Converted Incoming command to match with WebCore::Editor CommandMap.
* WebCoreSupport/DumpRenderTreeSupportGtk.h:

Tools:

* DumpRenderTree/gtk/TextInputController.cpp:
(doCommandCallback): Callback function for textInputController.doCommand

LayoutTests:

Removed skipped tests under textInputController.doCommand for Gtk Port.

* platform/gtk/Skipped:

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

LayoutTests/ChangeLog
LayoutTests/platform/gtk/Skipped
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h
Tools/ChangeLog
Tools/DumpRenderTree/gtk/TextInputController.cpp

index 3a9a0c8..0a5b266 100644 (file)
@@ -1,3 +1,14 @@
+2011-09-28  Kaustubh Atrawalkar  <kaustubh@motorola.com>
+
+        [Gtk] Implement textInputController.doCommand
+        https://bugs.webkit.org/show_bug.cgi?id=66496
+
+        Reviewed by Martin Robinson.
+
+        Removed skipped tests under textInputController.doCommand for Gtk Port.
+
+        * platform/gtk/Skipped:
+
 2011-09-28  Tom Sepez  <tsepez@chromium.org>
 
         Revert change which broke displaying end script tags in view-source, instead
index 5b71f0b..c0a4db9 100644 (file)
@@ -1545,13 +1545,6 @@ editing/spelling/grammar.html
 # layoutTestController::setTextDirection() is not implemented.
 fast/html/set-text-direction.html
 
-# textInputController.doCommand is not implemented.
-# https://bugs.webkit.org/show_bug.cgi?id=66496
-editing/input/password-echo-passnode.html
-editing/input/password-echo-passnode2.html
-editing/input/password-echo-passnode3.html
-editing/input/password-echo-textnode.html
-
 # https://bugs.webkit.org/show_bug.cgi?id=57160 
 # [GTK] layoutTestController.overridePreference("WebKitDefaultFontSize"...) does not take into account screen DPI
 fast/harness/override-preferences-2.html
index ebffb98..dbf4519 100644 (file)
@@ -1,3 +1,15 @@
+2011-09-28  Kaustubh Atrawalkar  <kaustubh@motorola.com>
+
+        [Gtk] Implement textInputController.doCommand
+        https://bugs.webkit.org/show_bug.cgi?id=66496
+
+        Reviewed by Martin Robinson.
+
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+        (DumpRenderTreeSupportGtk::doCommand): Function definition for doCommand 
+        callback. Converted Incoming command to match with WebCore::Editor CommandMap.
+        * WebCoreSupport/DumpRenderTreeSupportGtk.h:
+
 2011-09-27  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Reorganize header files
index a14e946..a7fd85b 100644 (file)
@@ -575,6 +575,31 @@ void DumpRenderTreeSupportGtk::confirmComposition(WebKitWebView* webView, const
     editor->confirmComposition();
 }
 
+void DumpRenderTreeSupportGtk::doCommand(WebKitWebView* webView, const char* command)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+    Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+    if (!frame)
+        return;
+
+    Editor* editor = frame->editor();
+    if (!editor)
+        return;
+
+    String commandString(command);
+    // Remove ending : here.
+    if (commandString.endsWith(":", true))
+        commandString = commandString.left(commandString.length() - 1);
+
+    // Make the first char in upper case.
+    String firstChar = commandString.left(1);
+    commandString = commandString.right(commandString.length() - 1);
+    firstChar.makeUpper();
+    commandString.insert(firstChar, 0);
+
+    editor->command(commandString).execute();
+}
+
 bool DumpRenderTreeSupportGtk::firstRectForCharacterRange(WebKitWebView* webView, int location, int length, cairo_rectangle_int_t* rect)
 {
     g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false);
index 73c445a..1a203d5 100644 (file)
@@ -109,7 +109,7 @@ public:
     static void confirmComposition(WebKitWebView*, const char*);
     static bool firstRectForCharacterRange(WebKitWebView*, int location, int length, cairo_rectangle_int_t*);
     static bool selectedRange(WebKitWebView*, int* start, int* length);
-
+    static void doCommand(WebKitWebView*, const char*);
     // GC
     static void gcCollectJavascriptObjects();
     static void gcCollectJavascriptObjectsOnAlternateThread(bool waitUntilDone);
index 1f72e22..375a8ca 100644 (file)
@@ -1,3 +1,13 @@
+2011-09-28  Kaustubh Atrawalkar  <kaustubh@motorola.com>
+
+        [Gtk] Implement textInputController.doCommand
+        https://bugs.webkit.org/show_bug.cgi?id=66496
+
+        Reviewed by Martin Robinson.
+
+        * DumpRenderTree/gtk/TextInputController.cpp:
+        (doCommandCallback): Callback function for textInputController.doCommand
+
 2011-09-28  David Levin  <levin@chromium.org>
 
         watchlist: Suggest corrections for typos and improve error message consistency.
index f9b2a6e..eed3bbe 100644 (file)
@@ -162,6 +162,25 @@ static JSValueRef selectedRangeCallback(JSContextRef context, JSObjectRef functi
     return arrayObject;
 }
 
+static JSValueRef doCommandCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
+    ASSERT(view);
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    JSStringRef string = JSValueToStringCopy(context, arguments[0], exception);
+    ASSERT(!exception || !*exception);
+
+    size_t bufferSize = JSStringGetMaximumUTF8CStringSize(string);
+    GOwnPtr<gchar> stringBuffer(static_cast<gchar*>(g_malloc(bufferSize)));
+    JSStringGetUTF8CString(string, stringBuffer.get(), bufferSize);
+    JSStringRelease(string);
+
+    DumpRenderTreeSupportGtk::doCommand(view, stringBuffer.get());
+    return JSValueMakeUndefined(context);
+}
+
 static JSStaticFunction staticFunctions[] = {
     { "setMarkedText", setMarkedTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "hasMarkedText", hasMarkedTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -170,6 +189,7 @@ static JSStaticFunction staticFunctions[] = {
     { "unmarkText", unmarkTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "firstRectForCharacterRange", firstRectForCharacterRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "selectedRange", selectedRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    { "doCommand", doCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { 0, 0, 0 }
 };