summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-12-05 11:32:04 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-12-05 11:32:04 +0000
commitdf8d6d2153719cff70bf91cb7fadba03af9b4544 (patch)
tree9625f31e94a3495582ba086f576a1043a929dccf /src/parse
parentcea9d48a81f8f93e199ccbbe2e4ac9fdc40a0389 (diff)
downloadlibcss-df8d6d2153719cff70bf91cb7fadba03af9b4544.tar.gz
libcss-df8d6d2153719cff70bf91cb7fadba03af9b4544.tar.bz2
A little more work on font-family.
svn path=/trunk/libcss/; revision=5883
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/properties.c111
-rw-r--r--src/parse/propstrings.h6
2 files changed, 85 insertions, 32 deletions
diff --git a/src/parse/properties.c b/src/parse/properties.c
index b6f3d6d..f6f18a0 100644
--- a/src/parse/properties.c
+++ b/src/parse/properties.c
@@ -2592,27 +2592,58 @@ css_error parse_font_family(css_language *c,
if (token->type == CSS_TOKEN_IDENT) {
if (first == false) {
required_size += sizeof(opv);
- } else {
- value = FONT_FAMILY_IDENT_LIST;
}
- required_size +=
- sizeof(parserutils_hash_entry *);
+ if (token->ilower == c->strings[SERIF]) {
+ if (first) {
+ value = FONT_FAMILY_SERIF;
+ }
+ } else if (token->ilower ==
+ c->strings[SANS_SERIF]) {
+ if (first) {
+ value = FONT_FAMILY_SANS_SERIF;
+ }
+ } else if (token->ilower ==
+ c->strings[CURSIVE]) {
+ if (first) {
+ value = FONT_FAMILY_CURSIVE;
+ }
+ } else if (token->ilower ==
+ c->strings[FANTASY]) {
+ if (first) {
+ value = FONT_FAMILY_FANTASY;
+ }
+ } else if (token->ilower ==
+ c->strings[MONOSPACE]) {
+ if (first) {
+ value = FONT_FAMILY_MONOSPACE;
+ }
+ } else {
+ if (first) {
+ value = FONT_FAMILY_IDENT_LIST;
+ }
+
+ required_size +=
+ sizeof(parserutils_hash_entry *);
- /* Skip past [ IDENT* S* ]* */
- while (token != NULL) {
- token = parserutils_vector_peek(
- vector, temp_ctx);
- if (token != NULL &&
+ /* Skip past [ IDENT* S* ]* */
+ while (token != NULL) {
+ token = parserutils_vector_peek(
+ vector,
+ temp_ctx);
+ if (token != NULL &&
token->type !=
CSS_TOKEN_IDENT &&
- token->type !=
- CSS_TOKEN_S) {
- break;
- }
-
- token = parserutils_vector_iterate(
+ token->type !=
+ CSS_TOKEN_S) {
+ break;
+ }
+
+ /** \todo idents must not
+ * match generic families */
+ token = parserutils_vector_iterate(
vector, &temp_ctx);
+ }
}
} else if (token->type == CSS_TOKEN_STRING) {
if (first == false) {
@@ -2686,28 +2717,44 @@ css_error parse_font_family(css_language *c,
/** \todo need to build string from idents */
const parserutils_hash_entry *name =
token->idata;
+
+ if (token->ilower == c->strings[SERIF]) {
+ opv = FONT_FAMILY_SERIF;
+ } else if (token->ilower ==
+ c->strings[SANS_SERIF]) {
+ opv = FONT_FAMILY_SANS_SERIF;
+ } else if (token->ilower ==
+ c->strings[CURSIVE]) {
+ opv = FONT_FAMILY_CURSIVE;
+ } else if (token->ilower ==
+ c->strings[FANTASY]) {
+ opv = FONT_FAMILY_FANTASY;
+ } else if (token->ilower ==
+ c->strings[MONOSPACE]) {
+ opv = FONT_FAMILY_MONOSPACE;
+ } else {
+ opv = FONT_FAMILY_IDENT_LIST;
- opv = FONT_FAMILY_IDENT_LIST;
-
- if (first == false) {
- memcpy(ptr, &opv, sizeof(opv));
- ptr += sizeof(opv);
- }
-
- /* Skip past [ IDENT* S* ]* */
- while (token != NULL) {
- token = parserutils_vector_peek(
- vector, temp_ctx);
- if (token != NULL &&
+ /* Skip past [ IDENT* S* ]* */
+ while (token != NULL) {
+ token = parserutils_vector_peek(
+ vector, temp_ctx);
+ if (token != NULL &&
token->type !=
CSS_TOKEN_IDENT &&
- token->type !=
- CSS_TOKEN_S) {
- break;
+ token->type !=
+ CSS_TOKEN_S) {
+ break;
+ }
+
+ token = parserutils_vector_iterate(
+ vector, ctx);
}
+ }
- token = parserutils_vector_iterate(
- vector, ctx);
+ if (first == false) {
+ memcpy(ptr, &opv, sizeof(opv));
+ ptr += sizeof(opv);
}
memcpy(ptr, &name, sizeof(name));
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index d9007fd..79e4586 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -67,6 +67,7 @@ enum {
NO_OPEN_QUOTE, NO_CLOSE_QUOTE, ATTR, COUNTER, COUNTERS, CROSSHAIR,
DEFAULT, POINTER, MOVE, E_RESIZE, NE_RESIZE, NW_RESIZE, N_RESIZE,
SE_RESIZE, SW_RESIZE, S_RESIZE, W_RESIZE, TEXT, WAIT, HELP, PROGRESS,
+ SERIF, SANS_SERIF, CURSIVE, FANTASY, MONOSPACE,
LAST_KNOWN
};
@@ -339,6 +340,11 @@ static struct {
{ "wait", SLEN("wait") },
{ "help", SLEN("help") },
{ "progress", SLEN("progress") },
+ { "serif", SLEN("serif") },
+ { "sans-serif", SLEN("sans-serif") },
+ { "cursive", SLEN("cursive") },
+ { "fantasy", SLEN("fantasy") },
+ { "monospace", SLEN("monospace") },
};
#endif