summaryrefslogtreecommitdiff
path: root/css
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2004-04-18 21:10:02 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2004-04-18 21:10:02 +0000
commit8e16babeaa4cad74ac7142e971223052cfaaa5dd (patch)
treeda0397684be1ff0f2b1295c060c30f05bda77334 /css
parent058e2d495dd09c057aa068398843ec1fe9218beb (diff)
downloadnetsurf-8e16babeaa4cad74ac7142e971223052cfaaa5dd.tar.gz
netsurf-8e16babeaa4cad74ac7142e971223052cfaaa5dd.tar.bz2
[project @ 2004-04-18 21:10:02 by jmb]
Work around the lack of a '#' at the start of a colour specified in #rrggbb format svn path=/import/netsurf/; revision=793
Diffstat (limited to 'css')
-rw-r--r--css/ruleset.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/css/ruleset.c b/css/ruleset.c
index 381e1fea3..d898dbcab 100644
--- a/css/ruleset.c
+++ b/css/ruleset.c
@@ -367,11 +367,23 @@ int parse_length(struct css_length * const length,
colour named_colour(const char *name)
{
struct colour_entry *col;
+ unsigned int r, g, b;
+
col = bsearch(name, colour_table,
sizeof(colour_table) / sizeof(colour_table[0]),
sizeof(colour_table[0]), (void*)strcasecmp);
- if (col == 0)
- return TRANSPARENT;
+ if (col == 0) {
+ /* A common error is the omission of the '#' from the
+ * start of a colour specified in #rrggbb format.
+ * This attempts to detect and recover from this.
+ */
+ if (strlen(name) == 6 &&
+ sscanf(name, "%2x%2x%2x", &r, &g, &b) == 3) {
+ return (b << 16) | (g << 8) | r;
+ }
+ else
+ return TRANSPARENT;
+ }
return col->col;
}