]> git.eshelyaron.com Git - emacs.git/commitdiff
Revert last change in 'shr-descend'
authorEli Zaretskii <eliz@gnu.org>
Fri, 6 Oct 2017 12:42:22 +0000 (15:42 +0300)
committerEli Zaretskii <eliz@gnu.org>
Fri, 6 Oct 2017 12:42:22 +0000 (15:42 +0300)
* lisp/net/shr.el (shr-descend): Revert the part of the last
change which introduced calls to shr-indirect-call into this
function.  Add a comment explaining the rationale for that.
(Bug#28402)

lisp/net/shr.el

index fe5197b35f72b46b2e145ecfc3efbf3560a2f361..260ada54222af637c0b10caaea9252387362a55e 100644 (file)
@@ -483,7 +483,11 @@ size, and full-buffer size."
           (apply 'shr-generic dom args)))))
 
 (defun shr-descend (dom)
-  (let ((tag-name (dom-tag dom))
+  (let ((function
+         (intern (concat "shr-tag-" (symbol-name (dom-tag dom))) obarray))
+        ;; Allow other packages to override (or provide) rendering
+        ;; of elements.
+        (external (cdr (assq (dom-tag dom) shr-external-rendering-functions)))
        (style (dom-attr dom 'style))
        (shr-stylesheet shr-stylesheet)
        (shr-depth (1+ shr-depth))
@@ -498,7 +502,17 @@ size, and full-buffer size."
          (setq style nil)))
       ;; If we have a display:none, then just ignore this part of the DOM.
       (unless (equal (cdr (assq 'display shr-stylesheet)) "none")
-       (shr-indirect-call tag-name dom)
+        ;; We don't use shr-indirect-call here, since shr-descend is
+        ;; the central bit of shr.el, and should be as fast as
+        ;; possible.  Having one more level of indirection with its
+        ;; negative effect on performance is deemed unjustified in
+        ;; this case.
+        (cond (external
+               (funcall external dom))
+              ((fboundp function)
+               (funcall function dom))
+              (t
+               (shr-generic dom)))
        (when (and shr-target-id
                   (equal (dom-attr dom 'id) shr-target-id))
          ;; If the element was empty, we don't have anything to put the