diff options
| -rw-r--r-- | lisp/ChangeLog | 1 | ||||
| -rw-r--r-- | lisp/net/eww.el | 38 |
2 files changed, 28 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a29cad13cc2..3f636698f43 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | the history. | 27 | the history. |
| 28 | (eww-process-text-input): Fix deletion at the start of the field, too. | 28 | (eww-process-text-input): Fix deletion at the start of the field, too. |
| 29 | (eww-mode): Revert mistanken removal of `buffer-disable-undo'. | 29 | (eww-mode): Revert mistanken removal of `buffer-disable-undo'. |
| 30 | (eww-process-text-input): Try to keep track of the size more reliably. | ||
| 30 | 31 | ||
| 31 | * dom.el (dom-pp): New function. | 32 | * dom.el (dom-pp): New function. |
| 32 | 33 | ||
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 38837675acf..f65403b3622 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -405,6 +405,7 @@ See the `eww-search-prefix' variable for the search engine used." | |||
| 405 | (forward-line 1))))) | 405 | (forward-line 1))))) |
| 406 | (plist-put eww-data :url url) | 406 | (plist-put eww-data :url url) |
| 407 | (setq eww-history-position 0) | 407 | (setq eww-history-position 0) |
| 408 | (eww-size-text-inputs) | ||
| 408 | (eww-update-header-line-format)))) | 409 | (eww-update-header-line-format)))) |
| 409 | 410 | ||
| 410 | (defun eww-handle-link (dom) | 411 | (defun eww-handle-link (dom) |
| @@ -953,7 +954,7 @@ appears in a <link> or <a> tag." | |||
| 953 | "List of input types which represent a text input. | 954 | "List of input types which represent a text input. |
| 954 | See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.") | 955 | See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.") |
| 955 | 956 | ||
| 956 | (defun eww-process-text-input (beg end length) | 957 | (defun eww-process-text-input (beg end replace-length) |
| 957 | (when-let (pos (and (< (1+ end) (point-max)) | 958 | (when-let (pos (and (< (1+ end) (point-max)) |
| 958 | (> (1- end) (point-min)) | 959 | (> (1- end) (point-min)) |
| 959 | (cond | 960 | (cond |
| @@ -964,24 +965,23 @@ See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.") | |||
| 964 | (let* ((form (get-text-property pos 'eww-form)) | 965 | (let* ((form (get-text-property pos 'eww-form)) |
| 965 | (properties (text-properties-at pos)) | 966 | (properties (text-properties-at pos)) |
| 966 | (inhibit-read-only t) | 967 | (inhibit-read-only t) |
| 968 | (length (- end beg replace-length)) | ||
| 967 | (type (plist-get form :type))) | 969 | (type (plist-get form :type))) |
| 968 | (when (and form | 970 | (when (and form |
| 969 | (member type eww-text-input-types)) | 971 | (member type eww-text-input-types)) |
| 970 | (cond | 972 | (cond |
| 971 | ((zerop length) | 973 | ((> length 0) |
| 972 | ;; Delete some space at the end. | 974 | ;; Delete some space at the end. |
| 973 | (save-excursion | 975 | (save-excursion |
| 974 | (goto-char | 976 | (goto-char |
| 975 | (if (equal type "textarea") | 977 | (if (equal type "textarea") |
| 976 | (1- (line-end-position)) | 978 | (1- (line-end-position)) |
| 977 | (eww-end-of-field))) | 979 | (eww-end-of-field))) |
| 978 | (let ((new (- end beg))) | 980 | (while (and (> length 0) |
| 979 | (while (and (> new 0) | 981 | (eql (following-char) ? )) |
| 980 | (eql (following-char) ? )) | 982 | (delete-region (1- (point)) (point)) |
| 981 | (delete-region (point) (1+ (point))) | 983 | (cl-decf length)))) |
| 982 | (setq new (1- new)))) | 984 | ((< length 0) |
| 983 | (set-text-properties beg end properties))) | ||
| 984 | ((> length 0) | ||
| 985 | ;; Add padding. | 985 | ;; Add padding. |
| 986 | (save-excursion | 986 | (save-excursion |
| 987 | (goto-char (1- end)) | 987 | (goto-char (1- end)) |
| @@ -990,8 +990,11 @@ See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.") | |||
| 990 | (1- (line-end-position)) | 990 | (1- (line-end-position)) |
| 991 | (1+ (eww-end-of-field)))) | 991 | (1+ (eww-end-of-field)))) |
| 992 | (let ((start (point))) | 992 | (let ((start (point))) |
| 993 | (insert (make-string length ? )) | 993 | (insert (make-string (abs length) ? )) |
| 994 | (set-text-properties start (point) properties))))) | 994 | (set-text-properties start (point) properties)) |
| 995 | (goto-char (1- end))))) | ||
| 996 | (set-text-properties (plist-get form :start) (plist-get form :end) | ||
| 997 | properties) | ||
| 995 | (let ((value (buffer-substring-no-properties | 998 | (let ((value (buffer-substring-no-properties |
| 996 | (eww-beginning-of-field) | 999 | (eww-beginning-of-field) |
| 997 | (eww-end-of-field)))) | 1000 | (eww-end-of-field)))) |
| @@ -1190,6 +1193,19 @@ See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.") | |||
| 1190 | (setq start (next-single-property-change start 'eww-form)))) | 1193 | (setq start (next-single-property-change start 'eww-form)))) |
| 1191 | (nreverse inputs))) | 1194 | (nreverse inputs))) |
| 1192 | 1195 | ||
| 1196 | (defun eww-size-text-inputs () | ||
| 1197 | (let ((start (point-min))) | ||
| 1198 | (while (and start | ||
| 1199 | (< start (point-max))) | ||
| 1200 | (when (or (get-text-property start 'eww-form) | ||
| 1201 | (setq start (next-single-property-change start 'eww-form))) | ||
| 1202 | (let ((props (get-text-property start 'eww-form))) | ||
| 1203 | (plist-put props :start (set-marker (make-marker) start)) | ||
| 1204 | (setq start (next-single-property-change | ||
| 1205 | start 'eww-form nil (point-max))) | ||
| 1206 | (plist-put props | ||
| 1207 | :end (set-marker (make-marker) start))))))) | ||
| 1208 | |||
| 1193 | (defun eww-input-value (input) | 1209 | (defun eww-input-value (input) |
| 1194 | (let ((type (plist-get input :type)) | 1210 | (let ((type (plist-get input :type)) |
| 1195 | (value (plist-get input :value))) | 1211 | (value (plist-get input :value))) |