[Webkit-unassigned] [Bug 138090] [GTK] Minibrowser: Add support for zoom using Control Key + Mouse scroll
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu Nov 13 00:40:11 PST 2014
https://bugs.webkit.org/show_bug.cgi?id=138090
Carlos Garcia Campos <cgarcia at igalia.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #240474|review? |review-
Flags| |
--- Comment #6 from Carlos Garcia Campos <cgarcia at igalia.com> ---
Comment on attachment 240474
--> https://bugs.webkit.org/attachment.cgi?id=240474
Patch
View in context: https://bugs.webkit.org/attachment.cgi?id=240474&action=review
I don't see the problem of having this in MiniBrowser, I have some comments about the patch, though.
> Tools/MiniBrowser/gtk/BrowserWindow.c:447
> +static void mouseZoomCallback(BrowserWindow *window, const GdkEvent *event)
This is actually the scroll-event callback, that is used to implement zoom, I would call this scrollEventCallback instead. The function is boolean not void.
> Tools/MiniBrowser/gtk/BrowserWindow.c:454
> + gdk_event_get_scroll_direction(event, &direction);
> + gdk_event_get_state(event, &state);
You could simply cast to GdkEventScroll or event change the function parameter to receive a GdkEventScroll directly, and then you can use event->state and event->direction directly.
> Tools/MiniBrowser/gtk/BrowserWindow.c:456
> + if (direction == GDK_SCROLL_UP && state == GDK_CONTROL_MASK) {
Instead of checking the state all the time, we can just return early when the state != GDK_CONTROL_MASK.
> Tools/MiniBrowser/gtk/BrowserWindow.c:459
> + zoomLevel = webkit_web_view_get_zoom_level(window->webView) * zoomStep;
> + webkit_web_view_set_zoom_level(window->webView, zoomLevel);
This is duplicated in zoomInCallback, we could move this to a function browser_window_zoom_in() for example and call it from here and zoomInCallback()
> Tools/MiniBrowser/gtk/BrowserWindow.c:466
> + zoomLevel = webkit_web_view_get_zoom_level(window->webView) / zoomStep;
> + webkit_web_view_set_zoom_level(window->webView, zoomLevel);
And the same here.
> Tools/MiniBrowser/gtk/BrowserWindow.c:468
> + }
You should probably handle the other direction, including GDK_SCROLL_SMOOTH, a switch would look much better than ifs, I think
> Tools/MiniBrowser/gtk/BrowserWindow.c:469
> +}
You should return TRUE when you have handled the event and FALSE otherwise to propagate the event.
> Tools/MiniBrowser/gtk/BrowserWindow.c:790
> + g_signal_connect(window, "scroll_event", G_CALLBACK(mouseZoomCallback), window);
scroll_event -> scroll-event. It doesn't make sense to pass the instance pointer as user data and you are not even handling the user data in the callback. I think it would be better if you implement the scroll_event vmethod of GtkWidgetClass instead of connecting to the signal.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20141113/885a39ec/attachment-0002.html>
More information about the webkit-unassigned
mailing list