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 css_select_select_h_
  9. #define css_select_select_h_
  10.  
  11. #include <stdbool.h>
  12. #include <stdint.h>
  13.  
  14. #include <libcss/select.h>
  15.  
  16. #include "stylesheet.h"
  17.  
  18. /**
  19.  * Item in the reject cache (only class and id types are valid)
  20.  */
  21. typedef struct reject_item {
  22.         lwc_string *value;
  23.         css_selector_type type;
  24. } reject_item;
  25.  
  26. typedef struct prop_state {
  27.         uint32_t specificity;           /* Specificity of property in result */
  28.         unsigned int set       : 1,     /* Whether property is set in result */
  29.                      origin    : 2,     /* Origin of property in result */
  30.                      important : 1,     /* Importance of property in result */
  31.                      inherit   : 1;     /* Property is set to inherit */
  32. } prop_state;
  33.  
  34. /**
  35.  * Selection state
  36.  */
  37. typedef struct css_select_state {
  38.         void *node;                     /* Node we're selecting for */
  39.         uint64_t media;                 /* Currently active media types */
  40.         css_select_results *results;    /* Result set to populate */
  41.  
  42.         css_pseudo_element current_pseudo;      /* Current pseudo element */
  43.         css_computed_style *computed;   /* Computed style to populate */
  44.  
  45.         css_select_handler *handler;    /* Handler functions */
  46.         void *pw;                       /* Client data for handlers */
  47.  
  48.         const css_stylesheet *sheet;    /* Current sheet being processed */
  49.  
  50.         css_origin current_origin;      /* Origin of current sheet */
  51.         uint32_t current_specificity;   /* Specificity of current rule */
  52.  
  53.         css_qname element;              /* Element we're selecting for */
  54.         lwc_string *id;                 /* Node id, if any */
  55.         lwc_string **classes;           /* Node classes, if any */
  56.         uint32_t n_classes;             /* Number of classes */
  57.  
  58.         reject_item reject_cache[128];  /* Reject cache (filled from end) */
  59.         reject_item *next_reject;       /* Next free slot in reject cache */
  60.  
  61.         prop_state props[CSS_N_PROPERTIES][CSS_PSEUDO_ELEMENT_COUNT];
  62. } css_select_state;
  63.  
  64. static inline void advance_bytecode(css_style *style, uint32_t n_bytes)
  65. {
  66.         style->used -= (n_bytes / sizeof(css_code_t));
  67.         style->bytecode = style->bytecode + (n_bytes / sizeof(css_code_t));
  68. }
  69.  
  70. bool css__outranks_existing(uint16_t op, bool important, css_select_state *state,
  71.                 bool inherit);
  72.  
  73. #endif
  74.  
  75.