diff options
author | Richard Wilson <rjw@netsurf-browser.org> | 2005-04-14 19:54:24 +0000 |
---|---|---|
committer | Richard Wilson <rjw@netsurf-browser.org> | 2005-04-14 19:54:24 +0000 |
commit | 487cad486dce950f51c60aee81ba792be1ef2f33 (patch) | |
tree | 1327ba6ce314fb76e4a224ecc8385b326b39e60d /css/css.c | |
parent | 92b2d468740c72094ae47ab1f72995ec60d93ae6 (diff) | |
download | netsurf-487cad486dce950f51c60aee81ba792be1ef2f33.tar.gz netsurf-487cad486dce950f51c60aee81ba792be1ef2f33.tar.bz2 |
[project @ 2005-04-14 19:54:24 by rjw]
Implement HTML table border setting. Improve support for the collapsing border model.
svn path=/import/netsurf/; revision=1632
Diffstat (limited to 'css/css.c')
-rw-r--r-- | css/css.c | 80 |
1 files changed, 80 insertions, 0 deletions
@@ -2864,6 +2864,86 @@ float css_len2px(const struct css_length *length, } +/** + * Return the most 'eyecatching' border. + * + * \return the most eyecatching border, favoured towards test2 + */ + +struct css_border *css_eyecatching_border(struct css_border *test1, + struct css_style *style1, struct css_border *test2, + struct css_style *style2) +{ + float width1, width2; + int impact = 0; + + assert(test1); + assert(style1); + assert(test2); + assert(style2); + + /* hidden border styles always win, none always loses */ + if ((test1->style == CSS_BORDER_STYLE_HIDDEN) || + (test2->style == CSS_BORDER_STYLE_NONE)) + return test1; + if ((test2->style == CSS_BORDER_STYLE_HIDDEN) || + (test1->style == CSS_BORDER_STYLE_NONE)) + return test2; + + /* the widest border wins */ + width1 = css_len2px(&test1->width.value, style1); + width2 = css_len2px(&test2->width.value, style2); + if (width1 > width2) + return test1; + if (width2 > width1) + return test2; + + /* the closest to a solid line wins */ + switch (test1->style) { + case CSS_BORDER_STYLE_DOUBLE: + impact++; + case CSS_BORDER_STYLE_SOLID: + impact++; + case CSS_BORDER_STYLE_DASHED: + impact++; + case CSS_BORDER_STYLE_DOTTED: + impact++; + case CSS_BORDER_STYLE_RIDGE: + impact++; + case CSS_BORDER_STYLE_OUTSET: + impact++; + case CSS_BORDER_STYLE_GROOVE: + impact++; + case CSS_BORDER_STYLE_INSET: + impact++; + default: + break; + } + switch (test2->style) { + case CSS_BORDER_STYLE_DOUBLE: + impact--; + case CSS_BORDER_STYLE_SOLID: + impact--; + case CSS_BORDER_STYLE_DASHED: + impact--; + case CSS_BORDER_STYLE_DOTTED: + impact--; + case CSS_BORDER_STYLE_RIDGE: + impact--; + case CSS_BORDER_STYLE_OUTSET: + impact--; + case CSS_BORDER_STYLE_GROOVE: + impact--; + case CSS_BORDER_STYLE_INSET: + impact--; + default: + break; + } + if (impact > 0) + return test1; + return test2; +} + #ifdef DEBUG int main() |