在GTK + 3中滚动WebKit2.Webkit窗口 [英] Scrolling a WebKit2.Webkit window in GTK+3

查看:386
本文介绍了在GTK + 3中滚动WebKit2.Webkit窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何滚动 webkit2gtk 小部件?



webkitgtk ScrolledWindow 中包含(aka。 webkit1 code>,所以可以使用它的 vadjustment 属性。



对于 wekit2gtk ,在 WebView 上的这个调用只返回 None ,并且我看不到其他方法调用。

作为解释,我想为 webkit2 添加触控支持。 我通过在 WebView 小部件¹上添加一个透明层来入侵我的方法,但现在我检测触摸我似乎无法使用它们。



¹今天发布的版本已经消除了对顶层图层的需求。尽管如此,我已经触及了一切,我也无能为力。

解决方案

WebKit2中的进程分离有一些优点,但它也是使许多事情变得更加复杂。我相信滚动是其中之一:它发生在web进程中,因为滚动条现在由webkit处理,而不是Gtk小部件。触摸处理同样适用:部分是在网络过程中完成的。 Carlos Garcia Campos撰写了博客文章,介绍如何使用WebKitWebExtension提供帮助在这。请注意,该设计对代码也有很多含义:部分代码将运行在完全不同的过程中。



答案的其余部分未经测试,请认为这更像是一个受过教育的猜测:



我相信控制滚动的方法是通过 DOM API ,更具体地说是 DOMDOMWindow.scroll * 函数。复杂的部分是获取对 DOMDOMWindow 的引用 - 您需要实现将运行的 WebExtension 在Web进程中,并允许您在创建 WebPage 时收到通知。 WebPage.get_dom_document()调用为您提供了 DOMDocument DOMDocument.get_default_view()应该给你你需要的 DOMDOMWindow

对于DOM API文档, Mozilla 可能比spartan WebKit-GTK-DOM文档更好。



如果我正在做你正在做的事情,我的第一站就是Freenode上的#webkitgtk + IRC频道,以检查上述内容是否真的是一种理想的方式来做你想做的事。 。


How does one scroll a webkit2gtk widget?

In webkitgtk (aka. webkit1) you wrap your WebView in a ScrolledWindow, so can use its vadjustment property.

For wekit2gtk, this call on the WebView just returns None, and I see no other method to call.

As an explanation, I want to add touch support to webkit2. I have hacked my way into this by adding a transparent layer over the WebView widget¹, but now I'm detecting touches I seem unable to use them.

¹ A release that came out today has removed the need for the layer on-top. Nevertheless, I have touches and nothing I can do with them.

解决方案

The process separation in WebKit2 has some advantages, but it also makes many things more complex. I believe scrolling is one of those things: it happens in the web process because scrollbars are now handled by webkit, and not the Gtk widget. The same should hold for touch handling: it is partly done in the web process. Carlos Garcia Campos has written a blog post about using WebKitWebExtension to help in this. Note that the design has lots of implications on your code as well: Part of the code will be running in a totally different process.

The rest of the answer is not tested, please consider this more like an educated guess:

I believe the way to control scrolling is through the DOM API, more specifically DOMDOMWindow.scroll* functions. The complex part is getting a reference to the DOMDOMWindow -- You'll need to implement a WebExtension which will be running in the web process and will allow you to get notified when a WebPage is created. The WebPage.get_dom_document() call gives you a DOMDocument and DOMDocument.get_default_view() should then give you the DOMDOMWindow you need.

For the DOM API documentation, Mozilla is probably a better reference than the spartan WebKit-GTK-DOM documentation.

If I was doing what you are trying to do, my first stop would be the #webkitgtk+ IRC channel on Freenode to check if the above really is a sane way to do what you want...

这篇关于在GTK + 3中滚动WebKit2.Webkit窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆