Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.  * This file was generated by LibCSS gen_parser
  3.  *
  4.  * Generated from:
  5.  *
  6.  * font_size:CSS_PROP_FONT_SIZE IDENT:( INHERIT: XX_SMALL:0,FONT_SIZE_XX_SMALL X_SMALL:0,FONT_SIZE_X_SMALL SMALL:0,FONT_SIZE_SMALL MEDIUM:0,FONT_SIZE_MEDIUM LARGE:0,FONT_SIZE_LARGE X_LARGE:0,FONT_SIZE_X_LARGE XX_LARGE:0,FONT_SIZE_XX_LARGE LARGER:0,FONT_SIZE_LARGER SMALLER:0,FONT_SIZE_SMALLER IDENT:) LENGTH_UNIT:( UNIT_PX:FONT_SIZE_DIMENSION DISALLOW:unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ RANGE:<0 LENGTH_UNIT:)
  7.  *
  8.  * Licensed under the MIT License,
  9.  *                http://www.opensource.org/licenses/mit-license.php
  10.  * Copyright 2010 The NetSurf Browser Project.
  11.  */
  12.  
  13. #include <assert.h>
  14. #include <string.h>
  15.  
  16. #include "bytecode/bytecode.h"
  17. #include "bytecode/opcodes.h"
  18. #include "parse/properties/properties.h"
  19. #include "parse/properties/utils.h"
  20.  
  21. /**
  22.  * Parse font_size
  23.  *
  24.  * \param c       Parsing context
  25.  * \param vector  Vector of tokens to process
  26.  * \param ctx     Pointer to vector iteration context
  27.  * \param result  resulting style
  28.  * \return CSS_OK on success,
  29.  *         CSS_NOMEM on memory exhaustion,
  30.  *         CSS_INVALID if the input is not valid
  31.  *
  32.  * Post condition: \a *ctx is updated with the next token to process
  33.  *                 If the input is invalid, then \a *ctx remains unchanged.
  34.  */
  35. css_error css__parse_font_size(css_language *c,
  36.                 const parserutils_vector *vector, int *ctx,
  37.                 css_style *result)
  38. {
  39.         int orig_ctx = *ctx;
  40.         css_error error;
  41.         const css_token *token;
  42.         bool match;
  43.  
  44.         token = parserutils_vector_iterate(vector, ctx);
  45.         if (token == NULL) {
  46.                 *ctx = orig_ctx;
  47.                 return CSS_INVALID;
  48.         }
  49.  
  50.         if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[INHERIT], &match) == lwc_error_ok && match)) {
  51.                         error = css_stylesheet_style_inherit(result, CSS_PROP_FONT_SIZE);
  52.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[XX_SMALL], &match) == lwc_error_ok && match)) {
  53.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_SIZE, 0,FONT_SIZE_XX_SMALL);
  54.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[X_SMALL], &match) == lwc_error_ok && match)) {
  55.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_SIZE, 0,FONT_SIZE_X_SMALL);
  56.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[SMALL], &match) == lwc_error_ok && match)) {
  57.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_SIZE, 0,FONT_SIZE_SMALL);
  58.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[MEDIUM], &match) == lwc_error_ok && match)) {
  59.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_SIZE, 0,FONT_SIZE_MEDIUM);
  60.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[LARGE], &match) == lwc_error_ok && match)) {
  61.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_SIZE, 0,FONT_SIZE_LARGE);
  62.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[X_LARGE], &match) == lwc_error_ok && match)) {
  63.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_SIZE, 0,FONT_SIZE_X_LARGE);
  64.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[XX_LARGE], &match) == lwc_error_ok && match)) {
  65.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_SIZE, 0,FONT_SIZE_XX_LARGE);
  66.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[LARGER], &match) == lwc_error_ok && match)) {
  67.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_SIZE, 0,FONT_SIZE_LARGER);
  68.         } else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[SMALLER], &match) == lwc_error_ok && match)) {
  69.                         error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_SIZE, 0,FONT_SIZE_SMALLER);
  70.         } else {
  71.                 css_fixed length = 0;
  72.                 uint32_t unit = 0;
  73.                 *ctx = orig_ctx;
  74.  
  75.                 error = css__parse_unit_specifier(c, vector, ctx, UNIT_PX, &length, &unit);
  76.                 if (error != CSS_OK) {
  77.                         *ctx = orig_ctx;
  78.                         return error;
  79.                 }
  80.  
  81.                 if (unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ) {
  82.                         *ctx = orig_ctx;
  83.                         return CSS_INVALID;
  84.                 }
  85.  
  86.                 if (length <0) {
  87.                         *ctx = orig_ctx;
  88.                         return CSS_INVALID;
  89.                 }
  90.  
  91.                 error = css__stylesheet_style_appendOPV(result, CSS_PROP_FONT_SIZE, 0, FONT_SIZE_DIMENSION);
  92.                 if (error != CSS_OK) {
  93.                         *ctx = orig_ctx;
  94.                         return error;
  95.                 }
  96.  
  97.                 error = css__stylesheet_style_vappend(result, 2, length, unit);
  98.         }
  99.  
  100.         if (error != CSS_OK)
  101.                 *ctx = orig_ctx;
  102.        
  103.         return error;
  104. }
  105.  
  106.