2011-02-07 Joone Hur <joone.hur@collabora.co.uk>
authorjoone.hur@collabora.co.uk <joone.hur@collabora.co.uk@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Feb 2011 01:23:29 +0000 (01:23 +0000)
committerjoone.hur@collabora.co.uk <joone.hur@collabora.co.uk@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Feb 2011 01:23:29 +0000 (01:23 +0000)
        Reviewed by Martin Robinson.

        [Gtk] Implement layoutTestController.findString
        https://bugs.webkit.org/show_bug.cgi?id=50237

        Unskip editing/text-iterator/findString.html.

        * platform/gtk/Skipped: Unskip findString test.
2011-02-07  Joone Hur  <joone.hur@collabora.co.uk>

        Reviewed by Martin Robinson.

        [Gtk] Implement layoutTestController.findString
        https://bugs.webkit.org/show_bug.cgi?id=50237

        * GNUmakefile.am: Add AssertMatchingEnums.cpp.
        * WebCoreSupport/AssertMatchingEnums.cpp: Add this file to assert that various
        WebKit API enum values continue matching WebCore defined enum values.
        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
        (DumpRenderTreeSupportGtk::findString):
        * WebCoreSupport/DumpRenderTreeSupportGtk.h:
2011-02-07  Joone Hur  <joone.hur@collabora.co.uk>

        Reviewed by Martin Robinson.

        [Gtk] Implement layoutTestController.findString
        https://bugs.webkit.org/show_bug.cgi?id=50237

        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
        (LayoutTestController::findString):

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

LayoutTests/ChangeLog
LayoutTests/platform/gtk/Skipped
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/GNUmakefile.am
Source/WebKit/gtk/WebCoreSupport/AssertMatchingEnums.cpp [new file with mode: 0644]
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h
Tools/ChangeLog
Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp

index 967b299..908d866 100644 (file)
@@ -1,3 +1,14 @@
+2011-02-07  Joone Hur  <joone.hur@collabora.co.uk>
+
+        Reviewed by Martin Robinson.
+
+        [Gtk] Implement layoutTestController.findString
+        https://bugs.webkit.org/show_bug.cgi?id=50237
+
+        Unskip editing/text-iterator/findString.html.
+
+        * platform/gtk/Skipped: Unskip findString test.
+
 2011-02-07  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Sam Weinig.
index 5e626ea..e7e7c13 100644 (file)
@@ -4550,9 +4550,6 @@ fast/text/large-text-composed-char-dos.html
 # LayoutTestController::addUserScript not implemented for gtk
 plugins/plugin-document-load-prevented-userscript.html
 
-# Missing layoutTestController.findString() http://webkit.org/b/50237
-editing/text-iterator/findString.html
-
 # https://bugs.webkit.org/show_bug.cgi?id=46942
 http/tests/websocket/tests/bad-sub-protocol-control-chars.html
 
index 57af67e..16a7089 100644 (file)
@@ -1,3 +1,17 @@
+2011-02-07  Joone Hur  <joone.hur@collabora.co.uk>
+
+        Reviewed by Martin Robinson.
+
+        [Gtk] Implement layoutTestController.findString
+        https://bugs.webkit.org/show_bug.cgi?id=50237
+
+        * GNUmakefile.am: Add AssertMatchingEnums.cpp.
+        * WebCoreSupport/AssertMatchingEnums.cpp: Add this file to assert that various 
+        WebKit API enum values continue matching WebCore defined enum values.
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+        (DumpRenderTreeSupportGtk::findString):
+        * WebCoreSupport/DumpRenderTreeSupportGtk.h:
+
 2011-02-07  Martin Robinson  <mrobinson@igalia.com>
 
         Reviewed by Daniel Bates.
index 82af08a..d207e00 100644 (file)
@@ -159,6 +159,7 @@ webkitgtk_sources += \
        Source/WebCore/bindings/gobject/WebKitDOMObject.h \
        Source/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp \
        Source/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.h \
+       Source/WebKit/gtk/WebCoreSupport/AssertMatchingEnums.cpp \
        Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp \
        Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h \
        Source/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp \
diff --git a/Source/WebKit/gtk/WebCoreSupport/AssertMatchingEnums.cpp b/Source/WebKit/gtk/WebCoreSupport/AssertMatchingEnums.cpp
new file mode 100644 (file)
index 0000000..9c596f8
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  Copyright (C) 2011 Collabora Ltd.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+// Use this file to assert that various WebKit API enum values continue
+// matching WebCore defined enum values.
+
+#include "config.h"
+
+#include "DumpRenderTreeSupportGtk.h"
+#include "FindOptions.h"
+#include <wtf/Assertions.h>
+
+#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \
+    COMPILE_ASSERT(int(WebKit::webkit_name) == int(WebCore::webcore_name), mismatching_enums)
+
+COMPILE_ASSERT_MATCHING_ENUM(WebFindOptionsCaseInsensitive , CaseInsensitive);
+COMPILE_ASSERT_MATCHING_ENUM(WebFindOptionsAtWordStarts, AtWordStarts);
+COMPILE_ASSERT_MATCHING_ENUM(WebFindOptionsTreatMedialCapitalAsWordStart, TreatMedialCapitalAsWordStart);
+COMPILE_ASSERT_MATCHING_ENUM(WebFindOptionsBackwards, Backwards);
+COMPILE_ASSERT_MATCHING_ENUM(WebFindOptionsWrapAround, WrapAround);
+COMPILE_ASSERT_MATCHING_ENUM(WebFindOptionsStartInSelection, StartInSelection);
index 6f31887..c6e6d0c 100644 (file)
@@ -532,3 +532,9 @@ bool DumpRenderTreeSupportGtk::webkitWebFrameSelectionHasSpellingMarker(WebKitWe
 
     return core(frame)->editor()->selectionStartHasSpellingMarkerFor(from, length);
 }
+
+bool DumpRenderTreeSupportGtk::findString(WebKitWebView* webView, const gchar* targetString, WebKitFindOptions findOptions)
+{
+    return core(webView)->findString(String::fromUTF8(targetString), findOptions);
+}
+
index 663f13a..ea6aa9d 100644 (file)
@@ -19,7 +19,6 @@
 #ifndef DumpRenderTreeSupportGtk_h
 #define DumpRenderTreeSupportGtk_h
 
-
 #include "JSStringRef.h"
 #include <webkit/webkitdefines.h>
 
 #include <webkit/webkitwebframe.h>
 #include <wtf/text/CString.h>
 
+namespace WebKit {
+
+enum {
+    WebFindOptionsCaseInsensitive = 1 << 0,
+    WebFindOptionsAtWordStarts = 1 << 1,
+    WebFindOptionsTreatMedialCapitalAsWordStart = 1 << 2,
+    WebFindOptionsBackwards = 1 << 3,
+    WebFindOptionsWrapAround = 1 << 4,
+    WebFindOptionsStartInSelection = 1 << 5
+};
+
+}
+typedef unsigned WebKitFindOptions;
+
 class DumpRenderTreeSupportGtk {
 
 public:
@@ -70,6 +83,7 @@ public:
     // WebKitWebView
     static void executeCoreCommandByName(WebKitWebView*, const gchar* name, const gchar* value);
     static bool isCommandEnabled(WebKitWebView*, const gchar* name);
+    static bool findString(WebKitWebView*, const gchar*, WebKitFindOptions);
 
     // GC
     static void gcCollectJavascriptObjects();
index b399b2d..fa9acaa 100644 (file)
@@ -1,3 +1,13 @@
+2011-02-07  Joone Hur  <joone.hur@collabora.co.uk>
+
+        Reviewed by Martin Robinson.
+
+        [Gtk] Implement layoutTestController.findString
+        https://bugs.webkit.org/show_bug.cgi?id=50237
+
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+        (LayoutTestController::findString):
+
 2011-02-07  Chang Shu  <chang.shu@nokia.com>
 
         Reviewed by Darin Adler.
index ffa3094..c8557f7 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
  * Copyright (C) 2008 Nuanti Ltd.
  * Copyright (C) 2009 Jan Michael Alonzo <jmalonzo@gmail.com>
- * Copyright (C) 2009 Collabora Ltd.
+ * Copyright (C) 2009,2011 Collabora Ltd.
  * Copyright (C) 2010 Joone Hur <joone@kldp.org>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -544,10 +544,42 @@ void LayoutTestController::execCommand(JSStringRef name, JSStringRef value)
     g_free(cValue);
 }
 
-bool LayoutTestController::findString(JSContextRef /* context */, JSStringRef /* target */, JSObjectRef /* optionsArray */)
+bool LayoutTestController::findString(JSContextRef context, JSStringRef target, JSObjectRef optionsArray)
 {
-    // FIXME: Implement
-    return false;
+    WebKitFindOptions findOptions = 0;
+    WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
+    ASSERT(webView);
+
+    JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
+    JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0); 
+    if (!JSValueIsNumber(context, lengthValue))
+        return false;
+
+    GOwnPtr<gchar> targetString(JSStringCopyUTF8CString(target));
+
+    size_t length = static_cast<size_t>(JSValueToNumber(context, lengthValue, 0));
+    for (size_t i = 0; i < length; ++i) {
+        JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0); 
+        if (!JSValueIsString(context, value))
+            continue;
+    
+        JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));
+
+        if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive"))
+            findOptions |= WebKit::WebFindOptionsCaseInsensitive;
+        else if (JSStringIsEqualToUTF8CString(optionName.get(), "AtWordStarts"))
+            findOptions |= WebKit::WebFindOptionsAtWordStarts;
+        else if (JSStringIsEqualToUTF8CString(optionName.get(), "TreatMedialCapitalAsWordStart"))
+            findOptions |= WebKit::WebFindOptionsTreatMedialCapitalAsWordStart;
+        else if (JSStringIsEqualToUTF8CString(optionName.get(), "Backwards"))
+            findOptions |= WebKit::WebFindOptionsBackwards;
+        else if (JSStringIsEqualToUTF8CString(optionName.get(), "WrapAround"))
+            findOptions |= WebKit::WebFindOptionsWrapAround;
+        else if (JSStringIsEqualToUTF8CString(optionName.get(), "StartInSelection"))
+            findOptions |= WebKit::WebFindOptionsStartInSelection;
+    }   
+
+    return DumpRenderTreeSupportGtk::findString(webView, targetString.get(), findOptions); 
 }
 
 bool LayoutTestController::isCommandEnabled(JSStringRef name)