aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-10-31 23:40:38 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-10-31 23:40:38 +0100
commitbef80608dea6e217b7014470b649bcfab0a9c0f4 (patch)
tree1f488f0a93a6839e5b4ddcfd968c071919d54081 /src
parent90be8873a5cae7c0d67b4e4d43ca15ca8ef14159 (diff)
make ol work
Diffstat (limited to 'src')
-rw-r--r--src/css.cc57
-rw-r--r--src/html.cc80
-rw-r--r--src/html_common.hh2
-rw-r--r--src/styleengine.cc3
-rw-r--r--src/table.cc8
5 files changed, 88 insertions, 62 deletions
diff --git a/src/css.cc b/src/css.cc
index a389fe18..d40a281e 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -84,14 +84,19 @@ CssContext::CssContext () {
void CssContext::apply (CssPropertyList *props, Doctree *docTree,
CssPropertyList *tagStyle, CssPropertyList *nonCss) {
- sheet[CSS_PRIMARY_USER_AGENT]->apply (props, docTree);
+ for (int o = CSS_PRIMARY_USER_AGENT; o <= CSS_PRIMARY_USER; o++)
+ if (sheet[o])
+ sheet[o]->apply (props, docTree);
+
if (nonCss)
nonCss->apply (props);
- for (int o = CSS_PRIMARY_USER; o <= CSS_PRIMARY_USER_IMPORTANT; o++)
+
+ for (int o = CSS_PRIMARY_AUTHOR; o <= CSS_PRIMARY_USER_IMPORTANT; o++)
if (sheet[o])
sheet[o]->apply (props, docTree);
+
if (tagStyle)
- nonCss->apply (props);
+ tagStyle->apply (props);
}
CssStyleSheet * CssContext::buildUserAgentStyle () {
@@ -139,6 +144,12 @@ CssStyleSheet * CssContext::buildUserAgentStyle () {
props->set (CssProperty::CSS_PROPERTY_FONT_SIZE, v);
s->addRule (new CssSelector(a_Html_tag_index("h3"), NULL, NULL), props);
+ // <ol>
+ props = new CssPropertyList ();
+ v.listStyleType = dw::core::style::LIST_STYLE_TYPE_DECIMAL;
+ props->set (CssProperty::CSS_PROPERTY_LIST_STYLE_TYPE, v);
+ s->addRule (new CssSelector(a_Html_tag_index("ol"), NULL, NULL), props);
+
// <pre>
props = new CssPropertyList ();
v.name = "DejaVu Sans Mono";
@@ -153,25 +164,27 @@ CssStyleSheet * CssContext::buildUserStyle (bool important) {
CssPropertyList *props;
CssProperty::Value v;
- // <a>
- props = new CssPropertyList ();
- v.color = prefs.link_color;
- props->set (CssProperty::CSS_PROPERTY_COLOR, v);
- s->addRule (new CssSelector(a_Html_tag_index("a"), NULL, NULL), props);
-
- // <body>
- props = new CssPropertyList ();
- v.name = prefs.vw_fontname;
- props->set (CssProperty::CSS_PROPERTY_FONT_FAMILY, v);
- v.color = prefs.text_color;
- props->set (CssProperty::CSS_PROPERTY_COLOR, v);
- s->addRule (new CssSelector(a_Html_tag_index("body"), NULL, NULL), props);
-
- // <pre>
- props = new CssPropertyList ();
- v.name = prefs.fw_fontname;
- props->set (CssProperty::CSS_PROPERTY_FONT_FAMILY, v);
- s->addRule (new CssSelector(a_Html_tag_index("pre"), NULL, NULL), props);
+ if (! important) {
+ // <a>
+ props = new CssPropertyList ();
+ v.color = prefs.link_color;
+ props->set (CssProperty::CSS_PROPERTY_COLOR, v);
+ s->addRule (new CssSelector(a_Html_tag_index("a"), NULL, NULL), props);
+
+ // <body>
+ props = new CssPropertyList ();
+ v.name = prefs.vw_fontname;
+ props->set (CssProperty::CSS_PROPERTY_FONT_FAMILY, v);
+ v.color = prefs.text_color;
+ props->set (CssProperty::CSS_PROPERTY_COLOR, v);
+ s->addRule (new CssSelector(a_Html_tag_index("body"), NULL, NULL), props);
+
+ // <pre>
+ props = new CssPropertyList ();
+ v.name = prefs.fw_fontname;
+ props->set (CssProperty::CSS_PROPERTY_FONT_FAMILY, v);
+ s->addRule (new CssSelector(a_Html_tag_index("pre"), NULL, NULL), props);
+ }
return s;
}
diff --git a/src/html.cc b/src/html.cc
index a7238158..f7934365 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -288,25 +288,26 @@ void a_Html_set_top_font(DilloHtml *html, const char *name, int size,
* 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)
{
- const char *align, *charattr;
+ const char *align;
if ((align = a_Html_get_attr(html, tag, tagsize, "align"))) {
- Style *old_style = html->styleEngine->style ();
- StyleAttrs style_attrs = *old_style;
+ CssProperty::Value v;
if (dStrcasecmp (align, "left") == 0)
- style_attrs.textAlign = TEXT_ALIGN_LEFT;
+ v.textAlignType = TEXT_ALIGN_LEFT;
else if (dStrcasecmp (align, "right") == 0)
- style_attrs.textAlign = TEXT_ALIGN_RIGHT;
+ v.textAlignType = TEXT_ALIGN_RIGHT;
else if (dStrcasecmp (align, "center") == 0)
- style_attrs.textAlign = TEXT_ALIGN_CENTER;
+ v.textAlignType = TEXT_ALIGN_CENTER;
else if (dStrcasecmp (align, "justify") == 0)
- style_attrs.textAlign = TEXT_ALIGN_JUSTIFY;
+ v.textAlignType = TEXT_ALIGN_JUSTIFY;
+#if 0
else if (dStrcasecmp (align, "char") == 0) {
/* TODO: Actually not supported for <p> etc. */
- style_attrs.textAlign = TEXT_ALIGN_STRING;
+ v.textAlign = TEXT_ALIGN_STRING;
if ((charattr = a_Html_get_attr(html, tag, tagsize, "char"))) {
if (charattr[0] == 0)
/* TODO: ALIGN=" ", and even ALIGN="&32;" will reult in
@@ -320,8 +321,8 @@ void a_Html_tag_set_align_attr(DilloHtml *html,
/* TODO: Examine LANG attr of <html>. */
style_attrs.textAlignChar = '.';
}
-// html->styleEngine->style () = Style::create (HT2LT(html), &style_attrs);
-// old_style->unref ();
+#endif
+ props->set (CssProperty::CSS_PROPERTY_TEXT_ALIGN, v);
}
}
@@ -1763,13 +1764,16 @@ static void Html_tag_close_body(DilloHtml *html, int TagIdx)
*/
static void Html_tag_open_p(DilloHtml *html, const char *tag, int tagsize)
{
+ CssPropertyList props;
+
if ((html->InFlags & IN_LI) && !html->WordAfterLI) {
/* ignore first parbreak after an empty <LI> */
html->WordAfterLI = true;
} else {
DW2TB(html->dw)->addParbreak (9, html->styleEngine->style ());
}
- a_Html_tag_set_align_attr (html, tag, tagsize);
+ a_Html_tag_set_align_attr (html, &props, tag, tagsize);
+ html->styleEngine->setNonCssProperties (&props);
}
/*
@@ -1858,13 +1862,12 @@ static void Html_tag_open_frameset (DilloHtml *html,
*/
static void Html_tag_open_h(DilloHtml *html, const char *tag, int tagsize)
{
+ CssPropertyList props;
+
DW2TB(html->dw)->addParbreak (9, html->styleEngine->style ());
- /* TODO: combining these two would be slightly faster */
- a_Html_set_top_font(html, prefs.vw_fontname,
- Html_level_to_fontsize(FontSizesNum - (tag[2] - '0')),
- 1, 3);
- a_Html_tag_set_align_attr (html, tag, tagsize);
+ a_Html_tag_set_align_attr (html, &props, tag, tagsize);
+ html->styleEngine->setNonCssProperties (&props);
/* First finalize unclosed H tags (we test if already named anyway) */
a_Menu_pagemarks_set_text(html->bw, html->Stash->str);
@@ -2592,11 +2595,8 @@ static void Html_tag_open_ul(DilloHtml *html, const char *tag, int tagsize)
*/
static void Html_tag_open_dir(DilloHtml *html, const char *tag, int tagsize)
{
- ListStyleType list_style_type = LIST_STYLE_TYPE_DISC;
-
DW2TB(html->dw)->addParbreak (9, html->styleEngine->style ());
- Html_add_indented(html, 40, 0, 9);
- HTML_SET_TOP_ATTR(html, listStyleType, list_style_type);
+
S_TOP(html)->list_type = HTML_LIST_UNORDERED;
S_TOP(html)->list_number = 0;
S_TOP(html)->ref_list_item = NULL;
@@ -2619,28 +2619,30 @@ static void Html_tag_open_menu(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_ol(DilloHtml *html, const char *tag, int tagsize)
{
const char *attrbuf;
- ListStyleType list_style_type;
int n = 1;
- DW2TB(html->dw)->addParbreak (9, html->styleEngine->style ());
- Html_add_indented(html, 40, 0, 9);
-
- list_style_type = LIST_STYLE_TYPE_DECIMAL;
-
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "type"))) {
+ CssPropertyList props;
+ CssProperty::Value v;
+
if (*attrbuf == '1')
- list_style_type = LIST_STYLE_TYPE_DECIMAL;
+ v.listStyleType = LIST_STYLE_TYPE_DECIMAL;
else if (*attrbuf == 'a')
- list_style_type = LIST_STYLE_TYPE_LOWER_ALPHA;
+ v.listStyleType = LIST_STYLE_TYPE_LOWER_ALPHA;
else if (*attrbuf == 'A')
- list_style_type = LIST_STYLE_TYPE_UPPER_ALPHA;
+ v.listStyleType = LIST_STYLE_TYPE_UPPER_ALPHA;
else if (*attrbuf == 'i')
- list_style_type = LIST_STYLE_TYPE_LOWER_ROMAN;
+ v.listStyleType = LIST_STYLE_TYPE_LOWER_ROMAN;
else if (*attrbuf == 'I')
- list_style_type = LIST_STYLE_TYPE_UPPER_ROMAN;
+ v.listStyleType = LIST_STYLE_TYPE_UPPER_ROMAN;
+
+ props.set (CssProperty::CSS_PROPERTY_LIST_STYLE_TYPE, v);
+ html->styleEngine->setNonCssProperties (&props);
}
- HTML_SET_TOP_ATTR(html, listStyleType, list_style_type);
+ DW2TB(html->dw)->addParbreak (9, html->styleEngine->style ());
+ Html_add_indented(html, 40, 0, 9);
+
S_TOP(html)->list_type = HTML_LIST_ORDERED;
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "start")) &&
@@ -3043,8 +3045,11 @@ static void Html_tag_open_sup(DilloHtml *html, const char *tag, int tagsize)
*/
static void Html_tag_open_div(DilloHtml *html, const char *tag, int tagsize)
{
+ CssPropertyList props;
+
DW2TB(html->dw)->addParbreak (0, html->styleEngine->style ());
- a_Html_tag_set_align_attr (html, tag, tagsize);
+ a_Html_tag_set_align_attr (html, &props, tag, tagsize);
+ html->styleEngine->setNonCssProperties (&props);
}
/*
@@ -3443,10 +3448,6 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
/* Push the tag into the stack */
Html_push_tag(html, ni);
- /* Call the open function for this tag */
- Tags[ni].open (html, tag, tagsize);
- if (html->stop_parser)
- break;
/* Now parse attributes that can appear on any tag */
if (tagsize >= 8 && /* length of "<t id=i>" */
@@ -3499,6 +3500,11 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
if (style)
free (style);
+ /* Call the open function for this tag */
+ Tags[ni].open (html, tag, tagsize);
+ if (html->stop_parser)
+ break;
+
/* let the parser know this was an open tag */
html->PrevWasOpenTag = true;
diff --git a/src/html_common.hh b/src/html_common.hh
index a35411ee..aa468522 100644
--- a/src/html_common.hh
+++ b/src/html_common.hh
@@ -269,7 +269,7 @@ 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,
+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,
diff --git a/src/styleengine.cc b/src/styleengine.cc
index 64f6a4db..e8b9cbe9 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -112,6 +112,9 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) {
case CssProperty::CSS_PROPERTY_FONT_WEIGHT:
fontAttrs.weight = p->value.weight;
break;
+ case CssProperty::CSS_PROPERTY_LIST_STYLE_TYPE:
+ attrs->listStyleType = p->value.listStyleType;
+ break;
case CssProperty::CSS_PROPERTY_TEXT_DECORATION:
attrs->textDecoration |= p->value.textDecoration;
break;
diff --git a/src/table.cc b/src/table.cc
index e0a0a624..815ce6c8 100644
--- a/src/table.cc
+++ b/src/table.cc
@@ -138,6 +138,7 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize)
dw::core::style::Style *style, *old_style;
int32_t bgcolor = -1;
bool new_style = false;
+ CssPropertyList props;
#ifdef USE_TABLES
switch (S_TOP(html)->table_mode) {
@@ -171,7 +172,8 @@ void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize)
if (a_Html_get_attr (html, tag, tagsize, "align")) {
S_TOP(html)->cell_text_align_set = TRUE;
- a_Html_tag_set_align_attr (html, tag, tagsize);
+ a_Html_tag_set_align_attr (html, &props, tag, tagsize);
+ html->styleEngine->setNonCssProperties (&props);
}
style_attrs = *S_TOP(html)->table_cell_style;
@@ -236,6 +238,7 @@ static void Html_tag_open_table_cell(DilloHtml *html,
dw::core::style::Style *style, *old_style;
int32_t bgcolor;
bool_t new_style;
+ CssPropertyList props;
switch (S_TOP(html)->table_mode) {
case DILLO_HTML_TABLE_MODE_NONE:
@@ -271,7 +274,8 @@ static void Html_tag_open_table_cell(DilloHtml *html,
// html->styleEngine->style () =
// Style::create (HT2LT(html), &style_attrs);
// old_style->unref ();
- a_Html_tag_set_align_attr (html, tag, tagsize);
+ a_Html_tag_set_align_attr (html, &props, tag, tagsize);
+ html->styleEngine->setNonCssProperties (&props);
/* cell style */
style_attrs = *S_TOP(html)->table_cell_style;