Bug 107131 - [GTK] Implement testRunner::setTextDirection
Summary: [GTK] Implement testRunner::setTextDirection
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-17 08:10 PST by Manuel Rego Casasnovas
Modified: 2013-01-22 01:16 PST (History)
4 users (show)

See Also:


Attachments
Patch (8.17 KB, patch)
2013-01-17 08:24 PST, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (6.39 KB, patch)
2013-01-18 01:49 PST, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (7.25 KB, patch)
2013-01-18 06:50 PST, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (7.19 KB, patch)
2013-01-18 07:53 PST, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (7.21 KB, patch)
2013-01-18 09:16 PST, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (7.98 KB, patch)
2013-01-22 00:53 PST, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Rego Casasnovas 2013-01-17 08:10:15 PST
fast/html/set-text-direction.html is skipped for this reason.
Comment 1 Manuel Rego Casasnovas 2013-01-17 08:24:06 PST
Created attachment 183193 [details]
Patch
Comment 2 Philippe Normand 2013-01-17 09:16:33 PST
Pretty nice! When this one is done the WK2 port might need a similar patch as well.
Comment 3 WebKit Review Bot 2013-01-17 09:17:10 PST
Attachment 183193 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/plat..." exit_code: 1
Source/WebKit/gtk/webkit/webkitwebview.h:467:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 1 in 7 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Martin Robinson 2013-01-17 09:19:12 PST
I wonder if it would be better to simply hook into gtk_widget_set_direction here. To be honest, I don't know even about RTL text to say for sure.
Comment 5 Manuel Rego Casasnovas 2013-01-18 01:49:45 PST
Created attachment 183402 [details]
Patch
Comment 6 Manuel Rego Casasnovas 2013-01-18 01:54:03 PST
Thanks for your quick review yesterday :-)

I've just attached a new patch using gtk_widget_set_direction as proposed by Martin and it works properly.

BTW, just a brief comment about the previous patch. The implementation in the previous patch was based in chromium and efl implementations as you can check in: 
* Source/WebKit/efl/ewk/ewk_view.cpp: ewk_view_text_direction_set
* Source/WebKit/chromium/src/WebViewImpl.cpp: WebViewImpl::setTextDirection
Comment 7 Manuel Rego Casasnovas 2013-01-18 06:50:16 PST
Created attachment 183443 [details]
Patch

Remove test from WK2 TestExpectations file as it was already passing before my patch
Comment 8 Philippe Normand 2013-01-18 06:56:57 PST
Comment on attachment 183443 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=183443&action=review

LGTM, just a couple of nitpicks!

> Source/WebKit/gtk/webkit/webkitwebview.cpp:272
> +static void webkit_web_view_direction_changed(WebKitWebView* webView, GtkTextDirection previousDirection, gpointer gpointer);

gpointer gpointer? I guess something like data would be better

> Source/WebKit/gtk/webkit/webkitwebview.cpp:5367
> +void webkit_web_view_direction_changed(WebKitWebView* webView, GtkTextDirection previousDirection, gpointer gpointer)

Well since the gpointer is not used you can omit to name it in the function signature.
Comment 9 Manuel Rego Casasnovas 2013-01-18 07:53:00 PST
Created attachment 183459 [details]
Patch

Update patch following comments provided by Philippe. Both attributes GtkTextDirection and gpointer are not used in the method.
Comment 10 Martin Robinson 2013-01-18 08:26:50 PST
Comment on attachment 183459 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=183459&action=review

> Source/WebKit/gtk/webkit/webkitwebview.cpp:5367
> +void webkit_web_view_direction_changed(WebKitWebView* webView, GtkTextDirection, gpointer)

Okay. One nit here is that this function doesn't follow WebKit naming conventions (we started doing that always at some point). I can fix that and land this.

> LayoutTests/platform/gtk-wk2/TestExpectations:-507
>  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 ]

How is the WebKit2 test passing now? Source/WebKit/gtk/webkit/webkitwebview.cpp is only used for WebKit1.
Comment 11 Manuel Rego Casasnovas 2013-01-18 08:32:25 PST
(In reply to comment #10)
> (From update of attachment 183459 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=183459&action=review
> 
> > Source/WebKit/gtk/webkit/webkitwebview.cpp:5367
> > +void webkit_web_view_direction_changed(WebKitWebView* webView, GtkTextDirection, gpointer)
> 
> Okay. One nit here is that this function doesn't follow WebKit naming conventions (we started doing that always at some point). I can fix that and land this.

I can fix it and provide a new patch but I'd like to be sure.

Then should I use the following style in the header:
static void webkit_web_view_direction_changed(WebKitWebView* webView, GtkTextDirection previousDirection, gpointer data);

And in the implementation:
void webkit_web_view_direction_changed(WebKitWebView* webView, GtkTextDirection previousDirecton, gpointer data);

Am I right?


> > LayoutTests/platform/gtk-wk2/TestExpectations:-507
> >  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 ]
> 
> How is the WebKit2 test passing now? Source/WebKit/gtk/webkit/webkitwebview.cpp is only used for WebKit1.

This patch was already passing in WebKit2, it was in the section "Tests working in WK2 and failing in WK1". That's the reason why I unflagged it in both TestExpection files for WK1 and WK2.
Comment 12 WebKit Review Bot 2013-01-18 08:40:48 PST
Comment on attachment 183459 [details]
Patch

Attachment 183459 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/15948432

New failing tests:
inspector-protocol/debugger-terminate-dedicated-worker-while-paused.html
Comment 13 Martin Robinson 2013-01-18 08:52:17 PST
(In reply to comment #11)
> (In reply to comment #10)
> > (From update of attachment 183459 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=183459&action=review
> > 
> > > Source/WebKit/gtk/webkit/webkitwebview.cpp:5367
> > > +void webkit_web_view_direction_changed(WebKitWebView* webView, GtkTextDirection, gpointer)
> > 
> > Okay. One nit here is that this function doesn't follow WebKit naming conventions (we started doing that always at some point). I can fix that and land this.
> 
> I can fix it and provide a new patch but I'd like to be sure.
> 
> Then should I use the following style in the header:
> static void webkit_web_view_direction_changed(WebKitWebView* webView, GtkTextDirection previousDirection, gpointer data);
> 
> And in the implementation:
> void webkit_web_view_direction_changed(WebKitWebView* webView, GtkTextDirection previousDirecton, gpointer data);

Essentially if the function is in the public API it would be called:
In the c++ file: webkit_web_view_direction_changed(WebkItWebView* webView, GtkTextDirection previousDirection, gpointer data);
In the header: webkit_web_view_direction_changed(WebkItWebView* web_view, GtkTextDirection previous_direction, gpointer data);

If the function is only used internally it should be called:
webkitWebViewDirectionChanged(WebkItWebView* webView, GtkTextDirection previousDirection, gpointer data);

The reason the name changes is that we try to follow WebKit function naming style wherever we can. The naming scheme of GObject APIs is not something we can change. The reason that the parameter names change in public headers is to make gtkdoc happy. It's a bit convoluted. :(

> > > LayoutTests/platform/gtk-wk2/TestExpectations:-507
> > >  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 ]
> > 
> > How is the WebKit2 test passing now? Source/WebKit/gtk/webkit/webkitwebview.cpp is only used for WebKit1.
> 
> This patch was already passing in WebKit2, it was in the section "Tests working in WK2 and failing in WK1". That's the reason why I unflagged it in both TestExpection files for WK1 and WK2.
Comment 14 Martin Robinson 2013-01-18 08:52:47 PST
(In reply to comment #13)

> > This patch was already passing in WebKit2, it was in the section "Tests working in WK2 and failing in WK1". That's the reason why I unflagged it in both TestExpection files for WK1 and WK2.

Oh, okay. You should probably wait to change WKTR until you actually implement text direction support in WebKit2.
Comment 15 Manuel Rego Casasnovas 2013-01-18 09:16:02 PST
Created attachment 183480 [details]
Patch

Fixed style in method. Avoid name for gpointer param as it's not used. Specified name for GtkTextDirection as previousDirection gives interesting information as someone could confuse it with current direction.
Comment 16 Martin Robinson 2013-01-18 09:37:46 PST
Comment on attachment 183480 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=183480&action=review

> Tools/DumpRenderTree/gtk/TestRunnerGtk.cpp:954
> -    // 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());
>  }

I think it makes sense to wait on adding this until you make this change in WebKitWebViewBase.cpp as well.
Comment 17 Manuel Rego Casasnovas 2013-01-21 01:56:19 PST
(In reply to comment #16)
> (From update of attachment 183480 [details])
> I think it makes sense to wait on adding this until you make this change in WebKitWebViewBase.cpp as well.

I think you don't understand me before, the test is already passing in WK2.

It's included in the TestExpectations file of WK2 in the section "Tests working in WK2 and failing in WK1". So, this is already working in W2, and I'm just fixing the test in WK1.

With my patch the tests passes in both WK1 and WK2, so I've unflagged it in both TestExpectations files (in WK1 it was marked as "Failure" and in WK2 as "Pass").

You can see how it's implemented in WK2 in WebFrame::setTextDirection which is used from TestRunner::setTextDirection (Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp).
Comment 18 Martin Robinson 2013-01-21 08:07:00 PST
(In reply to comment #17)

> You can see how it's implemented in WK2 in WebFrame::setTextDirection which is used from TestRunner::setTextDirection (Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp).

Sorry, I minterpreted the change to TestRunnerGtk.cpp as a change to WebKitTestRunner. This is passing in WebKit2 likely because WKTR is using the C API to change the text direction. If we want compatibility with WebKit1, you'll also need to change the non-C API version of WebKit2.
Comment 19 WebKit Review Bot 2013-01-21 12:12:13 PST
Comment on attachment 183480 [details]
Patch

Rejecting attachment 183480 [details] from commit-queue.

rego@igalia.com does not have committer permissions according to http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/committers.py.

- If you do not have committer rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags.

- If you have committer rights please correct the error in Tools/Scripts/webkitpy/common/config/committers.py by adding yourself to the file (no review needed).  The commit-queue restarts itself every 2 hours.  After restart the commit-queue will correctly respect your committer rights.
Comment 20 Martin Robinson 2013-01-21 12:14:27 PST
Oh,  I actually realized there might be an issue with this patch. There's a function in DRT called something like resetValuesToConsistentState (probably not the real name). This function ensures that once a test is finished the WebView is in a "clean" state for a new test. You likely need to set the text direction to LTR there.
Comment 21 Manuel Rego Casasnovas 2013-01-22 00:53:28 PST
Created attachment 183915 [details]
Patch

Modified resetDefaultsToConsistentValues to reset the direction to the default value.
Comment 22 WebKit Review Bot 2013-01-22 01:16:35 PST
Comment on attachment 183915 [details]
Patch

Clearing flags on attachment: 183915

Committed r140398: <http://trac.webkit.org/changeset/140398>
Comment 23 WebKit Review Bot 2013-01-22 01:16:40 PST
All reviewed patches have been landed.  Closing bug.