Subject: bug#22602: Patch to enable webgl and javascript debug on xwidget-webkit

From: "anderson.marco" <[email-masked]>
Date: Mon, 8 Feb 2016 18:57:49 -0200

Webkit in emacs 25.0.90 haven't supports  webgl and javascript debug. I
makes a  patch short to correct this problem.  This patch is annexed in
this email.
Forgive my english. I just know write a little english.
diff -rupN emacsOld/emacs-emacs-25.0.90/src/xwidget.c emacs-emacs-25.0.90/src/xwidget.c
--- emacsOld/emacs-emacs-25.0.90/src/xwidget.c	2016-01-30 13:00:54.000000000 -0200
+++ emacs-emacs-25.0.90/src/xwidget.c	2016-02-08 18:05:11.258102623 -0200
@@ -215,6 +215,12 @@ Returns the newly constructed xwidget, o
 	     GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS);
 
           xw->widget_osr = webkit_web_view_new ();
+          WebKitWebSettings *settings =webkit_web_view_get_settings (WEBKIT_WEB_VIEW(xw->widget_osr));
+
+          g_object_set (G_OBJECT(settings), "enable-webgl", TRUE, NULL);
+          g_object_set (G_OBJECT(settings), "enable-developer-extras",TRUE,NULL);         
+          WebKitWebInspector *webKitWebInspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW(xw->widget_osr));
+          g_signal_connect (G_OBJECT (webKitWebInspector), "inspect-web-view", G_CALLBACK(inspect_web_view), NULL);        
           gtk_container_add (GTK_CONTAINER (xw->widgetscrolledwindow_osr),
                              GTK_WIDGET (WEBKIT_WEB_VIEW (xw->widget_osr)));
         }
@@ -362,6 +368,32 @@ store_xwidget_event_string (struct xwidg
   kbd_buffer_store_event (&event);
 }
 
+
+WebKitWebView* inspect_web_view(WebKitWebInspector *web_inspector, 
+                                WebKitWebView      *web_view, gpointer user_data)
+
+{
+  GtkWidget *gtk_window_inspect= gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  GtkWidget *gtk_scrolled_window_inspect= gtk_scrolled_window_new (NULL, NULL);
+
+  gtk_window_set_resizable (GTK_WINDOW(gtk_window_inspect),TRUE);
+  //gtk_window_set_modal (GTK_WINDOW(gtk_window_inspect),TRUE);
+  gtk_window_set_default_size (GTK_WINDOW(gtk_window_inspect),750,320);
+  gtk_window_set_decorated (GTK_WINDOW(gtk_window_inspect),TRUE);
+  gtk_window_set_keep_above (GTK_WINDOW(gtk_window_inspect),TRUE);
+  gtk_window_set_skip_taskbar_hint (GTK_WINDOW(gtk_window_inspect),FALSE);
+  gtk_window_set_destroy_with_parent (GTK_WINDOW(gtk_window_inspect),TRUE);
+  g_object_set (G_OBJECT(gtk_window_inspect), "javascript-profiling-enabled",TRUE,NULL);
+  g_object_set (G_OBJECT(gtk_window_inspect), "timeline-profiling-enabled",TRUE,NULL);            
+  GtkWidget * web_view_inspect= webkit_web_view_new ();
+  gtk_widget_show(web_view_inspect);
+  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW (gtk_scrolled_window_inspect),web_view_inspect);
+  gtk_widget_show(gtk_scrolled_window_inspect);
+  gtk_container_add (GTK_CONTAINER (gtk_window_inspect),  gtk_scrolled_window_inspect);
+  gtk_widget_show(gtk_window_inspect);
+  return WEBKIT_WEB_VIEW(web_view_inspect);
+}
+
 /* TODO deprecated, use load-status.  */
 void
 webkit_document_load_finished_cb (WebKitWebView *webkitwebview,
diff -rupN emacsOld/emacs-emacs-25.0.90/src/xwidget.h emacs-emacs-25.0.90/src/xwidget.h
--- emacsOld/emacs-emacs-25.0.90/src/xwidget.h	2016-01-30 13:00:54.000000000 -0200
+++ emacs-emacs-25.0.90/src/xwidget.h	2016-02-08 17:25:41.853960914 -0200
@@ -30,7 +30,8 @@ struct window;
 
 #ifdef HAVE_XWIDGETS
 # include <gtk/gtk.h>
-
+#include <webkit/webkitwebview.h>
+#include <webkit/webkitwebinspector.h>
 struct xwidget
 {
   struct vectorlike_header header;
@@ -57,7 +58,7 @@ struct xwidget
   GtkWidget *widgetwindow_osr;
 
   /* Used if the widget (webkit) is to be wrapped in a scrolled window.  */
-  GtkWidget *widgetscrolledwindow_osr;
+  GtkWidget *widgetscrolledwindow_osr; 
 
   /* Kill silently if Emacs is exited.  */
   bool_bf kill_without_query : 1;
@@ -118,6 +119,7 @@ void x_draw_xwidget_glyph_string (struct
 struct xwidget *lookup_xwidget (Lisp_Object spec);
 void xwidget_end_redisplay (struct window *, struct glyph_matrix *);
 void kill_buffer_xwidgets (Lisp_Object);
+WebKitWebView* inspect_web_view(WebKitWebInspector *web_inspector, WebKitWebView      *web_view, gpointer user_data); //kite0101
 #else
 INLINE_HEADER_BEGIN
 INLINE void syms_of_xwidget (void) {}