Bug 137812 - [GTK] Add initial gestures support
Summary: [GTK] Add initial gestures support
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: Gtk
Depends on: 137735
Blocks: 137822
  Show dependency treegraph
 
Reported: 2014-10-17 01:11 PDT by Carlos Garcia Campos
Modified: 2014-10-20 01:44 PDT (History)
5 users (show)

See Also:


Attachments
Patch (22.99 KB, patch)
2014-10-17 01:33 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Rebased after r174817 (22.99 KB, patch)
2014-10-17 03:15 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Fix the build with GTK+ < 3.14 (22.99 KB, patch)
2014-10-17 05:13 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Addressed review comments (22.97 KB, patch)
2014-10-17 10:53 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch (22.80 KB, patch)
2014-10-17 11:00 PDT, Carlos Garcia Campos
svillar: review+
svillar: commit-queue-
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 2014-10-17 01:11:44 PDT
Now that GTK+ has support for gestures, we can use it to handle touch events and allow to scroll, zoom and tap with the fingers.
Comment 1 Carlos Garcia Campos 2014-10-17 01:33:54 PDT
Created attachment 240005 [details]
Patch

For now only drag, zoom and tap are supported, but at least it makes webkitgtk+ usable on touch screens
Comment 2 Carlos Garcia Campos 2014-10-17 01:42:43 PDT
It doesn't apply because it depends on patch attached to bug #137735.
Comment 3 Carlos Garcia Campos 2014-10-17 03:15:10 PDT
Created attachment 240009 [details]
Rebased after r174817
Comment 4 Carlos Garcia Campos 2014-10-17 05:13:41 PDT
Created attachment 240012 [details]
Fix the build with GTK+ < 3.14
Comment 5 Sergio Villar Senin 2014-10-17 05:51:09 PDT
Comment on attachment 240012 [details]
Fix the build with GTK+ < 3.14

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

I wonder if this allows us to pass any new tests. Otherwise I'd have to trust you on the gtk touch specific code. Have you double-checked the implementation with Garnacho?

> Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp:898
> +#endif

We should change this name as we need to make explicit the fact that it might create the GestureController. What about webkitWebViewBaseGetOrCreateGestureController ?

> Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h:79
> +WebKit::GestureController& webkitWebViewBaseGestureController(WebKitWebViewBase*);

See above.

> Source/WebKit2/UIProcess/gtk/GestureController.cpp:44
> +    return std::unique_ptr<GestureController>(new GestureController(page));

I think the preferred form is std::make_unique<GestureController>(page);

> Source/WebKit2/UIProcess/gtk/GestureController.cpp:133
> +    int delay;

Nit, uint

> Source/WebKit2/UIProcess/gtk/GestureController.cpp:137
> +    }, std::chrono::milliseconds(delay));

We should convert this to microseconds after r174818
Comment 6 Carlos Garcia Campos 2014-10-17 07:03:07 PDT
(In reply to comment #5)
> Comment on attachment 240012 [details]
> Fix the build with GTK+ < 3.14
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=240012&action=review

Thanks for the review.

> I wonder if this allows us to pass any new tests.

I haven't checked, will run touch tests.

>  Otherwise I'd have to
> trust you on the gtk touch specific code. Have you double-checked the
> implementation with Garnacho?

Yes.

> > Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp:898
> > +#endif
> 
> We should change this name as we need to make explicit the fact that it
> might create the GestureController. What about
> webkitWebViewBaseGetOrCreateGestureController ?

Why does it have to be explicit? The caller doesn't need to know anything since it's receiving a reference.

> > Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h:79
> > +WebKit::GestureController& webkitWebViewBaseGestureController(WebKitWebViewBase*);
> 
> See above.
> 
> > Source/WebKit2/UIProcess/gtk/GestureController.cpp:44
> > +    return std::unique_ptr<GestureController>(new GestureController(page));
> 
> I think the preferred form is std::make_unique<GestureController>(page);

It doesn't build.

> > Source/WebKit2/UIProcess/gtk/GestureController.cpp:133
> > +    int delay;
> 
> Nit, uint

gtk-long-press-time is a guint.

> > Source/WebKit2/UIProcess/gtk/GestureController.cpp:137
> > +    }, std::chrono::milliseconds(delay));
> 
> We should convert this to microseconds after r174818

No, this is already in milliseconds.
Comment 7 Carlos Garcia Campos 2014-10-17 10:39:13 PDT
(In reply to comment #6)
> > > Source/WebKit2/UIProcess/gtk/GestureController.cpp:44
> > > +    return std::unique_ptr<GestureController>(new GestureController(page));
> > 
> > I think the preferred form is std::make_unique<GestureController>(page);
> 
> It doesn't build.

I remember why now, because it requires the constructor to be public. It was private to make sure the class can only be created using create, but I'll make it public anyway to use make_unique
Comment 8 Carlos Garcia Campos 2014-10-17 10:53:47 PDT
Created attachment 240022 [details]
Addressed review comments

Use unsigned instead of int and make_unique
Comment 9 Carlos Garcia Campos 2014-10-17 11:00:41 PDT
Created attachment 240023 [details]
Updated patch

Just removed an unneeded header include in WebKitWebViewBase.cpp that I added by mistake.
Comment 10 Carlos Garcia Campos 2014-10-17 11:04:15 PDT
(In reply to comment #5)
> Comment on attachment 240012 [details]
> Fix the build with GTK+ < 3.14
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=240012&action=review
> 
> I wonder if this allows us to pass any new tests. Otherwise I'd have to
> trust you on the gtk touch specific code. Have you double-checked the
> implementation with Garnacho?
> 

This will not affect the tests anyway, because it requires GTK+ 3.14 and bots use 3.6.
Comment 11 Sergio Villar Senin 2014-10-20 00:51:34 PDT
Comment on attachment 240023 [details]
Updated patch

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

Let's give it a try! The only thing we need to address before landing is the misunderstanding related to the factory method and the constructor.

> Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp:894
> +        priv->gestureController = GestureController::create(*priv->pageProxy);

We should call the constructor here:

priv->gestureController = std::make_unique<GestureController>(*priv->pageProxy);

See comment below for the rationale.

> Source/WebKit2/UIProcess/gtk/GestureController.cpp:52
> +

Sorry if I didn't explain myself correctly, but this is not what I was asking about. This indeed looks very weird (a public factory and a public constructor). What I think we should do is to make the constructor public and use make_unique<> in the callers. That's something Anders is actively pushing for new code, see: https://bugs.webkit.org/show_bug.cgi?id=137765#c13

> Source/WebKit2/UIProcess/gtk/GestureController.h:47
> +    static std::unique_ptr<GestureController> create(WebPageProxy&);

We should get rid of this.

> Source/WebKit2/UIProcess/gtk/GestureController.h:49
> +    explicit GestureController(WebPageProxy&);

And the explicit won't be required I think...
Comment 12 Carlos Garcia Campos 2014-10-20 01:15:55 PDT
(In reply to comment #11)
> Comment on attachment 240023 [details]
> Updated patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=240023&action=review
> 
> Let's give it a try! The only thing we need to address before landing is the
> misunderstanding related to the factory method and the constructor.
> 
> > Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp:894
> > +        priv->gestureController = GestureController::create(*priv->pageProxy);
> 
> We should call the constructor here:
> 
> priv->gestureController =
> std::make_unique<GestureController>(*priv->pageProxy);
> 
> See comment below for the rationale.
> 
> > Source/WebKit2/UIProcess/gtk/GestureController.cpp:52
> > +
> 
> Sorry if I didn't explain myself correctly, but this is not what I was
> asking about. This indeed looks very weird (a public factory and a public
> constructor). What I think we should do is to make the constructor public
> and use make_unique<> in the callers. That's something Anders is actively
> pushing for new code, see: https://bugs.webkit.org/show_bug.cgi?id=137765#c13

Ok, understood.
Comment 13 Carlos Garcia Campos 2014-10-20 01:44:31 PDT
Committed r174880: <http://trac.webkit.org/changeset/174880>