diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-11-10 19:56:36 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-11-10 19:56:36 +0100 |
commit | fb551355dfb2f49d56cdaab8a55ed3cb00ec7dc8 (patch) | |
tree | cfeb5ea081e99b037b0f50ea3dfc51f166958828 /src | |
parent | b70459d1949191d86f3e420985c4b3dedc85f81a (diff) |
convert table code to new style handling
Diffstat (limited to 'src')
-rw-r--r-- | src/css.cc | 10 | ||||
-rw-r--r-- | src/css.hh | 16 | ||||
-rw-r--r-- | src/html.cc | 87 | ||||
-rw-r--r-- | src/html_common.hh | 5 | ||||
-rw-r--r-- | src/styleengine.cc | 27 | ||||
-rw-r--r-- | src/table.cc | 151 |
6 files changed, 159 insertions, 137 deletions
@@ -164,6 +164,16 @@ CssStyleSheet * CssContext::buildUserAgentStyle () { props = new CssPropertyList (); props->set (CssProperty::CSS_PROPERTY_FONT_FAMILY, "DejaVu Sans Mono"); s->addRule (new CssSelector(a_Html_tag_index("pre"), NULL, NULL), props); + + // <table> + props = new CssPropertyList (); + props->set (CssProperty::CSS_PROPERTY_BORDER_STYLE, BORDER_OUTSET); + s->addRule (new CssSelector(a_Html_tag_index("table"), NULL, NULL), props); + + // <td> + props = new CssPropertyList (); + props->set (CssProperty::CSS_PROPERTY_BORDER_STYLE, BORDER_INSET); + s->addRule (new CssSelector(a_Html_tag_index("td"), NULL, NULL), props); return s; } @@ -21,6 +21,7 @@ class CssProperty { CSS_PROPERTY_BORDER_BOTTOM_STYLE, CSS_PROPERTY_BORDER_BOTTOM_WIDTH, CSS_PROPERTY_BORDER_COLLAPSE, + CSS_PROPERTY_BORDER_COLOR, CSS_PROPERTY_BORDER_LEFT_COLOR, CSS_PROPERTY_BORDER_LEFT_STYLE, CSS_PROPERTY_BORDER_LEFT_WIDTH, @@ -28,9 +29,11 @@ class CssProperty { CSS_PROPERTY_BORDER_RIGHT_STYLE, CSS_PROPERTY_BORDER_RIGHT_WIDTH, CSS_PROPERTY_BORDER_SPACING, + CSS_PROPERTY_BORDER_STYLE, CSS_PROPERTY_BORDER_TOP_COLOR, CSS_PROPERTY_BORDER_TOP_STYLE, CSS_PROPERTY_BORDER_TOP_WIDTH, + CSS_PROPERTY_BORDER_WIDTH, CSS_PROPERTY_BOTTOM, CSS_PROPERTY_CAPTION_SIDE, CSS_PROPERTY_CLEAR, @@ -72,6 +75,7 @@ class CssProperty { CSS_PROPERTY_OUTLINE_STYLE, CSS_PROPERTY_OUTLINE_WIDTH, CSS_PROPERTY_OVERFLOW, + CSS_PROPERTY_PADDING, CSS_PROPERTY_PADDING_BOTTOM, CSS_PROPERTY_PADDING_LEFT, CSS_PROPERTY_PADDING_RIGHT, @@ -118,8 +122,15 @@ class CssProperty { }; class CssPropertyList : public lout::misc::SimpleVector <CssProperty> { + int refCount; + public: - CssPropertyList() : lout::misc::SimpleVector <CssProperty> (1) {}; + CssPropertyList() : lout::misc::SimpleVector <CssProperty> (1) { + refCount = 0; + }; + CssPropertyList(const CssPropertyList &p) : lout::misc::SimpleVector <CssProperty> (p) { + refCount = 0; + }; static CssPropertyList *parse (const char *buf); void set (CssProperty::Name name, CssProperty::Value value); @@ -134,6 +145,9 @@ class CssPropertyList : public lout::misc::SimpleVector <CssProperty> { set (name, v); }; void apply (CssPropertyList *props); + + inline void ref () { refCount++; } + inline void unref () { if(--refCount == 0) delete this; } }; /** \todo proper implementation */ diff --git a/src/html.cc b/src/html.cc index 711abe01..95e74342 100644 --- a/src/html.cc +++ b/src/html.cc @@ -331,19 +331,22 @@ void a_Html_tag_set_align_attr(DilloHtml *html, * sets the style in style_attrs. Returns true when set. */ bool a_Html_tag_set_valign_attr(DilloHtml *html, const char *tag, - int tagsize, StyleAttrs *style_attrs) + int tagsize, CssPropertyList *props) { const char *attr; + VAlignType valign; if ((attr = a_Html_get_attr(html, tag, tagsize, "valign"))) { if (dStrcasecmp (attr, "top") == 0) - style_attrs->valign = VALIGN_TOP; + valign = VALIGN_TOP; else if (dStrcasecmp (attr, "bottom") == 0) - style_attrs->valign = VALIGN_BOTTOM; + valign = VALIGN_BOTTOM; else if (dStrcasecmp (attr, "baseline") == 0) - style_attrs->valign = VALIGN_BASELINE; + valign = VALIGN_BASELINE; else - style_attrs->valign = VALIGN_MIDDLE; + valign = VALIGN_MIDDLE; + + props->set (CssProperty::CSS_PROPERTY_VERTICAL_ALIGN, valign); return true; } else return false; @@ -470,7 +473,7 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url, stack = new misc::SimpleVector <DilloHtmlState> (16); stack->increase(); - stack->getRef(0)->table_cell_style = NULL; + 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; @@ -514,8 +517,8 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url, images = new misc::SimpleVector <DilloLinkImage*> (16); //a_Dw_image_map_list_init(&maps); - link_color = prefs.link_color; - visited_color = prefs.visited_color; + link_color = -1; + visited_color = -1; /* Initialize the main widget */ initDw(); @@ -533,7 +536,7 @@ void DilloHtml::initDw() /* Create the main widget */ dw = stack->getRef(0)->textblock = new Textblock (prefs.limit_text_width); - stack->getRef(0)->table_cell_style = NULL; + stack->getRef(0)->table_cell_props = NULL; /* Handle it when the user clicks on a link */ connectSignals(dw); @@ -1254,9 +1257,8 @@ 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; - /* proper memory management, may be unref'd later */ - if (S_TOP(html)->table_cell_style) - (S_TOP(html)->table_cell_style)->ref (); + if (S_TOP(html)->table_cell_props) + S_TOP(html)->table_cell_props->ref (); html->dw = S_TOP(html)->textblock; } @@ -1276,10 +1278,9 @@ static void Html_real_pop_tag(DilloHtml *html) { bool hand_over_break; - //(html->styleEngine->style ())->unref (); - if (S_TOP(html)->table_cell_style) - (S_TOP(html)->table_cell_style)->unref (); 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); @@ -1686,8 +1687,7 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize) { const char *attrbuf; Textblock *textblock; - StyleAttrs style_attrs; - Style *style; + CssPropertyList props; int32_t color; if (!(html->InFlags & IN_BODY)) @@ -1705,43 +1705,37 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize) textblock = DW2TB(html->dw); - if (!prefs.force_my_colors) { - if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { - color = a_Html_color_parse(html, attrbuf, prefs.bg_color); - if (color == 0xffffff && !prefs.allow_white_bg) - color = prefs.bg_color; - - style_attrs = *html->dw->getStyle (); - style_attrs.backgroundColor = Color::createShaded(HT2LT(html), color); - style = Style::create (HT2LT(html), &style_attrs); - html->dw->setStyle (style); - style->unref (); - S_TOP(html)->current_bg_color = color; - } + if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { + color = a_Html_color_parse(html, attrbuf, prefs.bg_color); + if (color == 0xffffff && !prefs.allow_white_bg) + color = prefs.bg_color; + S_TOP(html)->current_bg_color = color; + props.set (CssProperty::CSS_PROPERTY_BACKGROUND_COLOR, color); + } - if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "text"))) { - color = a_Html_color_parse(html, attrbuf, prefs.text_color); - HTML_SET_TOP_ATTR (html, color, - Color::createSimple (HT2LT(html),color)); - } + if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "text"))) { + color = a_Html_color_parse(html, attrbuf, prefs.text_color); + props.set (CssProperty::CSS_PROPERTY_COLOR, color); + } - if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "link"))) - html->link_color = a_Html_color_parse(html,attrbuf,prefs.link_color); + if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "link"))) + html->link_color = a_Html_color_parse(html, attrbuf, -1); - if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "vlink"))) - html->visited_color = a_Html_color_parse(html, attrbuf, - prefs.visited_color); + if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "vlink"))) + html->visited_color = a_Html_color_parse(html, attrbuf, -1); - if (prefs.contrast_visited_color) { - /* get a color that has a "safe distance" from text, link and bg */ - html->visited_color = + if (prefs.contrast_visited_color) { + /* get a color that has a "safe distance" from text, link and bg */ + html->visited_color = a_Color_vc(html->visited_color, html->styleEngine->style ()->color->getColor(), html->link_color, S_TOP(html)->current_bg_color); - } } + html->styleEngine->setNonCssProperties (&props); + html->dw->setStyle (html->styleEngine->style ()); + S_TOP(html)->parse_mode = DILLO_HTML_PARSE_MODE_BODY; } @@ -2460,11 +2454,16 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize) if (a_Capi_get_flags(url) & CAPI_IsCached) { html->InVisitedLink = true; html->styleEngine->setPseudoClass ("visited"); + if (html->visited_color != -1) + props.set (CssProperty::CSS_PROPERTY_COLOR, html->visited_color); } else { html->styleEngine->setPseudoClass ("link"); + if (html->link_color != -1) + props.set (CssProperty::CSS_PROPERTY_COLOR, html->link_color); } props.set (CssProperty::PROPERTY_X_LINK, Html_set_new_link(html, &url)); + html->styleEngine->setNonCssProperties (&props); } diff --git a/src/html_common.hh b/src/html_common.hh index aa468522..3468ba89 100644 --- a/src/html_common.hh +++ b/src/html_common.hh @@ -114,8 +114,7 @@ struct _DilloLinkImage { }; struct _DilloHtmlState { -// dw::core::style::Style *style, *table_cell_style; - dw::core::style::Style *table_cell_style; + CssPropertyList *table_cell_props; DilloHtmlParseMode parse_mode; DilloHtmlTableMode table_mode; bool cell_text_align_set; @@ -273,7 +272,7 @@ void a_Html_tag_set_align_attr(DilloHtml *html, CssPropertyList *props, const char *tag, int tagsize); bool a_Html_tag_set_valign_attr(DilloHtml *html, const char *tag, int tagsize, - dw::core::style::StyleAttrs *style_attrs); + CssPropertyList *props); void a_Html_set_top_font(DilloHtml *html, const char *name, int size, int BI, int BImask); diff --git a/src/styleengine.cc b/src/styleengine.cc index 4b5f3f7a..bdd6affb 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -65,9 +65,11 @@ void StyleEngine::startElement (int tag, const char *id, const char *klass, /** * \brief set properties that were definded using (mostly deprecated) HTML - * attributes (e.g. bgColor). + * attributes (e.g. bgColor). */ void StyleEngine::setNonCssProperties (CssPropertyList *props) { + if (stack->getRef (stack->size () - 1)->style) + stack->getRef (stack->size () - 1)->style->unref (); style0 (props); // evaluate now, so caller can free props } @@ -93,6 +95,9 @@ void StyleEngine::endElement (int tag) { stack->setSize (stack->size () - 1); } +/** + * \brief Make changes to StyleAttrs attrs according to CssPropertyList props. + */ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) { FontAttrs fontAttrs = *attrs->font; @@ -109,9 +114,18 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) { attrs->borderColor.bottom = Color::createSimple (layout, p->value.intVal); break; + case CssProperty::CSS_PROPERTY_BORDER_COLOR: + attrs->setBorderColor (Color::createSimple (layout, p->value.intVal)); + break; case CssProperty::CSS_PROPERTY_BORDER_BOTTOM_STYLE: attrs->borderStyle.bottom = (BorderStyle) p->value.intVal; break; + case CssProperty::CSS_PROPERTY_BORDER_STYLE: + attrs->setBorderStyle ((BorderStyle) p->value.intVal); + break; + case CssProperty::CSS_PROPERTY_BORDER_WIDTH: + attrs->borderWidth.setVal (p->value.intVal); + break; case CssProperty::CSS_PROPERTY_COLOR: attrs->color = Color::createSimple (layout, p->value.intVal); break; @@ -147,12 +161,21 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) { case CssProperty::CSS_PROPERTY_LIST_STYLE_TYPE: attrs->listStyleType = (ListStyleType) p->value.intVal; break; + case CssProperty::CSS_PROPERTY_PADDING: + attrs->padding.setVal (p->value.intVal); + break; case CssProperty::CSS_PROPERTY_TEXT_ALIGN: attrs->textAlign = (TextAlignType) p->value.intVal; break; case CssProperty::CSS_PROPERTY_TEXT_DECORATION: attrs->textDecoration |= p->value.intVal; break; + case CssProperty::CSS_PROPERTY_VERTICAL_ALIGN: + attrs->valign = (VAlignType) p->value.intVal; + break; + case CssProperty::CSS_PROPERTY_WIDTH: + attrs->width = p->value.intVal; + break; case CssProperty::PROPERTY_X_LINK: attrs->x_link = p->value.intVal; break; @@ -180,6 +203,8 @@ Style * StyleEngine::style0 (CssPropertyList *nonCssProperties) { // get previous style from the stack StyleAttrs attrs = *stack->getRef (stack->size () - 2)->style; + // reset values that are not inherited according to CSS + attrs.resetValues (); cssContext->apply (&props, this, tagStyleProps, nonCssProperties); diff --git a/src/table.cc b/src/table.cc index 97f53064..63e1ba0e 100644 --- a/src/table.cc +++ b/src/table.cc @@ -18,6 +18,7 @@ #include "prefs.h" #include "msg.h" +#include "css.hh" /* Undefine if you want to unroll tables. For instance for PDAs */ #define USE_TABLES @@ -43,10 +44,9 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) { #ifdef USE_TABLES dw::core::Widget *table; - dw::core::style::StyleAttrs style_attrs; - dw::core::style::Style *cell_style, *old_style; + CssPropertyList props, *table_cell_props; const char *attrbuf; - int32_t border = 0, cellspacing = 1, cellpadding = 2, bgcolor; + int32_t border = -1, cellspacing = -1, cellpadding = -1, bgcolor = -1; #endif DW2TB(html->dw)->addParbreak (0, html->styleEngine->style ()); @@ -59,68 +59,65 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "cellpadding"))) cellpadding = strtol (attrbuf, NULL, 10); - /* The style for the table */ - style_attrs = *html->styleEngine->style (); + if (border != -1) + props.set (CssProperty::CSS_PROPERTY_BORDER_WIDTH, border); + if (cellspacing != -1) + props.set (CssProperty::CSS_PROPERTY_BORDER_SPACING, cellspacing); + + props.set (CssProperty::CSS_PROPERTY_BORDER_STYLE, BORDER_OUTSET); /* When dillo was started with the --debug-rendering option, there * is always a border around the table. */ - if (dillo_dbg_rendering) - style_attrs.borderWidth.setVal (MIN (border, 1)); - else - style_attrs.borderWidth.setVal (border); - - style_attrs.setBorderColor ( - Color::createShaded(HT2LT(html), S_TOP(html)->current_bg_color)); - style_attrs.setBorderStyle (BORDER_OUTSET); - style_attrs.hBorderSpacing = cellspacing; - style_attrs.vBorderSpacing = cellspacing; + if (dillo_dbg_rendering && border < 1) + props.set (CssProperty::CSS_PROPERTY_BORDER_WIDTH, 1); if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "width"))) - style_attrs.width = a_Html_parse_length (html, attrbuf); + props.set (CssProperty::CSS_PROPERTY_WIDTH, + a_Html_parse_length (html, attrbuf)); if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "align"))) { if (dStrcasecmp (attrbuf, "left") == 0) - style_attrs.textAlign = dw::core::style::TEXT_ALIGN_LEFT; + props.set (CssProperty::CSS_PROPERTY_TEXT_ALIGN, TEXT_ALIGN_LEFT); else if (dStrcasecmp (attrbuf, "right") == 0) - style_attrs.textAlign = dw::core::style::TEXT_ALIGN_RIGHT; + props.set (CssProperty::CSS_PROPERTY_TEXT_ALIGN, TEXT_ALIGN_RIGHT); else if (dStrcasecmp (attrbuf, "center") == 0) - style_attrs.textAlign = dw::core::style::TEXT_ALIGN_CENTER; + props.set (CssProperty::CSS_PROPERTY_TEXT_ALIGN, TEXT_ALIGN_CENTER); } - if (!prefs.force_my_colors && - (attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { + /** \todo figure out how to implement shaded colors with CSS */ + props.set (CssProperty::CSS_PROPERTY_BORDER_COLOR, 0x000000); + + if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { bgcolor = a_Html_color_parse(html, attrbuf, -1); if (bgcolor != -1) { if (bgcolor == 0xffffff && !prefs.allow_white_bg) bgcolor = prefs.bg_color; S_TOP(html)->current_bg_color = bgcolor; - style_attrs.backgroundColor = - Color::createShaded (HT2LT(html), bgcolor); + props.set (CssProperty::CSS_PROPERTY_BACKGROUND_COLOR, bgcolor); } } + html->styleEngine->setNonCssProperties (&props); + /* The style for the cells */ - cell_style = Style::create (HT2LT(html), &style_attrs); - style_attrs = *html->styleEngine->style (); - /* When dillo was started with the --debug-rendering option, there - * is always a border around the cells. */ - if (dillo_dbg_rendering) - style_attrs.borderWidth.setVal (1); - else - style_attrs.borderWidth.setVal (border ? 1 : 0); - style_attrs.padding.setVal(cellpadding); - style_attrs.setBorderColor (cell_style->borderColor.top); - style_attrs.setBorderStyle (BORDER_INSET); - - old_style = S_TOP(html)->table_cell_style; - S_TOP(html)->table_cell_style = - Style::create (HT2LT(html), &style_attrs); - if (old_style) - old_style->unref (); + table_cell_props = new CssPropertyList (); + table_cell_props->ref (); + if (border != -1) + table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_WIDTH, border); + if (dillo_dbg_rendering && border < 1) + table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_WIDTH, 1); + table_cell_props->set (CssProperty::CSS_PROPERTY_PADDING, cellpadding); + /** \todo figure out how to implement shaded colors with CSS */ + table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_COLOR, 0x000000); + table_cell_props->set (CssProperty::CSS_PROPERTY_BORDER_STYLE, BORDER_INSET); + + if (S_TOP(html)->table_cell_props) + S_TOP(html)->table_cell_props->unref (); + + S_TOP(html)->table_cell_props = table_cell_props; table = new dw::Table(prefs.limit_text_width); - DW2TB(html->dw)->addWidget (table, cell_style); - cell_style->unref (); + DW2TB(html->dw)->addWidget (table, html->styleEngine->style ()); S_TOP(html)->table_mode = DILLO_HTML_TABLE_MODE_TOP; S_TOP(html)->cell_text_align_set = FALSE; @@ -134,11 +131,9 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize) void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize) { const char *attrbuf; - dw::core::style::StyleAttrs style_attrs; - dw::core::style::Style *style, *old_style; int32_t bgcolor = -1; bool new_style = false; - CssPropertyList props; + CssPropertyList props, *table_cell_props; #ifdef USE_TABLES switch (S_TOP(html)->table_mode) { @@ -149,26 +144,20 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize) case DILLO_HTML_TABLE_MODE_TOP: case DILLO_HTML_TABLE_MODE_TR: case DILLO_HTML_TABLE_MODE_TD: - style = NULL; - if (!prefs.force_my_colors && - (attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { + if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { bgcolor = a_Html_color_parse(html, attrbuf, -1); if (bgcolor != -1) { if (bgcolor == 0xffffff && !prefs.allow_white_bg) bgcolor = prefs.bg_color; - - style_attrs = *html->styleEngine->style (); - style_attrs.backgroundColor = - Color::createShaded (HT2LT(html), bgcolor); - style = Style::create (HT2LT(html), &style_attrs); + props.set (CssProperty::CSS_PROPERTY_BACKGROUND_COLOR, bgcolor); S_TOP(html)->current_bg_color = bgcolor; } } - ((dw::Table*)S_TOP(html)->table)->addRow (style); - if (style) - style->unref (); + html->styleEngine->setNonCssProperties (&props); + + ((dw::Table*)S_TOP(html)->table)->addRow (html->styleEngine->style ()); if (a_Html_get_attr (html, tag, tagsize, "align")) { S_TOP(html)->cell_text_align_set = TRUE; @@ -176,18 +165,19 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize) html->styleEngine->setNonCssProperties (&props); } - style_attrs = *S_TOP(html)->table_cell_style; + table_cell_props = new CssPropertyList (*S_TOP(html)->table_cell_props); if (bgcolor != -1) { - style_attrs.backgroundColor =Color::createShaded(HT2LT(html),bgcolor); + props.set (CssProperty::CSS_PROPERTY_BACKGROUND_COLOR, bgcolor); new_style = true; } - if (a_Html_tag_set_valign_attr (html, tag, tagsize, &style_attrs)) + if (a_Html_tag_set_valign_attr (html, tag, tagsize, table_cell_props)) new_style = true; if (new_style) { - old_style = S_TOP(html)->table_cell_style; - S_TOP(html)->table_cell_style = - Style::create (HT2LT(html), &style_attrs); - old_style->unref (); + 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: @@ -235,10 +225,8 @@ static void Html_tag_open_table_cell(DilloHtml *html, int colspan = 1, rowspan = 1; const char *attrbuf; int32_t bgcolor; - StyleAttrs style_attrs; - Style *style; bool_t new_style; - CssPropertyList props; + CssPropertyList props (*S_TOP(html)->table_cell_props); switch (S_TOP(html)->table_mode) { case DILLO_HTML_TABLE_MODE_NONE: @@ -270,38 +258,29 @@ static void Html_tag_open_table_cell(DilloHtml *html, else props.set (CssProperty::CSS_PROPERTY_WHITE_SPACE, WHITE_SPACE_NORMAL); -// html->styleEngine->style () = -// Style::create (HT2LT(html), &style_attrs); -// old_style->unref (); a_Html_tag_set_align_attr (html, &props, tag, tagsize); - html->styleEngine->setNonCssProperties (&props); - - /* cell style */ - style_attrs = *S_TOP(html)->table_cell_style; - new_style = FALSE; if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "width"))) { - style_attrs.width = a_Html_parse_length (html, attrbuf); - new_style = TRUE; + props.set (CssProperty::CSS_PROPERTY_WIDTH, + a_Html_parse_length (html, attrbuf)); } - if (a_Html_tag_set_valign_attr (html, tag, tagsize, &style_attrs)) + if (a_Html_tag_set_valign_attr (html, tag, tagsize, &props)) new_style = TRUE; - if (!prefs.force_my_colors && - (attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { + if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) { bgcolor = a_Html_color_parse(html, attrbuf, -1); if (bgcolor != -1) { if (bgcolor == 0xffffff && !prefs.allow_white_bg) bgcolor = prefs.bg_color; - new_style = TRUE; - style_attrs.backgroundColor = - Color::createShaded (HT2LT(html), bgcolor); + props.set (CssProperty::CSS_PROPERTY_BACKGROUND_COLOR, bgcolor); S_TOP(html)->current_bg_color = bgcolor; } } + html->styleEngine->setNonCssProperties (&props); + if (html->styleEngine->style ()->textAlign == TEXT_ALIGN_STRING) col_tb = new dw::TableCell (((dw::Table*)S_TOP(html)->table)->getCellRef (), @@ -309,18 +288,14 @@ static void Html_tag_open_table_cell(DilloHtml *html, else col_tb = new Textblock (prefs.limit_text_width); - if (new_style) { - style = dw::core::style::Style::create (HT2LT(html), &style_attrs); - col_tb->setStyle (style); - style->unref (); - } else - col_tb->setStyle (S_TOP(html)->table_cell_style); + col_tb->setStyle (html->styleEngine->style ()); ((dw::Table*)S_TOP(html)->table)->addCell (col_tb, colspan, rowspan); S_TOP(html)->textblock = html->dw = col_tb; /* Handle it when the user clicks on a link */ html->connectSignals(col_tb); + break; default: |