all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: joakim@verona.se
To: raman@google.com
Cc: tv.raman.tv@gmail.com, emacs-devel@gnu.org
Subject: Re: XWidget/WebKit:  Getting Web Content From Webkit To Emacs
Date: Sat, 23 Jan 2016 22:56:56 +0100	[thread overview]
Message-ID: <m3zivw6jtj.fsf@exodia.verona.se> (raw)
In-Reply-To: <22179.60698.100856.373370@gargle.gargle.HOWL> (raman@google.com's message of "Sat, 23 Jan 2016 13:14:02 -0800")

raman@google.com writes:

> Now that we have XWidget/Webkit --- I was wondering what it would take
> to get content from Webkit into Emacs --- this time in the form of
> "real content" rather than "What You See Is All You Have Content".
>
> Some Thoughts:
>
> 1. Would it be possible to get the DOM (as an html DOM a la EWW) from
> Webkit? That would give us content that Emacs ordinarily cannot get --
> e.g. content generated through script evaluation.

When I wrote the code there were some problems with that area of the
webkit api.

There is a start of an implementation of this functionality in the main
xwidget branch(not the xwidget_branch): xwidget-webkit-dom-dump

I attach the partial implementation below.


> 2. Ability to send events / scripts from Emacs to WebKit -- I see that
> some of this might already be possible from looking at the code in
> xwidget.el. It's not clear how Emacs can get at structured content
> returned by JS.


You can have a look at xwidget-webkit-execute-script-rv.

Sadly there wasn't a good function for returning values from webkit in
their api when I wrote the code. I haven't checked if that situation has
changed recently. The return value is pased by setting the
document.title. Ahem... I'm not sure about the limits of this mechanism,
it has been working for the things I've done anyway.



>
>
> 3. Function xwidget-webkit-copy-selection-as-kill will hopefully let
> me get the rendered text contents into the kill ring -- but how do I
> select the contents of a webkit buffer (without using a mouse)?

You will need to code something that moves the selection about by
sending js code to the webkit through xwidget-webkit-execute-script.

I haven't done something like that yet. 

Initial DOM dump experimental code.

-#ifdef HAVE_XLXW_DOMDUMP
-/* dom dumping is work in progress.
-   2 of the methods used from webkit are deprecated nowm and replacements sought
- */
-static void
-xwidget_webkit_dom_dump (WebKitDOMNode * parent)
-{
-  WebKitDOMNodeList *list;
-  int length;
-  WebKitDOMNode *attribute;
-  WebKitDOMNamedNodeMap *attrs;
-  WebKitDOMNode *child;
-  printf ("node:%d type:%d name:%s content:%s\n", parent,
-          webkit_dom_node_get_node_type (parent),
-          //1 element 3 text 8 comment 2 attribute
-          webkit_dom_node_get_local_name (parent),
-          webkit_dom_node_get_text_content (parent));
-
-  if (webkit_dom_node_has_attributes (parent))
-    {
-      attrs = webkit_dom_node_get_attributes (parent);
-
-      length = webkit_dom_named_node_map_get_length (attrs);
-      for (int i = 0; i < length; i++)
-        {
-          attribute = webkit_dom_named_node_map_item (attrs, i);
-          printf (" attr node:%d type:%d name:%s content:%s\n",
-                  attribute, webkit_dom_node_get_node_type (attribute),
-                  //1 element 3 text 8 comment
-                  webkit_dom_node_get_local_name (attribute),
-                  webkit_dom_node_get_text_content (attribute));
-        }
-    }
-  list = webkit_dom_node_get_child_nodes (parent);
-  length = webkit_dom_node_list_get_length (list);
-
-  for (int i = 0; i < length; i++)
-    {
-      child = webkit_dom_node_list_item (list, i);
-      //if(webkit_dom_node_has_child_nodes(child))
-      xwidget_webkit_dom_dump (child);
-    }
-}
-
-
-DEFUN ("xwidget-webkit-dom-dump",
-       Fxwidget_webkit_dom_dump, Sxwidget_webkit_dom_dump,
-       1, 1, 0, doc:	/*Dump the DOM contained in the webkit
-                          instance in XWIDGET. */
-       )
-  (Lisp_Object xwidget)
-{
-  WEBKIT_FN_INIT ();
-  xwidget_webkit_dom_dump (WEBKIT_DOM_NODE
-                           (webkit_web_view_get_dom_document
-                            (WEBKIT_WEB_VIEW (xw->widget_osr))));
-  return Qnil;
-}
-
-#endif /* HAVE_XLXW_DOMDUMP */

> -- 

-- 
Joakim Verona



  reply	other threads:[~2016-01-23 21:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-23 21:14 XWidget/WebKit: Getting Web Content From Webkit To Emacs raman
2016-01-23 21:56 ` joakim [this message]
2016-01-25  1:42   ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2016-01-25 11:14 Vasilij Schneidermann
2016-01-25 11:34 ` joakim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3zivw6jtj.fsf@exodia.verona.se \
    --to=joakim@verona.se \
    --cc=emacs-devel@gnu.org \
    --cc=raman@google.com \
    --cc=tv.raman.tv@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.