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 <assert.h>
  9. #include <string.h>
  10.  
  11. #include "bytecode/bytecode.h"
  12. #include "bytecode/opcodes.h"
  13. #include "parse/properties/properties.h"
  14. #include "parse/properties/utils.h"
  15.  
  16. /**
  17.  * Parse list-style-type
  18.  *
  19.  * \param c       Parsing context
  20.  * \param vector  Vector of tokens to process
  21.  * \param ctx     Pointer to vector iteration context
  22.  * \param result  Pointer to location to receive resulting style
  23.  * \return CSS_OK on success,
  24.  *         CSS_NOMEM on memory exhaustion,
  25.  *         CSS_INVALID if the input is not valid
  26.  *
  27.  * Post condition: \a *ctx is updated with the next token to process
  28.  *                 If the input is invalid, then \a *ctx remains unchanged.
  29.  */
  30. css_error css__parse_list_style_type(css_language *c,
  31.                 const parserutils_vector *vector, int *ctx,
  32.                 css_style *result)
  33. {
  34.         int orig_ctx = *ctx;
  35.         css_error error;
  36.         const css_token *ident;
  37.         uint8_t flags = 0;
  38.         uint16_t value = 0;
  39.         bool match;
  40.  
  41.         /* IDENT (disc, circle, square, decimal, decimal-leading-zero,
  42.          *        lower-roman, upper-roman, lower-greek, lower-latin,
  43.          *        upper-latin, armenian, georgian, lower-alpha, upper-alpha,
  44.          *        none, inherit)
  45.          */
  46.         ident = parserutils_vector_iterate(vector, ctx);
  47.         if (ident == NULL || ident->type != CSS_TOKEN_IDENT) {
  48.                 *ctx = orig_ctx;
  49.                 return CSS_INVALID;
  50.         }
  51.  
  52.         if ((lwc_string_caseless_isequal(
  53.                         ident->idata, c->strings[INHERIT],
  54.                         &match) == lwc_error_ok && match)) {
  55.                 flags |= FLAG_INHERIT;
  56.         } else {
  57.                 error = css__parse_list_style_type_value(c, ident, &value);
  58.                 if (error != CSS_OK) {
  59.                         *ctx = orig_ctx;
  60.                         return error;
  61.                 }
  62.         }
  63.  
  64.         error = css__stylesheet_style_appendOPV(result, CSS_PROP_LIST_STYLE_TYPE, flags, value);
  65.  
  66.         if (error != CSS_OK)
  67.                 *ctx = orig_ctx;
  68.        
  69.         return error;
  70. }
  71.