Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * This file is part of LibCSS
  3.  * Licensed under the MIT License,
  4.  *                http://www.opensource.org/licenses/mit-license.php
  5.  * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
  6.  */
  7.  
  8. #include "bytecode/bytecode.h"
  9. #include "bytecode/opcodes.h"
  10. #include "select/propset.h"
  11. #include "select/propget.h"
  12. #include "utils/utils.h"
  13.  
  14. #include "select/properties/properties.h"
  15. #include "select/properties/helpers.h"
  16.  
  17. css_error css__cascade_voice_family(uint32_t opv, css_style *style,
  18.                 css_select_state *state)
  19. {
  20.         uint16_t value = 0;
  21.         lwc_string **voices = NULL;
  22.         uint32_t n_voices = 0;
  23.  
  24.         if (isInherit(opv) == false) {
  25.                 uint32_t v = getValue(opv);
  26.  
  27.                 while (v != VOICE_FAMILY_END) {
  28.                         lwc_string *voice = NULL;
  29.                         lwc_string **temp;
  30.  
  31.                         switch (v) {
  32.                         case VOICE_FAMILY_STRING:
  33.                         case VOICE_FAMILY_IDENT_LIST:
  34.                                 css__stylesheet_string_get(style->sheet, *((css_code_t *) style->bytecode), &voice);
  35.                                 advance_bytecode(style, sizeof(css_code_t));
  36.                                 break;
  37.                         case VOICE_FAMILY_MALE:
  38.                                 if (value == 0)
  39.                                         value = 1;
  40.                                 break;
  41.                         case VOICE_FAMILY_FEMALE:
  42.                                 if (value == 0)
  43.                                         value = 1;
  44.                                 break;
  45.                         case VOICE_FAMILY_CHILD:
  46.                                 if (value == 0)
  47.                                         value = 1;
  48.                                 break;
  49.                         }
  50.  
  51.                         /* Only use family-names which occur before the first
  52.                          * generic-family. Any values which occur after the
  53.                          * first generic-family are ignored. */
  54.                         /** \todo Do this at bytecode generation time? */
  55.                         if (value == 0 && voice != NULL) {
  56.                                 temp = state->computed->alloc(voices,
  57.                                         (n_voices + 1) * sizeof(lwc_string *),
  58.                                         state->computed->pw);
  59.                                 if (temp == NULL) {
  60.                                         if (voices != NULL) {
  61.                                                 state->computed->alloc(voices, 0,
  62.                                                         state->computed->pw);
  63.                                         }
  64.                                         return CSS_NOMEM;
  65.                                 }
  66.  
  67.                                 voices = temp;
  68.  
  69.                                 voices[n_voices] = voice;
  70.  
  71.                                 n_voices++;
  72.                         }
  73.  
  74.                         v = *((uint32_t *) style->bytecode);
  75.                         advance_bytecode(style, sizeof(v));
  76.                 }
  77.         }
  78.  
  79.         /* Terminate array with blank entry, if needed */
  80.         if (n_voices > 0) {
  81.                 lwc_string **temp;
  82.  
  83.                 temp = state->computed->alloc(voices,
  84.                                 (n_voices + 1) * sizeof(lwc_string *),
  85.                                 state->computed->pw);
  86.                 if (temp == NULL) {
  87.                         state->computed->alloc(voices, 0, state->computed->pw);
  88.                         return CSS_NOMEM;
  89.                 }
  90.  
  91.                 voices = temp;
  92.  
  93.                 voices[n_voices] = NULL;
  94.         }
  95.  
  96.         if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
  97.                         isInherit(opv))) {
  98.                 /** \todo voice-family */
  99.                 if (n_voices > 0)
  100.                         state->computed->alloc(voices, 0, state->computed->pw);
  101.         } else {
  102.                 if (n_voices > 0)
  103.                         state->computed->alloc(voices, 0, state->computed->pw);
  104.         }
  105.  
  106.         return CSS_OK;
  107. }
  108.  
  109. css_error css__set_voice_family_from_hint(const css_hint *hint,
  110.                 css_computed_style *style)
  111. {
  112.         UNUSED(hint);
  113.         UNUSED(style);
  114.  
  115.         return CSS_OK;
  116. }
  117.  
  118. css_error css__initial_voice_family(css_select_state *state)
  119. {
  120.         UNUSED(state);
  121.  
  122.         return CSS_OK;
  123. }
  124.  
  125. css_error css__compose_voice_family(const css_computed_style *parent,
  126.                 const css_computed_style *child,
  127.                 css_computed_style *result)
  128. {
  129.         UNUSED(parent);
  130.         UNUSED(child);
  131.         UNUSED(result);
  132.  
  133.         return CSS_OK;
  134. }
  135.  
  136.