changeset 678:d8829df904cf

convert Html_tag_open_img()
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Sun, 14 Dec 2008 21:58:05 +0100
parents b6ef23efdac7
children 14ce954d98c0
files src/css.cc src/form.cc src/html.cc src/html_common.hh
diffstat 4 files changed, 17 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/css.cc	Thu Dec 11 23:31:03 2008 +0100
+++ b/src/css.cc	Sun Dec 14 21:58:05 2008 +0100
@@ -267,6 +267,8 @@
      ":visited {color: green; text-decoration: underline; cursor: pointer; } "
      "h1, h2, h3, h4, h5, h6, b, strong {font-weight: bolder; } "
      "i, em, cite, address {font-style: italic; } "
+     "img {border-style: solid } "
+     "img:link, img:visited {border-width: 1px } "
      "frameset, ul, ol, dir {margin-left: 40px} "
      "h1 {font-size: 2em; margin-top: .67em; margin-bottom: 0em;} "
      "h2 {font-size: 1.5em; margin-top: .75em; margin-bottom: 0em;} "
--- a/src/form.cc	Thu Dec 11 23:31:03 2008 +0100
+++ b/src/form.cc	Sun Dec 14 21:58:05 2008 +0100
@@ -1914,8 +1914,7 @@
         style::Color::create (HT2LT(html), S_TOP(html)->current_bg_color);
 
       /* create new image and add it to the button */
-      if ((Image = a_Html_add_new_image(html, tag, tagsize, url, &style_attrs,
-                                        false))) {
+      if ((Image = a_Html_add_new_image(html, tag, tagsize, url, false))) {
          Style *style = Style::create (HT2LT(html), &style_attrs);
          IM2DW(Image)->setStyle (style);
          ResourceFactory *factory = HT2LT(html)->getResourceFactory();
--- a/src/html.cc	Thu Dec 11 23:31:03 2008 +0100
+++ b/src/html.cc	Sun Dec 14 21:58:05 2008 +0100
@@ -1979,7 +1979,6 @@
  */
 DilloImage *a_Html_add_new_image(DilloHtml *html, const char *tag,
                                  int tagsize, DilloUrl *url,
-                                 dw::core::style::StyleAttrs *style_attrs,
                                  bool add)
 {
    const int MAX_W = 6000, MAX_H = 6000;
@@ -1988,7 +1987,7 @@
    char *width_ptr, *height_ptr, *alt_ptr;
    const char *attrbuf;
    Length l_w, l_h;
-   int space, w = 0, h = 0;
+   int space, border, w = 0, h = 0;
    bool load_now;
    CssPropertyList props;
 
@@ -2052,6 +2051,18 @@
       }
    }
 
+   /* Border */
+   if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "border"))) {
+      border = strtol(attrbuf, NULL, 10);
+      if (border >= 0) {
+         border = CSS_CREATE_LENGTH(border, CSS_LENGTH_TYPE_PX);
+         props.set (CssProperty::CSS_PROPERTY_BORDER_TOP_WIDTH, border);
+         props.set (CssProperty::CSS_PROPERTY_BORDER_BOTTOM_WIDTH, border);
+         props.set (CssProperty::CSS_PROPERTY_BORDER_LEFT_WIDTH, border);
+         props.set (CssProperty::CSS_PROPERTY_BORDER_RIGHT_WIDTH, 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 */
    props.set (CssProperty::PROPERTY_X_IMG, html->images->size());
@@ -2105,9 +2116,7 @@
    DilloImage *Image;
    DilloUrl *url, *usemap_url;
    Textblock *textblock;
-   StyleAttrs style_attrs;
    const char *attrbuf;
-   int border;
 
    /* This avoids loading images. Useful for viewing suspicious HTML email. */
    if (URL_FLAGS(html->base_url) & URL_SpamSafe)
@@ -2124,28 +2133,7 @@
       /* TODO: usemap URLs outside of the document are not used. */
       usemap_url = a_Html_url_new(html, attrbuf, NULL, 0);
 
-   /* Set the style attributes for this image */
-   style_attrs = *html->styleEngine->style ();
-   if (html->styleEngine->style ()->x_link != -1 ||
-       usemap_url != NULL) {
-      /* Images within links */
-      border = 1;
-      if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "border")))
-         border = strtol (attrbuf, NULL, 10);
-
-      if (html->styleEngine->style ()->x_link != -1) {
-         /* In this case we can use the text color */
-         style_attrs.setBorderColor (
-            Color::create (HT2LT(html), style_attrs.color->getColor()));
-      } else {
-         style_attrs.setBorderColor (
-            Color::create (HT2LT(html), html->link_color));
-      }
-      style_attrs.setBorderStyle (BORDER_SOLID);
-      style_attrs.borderWidth.setVal (border);
-   }
-
-   Image = a_Html_add_new_image(html, tag, tagsize, url, &style_attrs, true);
+   Image = a_Html_add_new_image(html, tag, tagsize, url, true);
 
    /* Image maps */
    if (a_Html_get_attr(html, tag, tagsize, "ismap")) {
--- a/src/html_common.hh	Thu Dec 11 23:31:03 2008 +0100
+++ b/src/html_common.hh	Sun Dec 14 21:58:05 2008 +0100
@@ -258,7 +258,6 @@
 
 DilloImage *a_Html_add_new_image(DilloHtml *html, const char *tag,
                                  int tagsize, DilloUrl *url,
-                                 dw::core::style::StyleAttrs *style_attrs,
                                  bool add);
 
 char *a_Html_parse_entities(DilloHtml *html, const char *token, int toksize);