diff options
| author | Joakim Verona | 2011-08-02 00:32:00 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-08-02 00:32:00 +0200 |
| commit | e31c3c3f9c2118bf73f32a9573fefd01c9966bc2 (patch) | |
| tree | 94e326ba8f6145a798db169e4ff4cda302206fe6 | |
| parent | 022cd22bf1c735e7439dcdc51e5fe58c5411af97 (diff) | |
| download | emacs-e31c3c3f9c2118bf73f32a9573fefd01c9966bc2.tar.gz emacs-e31c3c3f9c2118bf73f32a9573fefd01c9966bc2.zip | |
some adaptor code that makes webkit mode work a bit more like image mode
| -rw-r--r-- | README.xwidget | 46 | ||||
| -rw-r--r-- | lisp/xwidget.el | 47 |
2 files changed, 82 insertions, 11 deletions
diff --git a/README.xwidget b/README.xwidget index 11406a99894..f457b5cd10e 100644 --- a/README.xwidget +++ b/README.xwidget | |||
| @@ -887,8 +887,16 @@ easy. | |||
| 887 | 887 | ||
| 888 | ** webkit related | 888 | ** webkit related |
| 889 | *** TODO webkit support webkit signals | 889 | *** TODO webkit support webkit signals |
| 890 | *** TODO particularily document-load-finished | 890 | |
| 891 | **** DONE particularily document-load-finished | ||
| 892 | CLOSED: [2011-08-01 Mon 22:34] | ||
| 891 | http://webkitgtk.org/reference/webkitgtk-webkitwebview.html#WebKitWebView-document-load-finished | 893 | http://webkitgtk.org/reference/webkitgtk-webkitwebview.html#WebKitWebView-document-load-finished |
| 894 | because one might need tell set a title and sizes and things when it loads. | ||
| 895 | **** TODO event bug | ||
| 896 | Debugger entered--Lisp error: (error "Two bases given in one event") | ||
| 897 | |||
| 898 | for some reason hapens sometimes with xwidget events. | ||
| 899 | |||
| 892 | *** TODO console messages | 900 | *** TODO console messages |
| 893 | http://webkitgtk.org/reference/webkitgtk-webkitwebview.html#WebKitWebView-console-message | 901 | http://webkitgtk.org/reference/webkitgtk-webkitwebview.html#WebKitWebView-console-message |
| 894 | http://getfirebug.com/wiki/index.php/Console_API#console.count.28.5Btitle.5D.29 | 902 | http://getfirebug.com/wiki/index.php/Console_API#console.count.28.5Btitle.5D.29 |
| @@ -898,8 +906,7 @@ because maybe we can make a simple JS REPL that way. | |||
| 898 | prints hello to stdout but theres no way to catch stdout from webkit I | 906 | prints hello to stdout but theres no way to catch stdout from webkit I |
| 899 | think other than receiving the signal. | 907 | think other than receiving the signal. |
| 900 | 908 | ||
| 901 | *** DONE webkit flashkiller by default | 909 | *** TODO webkit flashkiller by default |
| 902 | CLOSED: [2011-07-19 Tue 14:27] | ||
| 903 | while its possible to support plugins in the webkit xwidget, flash has | 910 | while its possible to support plugins in the webkit xwidget, flash has |
| 904 | issues on 64 bit, and slows down emacs to a halt with off screen | 911 | issues on 64 bit, and slows down emacs to a halt with off screen |
| 905 | rendering, and of course is not free software. its in the way for real | 912 | rendering, and of course is not free software. its in the way for real |
| @@ -912,6 +919,9 @@ http://stackoverflow.com/questions/4885513/prevent-flash-in-cocoa-webview | |||
| 912 | simply use this api: | 919 | simply use this api: |
| 913 | http://webkitgtk.org/reference/WebKitWebPluginDatabase.html | 920 | http://webkitgtk.org/reference/WebKitWebPluginDatabase.html |
| 914 | 921 | ||
| 922 | theres an implementation now but it's not robust enough webkit often | ||
| 923 | crashes taking emacs with it. | ||
| 924 | |||
| 915 | *** TODO webkit downloads | 925 | *** TODO webkit downloads |
| 916 | when clicking a download link in Webkit Emacs should take over and handle it | 926 | when clicking a download link in Webkit Emacs should take over and handle it |
| 917 | from there. Probably need signals. There are Emacs libraries to | 927 | from there. Probably need signals. There are Emacs libraries to |
| @@ -926,7 +936,8 @@ open a new window or something, which wont work. | |||
| 926 | have a look at how docview solves it | 936 | have a look at how docview solves it |
| 927 | webkit_web_view_search_text () | 937 | webkit_web_view_search_text () |
| 928 | *** TODO webkit relative references doesn't work | 938 | *** TODO webkit relative references doesn't work |
| 929 | probably because we handle scrolling in a non-standard way | 939 | probably because we handle scrolling in a non-standard way. It does |
| 940 | work sort of when theres a html frameset and webkit scrols by itself. | ||
| 930 | *** TODO webkit width adjustment handling issue | 941 | *** TODO webkit width adjustment handling issue |
| 931 | since there are so many levels of clipping and whatnot in xwidgets | 942 | since there are so many levels of clipping and whatnot in xwidgets |
| 932 | sizing issues are difficult. | 943 | sizing issues are difficult. |
| @@ -946,16 +957,33 @@ to see the problem surface to http://www.slashdot.org | |||
| 946 | - xwidget-webkit-adjust-size | 957 | - xwidget-webkit-adjust-size |
| 947 | - xwidget-webkit-adjust-size-to-content | 958 | - xwidget-webkit-adjust-size-to-content |
| 948 | 959 | ||
| 949 | and then try resizing Epiphany. | 960 | and then compare by resizing in Epiphany, which is also webkit based. |
| 950 | 961 | ||
| 951 | *** TODO xwidget webkit allow loading from string from emacs | 962 | *** TODO xwidget webkit allow loading from string from emacs |
| 952 | *** TODO xwidget-webkit-last-session | 963 | *** DONE xwidget-webkit-last-session |
| 964 | CLOSED: [2011-08-01 Mon 22:38] | ||
| 953 | was rather hurried. end result is that the lisp layer only really | 965 | was rather hurried. end result is that the lisp layer only really |
| 954 | allows for one webkit session. | 966 | allows for one webkit session. |
| 955 | *** TODO C-X b in other buffer from webkit | 967 | *** TODO C-X b in other buffer from webkit |
| 956 | bafflingly resets the webkit view to the top. Maybe the window | 968 | bafflingly resets the webkit view to the top. Maybe the window |
| 957 | reconfiguration hook code? further mystification is added because it | 969 | reconfiguration hook code? further mystification is added because it |
| 958 | only seems to happen with ido mode enabled. | 970 | only seems to happen with ido mode enabled. |
| 971 | |||
| 972 | in comparison with image-mode which does the right thing, I discovered | ||
| 973 | that image-mode has special code to handle scrolling. the browser mode | ||
| 974 | and image mode has some similarities. | ||
| 975 | |||
| 976 | ** TODO xwidget image display spec compatibility | ||
| 977 | some history: the first version of the xwidget display spec was | ||
| 978 | the same as an image spec. This turned out not to be fantastic because | ||
| 979 | an xwidget is both like a process and like an image. it has a separate | ||
| 980 | existence from display. So now the xwidget display spec is just a | ||
| 981 | pointer to a xwidget. But then some useful functionality in Emacs | ||
| 982 | can't be reused for xwidget, in particular image-mode. | ||
| 983 | |||
| 984 | Maybe a new image type could be added that was a wraper on an | ||
| 985 | xwidget. Then image mode could be reused for webkit mode. | ||
| 986 | |||
| 959 | ** socket related | 987 | ** socket related |
| 960 | *** TODO some flickering during redisplay of sockets | 988 | *** TODO some flickering during redisplay of sockets |
| 961 | with gtk3 an size allocation workaround is used. | 989 | with gtk3 an size allocation workaround is used. |
| @@ -987,9 +1015,10 @@ fine-tuning to reduce flicker. | |||
| 987 | 1015 | ||
| 988 | 1016 | ||
| 989 | 1017 | ||
| 990 | ** TODO xwidgets doesn't work during bootstrap all of a sudden | 1018 | ** DONE xwidgets doesn't work during bootstrap all of a sudden |
| 1019 | CLOSED: [2011-08-01 Mon 22:33] | ||
| 991 | might be some annoying local issues with my install because it is not | 1020 | might be some annoying local issues with my install because it is not |
| 992 | reliably reproducible. | 1021 | reliably reproducible. (went away during merges) |
| 993 | 1022 | ||
| 994 | ** TODO low impact xwidget based image viewer | 1023 | ** TODO low impact xwidget based image viewer |
| 995 | for instance to render SVG using webkit, or some other canvas. | 1024 | for instance to render SVG using webkit, or some other canvas. |
| @@ -998,6 +1027,7 @@ that way it would be possible to merge to trunk in stages. | |||
| 998 | so, webkit could be used to display the SVG. the display spec for | 1027 | so, webkit could be used to display the SVG. the display spec for |
| 999 | images would be used. multiple webkits would be used rather than | 1028 | images would be used. multiple webkits would be used rather than |
| 1000 | offscreen rendering, so it would be GTK2 compatible. | 1029 | offscreen rendering, so it would be GTK2 compatible. |
| 1030 | ** | ||
| 1001 | * old notes from x_draw_xwidget_glyph_string | 1031 | * old notes from x_draw_xwidget_glyph_string |
| 1002 | 1032 | ||
| 1003 | BUG it seems this method for some reason is called with bad s->x and s->y sometimes. | 1033 | BUG it seems this method for some reason is called with bad s->x and s->y sometimes. |
diff --git a/lisp/xwidget.el b/lisp/xwidget.el index aef04cfb542..5ca8fb58d69 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el | |||
| @@ -56,6 +56,7 @@ see xwidget.c for types suitable for TYPE. | |||
| 56 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 56 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 57 | ;;; webkit support | 57 | ;;; webkit support |
| 58 | (require 'browse-url) | 58 | (require 'browse-url) |
| 59 | (require 'image-mode) | ||
| 59 | ;;;###autoload | 60 | ;;;###autoload |
| 60 | (defun xwidget-webkit-browse-url (url &optional new-session) | 61 | (defun xwidget-webkit-browse-url (url &optional new-session) |
| 61 | "Ask xwidget-webkit to browse URL. | 62 | "Ask xwidget-webkit to browse URL. |
| @@ -81,23 +82,62 @@ defaults to the string looking like a url around the cursor position." | |||
| 81 | (define-key map "r" 'xwidget-webkit-reload ) | 82 | (define-key map "r" 'xwidget-webkit-reload ) |
| 82 | (define-key map "\C-m" 'xwidget-webkit-insert-string) | 83 | (define-key map "\C-m" 'xwidget-webkit-insert-string) |
| 83 | (define-key map [xwidget-event] 'xwidget-webkit-event-handler) | 84 | (define-key map [xwidget-event] 'xwidget-webkit-event-handler) |
| 85 | |||
| 86 | ;;similar to image mode bindings | ||
| 87 | (define-key map (kbd "SPC") 'image-scroll-up) | ||
| 88 | (define-key map (kbd "DEL") 'image-scroll-down) | ||
| 89 | |||
| 90 | (define-key map [remap forward-char] (xwidget-image-mode-navigation-adaptor 'image-forward-hscroll)) | ||
| 91 | (define-key map [remap backward-char] (xwidget-image-mode-navigation-adaptor 'image-backward-hscroll)) | ||
| 92 | (define-key map [remap right-char] (xwidget-image-mode-navigation-adaptor 'image-forward-hscroll)) | ||
| 93 | (define-key map [remap left-char] (xwidget-image-mode-navigation-adaptor 'image-backward-hscroll)) | ||
| 94 | (define-key map [remap previous-line] (xwidget-image-mode-navigation-adaptor 'image-previous-line)) | ||
| 95 | (define-key map [remap next-line] (xwidget-image-mode-navigation-adaptor 'image-next-line)) | ||
| 96 | (define-key map [remap scroll-up] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) | ||
| 97 | (define-key map [remap scroll-up-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) | ||
| 98 | |||
| 99 | (define-key map [remap scroll-down] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) | ||
| 100 | |||
| 101 | (define-key map [remap scroll-down-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) | ||
| 102 | (define-key map [remap move-beginning-of-line] (xwidget-image-mode-navigation-adaptor 'image-bol)) | ||
| 103 | (define-key map [remap move-end-of-line] (xwidget-image-mode-navigation-adaptor 'image-eol)) | ||
| 104 | (define-key map [remap beginning-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-bob)) | ||
| 105 | (define-key map [remap end-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-eob)) | ||
| 106 | |||
| 107 | |||
| 84 | map) | 108 | map) |
| 85 | 109 | ||
| 86 | "Keymap for `xwidget-webkit-mode'.") | 110 | "Keymap for `xwidget-webkit-mode'.") |
| 87 | 111 | ||
| 112 | (defun xwidget-image-display-size (spec &optional pixels frame) | ||
| 113 | (let ((xwi (xwidget-info (xwidget-at 1)))) | ||
| 114 | (cons (aref xwi 2) | ||
| 115 | (aref xwi 3)))) | ||
| 116 | |||
| 117 | (defmacro xwidget-image-mode-navigation-adaptor (fn) | ||
| 118 | `(lambda () (interactive) | ||
| 119 | (flet ((image-display-size (spec &optional pixels frame) (xwidget-image-display-size spec))) | ||
| 120 | (funcall ,fn)))) | ||
| 121 | ) | ||
| 122 | |||
| 88 | (defun xwidget-webkit-event-handler () | 123 | (defun xwidget-webkit-event-handler () |
| 89 | (interactive) | 124 | (interactive) |
| 90 | (message "stuff happened to webkit xwidget %S" last-input-event) | 125 | (message "stuff happened to webkit xwidget %S" last-input-event) |
| 91 | (let* | 126 | (let* |
| 92 | ((xwidget-event-type (nth 2 last-input-event)) | 127 | ((xwidget-event-type (nth 2 last-input-event)) |
| 93 | (xwidget (nth 1 last-input-event))) | 128 | (xwidget (nth 1 last-input-event))) |
| 94 | (cond ( (eq xwidget-event-type 'document-load-finished) | 129 | (cond ((eq xwidget-event-type 'document-load-finished) |
| 95 | (message "webkit loaded %s" xwidget)) | 130 | (message "webkit loaded %s" xwidget) |
| 131 | (xwidget-webkit-adjust-size-to-content)) | ||
| 96 | ))) | 132 | ))) |
| 97 | 133 | ||
| 98 | (define-derived-mode xwidget-webkit-mode | 134 | (define-derived-mode xwidget-webkit-mode |
| 99 | special-mode "xwidget-webkit" "xwidget webkit view mode" | 135 | special-mode "xwidget-webkit" "xwidget webkit view mode" |
| 100 | (setq buffer-read-only t)) | 136 | (setq buffer-read-only t) |
| 137 | ;; Keep track of [vh]scroll when switching buffers | ||
| 138 | (image-mode-setup-winprops) | ||
| 139 | |||
| 140 | ) | ||
| 101 | 141 | ||
| 102 | (defvar xwidget-webkit-last-session-buffer nil) | 142 | (defvar xwidget-webkit-last-session-buffer nil) |
| 103 | 143 | ||
| @@ -189,6 +229,7 @@ defaults to the string looking like a url around the cursor position." | |||
| 189 | ;;this is a workaround because I cant find the right place to put it in C | 229 | ;;this is a workaround because I cant find the right place to put it in C |
| 190 | (add-hook 'window-configuration-change-hook 'xwidget-cleanup) | 230 | (add-hook 'window-configuration-change-hook 'xwidget-cleanup) |
| 191 | 231 | ||
| 232 | ;;killflash is sadly not reliable yet. | ||
| 192 | (defvar xwidget-webkit-kill-flash-oneshot t) | 233 | (defvar xwidget-webkit-kill-flash-oneshot t) |
| 193 | (defun xwidget-webkit-kill-flash () | 234 | (defun xwidget-webkit-kill-flash () |
| 194 | ;;you can only call this once or webkit crashes and takes emacs with it. odd. | 235 | ;;you can only call this once or webkit crashes and takes emacs with it. odd. |