summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-02-11 18:28:10 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-02-11 18:28:10 +0000
commit0e320821bcd0d07116281c3bf78662329a7c9f7f (patch)
tree296d5e2fa86f490837489d8c8806b9c28dd11a71 /src
parenta8d230a3454cc82737a62e4193ad7accabb2ef2d (diff)
downloadlibcss-0e320821bcd0d07116281c3bf78662329a7c9f7f.tar.gz
libcss-0e320821bcd0d07116281c3bf78662329a7c9f7f.tar.bz2
Handle as much voice-family as we can.
svn path=/trunk/libcss/; revision=6445
Diffstat (limited to 'src')
-rw-r--r--src/select/properties.c90
1 files changed, 86 insertions, 4 deletions
diff --git a/src/select/properties.c b/src/select/properties.c
index 45bb2a5..ea81120 100644
--- a/src/select/properties.c
+++ b/src/select/properties.c
@@ -2564,11 +2564,93 @@ static css_error initial_visibility(css_computed_style *style)
static css_error cascade_voice_family(uint32_t opv, css_style *style,
css_select_state *state)
{
- UNUSED(opv);
- UNUSED(style);
- UNUSED(state);
+ uint16_t value = 0;
+ css_string *voices = NULL;
+ uint32_t n_voices = 0;
+
+ if (isInherit(opv) == false) {
+ uint32_t v = getValue(opv);
+
+ while (v != VOICE_FAMILY_END) {
+ const parserutils_hash_entry *voice = NULL;
+ css_string *temp;
- /** \todo voice-family */
+ switch (v) {
+ case VOICE_FAMILY_STRING:
+ case VOICE_FAMILY_IDENT_LIST:
+ voice = *((parserutils_hash_entry **)
+ style->bytecode);
+ advance_bytecode(style, sizeof(voice));
+ break;
+ case VOICE_FAMILY_MALE:
+ if (value == 0)
+ value = 1;
+ break;
+ case VOICE_FAMILY_FEMALE:
+ if (value == 0)
+ value = 1;
+ break;
+ case VOICE_FAMILY_CHILD:
+ if (value == 0)
+ value = 1;
+ break;
+ }
+
+ /* Only use family-names which occur before the first
+ * generic-family. Any values which occur after the
+ * first generic-family are ignored. */
+ /** \todo Do this at bytecode generation time? */
+ if (value == 0 && voice != NULL) {
+ temp = state->result->alloc(voices,
+ (n_voices + 1) * sizeof(css_string),
+ state->result->pw);
+ if (temp == NULL) {
+ if (voices != NULL) {
+ state->result->alloc(voices, 0,
+ state->result->pw);
+ }
+ return CSS_NOMEM;
+ }
+
+ voices = temp;
+
+ voices[n_voices].data = (uint8_t *) voice->data;
+ voices[n_voices].len = voice->len;
+
+ n_voices++;
+ }
+
+ v = *((uint32_t *) style->bytecode);
+ advance_bytecode(style, sizeof(v));
+ }
+ }
+
+ /* Terminate array with blank entry, if needed */
+ if (n_voices > 0) {
+ css_string *temp;
+
+ temp = state->result->alloc(voices,
+ (n_voices + 1) * sizeof(css_string),
+ state->result->pw);
+ if (temp == NULL) {
+ state->result->alloc(voices, 0, state->result->pw);
+ return CSS_NOMEM;
+ }
+
+ voices = temp;
+
+ voices[n_voices].data = NULL;
+ voices[n_voices].len = 0;
+ }
+
+ if (outranks_existing(getOpcode(opv), isImportant(opv), state)) {
+ /** \todo voice-family */
+ if (n_voices > 0)
+ state->result->alloc(voices, 0, state->result->pw);
+ } else {
+ if (n_voices > 0)
+ state->result->alloc(voices, 0, state->result->pw);
+ }
return CSS_OK;
}