changeset 194:e32a99e4bac8

- Moved image load logic into a common function.
author jcid
date Sun, 27 Apr 2008 15:55:09 +0200
parents 8aae0ee6e479
children 890bb568427b
files src/html.cc
diffstat 1 files changed, 12 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/html.cc	Sun Apr 27 02:52:42 2008 +0200
+++ b/src/html.cc	Sun Apr 27 15:55:09 2008 +0200
@@ -2770,6 +2770,7 @@
    const char *attrbuf;
    Length l_w, l_h;
    int space, w = 0, h = 0;
+   bool load_now;
 
 // if (prefs.show_tooltip &&
 //     (attrbuf = Html_get_attr(html, tag, tagsize, "title")))
@@ -2820,6 +2821,10 @@
          style_attrs->margin.top = style_attrs->margin.bottom = space;
    }
 
+   /* x_img is an index to a list of {url,image} pairs.
+    * We know Html_add_new_linkimage() will use size() as its next index */
+   style_attrs->x_img = html->images->size();
+
    /* Add a new image widget to this page */
    Image = a_Image_new(0,0,alt_ptr,style_attrs->backgroundColor->getColor());
    if (add) {
@@ -2827,6 +2832,11 @@
                       style_attrs);
    }
 
+   load_now = prefs.load_images || (a_Capi_get_flags(url) & CAPI_IsCached);
+   Html_add_new_linkimage(html, &url, load_now ? NULL : Image);
+   if (load_now)
+      Html_load_image(html->bw, url, Image);
+
    dFree(width_ptr);
    dFree(height_ptr);
    dFree(alt_ptr);
@@ -2865,7 +2875,7 @@
    Textblock *textblock;
    StyleAttrs style_attrs;
    const char *attrbuf;
-   int border, load_now;
+   int border;
 
    /* This avoids loading images. Useful for viewing suspicious HTML email. */
    if (URL_FLAGS(html->base_url) & URL_SpamSafe)
@@ -2902,15 +2912,8 @@
       style_attrs.setBorderStyle (BORDER_SOLID);
       style_attrs.borderWidth.setVal (border);
    }
-   /* x_img is an index to a list of {url,image} pairs.
-    * we know Html_add_new_linkimage() will use size() as its next index */
-   style_attrs.x_img = html->images->size();
-
-   load_now = (prefs.load_images || (a_Capi_get_flags(url) & CAPI_IsCached));
+
    Image = Html_add_new_image(html, tag, tagsize, url, &style_attrs, TRUE);
-   Html_add_new_linkimage(html, &url, load_now ? NULL : Image);
-   if (load_now)
-      Html_load_image(html->bw, url, Image);
 
    /* Image maps */
    if (Html_get_attr(html, tag, tagsize, "ismap")) {
@@ -4438,17 +4441,12 @@
    DilloImage *Image;
    Embed *button = NULL;
    DilloUrl *url = NULL;
-   bool load_now;
   
    if ((attrbuf = Html_get_attr(html, tag, tagsize, "src")) &&
        (url = Html_url_new(html, attrbuf, NULL, 0, 0, 0, 0))) {
       style_attrs = *S_TOP(html)->style;
       style_attrs.cursor = CURSOR_POINTER;
 
-      /* x_img is an index to a list of {url,image} pairs.
-       * we know Html_add_new_linkimage() will use size() as its next index */
-      style_attrs.x_img = html->images->size();
-
       /* create new image and add it to the button */
       if ((Image = Html_add_new_image(html, tag, tagsize, url, &style_attrs,
                                       FALSE))) {
@@ -4462,12 +4460,6 @@
 //       gtk_widget_set_sensitive(widget, FALSE); /* Until end of FORM! */
          style->unref();
 
-         load_now = prefs.load_images ||
-                    (a_Capi_get_flags(url) & CAPI_IsCached);
-         Html_add_new_linkimage(html, &url, load_now ? NULL : Image);
-         if (load_now)
-            Html_load_image(html->bw, url, Image);
-
          /* the button handles a left button click */
          complex_b_r->connectClicked (form->form_receiver);
          /* and a right button press brings up the image menu */