aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2012-01-12 16:30:04 +0100
committerJoakim Verona2012-01-12 16:30:04 +0100
commit69a8e78e4d1af91cf50a2870bb8cd9a5794161de (patch)
tree12709dbf3538c8749ef045108c6905c7183d68d6
parent16e9a80c0c3ca5f72f802b92ff5ca1f595a07eca (diff)
downloademacs-69a8e78e4d1af91cf50a2870bb8cd9a5794161de.tar.gz
emacs-69a8e78e4d1af91cf50a2870bb8cd9a5794161de.zip
fixes for typechecking to avoid crashes when some webkit functions are called with nil instead of valid webkit obj. intended to make it run on archlinux
-rw-r--r--lisp/xwidget.el12
-rw-r--r--src/xwidget.c23
2 files changed, 27 insertions, 8 deletions
diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index 8ed0c72f296..a8fa84da37f 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -72,7 +72,9 @@ NEW-SESSION specifies whether to create a new xwidget-webkit session. URL
72defaults to the string looking like a url around the cursor position." 72defaults to the string looking like a url around the cursor position."
73 (interactive (progn 73 (interactive (progn
74 (require 'browse-url) 74 (require 'browse-url)
75 (browse-url-interactive-arg "xwidget-webkit URL: " ( xwidget-webkit-current-url)))) 75 (browse-url-interactive-arg "xwidget-webkit URL: "
76 ;;( xwidget-webkit-current-url)
77 )))
76 (when (stringp url) 78 (when (stringp url)
77 (setq url (url-tidy url)) 79 (setq url (url-tidy url))
78 (if new-session 80 (if new-session
@@ -167,7 +169,8 @@ defaults to the string looking like a url around the cursor position."
167 169
168 ((eq xwidget-event-type 'navigation-policy-decision-requested) 170 ((eq xwidget-event-type 'navigation-policy-decision-requested)
169 (if (string-match ".*#\\(.*\\)" strarg) 171 (if (string-match ".*#\\(.*\\)" strarg)
170 (xwidget-webkit-show-id-or-named-element xwidget (match-string 1 strarg)))))))) 172 (xwidget-webkit-show-id-or-named-element xwidget (match-string 1 strarg))))
173 (t (message "unhandled event:%s" xwidget-event-type))))))
171 174
172(define-derived-mode xwidget-webkit-mode 175(define-derived-mode xwidget-webkit-mode
173 special-mode "xwidget-webkit" "xwidget webkit view mode" 176 special-mode "xwidget-webkit" "xwidget webkit view mode"
@@ -180,7 +183,7 @@ defaults to the string looking like a url around the cursor position."
180(defvar xwidget-webkit-last-session-buffer nil) 183(defvar xwidget-webkit-last-session-buffer nil)
181 184
182(defun xwidget-webkit-last-session () 185(defun xwidget-webkit-last-session ()
183 "Last active webkit, or a new one." 186 "Last active webkit, or nil."
184 (if (buffer-live-p xwidget-webkit-last-session-buffer) 187 (if (buffer-live-p xwidget-webkit-last-session-buffer)
185 (save-excursion 188 (save-excursion
186 (set-buffer xwidget-webkit-last-session-buffer) 189 (set-buffer xwidget-webkit-last-session-buffer)
@@ -348,7 +351,8 @@ Argument H height."
348(defun xwidget-webkit-current-url () 351(defun xwidget-webkit-current-url ()
349 "Get the webkit url. place it on kill ring." 352 "Get the webkit url. place it on kill ring."
350 (interactive) 353 (interactive)
351 (let ((url (kill-new (xwidget-webkit-execute-script-rv (xwidget-webkit-current-session) "document.URL")))) 354 (let* ((rv (xwidget-webkit-execute-script-rv (xwidget-webkit-current-session) "document.URL"))
355 (url (kill-new (if rv rv ""))))
352 (message "url: %s" url ) 356 (message "url: %s" url )
353 url)) 357 url))
354 358
diff --git a/src/xwidget.c b/src/xwidget.c
index 848e95fca1a..93d7c46a41f 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -826,22 +826,37 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
826 826
827 827
828#ifdef HAVE_WEBKIT_OSR 828#ifdef HAVE_WEBKIT_OSR
829
830//FUGLY macro that checks WEBKIT_IS_WEB_VIEW(xw->widget_osr) first
831#define WEBKIT_FN_INIT() \
832 struct xwidget* xw;\
833if(!XXWIDGETP(xwidget)) {printf("ERROR not an xwidget\n"); return Qnil;}; \
834if(Qnil == xwidget) {printf("ERROR xwidget nil\n"); return Qnil;}; \
835 xw = XXWIDGET(xwidget); \
836 if(NULL == xw) printf("ERROR xw is 0\n"); \
837 if((NULL == xw->widget_osr) || !WEBKIT_IS_WEB_VIEW(xw->widget_osr)){ \
838 printf("ERROR xw->widget_osr does not hold a webkit instance\n");\
839 return Qnil;\
840 };
841
842
829DEFUN ("xwidget-webkit-goto-uri", Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri, 2, 2, 0, 843DEFUN ("xwidget-webkit-goto-uri", Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri, 2, 2, 0,
830 doc: /* webkit goto uri.*/ 844 doc: /* webkit goto uri.*/
831 ) 845 )
832 (Lisp_Object xwidget, Lisp_Object uri) 846 (Lisp_Object xwidget, Lisp_Object uri)
833{ 847{
834 struct xwidget* xw = XXWIDGET(xwidget); 848 WEBKIT_FN_INIT();
835 webkit_web_view_load_uri ( WEBKIT_WEB_VIEW(xw->widget_osr), SDATA(uri)); 849 webkit_web_view_load_uri ( WEBKIT_WEB_VIEW(xw->widget_osr), SDATA(uri));
836 return Qnil; 850 return Qnil;
837} 851}
838 852
853
839DEFUN ("xwidget-webkit-execute-script", Fxwidget_webkit_execute_script, Sxwidget_webkit_execute_script, 2, 2, 0, 854DEFUN ("xwidget-webkit-execute-script", Fxwidget_webkit_execute_script, Sxwidget_webkit_execute_script, 2, 2, 0,
840 doc: /* webkit exec js.*/ 855 doc: /* webkit exec js.*/
841 ) 856 )
842 (Lisp_Object xwidget, Lisp_Object script) 857 (Lisp_Object xwidget, Lisp_Object script)
843{ 858{
844 struct xwidget* xw = XXWIDGET(xwidget); 859 WEBKIT_FN_INIT();
845 webkit_web_view_execute_script( WEBKIT_WEB_VIEW(xw->widget_osr), SDATA(script)); 860 webkit_web_view_execute_script( WEBKIT_WEB_VIEW(xw->widget_osr), SDATA(script));
846 return Qnil; 861 return Qnil;
847} 862}
@@ -852,7 +867,7 @@ DEFUN ("xwidget-webkit-get-title", Fxwidget_webkit_get_title, Sxwidget_webkit_g
852 (Lisp_Object xwidget) 867 (Lisp_Object xwidget)
853{ 868{
854 //TODO support multibyte strings 869 //TODO support multibyte strings
855 struct xwidget* xw = XXWIDGET(xwidget); 870 WEBKIT_FN_INIT();
856 const gchar* str=webkit_web_view_get_title( WEBKIT_WEB_VIEW(xw->widget_osr)); 871 const gchar* str=webkit_web_view_get_title( WEBKIT_WEB_VIEW(xw->widget_osr));
857 //return make_string_from_bytes(str, wcslen((const wchar_t *)str), strlen(str)); 872 //return make_string_from_bytes(str, wcslen((const wchar_t *)str), strlen(str));
858 if(str == 0){ 873 if(str == 0){
@@ -931,7 +946,7 @@ DEFUN ("xwidget-webkit-dom-dump", Fxwidget_webkit_dom_dump, Sxwidget_webkit_dom
931 ) 946 )
932 (Lisp_Object xwidget) 947 (Lisp_Object xwidget)
933{ 948{
934 struct xwidget* xw = XXWIDGET(xwidget); 949 WEBKIT_FN_INIT();
935 xwidget_webkit_dom_dump(WEBKIT_DOM_NODE(webkit_web_view_get_dom_document( WEBKIT_WEB_VIEW(xw->widget_osr)))); 950 xwidget_webkit_dom_dump(WEBKIT_DOM_NODE(webkit_web_view_get_dom_document( WEBKIT_WEB_VIEW(xw->widget_osr))));
936 return Qnil; 951 return Qnil;
937} 952}