ext: get the right DOM on msg
When navigating history, the document-loaded signal isn't triggered and we can't directly get back the previous webview, so we have no other choice than to look it up everytime a new message is received.
This commit is contained in:
parent
1901359efa
commit
660413256f
|
@ -15,7 +15,6 @@
|
||||||
typedef struct Page {
|
typedef struct Page {
|
||||||
guint64 id;
|
guint64 id;
|
||||||
WebKitWebPage *webpage;
|
WebKitWebPage *webpage;
|
||||||
WebKitDOMDOMWindow *view;
|
|
||||||
struct Page *next;
|
struct Page *next;
|
||||||
} Page;
|
} Page;
|
||||||
|
|
||||||
|
@ -63,6 +62,7 @@ readpipe(GIOChannel *s, GIOCondition c, gpointer unused)
|
||||||
{
|
{
|
||||||
char msg[MSGBUFSZ];
|
char msg[MSGBUFSZ];
|
||||||
gsize msgsz;
|
gsize msgsz;
|
||||||
|
WebKitDOMDOMWindow *view;
|
||||||
GError *gerr = NULL;
|
GError *gerr = NULL;
|
||||||
glong wh, ww;
|
glong wh, ww;
|
||||||
Page *p;
|
Page *p;
|
||||||
|
@ -80,18 +80,19 @@ readpipe(GIOChannel *s, GIOCondition c, gpointer unused)
|
||||||
if (p->id == msg[0])
|
if (p->id == msg[0])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!p || !p->view)
|
if (!p || !(view = webkit_dom_document_get_default_view(
|
||||||
|
webkit_web_page_get_dom_document(p->webpage))))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
switch (msg[1]) {
|
switch (msg[1]) {
|
||||||
case 'h':
|
case 'h':
|
||||||
ww = webkit_dom_dom_window_get_inner_width(p->view);
|
ww = webkit_dom_dom_window_get_inner_width(view);
|
||||||
webkit_dom_dom_window_scroll_by(p->view,
|
webkit_dom_dom_window_scroll_by(view,
|
||||||
(ww / 100) * msg[2], 0);
|
(ww / 100) * msg[2], 0);
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
wh = webkit_dom_dom_window_get_inner_height(p->view);
|
wh = webkit_dom_dom_window_get_inner_height(view);
|
||||||
webkit_dom_dom_window_scroll_by(p->view,
|
webkit_dom_dom_window_scroll_by(view,
|
||||||
0, (wh / 100) * msg[2]);
|
0, (wh / 100) * msg[2]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -99,19 +100,10 @@ readpipe(GIOChannel *s, GIOCondition c, gpointer unused)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
documentloaded(WebKitWebPage *wp, Page *p)
|
|
||||||
{
|
|
||||||
p->view = webkit_dom_document_get_default_view(
|
|
||||||
webkit_web_page_get_dom_document(wp));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
webpagecreated(WebKitWebExtension *e, WebKitWebPage *wp, gpointer unused)
|
webpagecreated(WebKitWebExtension *e, WebKitWebPage *wp, gpointer unused)
|
||||||
{
|
{
|
||||||
Page *p = newpage(wp);
|
Page *p = newpage(wp);
|
||||||
|
|
||||||
g_signal_connect(wp, "document-loaded", G_CALLBACK(documentloaded), p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
G_MODULE_EXPORT void
|
G_MODULE_EXPORT void
|
||||||
|
|
Loading…
Reference in New Issue
Block a user