Bug 58416 - [GTK] Implement UI client in minibrowser
Summary: [GTK] Implement UI client in minibrowser
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on: 58024
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-13 01:05 PDT by Carlos Garcia Campos
Modified: 2011-04-29 02:56 PDT (History)
0 users

See Also:


Attachments
Patch (7.28 KB, patch)
2011-04-13 01:09 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch acording to review (7.41 KB, patch)
2011-04-15 02:50 PDT, Carlos Garcia Campos
mrobinson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2011-04-13 01:05:02 PDT
An initial implementaion would allow to open links in a new browser window from the context menu, see bug #54827.
Comment 1 Carlos Garcia Campos 2011-04-13 01:09:44 PDT
Created attachment 89348 [details]
Patch

It also allows to open more than one window from the command line. It depends on bug #58024
Comment 2 Martin Robinson 2011-04-13 08:10:32 PDT
Comment on attachment 89348 [details]
Patch

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

> Tools/MiniBrowser/gtk/BrowserWindow.c:52
> +static void browserWindowUiClientInit(BrowserWindow*);

Should be browserWindowUIClientInit

> Tools/MiniBrowser/gtk/BrowserWindow.c:390
> +{
> +    WKViewRef webView = WKViewCreate(WKPageGetContext(page), 0);
> +    BrowserWindow* window = BROWSER_WINDOW(browserWindowNew(webView));
> +    return WKViewGetPage(window->webView);
> +}

Maybe browser_window_new should take in the features dictionary to set the size, etc.

> Tools/MiniBrowser/gtk/BrowserWindow.c:426
> +    WKPageUIClient uiClient = {
> +        0,      /* version */
> +        window, /* clientInfo */
> +        createNewPage,
> +        showPage,
> +        closePage,
> +        runJavaScriptAlert,
> +        0,  /* runJavaScriptConfirm */
> +        0,  /* runJavaScriptPrompt */
> +        0,  /* setStatusText */
> +        0,  /* mouseDidMoveOverElement */
> +        0,  /* missingPluginButtonClicked */
> +        0,  /* didNotHandleKeyEvent */
> +        0,  /* toolbarsAreVisible */
> +        0,  /* setToolbarsAreVisible */
> +        0,  /* menuBarIsVisible */
> +        0,  /* setMenuBarIsVisible */

Please line up the comments on these lines. :)

> Tools/MiniBrowser/gtk/main.c:43
> +static void loadUri(const gchar *uri)

Should be loadURI.

> Tools/MiniBrowser/gtk/main.c:57
> +    { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, 0, "[URLâ¦]" },

Are there some extra characters at the end of "[URLâ¦]"
Comment 3 Carlos Garcia Campos 2011-04-14 01:57:41 PDT
(In reply to comment #2)
> (From update of attachment 89348 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=89348&action=review
> 
> > Tools/MiniBrowser/gtk/BrowserWindow.c:52
> > +static void browserWindowUiClientInit(BrowserWindow*);
> 
> Should be browserWindowUIClientInit

Ok.

> > Tools/MiniBrowser/gtk/BrowserWindow.c:390
> > +{
> > +    WKViewRef webView = WKViewCreate(WKPageGetContext(page), 0);
> > +    BrowserWindow* window = BROWSER_WINDOW(browserWindowNew(webView));
> > +    return WKViewGetPage(window->webView);
> > +}
> 
> Maybe browser_window_new should take in the features dictionary to set the size, etc.

We could use the features to set up the window before showing it, but I'm not sure the window should take the features. We can leave this for future patches, other ports ignore this for now too.

> > Tools/MiniBrowser/gtk/BrowserWindow.c:426
> > +    WKPageUIClient uiClient = {
> > +        0,      /* version */
> > +        window, /* clientInfo */
> > +        createNewPage,
> > +        showPage,
> > +        closePage,
> > +        runJavaScriptAlert,
> > +        0,  /* runJavaScriptConfirm */
> > +        0,  /* runJavaScriptPrompt */
> > +        0,  /* setStatusText */
> > +        0,  /* mouseDidMoveOverElement */
> > +        0,  /* missingPluginButtonClicked */
> > +        0,  /* didNotHandleKeyEvent */
> > +        0,  /* toolbarsAreVisible */
> > +        0,  /* setToolbarsAreVisible */
> > +        0,  /* menuBarIsVisible */
> > +        0,  /* setMenuBarIsVisible */
> 
> Please line up the comments on these lines. :)

Sure.

> > Tools/MiniBrowser/gtk/main.c:43
> > +static void loadUri(const gchar *uri)
> 
> Should be loadURI.

Ok.

> > Tools/MiniBrowser/gtk/main.c:57
> > +    { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, 0, "[URLâ¦]" },
> 
> Are there some extra characters at the end of "[URLâ¦]"

Looks like a bug in review tool, it's utf-8 text, try opening the attachment.
Comment 4 Carlos Garcia Campos 2011-04-15 02:50:00 PDT
Created attachment 89760 [details]
Updated patch acording to review

Patch updated to current git master, fixing the issues pointed out by martin and fixing a crash while opening a link in a new window from the context menu.
Comment 5 Martin Robinson 2011-04-26 16:19:42 PDT
Comment on attachment 89760 [details]
Updated patch acording to review

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

Looks good, but please fix the style errors before landing.

> Tools/MiniBrowser/gtk/BrowserWindow.c:406
> +static void browserWindowUIClientInit(BrowserWindow* window)

Please shift the asterisk over.

> Tools/MiniBrowser/gtk/main.c:32
> +static const gchar** uriArguments = NULL;

The asterisks should be on uriArguments.

> Tools/MiniBrowser/gtk/main.c:48
> +    GtkWidget* mainWindow = browser_window_new(webView);
> +    gchar* url = argumentToURL(uri);
> +    WKPageLoadURL(WKViewGetPage(webView), WKURLCreateWithUTF8CString(url));

Ditto

> Tools/MiniBrowser/gtk/main.c:66
> +    GOptionContext* context = g_option_context_new(NULL);

Ditto

> Tools/MiniBrowser/gtk/main.c:70
> +    GError* error = NULL;

Ditto. Please use 0 here instead of NULL.

> Tools/MiniBrowser/gtk/main.c:81
> +        gint i;

Please just use int here.
Comment 6 Carlos Garcia Campos 2011-04-27 05:47:08 PDT
(In reply to comment #5)
> (From update of attachment 89760 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=89760&action=review
> 
> Looks good, but please fix the style errors before landing.
> 
> > Tools/MiniBrowser/gtk/BrowserWindow.c:406
> > +static void browserWindowUIClientInit(BrowserWindow* window)
> 
> Please shift the asterisk over.

Ok, I thought the style was the same for non-C++ files, sorry.

> > Tools/MiniBrowser/gtk/main.c:32
> > +static const gchar** uriArguments = NULL;
> 
> The asterisks should be on uriArguments.
> 
> > Tools/MiniBrowser/gtk/main.c:48
> > +    GtkWidget* mainWindow = browser_window_new(webView);
> > +    gchar* url = argumentToURL(uri);
> > +    WKPageLoadURL(WKViewGetPage(webView), WKURLCreateWithUTF8CString(url));
> 
> Ditto
> 
> > Tools/MiniBrowser/gtk/main.c:66
> > +    GOptionContext* context = g_option_context_new(NULL);
> 
> Ditto
> 
> > Tools/MiniBrowser/gtk/main.c:70
> > +    GError* error = NULL;
> 
> Ditto. Please use 0 here instead of NULL.
> 
> > Tools/MiniBrowser/gtk/main.c:81
> > +        gint i;
> 
> Please just use int here.

Ok, Thanks. Note that this depends on uncommitted not yet approved patches, so I'll push it as soon as other patches are committed.
Comment 7 Carlos Garcia Campos 2011-04-29 02:56:12 PDT
Committed r85313: <http://trac.webkit.org/changeset/85313>