diff options
author | Richard Wilson <rjw@netsurf-browser.org> | 2005-03-22 00:10:42 +0000 |
---|---|---|
committer | Richard Wilson <rjw@netsurf-browser.org> | 2005-03-22 00:10:42 +0000 |
commit | b832e05f034ccca6d2bcaa058ca0d9d6214bd22b (patch) | |
tree | 472ef7907956bd00501387a6588a51548a0d4793 /css | |
parent | 28d9260ca463abe3992fd674cc127b6b2baa04aa (diff) | |
download | netsurf-b832e05f034ccca6d2bcaa058ca0d9d6214bd22b.tar.gz netsurf-b832e05f034ccca6d2bcaa058ca0d9d6214bd22b.tar.bz2 |
[project @ 2005-03-22 00:10:42 by rjw]
Experimental cellpadding support
svn path=/import/netsurf/; revision=1569
Diffstat (limited to 'css')
-rw-r--r-- | css/css.c | 34 | ||||
-rw-r--r-- | css/css.h | 11 | ||||
-rw-r--r-- | css/ruleset.c | 7 |
3 files changed, 38 insertions, 14 deletions
@@ -109,6 +109,7 @@ static void css_dump_selector(const struct css_selector *r); /** Default style for a document. These are the 'Initial values' from the * spec. */ const struct css_style css_base_style = { + { {CSS_CELLPADDING_VALUE, 1} }, CSS_BACKGROUND_ATTACHMENT_SCROLL, 0xffffff, { CSS_BACKGROUND_IMAGE_NONE, 0 }, @@ -165,10 +166,10 @@ const struct css_style css_base_style = { { CSS_BORDER_WIDTH_LENGTH, { 2, CSS_UNIT_PX } }, CSS_BORDER_STYLE_NONE }, CSS_OVERFLOW_VISIBLE, - { { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } }, - { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } }, - { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } }, - { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } } }, + { { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false }, + { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false }, + { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false }, + { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false }, }, CSS_PAGE_BREAK_AFTER_AUTO, CSS_PAGE_BREAK_BEFORE_AUTO, CSS_PAGE_BREAK_INSIDE_AUTO, @@ -194,6 +195,7 @@ const struct css_style css_base_style = { /** Style with no values set. */ const struct css_style css_empty_style = { + { { CSS_CELLPADDING_NOT_SET, 0 } }, CSS_BACKGROUND_ATTACHMENT_NOT_SET, CSS_COLOR_NOT_SET, { CSS_BACKGROUND_IMAGE_NOT_SET, 0 }, @@ -250,10 +252,10 @@ const struct css_style css_empty_style = { { CSS_BORDER_WIDTH_NOT_SET, { 0, CSS_UNIT_PX } }, CSS_BORDER_STYLE_NOT_SET }, CSS_OVERFLOW_NOT_SET, - { { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } } }, - { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } } }, - { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } } }, - { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } } } }, + { { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } }, false }, + { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } }, false }, + { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } }, false }, + { CSS_PADDING_NOT_SET, { { 0, CSS_UNIT_PX } }, false }, }, CSS_PAGE_BREAK_AFTER_NOT_SET, CSS_PAGE_BREAK_BEFORE_NOT_SET, CSS_PAGE_BREAK_INSIDE_NOT_SET, @@ -280,6 +282,7 @@ const struct css_style css_empty_style = { /** Default style for an element. These should be INHERIT if 'Inherited' is yes, * and the 'Initial value' otherwise. */ const struct css_style css_blank_style = { + { { CSS_CELLPADDING_INHERIT, 0 } }, CSS_BACKGROUND_ATTACHMENT_SCROLL, TRANSPARENT, { CSS_BACKGROUND_IMAGE_NONE, 0 }, @@ -336,10 +339,10 @@ const struct css_style css_blank_style = { { CSS_BORDER_WIDTH_LENGTH, { 2, CSS_UNIT_PX } }, CSS_BORDER_STYLE_NONE }, CSS_OVERFLOW_VISIBLE, - { { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } }, - { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } }, - { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } }, - { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } } } }, + { { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false }, + { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false }, + { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false }, + { CSS_PADDING_LENGTH, { { 0, CSS_UNIT_PX } }, false }, }, CSS_PAGE_BREAK_AFTER_AUTO, CSS_PAGE_BREAK_BEFORE_AUTO, CSS_PAGE_BREAK_INSIDE_INHERIT, @@ -2378,6 +2381,11 @@ void css_cascade(struct css_style * const style, unsigned int i; float f; + if (apply->html_style.cellpadding.type != + CSS_CELLPADDING_INHERIT && + apply->html_style.cellpadding.type != + CSS_CELLPADDING_NOT_SET) + style->html_style.cellpadding = apply->html_style.cellpadding; if (apply->background_attachment != CSS_BACKGROUND_ATTACHMENT_INHERIT && apply->background_attachment != @@ -2668,6 +2676,8 @@ void css_merge(struct css_style * const style, { unsigned int i; + if (apply->html_style.cellpadding.type != CSS_CELLPADDING_NOT_SET) + style->html_style.cellpadding = apply->html_style.cellpadding; if (apply->background_attachment != CSS_BACKGROUND_ATTACHMENT_NOT_SET) style->background_attachment = apply->background_attachment; if (apply->background_color != CSS_COLOR_NOT_SET) @@ -149,6 +149,16 @@ struct css_content { /** Representation of a complete CSS 2 style. */ struct css_style { + /* html styles that don't translate directly to CSS */ + struct { + struct { + enum { CSS_CELLPADDING_INHERIT, + CSS_CELLPADDING_VALUE, + CSS_CELLPADDING_NOT_SET } type; + int value; + } cellpadding; + } html_style; + /* background properties */ css_background_attachment background_attachment; colour background_color; @@ -368,6 +378,7 @@ struct css_style { struct css_length length; float percent; } value; + bool override_cellpadding; /* override HTML setting */ } padding[4]; /**< top, right, bottom, left */ css_page_break_after page_break_after; diff --git a/css/ruleset.c b/css/ruleset.c index 117a69b92..c09bd0d1c 100644 --- a/css/ruleset.c +++ b/css/ruleset.c @@ -2665,14 +2665,17 @@ void parse_padding_side(struct css_style * const s, const struct css_node * cons unsigned int i) { if (v->type == CSS_NODE_IDENT && v->data_length == 7 && - strncasecmp(v->data, "inherit", 7) == 0) + strncasecmp(v->data, "inherit", 7) == 0) { s->padding[i].padding = CSS_PADDING_INHERIT; - else if (v->type == CSS_NODE_PERCENTAGE) { + s->padding[i].override_cellpadding = true; + } else if (v->type == CSS_NODE_PERCENTAGE) { s->padding[i].padding = CSS_PADDING_PERCENT; s->padding[i].value.percent = atof(v->data); + s->padding[i].override_cellpadding = true; } else if ((v->type == CSS_NODE_DIMENSION || v->type == CSS_NODE_NUMBER) && parse_length(&s->padding[i].value.length, v, true) == 0) { s->padding[i].padding = CSS_PADDING_LENGTH; + s->padding[i].override_cellpadding = true; } } |