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 2008 John-Mark Bell <jmb@netsurf-browser.org>
  6.  */
  7.  
  8. #ifndef css_css__parse_parse_h_
  9. #define css_css__parse_parse_h_
  10.  
  11. #include <libwapcaplet/libwapcaplet.h>
  12.  
  13. #include <parserutils/utils/vector.h>
  14.  
  15. #include <libcss/errors.h>
  16. #include <libcss/functypes.h>
  17. #include <libcss/types.h>
  18.  
  19. typedef struct css_parser css_parser;
  20.  
  21. /**
  22.  * Parser event types
  23.  */
  24. typedef enum css_parser_event {
  25.         CSS_PARSER_START_STYLESHEET,
  26.         CSS_PARSER_END_STYLESHEET,
  27.         CSS_PARSER_START_RULESET,
  28.         CSS_PARSER_END_RULESET,
  29.         CSS_PARSER_START_ATRULE,
  30.         CSS_PARSER_END_ATRULE,
  31.         CSS_PARSER_START_BLOCK,
  32.         CSS_PARSER_END_BLOCK,
  33.         CSS_PARSER_BLOCK_CONTENT,
  34.         CSS_PARSER_DECLARATION
  35. } css_parser_event;
  36.  
  37. typedef css_error (*css_parser_event_handler)(css_parser_event type,
  38.                 const parserutils_vector *tokens, void *pw);
  39.  
  40. /**
  41.  * Parser option types
  42.  */
  43. typedef enum css_parser_opttype {
  44.         CSS_PARSER_QUIRKS,
  45.         CSS_PARSER_EVENT_HANDLER
  46. } css_parser_opttype;
  47.  
  48. /**
  49.  * Parser option parameters
  50.  */
  51. typedef union css_parser_optparams {
  52.         bool quirks;
  53.  
  54.         struct {
  55.                 css_parser_event_handler handler;
  56.                 void *pw;
  57.         } event_handler;
  58. } css_parser_optparams;
  59.  
  60. css_error css__parser_create(const char *charset, css_charset_source cs_source,
  61.                 css_allocator_fn alloc, void *pw,
  62.                 css_parser **parser);
  63. css_error css__parser_create_for_inline_style(const char *charset,
  64.                 css_charset_source cs_source,
  65.                 css_allocator_fn alloc, void *pw, css_parser **parser);
  66. css_error css__parser_destroy(css_parser *parser);
  67.  
  68. css_error css__parser_setopt(css_parser *parser, css_parser_opttype type,
  69.                 css_parser_optparams *params);
  70.  
  71. css_error css__parser_parse_chunk(css_parser *parser, const uint8_t *data,
  72.                 size_t len);
  73. css_error css__parser_completed(css_parser *parser);
  74.  
  75. const char *css__parser_read_charset(css_parser *parser,
  76.                 css_charset_source *source);
  77. bool css__parser_quirks_permitted(css_parser *parser);
  78.  
  79. #endif
  80.  
  81.