Title: [88498] trunk
Revision
88498
Author
[email protected]
Date
2011-06-09 16:33:49 -0700 (Thu, 09 Jun 2011)

Log Message

2011-06-09  Martin Robinson  <[email protected]>

        Reviewed by Eric Seidel.

        [GTK] Implement the next bit of the TextInputController (hasMarkedText and markedRange)
        https://bugs.webkit.org/show_bug.cgi?id=55603

        * platform/gtk/Skipped: Unskip a test that is now passing. Better describe remaining failures.
2011-06-09  Martin Robinson  <[email protected]>

        Reviewed by Eric Seidel.

        [GTK] Implement the next bit of the TextInputController (hasMarkedText and markedRange)
        https://bugs.webkit.org/show_bug.cgi?id=55603

        Added DumpRenderTreeSupport methods to support hasMarkedText and markedRange.

        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
        (DumpRenderTreeSupportGtk::setComposition): Use start and length rather than start and
        end. This matches other ports. Only use GLib style early returns when checking the
        validity of GObjects.
        (DumpRenderTreeSupportGtk::hasComposition):  Added.
        (DumpRenderTreeSupportGtk::compositionRange): Added.
        (DumpRenderTreeSupportGtk::confirmComposition): Cleanup as described above.
        (DumpRenderTreeSupportGtk::firstRectForCharacterRange): Cleanup as described above.
        (DumpRenderTreeSupportGtk::selectedRange): Cleanup as described above.
        * WebCoreSupport/DumpRenderTreeSupportGtk.h: Added new declarations.
2011-06-09  Martin Robinson  <[email protected]>

        Reviewed by Eric Seidel.

        [GTK] Implement the next bit of the TextInputController (hasMarkedText and markedRange)
        https://bugs.webkit.org/show_bug.cgi?id=55603

        Add callbacks to support hasMarkedText and markedRange and also clean up existing
        TextInputController support.

        * DumpRenderTree/gtk/TextInputController.cpp:
        (setMarkedTextCallback): Accept parameters in terms of start and length, instead
        of start and end. This matches the other ports. Do not use GLib style early returns.
        (hasMarkedTextCallback): Added.
        (markedRangeCallback): Added.
        (insertTextCallback): Cleanup as described above.
        (unmarkTextCallback): Cleanup as described above.
        (firstRectForCharacterRangeCallback): Cleanup as described above.
        (selectedRangeCallback): Cleanup as described above.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (88497 => 88498)


--- trunk/LayoutTests/ChangeLog	2011-06-09 23:04:51 UTC (rev 88497)
+++ trunk/LayoutTests/ChangeLog	2011-06-09 23:33:49 UTC (rev 88498)
@@ -1,3 +1,12 @@
+2011-06-09  Martin Robinson  <[email protected]>
+
+        Reviewed by Eric Seidel.
+
+        [GTK] Implement the next bit of the TextInputController (hasMarkedText and markedRange)
+        https://bugs.webkit.org/show_bug.cgi?id=55603
+
+        * platform/gtk/Skipped: Unskip a test that is now passing. Better describe remaining failures.
+
 2011-06-09  Kenneth Russell  <[email protected]>
 
         Skipped new tests from r88489 on WebKit Win, since WebGL is not yet enabled.

Modified: trunk/LayoutTests/platform/gtk/Skipped (88497 => 88498)


--- trunk/LayoutTests/platform/gtk/Skipped	2011-06-09 23:04:51 UTC (rev 88497)
+++ trunk/LayoutTests/platform/gtk/Skipped	2011-06-09 23:33:49 UTC (rev 88498)
@@ -753,8 +753,8 @@
 # Need to add functionality to DumpRenderTree to handle error pages
 fast/history/back-forward-reset-after-error-handling.html
 
-# Missing textInputController
-editing/input/setting-input-value-cancel-ime-composition.html
+# These tests also use firstRectForCharacterRange, but they generate slightly
+# different values. (Chromium also fails here; see their test_expectations.txt file)
 editing/selection/mixed-editability-10.html
 editing/selection/5825350-1.html
 editing/selection/5825350-2.html

Modified: trunk/Source/WebKit/gtk/ChangeLog (88497 => 88498)


--- trunk/Source/WebKit/gtk/ChangeLog	2011-06-09 23:04:51 UTC (rev 88497)
+++ trunk/Source/WebKit/gtk/ChangeLog	2011-06-09 23:33:49 UTC (rev 88498)
@@ -1,3 +1,23 @@
+2011-06-09  Martin Robinson  <[email protected]>
+
+        Reviewed by Eric Seidel.
+
+        [GTK] Implement the next bit of the TextInputController (hasMarkedText and markedRange)
+        https://bugs.webkit.org/show_bug.cgi?id=55603
+
+        Added DumpRenderTreeSupport methods to support hasMarkedText and markedRange.
+
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+        (DumpRenderTreeSupportGtk::setComposition): Use start and length rather than start and
+        end. This matches other ports. Only use GLib style early returns when checking the
+        validity of GObjects.
+        (DumpRenderTreeSupportGtk::hasComposition):  Added.
+        (DumpRenderTreeSupportGtk::compositionRange): Added.
+        (DumpRenderTreeSupportGtk::confirmComposition): Cleanup as described above.
+        (DumpRenderTreeSupportGtk::firstRectForCharacterRange): Cleanup as described above.
+        (DumpRenderTreeSupportGtk::selectedRange): Cleanup as described above.
+        * WebCoreSupport/DumpRenderTreeSupportGtk.h: Added new declarations.
+
 2011-06-08  Xan Lopez  <[email protected]>
 
         Reviewed by Martin Robinson.

Modified: trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp (88497 => 88498)


--- trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp	2011-06-09 23:04:51 UTC (rev 88497)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp	2011-06-09 23:33:49 UTC (rev 88498)
@@ -512,7 +512,7 @@
     return core(webView)->focusController()->focusedOrMainFrame()->editor()->command(name).isEnabled();
 }
 
-void DumpRenderTreeSupportGtk::setComposition(WebKitWebView* webView, const char* text, int start, int end)
+void DumpRenderTreeSupportGtk::setComposition(WebKitWebView* webView, const char* text, int start, int length)
 {
     g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
     g_return_if_fail(text);
@@ -522,17 +522,47 @@
         return;
 
     Editor* editor = frame->editor();
-    if (!editor)
+    if (!editor || (!editor->canEdit() && !editor->hasComposition()))
         return;
-    if (!editor->canEdit() && !editor->hasComposition())
-        return;
 
     String compositionString = String::fromUTF8(text);
     Vector<CompositionUnderline> underlines;
     underlines.append(CompositionUnderline(0, compositionString.length(), Color(0, 0, 0), false));
-    editor->setComposition(compositionString, underlines, start, end);
+    editor->setComposition(compositionString, underlines, start, start + length);
 }
 
+bool DumpRenderTreeSupportGtk::hasComposition(WebKitWebView* webView)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false);
+    Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+    if (!frame)
+        return false;
+    Editor* editor = frame->editor();
+    if (!editor)
+        return false;
+
+    return editor->hasComposition();
+}
+
+bool DumpRenderTreeSupportGtk::compositionRange(WebKitWebView* webView, int* start, int* length)
+{
+    g_return_val_if_fail(start && length, false);
+    *start = *length = 0;
+
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false);
+    Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+    if (!frame)
+        return false;
+
+    Editor* editor = frame->editor();
+    if (!editor || !editor->hasComposition())
+        return false;
+
+    *start = editor->compositionStart();
+    *length = editor->compositionEnd() - *start;
+    return true;
+}
+
 void DumpRenderTreeSupportGtk::confirmComposition(WebKitWebView* webView, const char* text)
 {
     g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
@@ -542,16 +572,18 @@
         return;
 
     Editor* editor = frame->editor();
-    if (!editor || (!editor->hasComposition() && !text))
+    if (!editor)
         return;
 
-    if (editor->hasComposition()) {
-        if (text)
-            editor->confirmComposition(String::fromUTF8(text));
-        else
-            editor->confirmComposition();
-    } else
+    if (!editor->hasComposition()) {
         editor->insertText(String::fromUTF8(text), 0);
+        return;
+    }
+    if (text) {
+        editor->confirmComposition(String::fromUTF8(text));
+        return;
+    }
+    editor->confirmComposition();
 }
 
 bool DumpRenderTreeSupportGtk::firstRectForCharacterRange(WebKitWebView* webView, int location, int length, GdkRectangle* rect)
@@ -577,21 +609,21 @@
         return false;
 
     *rect = editor->firstRectForRange(range.get());
-
     return true;
 }
 
-bool DumpRenderTreeSupportGtk::selectedRange(WebKitWebView* webView, int* start, int* end)
+bool DumpRenderTreeSupportGtk::selectedRange(WebKitWebView* webView, int* start, int* length)
 {
     g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false);
-    g_return_val_if_fail(start, false);
-    g_return_val_if_fail(end, false);
+    g_return_val_if_fail(start && length, false);
 
     Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
     if (!frame)
         return false;
 
     RefPtr<Range> range = frame->selection()->toNormalizedRange().get();
+    if (!range)
+        return false;
 
     Element* selectionRoot = frame->selection()->rootEditableElement();
     Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
@@ -603,7 +635,7 @@
     ExceptionCode ec;
     testRange->setEnd(range->endContainer(), range->endOffset(), ec);
     ASSERT(testRange->startContainer() == scope);
-    *end = TextIterator::rangeLength(testRange.get());
+    *length = TextIterator::rangeLength(testRange.get());
 
     return true;
 }

Modified: trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h (88497 => 88498)


--- trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h	2011-06-09 23:04:51 UTC (rev 88497)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h	2011-06-09 23:33:49 UTC (rev 88498)
@@ -97,10 +97,6 @@
     static void executeCoreCommandByName(WebKitWebView*, const gchar* name, const gchar* value);
     static bool isCommandEnabled(WebKitWebView*, const gchar* name);
     static bool findString(WebKitWebView*, const gchar*, WebKitFindOptions);
-    static void setComposition(WebKitWebView*, const char* text, int start, int end);
-    static void confirmComposition(WebKitWebView*, const char* text);
-    static bool firstRectForCharacterRange(WebKitWebView*, int location, int length, GdkRectangle*);
-    static bool selectedRange(WebKitWebView*, int* start, int* end);
     static double defaultMinimumTimerInterval(); // Not really tied to WebView
     static void setMinimumTimerInterval(WebKitWebView*, double);
     static void rectangleForSelection(WebKitWebFrame*, GdkRectangle*);
@@ -111,6 +107,14 @@
     static void incrementAccessibilityValue(AtkObject*);
     static void decrementAccessibilityValue(AtkObject*);
 
+    // TextInputController
+    static void setComposition(WebKitWebView*, const char*, int start, int length);
+    static bool hasComposition(WebKitWebView*);
+    static bool compositionRange(WebKitWebView*, int* start, int* length);
+    static void confirmComposition(WebKitWebView*, const char*);
+    static bool firstRectForCharacterRange(WebKitWebView*, int location, int length, GdkRectangle*);
+    static bool selectedRange(WebKitWebView*, int* start, int* length);
+
     // GC
     static void gcCollectJavascriptObjects();
     static void gcCollectJavascriptObjectsOnAlternateThread(bool waitUntilDone);

Modified: trunk/Tools/ChangeLog (88497 => 88498)


--- trunk/Tools/ChangeLog	2011-06-09 23:04:51 UTC (rev 88497)
+++ trunk/Tools/ChangeLog	2011-06-09 23:33:49 UTC (rev 88498)
@@ -1,3 +1,23 @@
+2011-06-09  Martin Robinson  <[email protected]>
+
+        Reviewed by Eric Seidel.
+
+        [GTK] Implement the next bit of the TextInputController (hasMarkedText and markedRange)
+        https://bugs.webkit.org/show_bug.cgi?id=55603
+
+        Add callbacks to support hasMarkedText and markedRange and also clean up existing 
+        TextInputController support.
+
+        * DumpRenderTree/gtk/TextInputController.cpp:
+        (setMarkedTextCallback): Accept parameters in terms of start and length, instead
+        of start and end. This matches the other ports. Do not use GLib style early returns.
+        (hasMarkedTextCallback): Added.
+        (markedRangeCallback): Added.
+        (insertTextCallback): Cleanup as described above.
+        (unmarkTextCallback): Cleanup as described above.
+        (firstRectForCharacterRangeCallback): Cleanup as described above.
+        (selectedRangeCallback): Cleanup as described above.
+
 2011-06-09  Dirk Pranke  <[email protected]>
 
         Reviewed by Tony Chang.

Modified: trunk/Tools/DumpRenderTree/gtk/TextInputController.cpp (88497 => 88498)


--- trunk/Tools/DumpRenderTree/gtk/TextInputController.cpp	2011-06-09 23:04:51 UTC (rev 88497)
+++ trunk/Tools/DumpRenderTree/gtk/TextInputController.cpp	2011-06-09 23:33:49 UTC (rev 88498)
@@ -41,14 +41,12 @@
 static JSValueRef setMarkedTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
-    if (!view)
-        return JSValueMakeUndefined(context);
-
+    ASSERT(view);
     if (argumentCount < 3)
         return JSValueMakeUndefined(context);
 
     JSStringRef string = JSValueToStringCopy(context, arguments[0], exception);
-    g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context));
+    ASSERT(!exception || !*exception);
 
     size_t bufferSize = JSStringGetMaximumUTF8CStringSize(string);
     GOwnPtr<gchar> stringBuffer(static_cast<gchar*>(g_malloc(bufferSize)));
@@ -56,27 +54,49 @@
     JSStringRelease(string);
 
     int start = static_cast<int>(JSValueToNumber(context, arguments[1], exception));
-    g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context));
+    ASSERT(!exception || !*exception);
 
-    int end = static_cast<int>(JSValueToNumber(context, arguments[2], exception));
-    g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context));
+    int length = static_cast<int>(JSValueToNumber(context, arguments[2], exception));
+    ASSERT(!exception || !*exception);
 
-    DumpRenderTreeSupportGtk::setComposition(view, stringBuffer.get(), start, end);
-
+    DumpRenderTreeSupportGtk::setComposition(view, stringBuffer.get(), start, length);
     return JSValueMakeUndefined(context);
 }
 
-static JSValueRef insertTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+static JSValueRef hasMarkedTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
-    if (!view)
+    ASSERT(view);
+    return JSValueMakeBoolean(context, DumpRenderTreeSupportGtk::hasComposition(view));
+}
+
+static JSValueRef markedRangeCallback(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);
+
+    int start, length;
+    if (!DumpRenderTreeSupportGtk::compositionRange(view, &start, &length))
         return JSValueMakeUndefined(context);
 
+    JSValueRef arrayValues[2];
+    arrayValues[0] = JSValueMakeNumber(context, start);
+    arrayValues[1] = JSValueMakeNumber(context, length);
+    JSObjectRef arrayObject = JSObjectMakeArray(context, 2, arrayValues, exception);
+    ASSERT(!exception || !*exception);
+    return arrayObject;
+}
+
+static JSValueRef insertTextCallback(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);
-    g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context));
+    ASSERT(!exception || !*exception);
 
     size_t bufferSize = JSStringGetMaximumUTF8CStringSize(string);
     GOwnPtr<gchar> stringBuffer(static_cast<gchar*>(g_malloc(bufferSize)));
@@ -84,15 +104,13 @@
     JSStringRelease(string);
 
     DumpRenderTreeSupportGtk::confirmComposition(view, stringBuffer.get());
-
     return JSValueMakeUndefined(context);
 }
 
 static JSValueRef unmarkTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
-    if (!view)
-        return JSValueMakeUndefined(context);
+    ASSERT(view);
 
     DumpRenderTreeSupportGtk::confirmComposition(view, 0);
     return JSValueMakeUndefined(context);
@@ -101,17 +119,15 @@
 static JSValueRef firstRectForCharacterRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
-    if (!view)
-        return JSValueMakeUndefined(context);
-
+    ASSERT(view);
     if (argumentCount < 2)
         return JSValueMakeUndefined(context);
 
     int location = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
-    g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context));
+    ASSERT(!exception || !*exception);
 
     int length = static_cast<int>(JSValueToNumber(context, arguments[1], exception));
-    g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context));
+    ASSERT(!exception || !*exception);
 
     GdkRectangle rect;
     if (!DumpRenderTreeSupportGtk::firstRectForCharacterRange(view, location, length, &rect))
@@ -123,7 +139,7 @@
     arrayValues[2] = JSValueMakeNumber(context, rect.width);
     arrayValues[3] = JSValueMakeNumber(context, rect.height);
     JSObjectRef arrayObject = JSObjectMakeArray(context, 4, arrayValues, exception);
-    g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context));
+    ASSERT(!exception || !*exception);
 
     return arrayObject;
 }
@@ -131,24 +147,25 @@
 static JSValueRef selectedRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
-    if (!view)
-        return JSValueMakeUndefined(context);
+    ASSERT(view);
 
-    int start, end;
-    if (!DumpRenderTreeSupportGtk::selectedRange(view, &start, &end))
+    int start, length;
+    if (!DumpRenderTreeSupportGtk::selectedRange(view, &start, &length))
         return JSValueMakeUndefined(context);
 
     JSValueRef arrayValues[2];
     arrayValues[0] = JSValueMakeNumber(context, start);
-    arrayValues[1] = JSValueMakeNumber(context, end);
+    arrayValues[1] = JSValueMakeNumber(context, length);
     JSObjectRef arrayObject = JSObjectMakeArray(context, 2, arrayValues, exception);
-    g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context));
+    ASSERT(!exception || !*exception);
 
     return arrayObject;
 }
 
 static JSStaticFunction staticFunctions[] = {
     { "setMarkedText", setMarkedTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    { "hasMarkedText", hasMarkedTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    { "markedRange", markedRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "insertText", insertTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "unmarkText", unmarkTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     { "firstRectForCharacterRange", firstRectForCharacterRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to