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. #ifndef libcss_select_h_
  9. #define libcss_select_h_
  10.  
  11. #ifdef __cplusplus
  12. extern "C"
  13. {
  14. #endif
  15.  
  16. #include <libcss/errors.h>
  17. #include <libcss/functypes.h>
  18. #include <libcss/hint.h>
  19. #include <libcss/types.h>
  20. #include <libcss/computed.h>
  21.  
  22. typedef enum css_pseudo_element {
  23.         CSS_PSEUDO_ELEMENT_NONE         = 0,
  24.         CSS_PSEUDO_ELEMENT_FIRST_LINE   = 1,
  25.         CSS_PSEUDO_ELEMENT_FIRST_LETTER = 2,
  26.         CSS_PSEUDO_ELEMENT_BEFORE       = 3,
  27.         CSS_PSEUDO_ELEMENT_AFTER        = 4,
  28.  
  29.         CSS_PSEUDO_ELEMENT_COUNT        = 5     /**< Number of pseudo elements */
  30. } css_pseudo_element;
  31.  
  32. /**
  33.  * Style selection result set
  34.  */
  35. typedef struct css_select_results {
  36.         css_allocator_fn alloc;
  37.         void *pw;
  38.  
  39.         /**
  40.          * Array of pointers to computed styles,
  41.          * indexed by css_pseudo_element. If there
  42.          * was no styling for a given pseudo element,
  43.          * then no computed style will be created and
  44.          * the corresponding pointer will be set to NULL
  45.          */
  46.         css_computed_style *styles[CSS_PSEUDO_ELEMENT_COUNT];
  47. } css_select_results;
  48.  
  49. typedef enum css_select_handler_version {
  50.         CSS_SELECT_HANDLER_VERSION_1 = 1
  51. } css_select_handler_version;
  52.  
  53. typedef struct css_select_handler {
  54.         /** ABI version of this structure */
  55.         uint32_t handler_version;
  56.  
  57.         css_error (*node_name)(void *pw, void *node,
  58.                         css_qname *qname);
  59.         css_error (*node_classes)(void *pw, void *node,
  60.                         lwc_string ***classes,
  61.                         uint32_t *n_classes);
  62.         css_error (*node_id)(void *pw, void *node,
  63.                         lwc_string **id);
  64.  
  65.         css_error (*named_ancestor_node)(void *pw, void *node,
  66.                         const css_qname *qname, void **ancestor);
  67.         css_error (*named_parent_node)(void *pw, void *node,
  68.                         const css_qname *qname, void **parent);
  69.         css_error (*named_sibling_node)(void *pw, void *node,
  70.                         const css_qname *qname, void **sibling);
  71.         css_error (*named_generic_sibling_node)(void *pw, void *node,
  72.                         const css_qname *qname, void **sibling);
  73.  
  74.         css_error (*parent_node)(void *pw, void *node, void **parent);
  75.         css_error (*sibling_node)(void *pw, void *node, void **sibling);
  76.  
  77.         css_error (*node_has_name)(void *pw, void *node,
  78.                         const css_qname *qname, bool *match);
  79.         css_error (*node_has_class)(void *pw, void *node,
  80.                         lwc_string *name, bool *match);
  81.         css_error (*node_has_id)(void *pw, void *node,
  82.                         lwc_string *name, bool *match);
  83.         css_error (*node_has_attribute)(void *pw, void *node,
  84.                         const css_qname *qname, bool *match);
  85.         css_error (*node_has_attribute_equal)(void *pw, void *node,
  86.                         const css_qname *qname, lwc_string *value,
  87.                         bool *match);
  88.         css_error (*node_has_attribute_dashmatch)(void *pw, void *node,
  89.                         const css_qname *qname, lwc_string *value,
  90.                         bool *match);
  91.         css_error (*node_has_attribute_includes)(void *pw, void *node,
  92.                         const css_qname *qname, lwc_string *value,
  93.                         bool *match);
  94.         css_error (*node_has_attribute_prefix)(void *pw, void *node,
  95.                         const css_qname *qname, lwc_string *value,
  96.                         bool *match);
  97.         css_error (*node_has_attribute_suffix)(void *pw, void *node,
  98.                         const css_qname *qname, lwc_string *value,
  99.                         bool *match);
  100.         css_error (*node_has_attribute_substring)(void *pw, void *node,
  101.                         const css_qname *qname, lwc_string *value,
  102.                         bool *match);
  103.  
  104.         css_error (*node_is_root)(void *pw, void *node, bool *match);
  105.         css_error (*node_count_siblings)(void *pw, void *node,
  106.                         bool same_name, bool after, int32_t *count);
  107.         css_error (*node_is_empty)(void *pw, void *node, bool *match);
  108.  
  109.         css_error (*node_is_link)(void *pw, void *node, bool *match);
  110.         css_error (*node_is_visited)(void *pw, void *node, bool *match);
  111.         css_error (*node_is_hover)(void *pw, void *node, bool *match);
  112.         css_error (*node_is_active)(void *pw, void *node, bool *match);
  113.         css_error (*node_is_focus)(void *pw, void *node, bool *match);
  114.  
  115.         css_error (*node_is_enabled)(void *pw, void *node, bool *match);
  116.         css_error (*node_is_disabled)(void *pw, void *node, bool *match);
  117.         css_error (*node_is_checked)(void *pw, void *node, bool *match);
  118.  
  119.         css_error (*node_is_target)(void *pw, void *node, bool *match);
  120.         css_error (*node_is_lang)(void *pw, void *node,
  121.                         lwc_string *lang, bool *match);
  122.  
  123.         css_error (*node_presentational_hint)(void *pw, void *node,
  124.                         uint32_t property, css_hint *hint);
  125.  
  126.         css_error (*ua_default_for_property)(void *pw, uint32_t property,
  127.                         css_hint *hint);
  128.  
  129.         css_error (*compute_font_size)(void *pw, const css_hint *parent,
  130.                         css_hint *size);
  131. } css_select_handler;
  132.  
  133. /**
  134.  * Font face selection result set
  135.  */
  136. typedef struct css_select_font_faces_results {
  137.         css_allocator_fn alloc;
  138.         void *pw;
  139.        
  140.         /**
  141.          * Array of pointers to computed font faces.
  142.          */
  143.         css_font_face **font_faces;
  144.         uint32_t n_font_faces;
  145. } css_select_font_faces_results;
  146.  
  147. css_error css_select_ctx_create(css_allocator_fn alloc, void *pw,
  148.                 css_select_ctx **result);
  149. css_error css_select_ctx_destroy(css_select_ctx *ctx);
  150.  
  151. css_error css_select_ctx_append_sheet(css_select_ctx *ctx,
  152.                 const css_stylesheet *sheet,
  153.                 css_origin origin, uint64_t media);
  154. css_error css_select_ctx_insert_sheet(css_select_ctx *ctx,
  155.                 const css_stylesheet *sheet, uint32_t index,
  156.                 css_origin origin, uint64_t media);
  157. css_error css_select_ctx_remove_sheet(css_select_ctx *ctx,
  158.                 const css_stylesheet *sheet);
  159.  
  160. css_error css_select_ctx_count_sheets(css_select_ctx *ctx, uint32_t *count);
  161. css_error css_select_ctx_get_sheet(css_select_ctx *ctx, uint32_t index,
  162.                 const css_stylesheet **sheet);
  163.  
  164. css_error css_select_style(css_select_ctx *ctx, void *node,
  165.                 uint64_t media, const css_stylesheet *inline_style,
  166.                 css_select_handler *handler, void *pw,
  167.                 css_select_results **result);
  168. css_error css_select_results_destroy(css_select_results *results);    
  169.  
  170. css_error css_select_font_faces(css_select_ctx *ctx,
  171.                 uint64_t media, lwc_string *font_family,
  172.                 css_select_font_faces_results **result);
  173. css_error css_select_font_faces_results_destroy(
  174.                 css_select_font_faces_results *results);       
  175.  
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179.  
  180. #endif
  181.