Source/WebKit/gtk: [GTK] Add listener for direction-changed signal in WebKitWebView
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Jan 2013 09:15:07 +0000 (09:15 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Jan 2013 09:15:07 +0000 (09:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107131

Patch by Manuel Rego Casasnovas <rego@igalia.com> on 2013-01-22
Reviewed by Philippe Normand.

* webkit/webkitwebview.cpp:
(webkit_web_view_init): Add listener for direction-changed signal.
(webkitWebViewDirectionChanged): Implement listener using
Editor::setBaseWritingDirection().

Tools: [GTK] Implement TestRunner::setTextDirection
https://bugs.webkit.org/show_bug.cgi?id=107131

Patch by Manuel Rego Casasnovas <rego@igalia.com> on 2013-01-22
Reviewed by Philippe Normand.

* DumpRenderTree/gtk/DumpRenderTree.cpp:
(resetDefaultsToConsistentValues): Reset direction to default value.
* DumpRenderTree/gtk/TestRunnerGtk.cpp:
(TestRunner::setTextDirection): Implement method using
gtk_widget_set_direction.

LayoutTests: [GTK] Implement testRunner::setTextDirection
https://bugs.webkit.org/show_bug.cgi?id=107131

Patch by Manuel Rego Casasnovas <rego@igalia.com> on 2013-01-22
Reviewed by Philippe Normand.

* platform/gtk-wk2/TestExpectations: Unflag
fast/html/set-text-direction.html as it was already passing in WK2.
* platform/gtk/TestExpectations: Remove
fast/html/set-text-direction.html.

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

LayoutTests/ChangeLog
LayoutTests/platform/gtk-wk2/TestExpectations
LayoutTests/platform/gtk/TestExpectations
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/webkit/webkitwebview.cpp
Tools/ChangeLog
Tools/DumpRenderTree/gtk/DumpRenderTree.cpp
Tools/DumpRenderTree/gtk/TestRunnerGtk.cpp

index 4bf2777..57a8f6f 100644 (file)
@@ -1,3 +1,15 @@
+2013-01-22  Manuel Rego Casasnovas  <rego@igalia.com>
+
+        [GTK] Implement testRunner::setTextDirection
+        https://bugs.webkit.org/show_bug.cgi?id=107131
+
+        Reviewed by Philippe Normand.
+
+        * platform/gtk-wk2/TestExpectations: Unflag
+        fast/html/set-text-direction.html as it was already passing in WK2.
+        * platform/gtk/TestExpectations: Remove
+        fast/html/set-text-direction.html.
+
 2013-01-22  Christophe Dumez  <christophe.dumez@intel.com>
 
         Unreviewed EFL gardening.
index 7c025b4..88b6b1c 100644 (file)
@@ -507,7 +507,6 @@ Bug(GTK) fast/events/clear-edit-drag-state.html [ Pass ]
 Bug(GTK) fast/events/dont-loose-last-event.html [ Pass ]
 Bug(GTK) fast/events/drag-selects-image.html [ Pass ]
 Bug(GTK) fast/forms/text-input-event.html [ Pass ]
-Bug(GTK) fast/html/set-text-direction.html [ Pass ]
 Bug(GTK) fast/js/names.html [ Pass ]
 Bug(GTK) fast/loader/form-submission-after-beforeunload-cancel.html [ Pass ]
 Bug(GTK) fast/loader/stop-provisional-loads.html [ Pass ]
index cc52768..da8034b 100644 (file)
@@ -1086,9 +1086,6 @@ Bug(GTK) editing/spelling/grammar.html [ Failure ]
 Bug(GTK) editing/spelling/grammar-paste.html [ Skip ]
 Bug(GTK) editing/spelling/markers.html [ Skip ]
 
-# testRunner::setTextDirection() is not implemented.
-Bug(GTK) fast/html/set-text-direction.html [ Failure ]
-
 # testRunner.overridePreference("WebKitDefaultFontSize"...) does not take into account screen DPI
 webkit.org/b/57160 fast/harness/override-preferences-2.html [ Failure ]
 
index ec32510..a5941ad 100644 (file)
@@ -1,3 +1,15 @@
+2013-01-22  Manuel Rego Casasnovas  <rego@igalia.com>
+
+        [GTK] Add listener for direction-changed signal in WebKitWebView
+        https://bugs.webkit.org/show_bug.cgi?id=107131
+
+        Reviewed by Philippe Normand.
+
+        * webkit/webkitwebview.cpp:
+        (webkit_web_view_init): Add listener for direction-changed signal.
+        (webkitWebViewDirectionChanged): Implement listener using
+        Editor::setBaseWritingDirection().
+
 2013-01-21  Oleg Smirnov  <oleg.smirnov@lge.com>
 
         [Gtk] Dispatching event list into input element.
index d1a5f5f..6becfaa 100644 (file)
@@ -269,6 +269,7 @@ G_DEFINE_TYPE_WITH_CODE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER,
 
 static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView);
 static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures);
+static void webkitWebViewDirectionChanged(WebKitWebView*, GtkTextDirection previousDirection, gpointer);
 
 #if ENABLE(CONTEXT_MENUS)
 static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData)
@@ -3696,6 +3697,8 @@ static void webkit_web_view_init(WebKitWebView* webView)
 #if USE(ACCELERATED_COMPOSITING)
     priv->acceleratedCompositingContext = AcceleratedCompositingContext::create(webView);
 #endif
+
+    g_signal_connect(webView, "direction-changed", G_CALLBACK(webkitWebViewDirectionChanged), 0);
 }
 
 GtkWidget* webkit_web_view_new(void)
@@ -5361,6 +5364,36 @@ void webkitWebViewRegisterForIconNotification(WebKitWebView* webView, bool shoul
 }
 #endif
 
+void webkitWebViewDirectionChanged(WebKitWebView* webView, GtkTextDirection previousDirection, gpointer)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+    GtkTextDirection direction = gtk_widget_get_direction(GTK_WIDGET(webView));
+
+    Frame* focusedFrame = core(webView)->focusController()->focusedFrame();
+    if (!focusedFrame)
+        return;
+
+    Editor* editor = focusedFrame->editor();
+    if (!editor || !editor->canEdit())
+        return;
+
+    switch (direction) {
+    case GTK_TEXT_DIR_NONE:
+        editor->setBaseWritingDirection(NaturalWritingDirection);
+        break;
+    case GTK_TEXT_DIR_LTR:
+        editor->setBaseWritingDirection(LeftToRightWritingDirection);
+        break;
+    case GTK_TEXT_DIR_RTL:
+        editor->setBaseWritingDirection(RightToLeftWritingDirection);
+        break;
+    default:
+        g_assert_not_reached();
+        return;
+    }
+}
+
 namespace WebKit {
 
 WebCore::Page* core(WebKitWebView* webView)
index 14e2c9a..3b8206c 100644 (file)
@@ -1,3 +1,16 @@
+2013-01-22  Manuel Rego Casasnovas  <rego@igalia.com>
+
+        [GTK] Implement TestRunner::setTextDirection
+        https://bugs.webkit.org/show_bug.cgi?id=107131
+
+        Reviewed by Philippe Normand.
+
+        * DumpRenderTree/gtk/DumpRenderTree.cpp:
+        (resetDefaultsToConsistentValues): Reset direction to default value.
+        * DumpRenderTree/gtk/TestRunnerGtk.cpp:
+        (TestRunner::setTextDirection): Implement method using
+        gtk_widget_set_direction.
+
 2013-01-22  Jochen Eisinger  <jochen@chromium.org>
 
         [chromium] move spell checking mocks to TestRunner library
index b422bb3..fadc3ec 100644 (file)
@@ -527,6 +527,8 @@ static void resetDefaultsToConsistentValues()
         gTestRunner->setAuthenticationUsername("");
         gTestRunner->setHandlesAuthenticationChallenges(false);
     }
+
+    gtk_widget_set_direction(GTK_WIDGET(webView), GTK_TEXT_DIR_NONE);
 }
 
 static bool useLongRunningServerMode(int argc, char *argv[])
index 8be341b..e54bfef 100644 (file)
@@ -939,7 +939,19 @@ void TestRunner::setMinimumTimerInterval(double minimumTimerInterval)
 
 void TestRunner::setTextDirection(JSStringRef direction)
 {
-    // FIXME: Implement.
+    GOwnPtr<gchar> writingDirection(JSStringCopyUTF8CString(direction));
+
+    WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
+    ASSERT(view);
+
+    if (g_str_equal(writingDirection.get(), "auto"))
+        gtk_widget_set_direction(GTK_WIDGET(view), GTK_TEXT_DIR_NONE);
+    else if (g_str_equal(writingDirection.get(), "ltr"))
+        gtk_widget_set_direction(GTK_WIDGET(view), GTK_TEXT_DIR_LTR);
+    else if (g_str_equal(writingDirection.get(), "rtl"))
+        gtk_widget_set_direction(GTK_WIDGET(view), GTK_TEXT_DIR_RTL);
+    else
+        fprintf(stderr, "TestRunner::setTextDirection called with unknown direction: '%s'.\n", writingDirection.get());
 }
 
 void TestRunner::addChromeInputField()