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_counter_increment(uint32_t opv, css_style *style,
  18.                 css_select_state *state)
  19. {      
  20.         return css__cascade_counter_increment_reset(opv, style, state,
  21.                         set_counter_increment);
  22. }
  23.  
  24. css_error css__set_counter_increment_from_hint(const css_hint *hint,
  25.                 css_computed_style *style)
  26. {
  27.         css_computed_counter *item;
  28.         css_error error;
  29.  
  30.         error = set_counter_increment(style, hint->status, hint->data.counter);
  31.  
  32.         if (hint->status == CSS_COUNTER_INCREMENT_NAMED &&
  33.                         hint->data.counter != NULL) {
  34.                 for (item = hint->data.counter; item->name != NULL; item++) {
  35.                         lwc_string_unref(item->name);
  36.                 }
  37.         }
  38.  
  39.         if (error != CSS_OK && hint->data.counter != NULL)
  40.                 style->alloc(hint->data.counter, 0, style->pw);
  41.  
  42.         return error;
  43. }
  44.  
  45. css_error css__initial_counter_increment(css_select_state *state)
  46. {
  47.         return set_counter_increment(state->computed,
  48.                         CSS_COUNTER_INCREMENT_NONE, NULL);
  49. }
  50.  
  51. css_error css__compose_counter_increment(const css_computed_style *parent,
  52.                 const css_computed_style *child,
  53.                 css_computed_style *result)
  54. {
  55.         css_error error;
  56.         const css_computed_counter *items = NULL;
  57.         uint8_t type = get_counter_increment(child, &items);
  58.  
  59.         if ((child->uncommon == NULL && parent->uncommon != NULL) ||
  60.                         type == CSS_COUNTER_INCREMENT_INHERIT ||
  61.                         (child->uncommon != NULL && result != child)) {
  62.                 size_t n_items = 0;
  63.                 css_computed_counter *copy = NULL;
  64.  
  65.                 if ((child->uncommon == NULL && parent->uncommon != NULL) ||
  66.                                 type == CSS_COUNTER_INCREMENT_INHERIT) {
  67.                         type = get_counter_increment(parent, &items);
  68.                 }
  69.  
  70.                 if (type == CSS_COUNTER_INCREMENT_NAMED && items != NULL) {
  71.                         const css_computed_counter *i;
  72.  
  73.                         for (i = items; i->name != NULL; i++)
  74.                                 n_items++;
  75.  
  76.                         copy = result->alloc(NULL, (n_items + 1) *
  77.                                         sizeof(css_computed_counter),
  78.                                         result->pw);
  79.                         if (copy == NULL)
  80.                                 return CSS_NOMEM;
  81.  
  82.                         memcpy(copy, items, (n_items + 1) *
  83.                                         sizeof(css_computed_counter));
  84.                 }
  85.  
  86.                 error = set_counter_increment(result, type, copy);
  87.                 if (error != CSS_OK && copy != NULL)
  88.                         result->alloc(copy, 0, result->pw);
  89.  
  90.                 return error;
  91.         }
  92.  
  93.         return CSS_OK;
  94. }
  95.  
  96.