[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: pages with many images slow



青田です。

Hideyuki SHIRAI (白井秀行) <shirai@xxxxxxxxxxx> writes:

> From: Naohiro Aota <naota@xxxxxxxxx> さん曰く
> Subject: [emacs-w3m:10639] Re: pages with many images slow
> Message-ID: <87ocxuja5o.fsf@xxxxxxxxxxxxxxxx>
> Date: Tue, 27 Jan 2009 01:37:39 +0900
>
>> To be exact, emacs-w3m waits for retrieving process creating or image
>> size conversion (if cached and need to resize). Anyway, I changed the
>> code to use the idle-timer system only when all the following conditions
>> are met.
>> 
>> 1. the image is remote one
>> 2. emacs-w3m doesn't have cache of the image
>> 3. emacs-w3m doesn't need to resize the image
>> 
>> Now, I think the code is good enough to be tested in emacs-w3m CVS. If
>> there is no objection, I'll commit the code in the CVS.
>
> 一点不味いところを見つけました。Mew で text/html のパートを表示
> するときの話ですが、他の MUA も同じじゃないかな?
>
> 従来は Mew + w3m の設定で (setq mew-w3m-auto-insert-image t)
> とすると、text/html のパート内部のうち、mew-w3m-safe-url-regexp
> で示された "\\`cid:" だけを自動的に表示して、外部にアクセスする
> 画像データは取得しに行きませんでした。
>
> が、現在は同時に取得しに行ってしまいます。ちょっとまずい。
>
> Mew だと↓のように w3m-region() を呼ぶわけなので、w3m-region()
> には、w3m-safe-url-regexp が効いていて外部にはアクセスしなかった
> のですが、現状では、timer で遅れて起動されるので、その時に呼ばれ
> た w3m-image() => w3m-retrieve() ではすでに w3m-safe-url-regexp
> が nil となっていてガードが効かない、ということだと思います。
>
> メインルーチンの方で直すなら、現状「変数 w3m-safe-url-regexp」だ
> けをみているところを「プロパティ w3m-safe-url-regexp」も見るよう
> にすれば大丈夫だと思います。画像の delay 表示側で対応するより、
> その方が素直かも。

「プロパティ w3m-safe-url-regexp」も見るようにしてしまうと、 今度は
interactive に w3m-toggle-inline-images を呼んで、 "Are you sure you
really want to show all images (maybe insecure)? " に yes と答えても一部
の画像が表示されないことになりそうな気がします。

二度手間になってしまいますが、 w3m-toggle-inline-images-internal にも
safe-regexp を渡してあげるのがいいと思います。 (こうしておくと 上の質問に
no とした時に safe な画像だけを表示ということもできるようになるはず。)

--
青田
Index: w3m.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m.el,v
retrieving revision 1.1414
diff -u -r1.1414 w3m.el
--- w3m.el	27 Jan 2009 04:33:33 -0000	1.1414
+++ w3m.el	31 Jan 2009 09:39:33 -0000
@@ -3684,7 +3684,8 @@
 
 (defsubst w3m-toggle-inline-images-internal (status
 					     &optional no-cache url
-					     begin-pos end-pos)
+					     begin-pos end-pos
+					     safe-regexp)
   "Toggle displaying of inline images on current buffer.
 STATUS is current image status.
 If NO-CACHE is non-nil, cache is not used.
@@ -3731,6 +3732,8 @@
 		    (setq end (point)))
 		(goto-char cur-point)
 		(when (and (w3m-url-valid iurl)
+			   (or (null safe-regexp)
+			       (string-match safe-regexp iurl))
 			   (or (not w3m-current-ssl)
 			       (string-match "\\`\\(?:ht\\|f\\)tps://" iurl)
 			       allow-non-secure-images
@@ -3930,7 +3933,9 @@
 	(progn
 	  (unwind-protect
 	      (w3m-toggle-inline-images-internal (if status 'on 'off)
-						 no-cache nil beg end)
+						 no-cache nil beg end
+						 (unless (interactive-p)
+						   safe-regexp))
 	    (setq w3m-display-inline-images (not status))
 	    (when status (w3m-process-stop (current-buffer)))
 	    (force-mode-line-update)))