diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/IO/mime.c | 1 | ||||
-rw-r--r-- | src/cache.c | 4 | ||||
-rw-r--r-- | src/css.cc | 4 | ||||
-rw-r--r-- | src/css.hh | 10 | ||||
-rw-r--r-- | src/cssparser.cc | 7 | ||||
-rw-r--r-- | src/dillo.cc | 1 | ||||
-rw-r--r-- | src/form.cc | 7 | ||||
-rw-r--r-- | src/html.cc | 210 | ||||
-rw-r--r-- | src/html_common.hh | 7 | ||||
-rw-r--r-- | src/misc.c | 6 | ||||
-rw-r--r-- | src/styleengine.cc | 156 | ||||
-rw-r--r-- | src/styleengine.hh | 38 | ||||
-rw-r--r-- | src/table.cc | 152 |
13 files changed, 326 insertions, 277 deletions
diff --git a/src/IO/mime.c b/src/IO/mime.c index 9bffd619..19dc601a 100644 --- a/src/IO/mime.c +++ b/src/IO/mime.c @@ -108,6 +108,7 @@ void a_Mime_init() Mime_add_minor_type("image/x-png", a_Dicache_png_image); /* deprecated */ #endif Mime_add_minor_type("text/html", a_Html_text); + Mime_add_minor_type("application/xhtml+xml", a_Html_text); /* Add a major type to handle all the text stuff */ Mime_add_major_type("text", a_Plain_text); diff --git a/src/cache.c b/src/cache.c index 078f4bbd..ec7af67d 100644 --- a/src/cache.c +++ b/src/cache.c @@ -516,6 +516,10 @@ const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype, ((!major || !*major) && (!minor || !*minor))) { /* META only gives charset; use detected MIME type too */ entry->TypeNorm = dStrconcat(entry->TypeDet, ctype, NULL); + } else if (*from == 'm' && + !dStrncasecmp(ctype, "text/xhtml", 10)) { + /* WORKAROUND: doxygen uses "text/xhtml" in META */ + entry->TypeNorm = dStrdup(entry->TypeDet); } if (charset) { if (entry->CharsetDecoder) @@ -588,8 +588,8 @@ void CssContext::buildUserAgentStyle () { "sub {vertical-align: sub}" "sup {vertical-align: super}" "s, strike, del {text-decoration: line-through}" - "table {border-style: outset; border-spacing: 1px}" - "td, th {border-style: inset; padding: 2px}" + "table {border-spacing: 1px}" + "td, th {padding: 2px}" "thead, tbody, tfoot {vertical-align: middle}" "th {font-weight: bolder; text-align: center}" "code, tt, pre, samp, kbd {font-family: monospace}" @@ -313,16 +313,6 @@ class CssPropertyList : public lout::misc::SimpleVector <CssProperty> { void set (CssPropertyName name, CssValueType type, CssPropertyValue value); - inline void set (CssPropertyName name, CssValueType type, char *value) { - CssPropertyValue v; - v.strVal = value; - set (name, type, v); - }; - inline void set (CssPropertyName name, CssValueType type, int value) { - CssPropertyValue v; - v.intVal = value; - set (name, type, v); - }; void apply (CssPropertyList *props); void print (); inline void ref () { refCount++; } diff --git a/src/cssparser.cc b/src/cssparser.cc index 00ba7428..23085352 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -77,6 +77,10 @@ static const char *const Css_font_style_enum_vals[] = { "normal", "italic", "oblique", NULL }; +static const char *const Css_font_variant_enum_vals[] = { + "normal", "small-caps", NULL +}; + static const char *const Css_font_weight_enum_vals[] = { "bold", "bolder", "light", "lighter", "normal", NULL }; @@ -169,7 +173,8 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = { {"font-size-adjust", {CSS_TYPE_UNUSED}, NULL}, {"font-stretch", {CSS_TYPE_UNUSED}, NULL}, {"font-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_font_style_enum_vals}, - {"font-variant", {CSS_TYPE_UNUSED}, NULL}, + {"font-variant", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, + Css_font_variant_enum_vals}, {"font-weight", {CSS_TYPE_ENUM, CSS_TYPE_FONT_WEIGHT, CSS_TYPE_UNUSED}, Css_font_weight_enum_vals}, {"height", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL}, diff --git a/src/dillo.cc b/src/dillo.cc index a42b0dab..3159674e 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -22,6 +22,7 @@ #include <stdlib.h> #include <time.h> #include <signal.h> +#include <locale.h> #include <fltk/Window.h> #include <fltk/TabGroup.h> diff --git a/src/form.cc b/src/form.cc index 38afea8f..a74bcdd6 100644 --- a/src/form.cc +++ b/src/form.cc @@ -554,12 +554,9 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) } if (prefs.show_tooltip && (attrbuf = a_Html_get_attr(html, tag, tagsize, "title"))) { - CssPropertyList props; - char *tooltip_str = dStrdup(attrbuf); - props.set (PROPERTY_X_TOOLTIP, CSS_TYPE_STRING, tooltip_str); - html->styleEngine->setNonCssHints (&props); - dFree(tooltip_str); + html->styleEngine->setNonCssHint (PROPERTY_X_TOOLTIP, CSS_TYPE_STRING, + attrbuf); } HT2TB(html)->addWidget (embed, html->styleEngine->backgroundStyle()); } diff --git a/src/html.cc b/src/html.cc index 1a353224..9b53a082 100644 --- a/src/html.cc +++ b/src/html.cc @@ -304,9 +304,7 @@ static void Html_add_new_htmlimage(DilloHtml *html, * Evaluates the ALIGN attribute (left|center|right|justify) and * sets the style at the top of the stack. */ -void a_Html_tag_set_align_attr(DilloHtml *html, - CssPropertyList *props, - const char *tag, int tagsize) +void a_Html_tag_set_align_attr(DilloHtml *html, const char *tag, int tagsize) { const char *align; @@ -339,7 +337,8 @@ void a_Html_tag_set_align_attr(DilloHtml *html, style_attrs.textAlignChar = '.'; } #endif - props->set (CSS_PROPERTY_TEXT_ALIGN, CSS_TYPE_ENUM, textAlignType); + html->styleEngine->setNonCssHint(CSS_PROPERTY_TEXT_ALIGN, CSS_TYPE_ENUM, + textAlignType); } } @@ -347,8 +346,7 @@ void a_Html_tag_set_align_attr(DilloHtml *html, * Evaluates the VALIGN attribute (top|bottom|middle|baseline) and * sets the style in style_attrs. Returns true when set. */ -bool a_Html_tag_set_valign_attr(DilloHtml *html, const char *tag, - int tagsize, CssPropertyList *props) +bool a_Html_tag_set_valign_attr(DilloHtml *html, const char *tag, int tagsize) { const char *attr; VAlignType valign; @@ -363,7 +361,8 @@ bool a_Html_tag_set_valign_attr(DilloHtml *html, const char *tag, else valign = VALIGN_MIDDLE; - props->set (CSS_PROPERTY_VERTICAL_ALIGN, CSS_TYPE_ENUM, valign); + html->styleEngine->setNonCssHint (CSS_PROPERTY_VERTICAL_ALIGN, + CSS_TYPE_ENUM, valign); return true; } else return false; @@ -427,7 +426,6 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url, stack = new misc::SimpleVector <DilloHtmlState> (16); stack->increase(); - stack->getRef(0)->table_cell_props = NULL; stack->getRef(0)->parse_mode = DILLO_HTML_PARSE_MODE_INIT; stack->getRef(0)->table_mode = DILLO_HTML_TABLE_MODE_NONE; stack->getRef(0)->cell_text_align_set = false; @@ -580,9 +578,6 @@ int DilloHtml::getCurTagLineNumber() */ void DilloHtml::freeParseData() { - for (int i = stack->size () - 1; i >= 0; i--) - if (stack->getRef (i)->table_cell_props) - stack->getRef (i)->table_cell_props->unref (); delete(stack); dStr_free(Stash, TRUE); @@ -1278,8 +1273,6 @@ static void Html_push_tag(DilloHtml *html, int tag_idx) * instead of copying all fields except for tag. --Jcid */ *html->stack->getRef(n_items) = *html->stack->getRef(n_items - 1); html->stack->getRef(n_items)->tag_idx = tag_idx; - if (S_TOP(html)->table_cell_props) - S_TOP(html)->table_cell_props->ref (); html->dw = S_TOP(html)->textblock; } @@ -1301,8 +1294,6 @@ static void Html_real_pop_tag(DilloHtml *html) bool hand_over_break; html->styleEngine->endElement (S_TOP(html)->tag_idx); - if (S_TOP(html)->table_cell_props) - S_TOP(html)->table_cell_props->unref (); hand_over_break = S_TOP(html)->hand_over_break; html->stack->setSize (html->stack->size() - 1); Html_eventually_pop_dw(html, hand_over_break); @@ -1722,7 +1713,6 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize) { const char *attrbuf; Textblock *textblock; - CssPropertyList props; int32_t color; int tag_index_a = a_Html_tag_index ("a"); int tag_index_body = a_Html_tag_index ("body"); @@ -1763,13 +1753,15 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize) if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { color = a_Html_color_parse(html, attrbuf, -1); if (color != -1) - props.set (CSS_PROPERTY_BACKGROUND_COLOR, CSS_TYPE_COLOR, color); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BACKGROUND_COLOR, + CSS_TYPE_COLOR, color); } if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "text"))) { color = a_Html_color_parse(html, attrbuf, -1); if (color != -1) - props.set (CSS_PROPERTY_COLOR, CSS_TYPE_COLOR, color); + html->styleEngine->setNonCssHint (CSS_PROPERTY_COLOR, + CSS_TYPE_COLOR, color); } if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "link"))) @@ -1778,7 +1770,6 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize) if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "vlink"))) html->non_css_visited_color = a_Html_color_parse(html, attrbuf, -1); - html->styleEngine->setNonCssHints (&props); html->dw->setStyle (html->styleEngine->style ()); /* Set canvas color if not already set from Html_open_html(). @@ -1798,10 +1789,8 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize) html->styleEngine->startElement (tag_index_a); html->styleEngine->setPseudoVisited (); if (html->non_css_visited_color != -1) { - CssPropertyList vprops; - vprops.set (CSS_PROPERTY_COLOR, CSS_TYPE_COLOR, - html->non_css_visited_color); - html->styleEngine->setNonCssHints (&vprops); + html->styleEngine->setNonCssHint (CSS_PROPERTY_COLOR, CSS_TYPE_COLOR, + html->non_css_visited_color); } html->visited_color = html->styleEngine->style ()->color->getColor (); html->styleEngine->endElement (tag_index_a); @@ -1839,9 +1828,8 @@ static void Html_tag_open_p(DilloHtml *html, const char *tag, int tagsize) { CssPropertyList props; - a_Html_tag_set_align_attr (html, &props, tag, tagsize); + a_Html_tag_set_align_attr (html, tag, tagsize); html->styleEngine->inheritBackgroundColor (); - html->styleEngine->setNonCssHints (&props); HT2TB(html)->addParbreak (9, html->styleEngine->wordStyle ()); } @@ -1877,8 +1865,8 @@ static void Html_tag_open_frame (DilloHtml *html, const char *tag, int tagsize) html->styleEngine->setPseudoLink (); } - props.set (PROPERTY_X_LINK, CSS_TYPE_INTEGER, Html_set_new_link(html,&url)); - html->styleEngine->setNonCssHints (&props); + html->styleEngine->setNonCssHint (PROPERTY_X_LINK, CSS_TYPE_INTEGER, + Html_set_new_link(html,&url)); textblock->addParbreak (5, html->styleEngine->wordStyle ()); @@ -1924,12 +1912,8 @@ static void Html_tag_open_frameset (DilloHtml *html, */ static void Html_tag_open_h(DilloHtml *html, const char *tag, int tagsize) { - CssPropertyList props; - - html->styleEngine->inheritBackgroundColor (); - a_Html_tag_set_align_attr (html, &props, tag, tagsize); - html->styleEngine->setNonCssHints (&props); + a_Html_tag_set_align_attr (html, tag, tagsize); HT2TB(html)->addParbreak (9, html->styleEngine->wordStyle ()); @@ -1954,7 +1938,6 @@ static void Html_tag_open_font(DilloHtml *html, const char *tag, int tagsize) const char *attrbuf; char *fontFamily = NULL; int32_t color; - CssPropertyList props; if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "color"))) { if (prefs.contrast_visited_color && html->InVisitedLink) { @@ -1964,15 +1947,16 @@ static void Html_tag_open_font(DilloHtml *html, const char *tag, int tagsize) color = a_Html_color_parse(html, attrbuf, -1); } if (color != -1) - props.set (CSS_PROPERTY_COLOR, CSS_TYPE_COLOR, color); + html->styleEngine->setNonCssHint (CSS_PROPERTY_COLOR, + CSS_TYPE_COLOR, color); } if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "face"))) { fontFamily = dStrdup(attrbuf); - props.set (CSS_PROPERTY_FONT_FAMILY, CSS_TYPE_SYMBOL, fontFamily); + html->styleEngine->setNonCssHint (CSS_PROPERTY_FONT_FAMILY, + CSS_TYPE_SYMBOL, fontFamily); } - html->styleEngine->setNonCssHints (&props); dFree(fontFamily); } @@ -1987,12 +1971,9 @@ static void Html_tag_open_abbr(DilloHtml *html, const char *tag, int tagsize) if (prefs.show_tooltip && (attrbuf = a_Html_get_attr(html, tag, tagsize, "title"))) { - CssPropertyList props; - char *tooltip_str = dStrdup(attrbuf); - props.set (PROPERTY_X_TOOLTIP, CSS_TYPE_STRING, tooltip_str); - html->styleEngine->setNonCssHints (&props); - dFree(tooltip_str); + html->styleEngine->setNonCssHint (PROPERTY_X_TOOLTIP, CSS_TYPE_STRING, + attrbuf); } } @@ -2036,13 +2017,11 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag, CssLength l_h = CSS_CREATE_LENGTH(0.0, CSS_LENGTH_TYPE_AUTO); int space, border, w = 0, h = 0; bool load_now; - CssPropertyList props; - char *tooltip_str = NULL; if (prefs.show_tooltip && (attrbuf = a_Html_get_attr(html, tag, tagsize, "title"))) { - tooltip_str = dStrdup(attrbuf); - props.set (PROPERTY_X_TOOLTIP, CSS_TYPE_STRING, tooltip_str); + html->styleEngine->setNonCssHint(PROPERTY_X_TOOLTIP, CSS_TYPE_STRING, + attrbuf); } alt_ptr = a_Html_get_attr_wdef(html, tag, tagsize, "alt", NULL); if ((!alt_ptr || !*alt_ptr) && !prefs.load_images) { @@ -2081,9 +2060,11 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag, MSG("a_Html_image_new: suspicious image size request %dx%d\n", w, h); } else { if (CSS_LENGTH_TYPE(l_w) != CSS_LENGTH_TYPE_AUTO) - props.set (CSS_PROPERTY_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, l_w); + html->styleEngine->setNonCssHint (CSS_PROPERTY_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, l_w); if (CSS_LENGTH_TYPE(l_h) != CSS_LENGTH_TYPE_AUTO) - props.set (CSS_PROPERTY_HEIGHT, CSS_TYPE_LENGTH_PERCENTAGE, l_h); + html->styleEngine->setNonCssHint (CSS_PROPERTY_HEIGHT, + CSS_TYPE_LENGTH_PERCENTAGE, l_h); } /* TODO: we should scale the image respecting its ratio. @@ -2098,10 +2079,10 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag, space = strtol(attrbuf, NULL, 10); if (space > 0) { space = CSS_CREATE_LENGTH(space, CSS_LENGTH_TYPE_PX); - props.set (CSS_PROPERTY_MARGIN_LEFT, CSS_TYPE_LENGTH_PERCENTAGE, - space); - props.set (CSS_PROPERTY_MARGIN_RIGHT, CSS_TYPE_LENGTH_PERCENTAGE, - space); + html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_LEFT, + CSS_TYPE_LENGTH_PERCENTAGE, space); + html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_RIGHT, + CSS_TYPE_LENGTH_PERCENTAGE, space); } } @@ -2110,10 +2091,10 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag, space = strtol(attrbuf, NULL, 10); if (space > 0) { space = CSS_CREATE_LENGTH(space, CSS_LENGTH_TYPE_PX); - props.set (CSS_PROPERTY_MARGIN_TOP, CSS_TYPE_LENGTH_PERCENTAGE, - space); - props.set (CSS_PROPERTY_MARGIN_BOTTOM, CSS_TYPE_LENGTH_PERCENTAGE, - space); + html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_TOP, + CSS_TYPE_LENGTH_PERCENTAGE, space); + html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_BOTTOM, + CSS_TYPE_LENGTH_PERCENTAGE, space); } } @@ -2122,31 +2103,30 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag, border = strtol(attrbuf, NULL, 10); if (border >= 0) { border = CSS_CREATE_LENGTH(border, CSS_LENGTH_TYPE_PX); - props.set (CSS_PROPERTY_BORDER_TOP_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - border); - props.set (CSS_PROPERTY_BORDER_BOTTOM_WIDTH, - CSS_TYPE_LENGTH_PERCENTAGE, border); - props.set (CSS_PROPERTY_BORDER_LEFT_WIDTH, - CSS_TYPE_LENGTH_PERCENTAGE, border); - props.set (CSS_PROPERTY_BORDER_RIGHT_WIDTH, - CSS_TYPE_LENGTH_PERCENTAGE, border); - - props.set (CSS_PROPERTY_BORDER_TOP_STYLE, CSS_TYPE_ENUM, - BORDER_SOLID); - props.set (CSS_PROPERTY_BORDER_BOTTOM_STYLE, CSS_TYPE_ENUM, - BORDER_SOLID); - props.set (CSS_PROPERTY_BORDER_LEFT_STYLE, CSS_TYPE_ENUM, - BORDER_SOLID); - props.set (CSS_PROPERTY_BORDER_RIGHT_STYLE, CSS_TYPE_ENUM, - BORDER_SOLID); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, border); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, border); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, border); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, border); + + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_STYLE, + CSS_TYPE_ENUM, BORDER_SOLID); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_STYLE, + CSS_TYPE_ENUM, BORDER_SOLID); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_STYLE, + CSS_TYPE_ENUM, BORDER_SOLID); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_STYLE, + CSS_TYPE_ENUM, BORDER_SOLID); } } /* x_img is an index to a list of {url,image} pairs. * We know Html_add_new_htmlimage() will use size() as its next index */ - props.set (PROPERTY_X_IMG, CSS_TYPE_INTEGER, html->images->size()); - - html->styleEngine->setNonCssHints(&props); + html->styleEngine->setNonCssHint (PROPERTY_X_IMG, CSS_TYPE_INTEGER, + html->images->size()); /* Add a new image widget to this page */ Image = a_Image_new(alt_ptr, 0); @@ -2161,7 +2141,6 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag, loading = Html_load_image(html->bw, url, html->page_url, Image); Html_add_new_htmlimage(html, &url, loading ? NULL : Image); - dFree(tooltip_str); dFree(width_ptr); dFree(height_ptr); dFree(alt_ptr); @@ -2405,7 +2384,6 @@ static void Html_tag_open_object(DilloHtml *html, const char *tag, int tagsize) { DilloUrl *url, *base_url = NULL; const char *attrbuf; - CssPropertyList props; if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "codebase"))) { base_url = a_Html_url_new(html, attrbuf, NULL, 0); @@ -2422,9 +2400,8 @@ static void Html_tag_open_object(DilloHtml *html, const char *tag, int tagsize) html->styleEngine->setPseudoLink (); } - props.set(PROPERTY_X_LINK, CSS_TYPE_INTEGER, - Html_set_new_link(html, &url)); - html->styleEngine->setNonCssHints (&props); + html->styleEngine->setNonCssHint(PROPERTY_X_LINK, CSS_TYPE_INTEGER, + Html_set_new_link(html, &url)); HT2TB(html)->addText("[OBJECT]", html->styleEngine->wordStyle ()); } @@ -2478,8 +2455,6 @@ static void Html_add_anchor(DilloHtml *html, const char *name) static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize) { DilloUrl *url; - char *tooltip_str = NULL; - CssPropertyList props; const char *attrbuf; /* TODO: add support for MAP with A HREF */ @@ -2498,25 +2473,23 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize) html->InVisitedLink = true; html->styleEngine->setPseudoVisited (); if (html->non_css_visited_color != -1) - props.set (CSS_PROPERTY_COLOR, CSS_TYPE_COLOR, - html->non_css_visited_color); + html->styleEngine->setNonCssHint(CSS_PROPERTY_COLOR, CSS_TYPE_COLOR, + html->non_css_visited_color); } else { html->styleEngine->setPseudoLink (); if (html->non_css_link_color != -1) - props.set (CSS_PROPERTY_COLOR, CSS_TYPE_COLOR, - html->non_css_link_color); + html->styleEngine->setNonCssHint(CSS_PROPERTY_COLOR, CSS_TYPE_COLOR, + html->non_css_link_color); } - props.set (PROPERTY_X_LINK, CSS_TYPE_INTEGER, - Html_set_new_link(html, &url)); + html->styleEngine->setNonCssHint (PROPERTY_X_LINK, CSS_TYPE_INTEGER, + Html_set_new_link(html, &url)); } if (prefs.show_tooltip && (attrbuf = a_Html_get_attr(html, tag, tagsize, "title"))) { - tooltip_str = dStrdup(attrbuf); - props.set (PROPERTY_X_TOOLTIP, CSS_TYPE_STRING, tooltip_str); + html->styleEngine->setNonCssHint (PROPERTY_X_TOOLTIP, CSS_TYPE_STRING, + attrbuf); } - html->styleEngine->setNonCssHints (&props); - dFree(tooltip_str); html->styleEngine->inheritBackgroundColor (); @@ -2594,7 +2567,6 @@ static void Html_tag_open_ul(DilloHtml *html, const char *tag, int tagsize) ListStyleType list_style_type; if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "type"))) { - CssPropertyList props; /* list_style_type explicitly defined */ if (dStrcasecmp(attrbuf, "disc") == 0) @@ -2607,8 +2579,8 @@ static void Html_tag_open_ul(DilloHtml *html, const char *tag, int tagsize) /* invalid value */ list_style_type = LIST_STYLE_TYPE_DISC; - props.set(CSS_PROPERTY_LIST_STYLE_TYPE, CSS_TYPE_ENUM, list_style_type); - html->styleEngine->setNonCssHints (&props); + html->styleEngine->setNonCssHint (CSS_PROPERTY_LIST_STYLE_TYPE, + CSS_TYPE_ENUM, list_style_type); } Html_add_textblock(html, 9); @@ -2652,7 +2624,6 @@ static void Html_tag_open_ol(DilloHtml *html, const char *tag, int tagsize) int n = 1; if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "type"))) { - CssPropertyList props; ListStyleType listStyleType = LIST_STYLE_TYPE_DECIMAL; if (*attrbuf == '1') @@ -2666,8 +2637,8 @@ static void Html_tag_open_ol(DilloHtml *html, const char *tag, int tagsize) else if (*attrbuf == 'I') listStyleType = LIST_STYLE_TYPE_UPPER_ROMAN; - props.set (CSS_PROPERTY_LIST_STYLE_TYPE, CSS_TYPE_ENUM, listStyleType); - html->styleEngine->setNonCssHints (&props); + html->styleEngine->setNonCssHint (CSS_PROPERTY_LIST_STYLE_TYPE, + CSS_TYPE_ENUM, listStyleType); } Html_add_textblock(html, 9); @@ -2745,29 +2716,33 @@ static void Html_tag_close_li(DilloHtml *html, int TagIdx) static void Html_tag_open_hr(DilloHtml *html, const char *tag, int tagsize) { Widget *hruler; - CssPropertyList props; char *width_ptr; const char *attrbuf; int32_t size = 0; width_ptr = a_Html_get_attr_wdef(html, tag, tagsize, "width", NULL); if (width_ptr) { - props.set (CSS_PROPERTY_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - a_Html_parse_length (html, width_ptr)); + html->styleEngine->setNonCssHint (CSS_PROPERTY_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, + a_Html_parse_length (html, width_ptr)); dFree(width_ptr); } if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "size"))) size = strtol(attrbuf, NULL, 10); - a_Html_tag_set_align_attr(html, &props, tag, tagsize); + a_Html_tag_set_align_attr(html, tag, tagsize); /* TODO: evaluate attribute */ if (a_Html_get_attr(html, tag, tagsize, "noshade")) { - props.set (CSS_PROPERTY_BORDER_TOP_STYLE, CSS_TYPE_ENUM, BORDER_SOLID); - props.set (CSS_PROPERTY_BORDER_BOTTOM_STYLE,CSS_TYPE_ENUM,BORDER_SOLID); - props.set (CSS_PROPERTY_BORDER_LEFT_STYLE, CSS_TYPE_ENUM, BORDER_SOLID); - props.set (CSS_PROPERTY_BORDER_RIGHT_STYLE, CSS_TYPE_ENUM, BORDER_SOLID); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_STYLE, + CSS_TYPE_ENUM, BORDER_SOLID); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_STYLE, + CSS_TYPE_ENUM, BORDER_SOLID); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_STYLE, + CSS_TYPE_ENUM, BORDER_SOLID); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_STYLE, + CSS_TYPE_ENUM, BORDER_SOLID); if (size <= 0) size = 1; @@ -2776,18 +2751,16 @@ static void Html_tag_open_hr(DilloHtml *html, const char *tag, int tagsize) if (size > 0) { CssLength size_top = CSS_CREATE_LENGTH ((size+1)/2, CSS_LENGTH_TYPE_PX); CssLength size_bottom = CSS_CREATE_LENGTH (size / 2, CSS_LENGTH_TYPE_PX); - props.set (CSS_PROPERTY_BORDER_TOP_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - size_top); - props.set (CSS_PROPERTY_BORDER_LEFT_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - size_top); - props.set (CSS_PROPERTY_BORDER_BOTTOM_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - size_bottom); - props.set (CSS_PROPERTY_BORDER_RIGHT_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - size_bottom); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, size_top); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, size_top); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, size_bottom); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, size_bottom); } - html->styleEngine->setNonCssHints (&props); - HT2TB(html)->addParbreak (5, html->styleEngine->wordStyle ()); hruler = new Ruler(); @@ -3126,10 +3099,7 @@ static void Html_tag_open_default(DilloHtml *html,const char *tag,int tagsize) */ static void Html_tag_open_div(DilloHtml *html, const char *tag, int tagsize) { - CssPropertyList props; - - a_Html_tag_set_align_attr (html, &props, tag, tagsize); - html->styleEngine->setNonCssHints (&props); + a_Html_tag_set_align_attr (html, tag, tagsize); Html_add_textblock(html, 0); } diff --git a/src/html_common.hh b/src/html_common.hh index 3cca82de..868d5d63 100644 --- a/src/html_common.hh +++ b/src/html_common.hh @@ -94,7 +94,6 @@ struct _DilloHtmlImage { }; struct _DilloHtmlState { - CssPropertyList *table_cell_props; DilloHtmlParseMode parse_mode; DilloHtmlTableMode table_mode; bool cell_text_align_set; @@ -242,11 +241,9 @@ int32_t a_Html_color_parse(DilloHtml *html, const char *subtag, int32_t default_color); dw::core::style::Length a_Html_parse_length (DilloHtml *html, const char *attr); -void a_Html_tag_set_align_attr(DilloHtml *html, CssPropertyList *props, - const char *tag, int tagsize); +void a_Html_tag_set_align_attr(DilloHtml *html, const char *tag, int tagsize); bool a_Html_tag_set_valign_attr(DilloHtml *html, - const char *tag, int tagsize, - CssPropertyList *props); + const char *tag, int tagsize); void a_Html_load_stylesheet(DilloHtml *html, DilloUrl *url); @@ -104,6 +104,7 @@ typedef struct ContentType_ { static const ContentType_t MimeTypes[] = { { "application/octet-stream", 24 }, + { "application/xhtml+xml", 21 }, { "text/html", 9 }, { "text/plain", 10 }, { "image/gif", 9 }, @@ -341,7 +342,12 @@ int a_Misc_content_type_check(const char *EntryType, const char *DetectedType) dStrncasecmp(DetectedType, "application/", 12)) { /* Not an application sent as text */ st = 0; + } else if (dStrncasecmp(EntryType, "application/xhtml+xml", 21) && + dStrncasecmp(DetectedType, "text/html", 9)) { + /* XML version of HTML */ + st = 0; } + _MSG("Type check: %s\n", st == 0 ? "MATCH" : "MISMATCH"); return st; } diff --git a/src/styleengine.cc b/src/styleengine.cc index b9f30054..8653ed68 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -41,6 +41,7 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) { font_attrs.weight = 400; font_attrs.style = FONT_STYLE_NORMAL; font_attrs.letterSpacing = 0; + font_attrs.fontVariant = FONT_VARIANT_NORMAL; style_attrs.initValues (); style_attrs.font = Font::create (layout, &font_attrs); @@ -49,7 +50,8 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) { n->style = Style::create (layout, &style_attrs); n->wordStyle = NULL; - n->styleAttribute = NULL; + n->styleAttrProperties = NULL; + n->nonCssProperties = NULL; n->inheritBackgroundColor = false; } @@ -66,13 +68,14 @@ StyleEngine::~StyleEngine () { */ void StyleEngine::startElement (int element) { if (stack->getRef (stack->size () - 1)->style == NULL) - style0 (); + style0 (stack->size () - 1); stack->increase (); Node *n = stack->getRef (stack->size () - 1); + n->styleAttrProperties = NULL; + n->nonCssProperties = NULL; n->style = NULL; n->wordStyle = NULL; - n->styleAttribute = NULL; n->inheritBackgroundColor = false; DoctreeNode *dn = doctree->push (); @@ -120,20 +123,45 @@ void StyleEngine::setClass (const char *klass) { dn->klass = splitStr (klass, ' '); }; -void StyleEngine::setStyle (const char *style) { +void StyleEngine::setStyle (const char *styleAttr) { Node *n = stack->getRef (stack->size () - 1); - assert (n->styleAttribute == NULL); - n->styleAttribute = dStrdup (style); + assert (n->styleAttrProperties == NULL); + // parse style information from style="" attribute, if it exists + if (styleAttr && prefs.parse_embedded_css) + n->styleAttrProperties = + CssParser::parseDeclarationBlock (styleAttr, + strlen (styleAttr)); }; /** * \brief set properties that were definded using (mostly deprecated) HTML * attributes (e.g. bgColor). */ -void StyleEngine::setNonCssHints (CssPropertyList *nonCssHints) { - if (stack->getRef (stack->size () - 1)->style) - stack->getRef (stack->size () - 1)->style->unref (); - style0 (nonCssHints); // evaluate now, so caller can free nonCssHints +void StyleEngine::setNonCssHint (CssPropertyName name, CssValueType type, + CssPropertyValue value) { + Node *n = stack->getRef (stack->size () - 1); + + if (!n->nonCssProperties) + n->nonCssProperties = new CssPropertyList (true); + + n->nonCssProperties->set(name, type, value); +} + +void StyleEngine::inheritNonCssHints () { + Node *pn = stack->getRef (stack->size () - 2); + Node *n = stack->getRef (stack->size () - 1); + + if (pn->nonCssProperties) + n->nonCssProperties = new CssPropertyList (*pn->nonCssProperties); +} + +void StyleEngine::clearNonCssHints () { + Node *n = stack->getRef (stack->size () - 1); + + if (n->nonCssProperties) { + delete n->nonCssProperties; + n->nonCssProperties = NULL; + } } /** @@ -171,17 +199,55 @@ void StyleEngine::endElement (int element) { Node *n = stack->getRef (stack->size () - 1); + if (n->styleAttrProperties) + delete n->styleAttrProperties; + if (n->nonCssProperties) + delete n->nonCssProperties; if (n->style) n->style->unref (); if (n->wordStyle) n->wordStyle->unref (); - if (n->styleAttribute) - dFree ((void*) n->styleAttribute); doctree->pop (); stack->setSize (stack->size () - 1); } +void StyleEngine::preprocessAttrs (dw::core::style::StyleAttrs *attrs) { + /* workaround for styling of inline elements */ + if (stack->getRef (stack->size () - 2)->inheritBackgroundColor) { + attrs->backgroundColor = + stack->getRef (stack->size () - 2)->style->backgroundColor; + + attrs->valign = stack->getRef (stack->size () - 2)->style->valign; + } + /* initial value of border-width is 'medium' */ + attrs->borderWidth.top = 2; + attrs->borderWidth.bottom = 2; + attrs->borderWidth.left = 2; + attrs->borderWidth.right = 2; +} + +void StyleEngine::postprocessAttrs (dw::core::style::StyleAttrs *attrs) { + /* if border-color is not specified use color as computed value */ + if (attrs->borderColor.top == NULL) + attrs->borderColor.top = attrs->color; + if (attrs->borderColor.bottom == NULL) + attrs->borderColor.bottom = attrs->color; + if (attrs->borderColor.left == NULL) + attrs->borderColor.left = attrs->color; + if (attrs->borderColor.right == NULL) + attrs->borderColor.right = attrs->color; + /* computed value of border-width is 0 if border-style is 'none' */ + if (attrs->borderStyle.top == BORDER_NONE) + attrs->borderWidth.top = 0; + if (attrs->borderStyle.bottom == BORDER_NONE) + attrs->borderWidth.bottom = 0; + if (attrs->borderStyle.left == BORDER_NONE) + attrs->borderWidth.left = 0; + if (attrs->borderStyle.right == BORDER_NONE) + attrs->borderWidth.right = 0; +} + /** * \brief Make changes to StyleAttrs attrs according to CssPropertyList props. */ @@ -191,7 +257,7 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) { char *c, *fontName; int lineHeight; - /* Determine font first so it can be used to resolve relative lenths. */ + /* Determine font first so it can be used to resolve relative lengths. */ for (int i = 0; i < props->size (); i++) { CssProperty *p = props->getRef (i); @@ -327,6 +393,9 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) { else if (fontAttrs.letterSpacing < -1000) fontAttrs.letterSpacing = -1000; break; + case CSS_PROPERTY_FONT_VARIANT: + fontAttrs.fontVariant = (FontVariant) p->value.intVal; + break; default: break; } @@ -498,16 +567,6 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) { } } - /* make sure border colors are set */ - if (attrs->borderColor.top == NULL) - attrs->borderColor.top = attrs->color; - if (attrs->borderColor.bottom == NULL) - attrs->borderColor.bottom = attrs->color; - if (attrs->borderColor.left == NULL) - attrs->borderColor.left = attrs->color; - if (attrs->borderColor.right == NULL) - attrs->borderColor.right = attrs->color; - } /** @@ -607,56 +666,44 @@ Style * StyleEngine::backgroundStyle () { * HTML elements and the nonCssProperties that have been set. * This method is private. Call style() to get a current style object. */ -Style * StyleEngine::style0 (CssPropertyList *nonCssProperties) { - CssPropertyList props, *styleAttributeProps = NULL; - const char *styleAttribute = - stack->getRef (stack->size () - 1)->styleAttribute; +Style * StyleEngine::style0 (int i) { + CssPropertyList props, *styleAttrProperties, *nonCssProperties; // get previous style from the stack - StyleAttrs attrs = *stack->getRef (stack->size () - 2)->style; + StyleAttrs attrs = *stack->getRef (i - 1)->style; // Ensure that StyleEngine::style0() has not been called before for // this element. // Style computation is expensive so limit it as much as possible. // If this assertion is hit, you need to rearrange the code that is - // doing styleEngine calls to call setNonCssHints() before calling + // doing styleEngine calls to call setNonCssHint() before calling // style() or wordStyle() for each new element. - assert (stack->getRef (stack->size () - 1)->style == NULL); + assert (stack->getRef (i)->style == NULL); // reset values that are not inherited according to CSS attrs.resetValues (); + preprocessAttrs (&attrs); - if (stack->getRef (stack->size () - 2)->inheritBackgroundColor) { - attrs.backgroundColor = - stack->getRef (stack->size () - 2)->style->backgroundColor; - - attrs.valign = stack->getRef (stack->size () - 2)->style->valign; - } - - // parse style information from style="" attribute, if it exists - if (styleAttribute && prefs.parse_embedded_css) - styleAttributeProps = - CssParser::parseDeclarationBlock (styleAttribute, - strlen (styleAttribute)); + styleAttrProperties = stack->getRef (i)->styleAttrProperties; + nonCssProperties = stack->getRef (i)->nonCssProperties; // merge style information - cssContext->apply (&props, doctree, styleAttributeProps, nonCssProperties); + cssContext->apply (&props, doctree, styleAttrProperties, nonCssProperties); // apply style apply (&attrs, &props); - stack->getRef (stack->size () - 1)->style = Style::create (layout, &attrs); + postprocessAttrs (&attrs); - if (styleAttributeProps) - delete styleAttributeProps; + stack->getRef (i)->style = Style::create (layout, &attrs); - return stack->getRef (stack->size () - 1)->style; + return stack->getRef (i)->style; } -Style * StyleEngine::wordStyle0 (CssPropertyList *nonCssProperties) { +Style * StyleEngine::wordStyle0 () { StyleAttrs attrs = *style (); attrs.resetValues (); - if (stack->getRef (stack->size () - 1)->inheritBackgroundColor) + if (stack->getRef (stack->size() - 1)->inheritBackgroundColor) attrs.backgroundColor = style ()->backgroundColor; attrs.valign = style ()->valign; @@ -665,6 +712,17 @@ Style * StyleEngine::wordStyle0 (CssPropertyList *nonCssProperties) { return stack->getRef (stack->size () - 1)->wordStyle; } +void StyleEngine::restyle () { + for (int i = 0; i < stack->size (); i++) { + Node *n = stack->getRef (i); + if (n->style) { + n->style->unref (); + n->style = NULL; + } + style0 (i); + } +} + void StyleEngine::parse (DilloHtml *html, DilloUrl *url, const char *buf, int buflen, CssOrigin origin) { if (importDepth > 10) { // avoid looping with recursive @import directives diff --git a/src/styleengine.hh b/src/styleengine.hh index 66f28cee..a0fcdc08 100644 --- a/src/styleengine.hh +++ b/src/styleengine.hh @@ -19,12 +19,12 @@ class StyleEngine; */ class StyleEngine { private: - class Node { - public: - dw::core::style::Style *style; - dw::core::style::Style *wordStyle; - const char *styleAttribute; - bool inheritBackgroundColor; + struct Node { + CssPropertyList *styleAttrProperties; + CssPropertyList *nonCssProperties; + dw::core::style::Style *style; + dw::core::style::Style *wordStyle; + bool inheritBackgroundColor; }; dw::core::Layout *layout; @@ -33,8 +33,12 @@ class StyleEngine { Doctree *doctree; int importDepth; - dw::core::style::Style *style0 (CssPropertyList *nonCssHints = NULL); - dw::core::style::Style *wordStyle0 (CssPropertyList *nonCssHints = NULL); + dw::core::style::Style *style0 (int i); + dw::core::style::Style *wordStyle0 (); + void setNonCssHint(CssPropertyName name, CssValueType type, + CssPropertyValue value); + void preprocessAttrs (dw::core::style::StyleAttrs *attrs); + void postprocessAttrs (dw::core::style::StyleAttrs *attrs); void apply (dw::core::style::StyleAttrs *attrs, CssPropertyList *props); bool computeValue (int *dest, CssLength value, dw::core::style::Font *font); @@ -60,7 +64,21 @@ class StyleEngine { void endElement (int tag); void setPseudoLink (); void setPseudoVisited (); - void setNonCssHints (CssPropertyList *nonCssHints); + void setNonCssHint(CssPropertyName name, CssValueType type, + int value) { + CssPropertyValue v; + v.intVal = value; + setNonCssHint (name, type, v); + } + void setNonCssHint(CssPropertyName name, CssValueType type, + const char *value) { + CssPropertyValue v; + v.strVal = dStrdup(value); + setNonCssHint (name, type, v); + } + void inheritNonCssHints (); + void clearNonCssHints (); + void restyle (); void inheritBackgroundColor (); /* \todo get rid of this somehow */ dw::core::style::Style *backgroundStyle (); @@ -69,7 +87,7 @@ class StyleEngine { if (s) return s; else - return style0 (); + return style0 (stack->size () - 1); }; inline dw::core::style::Style *wordStyle () { diff --git a/src/table.cc b/src/table.cc index 43304206..751d18a4 100644 --- a/src/table.cc +++ b/src/table.cc @@ -38,7 +38,6 @@ static void Html_tag_open_table_cell(DilloHtml *html, void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) { dw::core::Widget *table; - CssPropertyList props, *table_cell_props; const char *attrbuf; int32_t border = -1, cellspacing = -1, cellpadding = -1, bgcolor = -1; CssLength cssLength; @@ -52,77 +51,90 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) if (border != -1) { cssLength = CSS_CREATE_LENGTH (border, CSS_LENGTH_TYPE_PX); - props.set (CSS_PROPERTY_BORDER_TOP_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - cssLength); - props.set (CSS_PROPERTY_BORDER_BOTTOM_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - cssLength); - props.set (CSS_PROPERTY_BORDER_LEFT_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - cssLength); - props.set (CSS_PROPERTY_BORDER_RIGHT_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_STYLE, + CSS_TYPE_ENUM, BORDER_OUTSET); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_STYLE, + CSS_TYPE_ENUM, BORDER_OUTSET); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_STYLE, + CSS_TYPE_ENUM, BORDER_OUTSET); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_STYLE, + CSS_TYPE_ENUM, BORDER_OUTSET); } if (cellspacing != -1) { cssLength = CSS_CREATE_LENGTH (cellspacing, CSS_LENGTH_TYPE_PX); - props.set (CSS_PROPERTY_BORDER_SPACING, CSS_TYPE_LENGTH_PERCENTAGE, - cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_SPACING, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); } if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "width"))) - props.set (CSS_PROPERTY_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - a_Html_parse_length (html, attrbuf)); + html->styleEngine->setNonCssHint (CSS_PROPERTY_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, + a_Html_parse_length (html, attrbuf)); if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "align"))) { if (dStrcasecmp (attrbuf, "left") == 0) - props.set (CSS_PROPERTY_TEXT_ALIGN, CSS_TYPE_ENUM, TEXT_ALIGN_LEFT); + html->styleEngine->setNonCssHint (CSS_PROPERTY_TEXT_ALIGN, + CSS_TYPE_ENUM, TEXT_ALIGN_LEFT); else if (dStrcasecmp (attrbuf, "right") == 0) - props.set (CSS_PROPERTY_TEXT_ALIGN, CSS_TYPE_ENUM, TEXT_ALIGN_RIGHT); + html->styleEngine->setNonCssHint (CSS_PROPERTY_TEXT_ALIGN, + CSS_TYPE_ENUM, TEXT_ALIGN_RIGHT); else if (dStrcasecmp (attrbuf, "center") == 0) - props.set (CSS_PROPERTY_TEXT_ALIGN, CSS_TYPE_ENUM, TEXT_ALIGN_CENTER); + html->styleEngine->setNonCssHint (CSS_PROPERTY_TEXT_ALIGN, + CSS_TYPE_ENUM, TEXT_ALIGN_CENTER); } if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { bgcolor = a_Html_color_parse(html, attrbuf, -1); if (bgcolor != -1) - props.set (CSS_PROPERTY_BACKGROUND_COLOR, CSS_TYPE_COLOR, bgcolor); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BACKGROUND_COLOR, + CSS_TYPE_COLOR, bgcolor); } - html->styleEngine->setNonCssHints (&props); - HT2TB(html)->addParbreak (0, html->styleEngine->wordStyle ()); /* The style for the cells */ - table_cell_props = new CssPropertyList (); + html->styleEngine->clearNonCssHints (); if (border > 0) { cssLength = CSS_CREATE_LENGTH (1, CSS_LENGTH_TYPE_PX); - table_cell_props->set (CSS_PROPERTY_BORDER_TOP_WIDTH, - CSS_TYPE_LENGTH_PERCENTAGE, cssLength); - table_cell_props->set (CSS_PROPERTY_BORDER_BOTTOM_WIDTH, - CSS_TYPE_LENGTH_PERCENTAGE, cssLength); - table_cell_props->set (CSS_PROPERTY_BORDER_LEFT_WIDTH, - CSS_TYPE_LENGTH_PERCENTAGE, cssLength); - table_cell_props->set (CSS_PROPERTY_BORDER_RIGHT_WIDTH, - CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_STYLE, + CSS_TYPE_ENUM, BORDER_INSET); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_STYLE, + CSS_TYPE_ENUM, BORDER_INSET); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_STYLE, + CSS_TYPE_ENUM, BORDER_INSET); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_STYLE, + CSS_TYPE_ENUM, BORDER_INSET); } if (cellpadding != -1) { cssLength = CSS_CREATE_LENGTH (cellpadding, CSS_LENGTH_TYPE_PX); - table_cell_props->set (CSS_PROPERTY_PADDING_TOP, - CSS_TYPE_LENGTH_PERCENTAGE, cssLength); - table_cell_props->set (CSS_PROPERTY_PADDING_BOTTOM, - CSS_TYPE_LENGTH_PERCENTAGE, cssLength); - table_cell_props->set (CSS_PROPERTY_PADDING_LEFT, - CSS_TYPE_LENGTH_PERCENTAGE, cssLength); - table_cell_props->set (CSS_PROPERTY_PADDING_RIGHT, - CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_PADDING_TOP, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_PADDING_BOTTOM, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_PADDING_LEFT, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); + html->styleEngine->setNonCssHint (CSS_PROPERTY_PADDING_RIGHT, + CSS_TYPE_LENGTH_PERCENTAGE, cssLength); } - if (S_TOP(html)->table_cell_props) - S_TOP(html)->table_cell_props->unref (); - - S_TOP(html)->table_cell_props = table_cell_props; - S_TOP(html)->table_cell_props->ref (); - table = new dw::Table(prefs.limit_text_width); HT2TB(html)->addWidget (table, html->styleEngine->style ()); @@ -139,7 +151,8 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize) const char *attrbuf; int32_t bgcolor = -1; bool new_style = false; - CssPropertyList props, *table_cell_props; + + html->styleEngine->inheritNonCssHints (); switch (S_TOP(html)->table_mode) { case DILLO_HTML_TABLE_MODE_NONE: @@ -153,34 +166,26 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize) if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { bgcolor = a_Html_color_parse(html, attrbuf, -1); if (bgcolor != -1) - props.set (CSS_PROPERTY_BACKGROUND_COLOR, CSS_TYPE_COLOR, bgcolor); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BACKGROUND_COLOR, + CSS_TYPE_COLOR, bgcolor); } if (a_Html_get_attr (html, tag, tagsize, "align")) { S_TOP(html)->cell_text_align_set = TRUE; - a_Html_tag_set_align_attr (html, &props, tag, tagsize); + a_Html_tag_set_align_attr (html, tag, tagsize); } html->styleEngine->inheritBackgroundColor (); - html->styleEngine->setNonCssHints (&props); ((dw::Table*)S_TOP(html)->table)->addRow (html->styleEngine->style ()); - table_cell_props = new CssPropertyList (*S_TOP(html)->table_cell_props); if (bgcolor != -1) { - table_cell_props->set (CSS_PROPERTY_BACKGROUND_COLOR, - CSS_TYPE_COLOR, bgcolor); + html->styleEngine->setNonCssHint(CSS_PROPERTY_BACKGROUND_COLOR, + CSS_TYPE_COLOR, bgcolor); new_style = true; } - if (a_Html_tag_set_valign_attr (html, tag, tagsize, table_cell_props)) + if (a_Html_tag_set_valign_attr (html, tag, tagsize)) new_style = true; - if (new_style) { - S_TOP(html)->table_cell_props->unref (); - S_TOP(html)->table_cell_props = table_cell_props; - S_TOP(html)->table_cell_props->ref (); - } else { - delete table_cell_props; - } break; default: break; @@ -224,6 +229,8 @@ static void Html_tag_open_table_cell(DilloHtml *html, int32_t bgcolor; bool_t new_style; + html->styleEngine->inheritNonCssHints (); + switch (S_TOP(html)->table_mode) { case DILLO_HTML_TABLE_MODE_NONE: BUG_MSG("<td> or <th> outside <table>\n"); @@ -245,41 +252,36 @@ static void Html_tag_open_table_cell(DilloHtml *html, if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "rowspan"))) rowspan = MAX(1, strtol (attrbuf, NULL, 10)); - CssPropertyList *props; - // \todo any shorter way to do this? - if (S_TOP(html)->table_cell_props != NULL) - props = new CssPropertyList (*S_TOP(html)->table_cell_props); - else - props = new CssPropertyList (); - /* text style */ if (!S_TOP(html)->cell_text_align_set) { - props->set (CSS_PROPERTY_TEXT_ALIGN, CSS_TYPE_ENUM, text_align); + html->styleEngine->setNonCssHint (CSS_PROPERTY_TEXT_ALIGN, + CSS_TYPE_ENUM, text_align); } if (a_Html_get_attr(html, tag, tagsize, "nowrap")) - props->set(CSS_PROPERTY_WHITE_SPACE,CSS_TYPE_ENUM,WHITE_SPACE_NOWRAP); + html->styleEngine->setNonCssHint(CSS_PROPERTY_WHITE_SPACE, + CSS_TYPE_ENUM, WHITE_SPACE_NOWRAP); else - props->set(CSS_PROPERTY_WHITE_SPACE,CSS_TYPE_ENUM,WHITE_SPACE_NORMAL); + html->styleEngine->setNonCssHint(CSS_PROPERTY_WHITE_SPACE, + CSS_TYPE_ENUM, WHITE_SPACE_NORMAL); - a_Html_tag_set_align_attr (html, props, tag, tagsize); + a_Html_tag_set_align_attr (html, tag, tagsize); if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "width"))) { - props->set (CSS_PROPERTY_WIDTH, CSS_TYPE_LENGTH_PERCENTAGE, - a_Html_parse_length (html, attrbuf)); + html->styleEngine->setNonCssHint (CSS_PROPERTY_WIDTH, + CSS_TYPE_LENGTH_PERCENTAGE, + a_Html_parse_length (html, attrbuf)); } - if (a_Html_tag_set_valign_attr (html, tag, tagsize, props)) + if (a_Html_tag_set_valign_attr (html, tag, tagsize)) new_style = TRUE; if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { bgcolor = a_Html_color_parse(html, attrbuf, -1); if (bgcolor != -1) - props->set (CSS_PROPERTY_BACKGROUND_COLOR, CSS_TYPE_COLOR,bgcolor); + html->styleEngine->setNonCssHint (CSS_PROPERTY_BACKGROUND_COLOR, + CSS_TYPE_COLOR, bgcolor); } - html->styleEngine->setNonCssHints (props); - delete props; - if (html->styleEngine->style ()->textAlign == TEXT_ALIGN_STRING) col_tb = new dw::TableCell ( |