Bug 128459 - [GTK] Minibrowser: On opening search bar, search for selected text if any
Summary: [GTK] Minibrowser: On opening search bar, search for selected text if any
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-08 10:49 PST by Diego Pino
Modified: 2017-03-11 11:04 PST (History)
6 users (show)

See Also:


Attachments
Patch (5.19 KB, patch)
2014-02-08 11:07 PST, Diego Pino
mcatanzaro: review-
mcatanzaro: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Diego Pino 2014-02-08 10:49:56 PST
In all major most browsers, selecting a text and opening the search bar immediately searches for that string in the current page. Implement that functionality in Minibrowser.
Comment 1 Diego Pino 2014-02-08 11:07:19 PST
Created attachment 223572 [details]
Patch
Comment 2 Andres Gomez Garcia 2014-03-24 07:45:44 PDT
Comment on attachment 223572 [details]
Patch

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

> Tools/MiniBrowser/gtk/BrowserSearchBar.c:275
> +static void open_search_bar(BrowserSearchBar *searchBar)

Non public API follows WK's C++ style. Hence, the name should be something like openSearchBar.

> Tools/MiniBrowser/gtk/BrowserSearchBar.c:286
> +static void get_selected_text_cb(GObject *object, GAsyncResult *result, gpointer userData)

Ditto.

In addition, the outcome of this cb is to open the search bar regardless to the existence of selected text. Hence, the name of the function is actually misleading.

> Tools/MiniBrowser/gtk/BrowserSearchBar.c:293
> +

As this should be C++ style, only declare your variables when using, and not sooner.

> Tools/MiniBrowser/gtk/BrowserSearchBar.c:298
> +        g_error_free(error);

Don't we do anything with the error?

> Tools/MiniBrowser/gtk/BrowserSearchBar.c:310
> +

Same here, don't declare your variables in advance.

> Tools/MiniBrowser/gtk/BrowserSearchBar.c:324
> +    open_search_bar(searchBar);

Just wondering if it wouldn't be better to change the "open_search_bar" API to have a second parameter with the text to set in the entry, instead of doing that here.

> Tools/MiniBrowser/gtk/BrowserSearchBar.c:330
> +    gchar *script;

Do not declare in advance.

> Tools/MiniBrowser/gtk/BrowserSearchBar.c:340
> +    open_search_bar_and_search_selected_text(searchBar);

I would place here the content of this function and remove it completely. It is an unneeded indirection.
Comment 3 Michael Catanzaro 2016-01-02 09:31:36 PST
Comment on attachment 223572 [details]
Patch

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

Thanks for the review, Berto. Updating the flags to make it official and remove this from request queue....

> Tools/MiniBrowser/gtk/BrowserSearchBar.c:322
> +        g_free(selectedText);

Surely you need to free selectedText even if it's zero-length, since you allocated the memory.
Comment 4 Diego Pino 2016-01-04 00:06:53 PST
I'm afraid that I won't be able to work on this patch in the short/medium term. If anyone would like to take it over I'm happy with that :)