#ifndef EL__DOCUMENT_CSS_STYLESHEET_H #define EL__DOCUMENT_CSS_STYLESHEET_H #include "util/lists.h" /* TODO: We need a memory efficient and fast way to define how properties * cascade. What we are interested in is making it fast and easy to find * all properties we need. * * struct css_cascade { * struct css_cascade *parent; * struct list_head properties; * * - Can later be turned into a table to not waste memory: * struct css_property properties[1]; * }; * * And the selector should then only map a document element into this * data structure. * * All the CSS applier has to do is require the css_cascade of the current * element and it should nicely inherit any style from parent cascades. * Question is in what direction to apply. It should be possible for the user * to overwrite any document provided stylesheet using "!important" so we need * to keep track in some table what properties was already applied so we only * overwrite when we have to. --jonas */ /* XXX: This is one of the TODOs where I have no clue what is it talking about * in particular. Is it obsolete now when we grok 'td.foo p#x>a:hover' without * hesitation? --pasky */ /* The {struct css_selector} is used for mapping elements (or nodes) in the * document structure to properties. See README for some hints about how the * trees of these span. */ /* TODO: Hash the selectors at least at the top levels? Binary trees could * still give an excellent gain while not giving a constant memory usage hit. * --pasky */ struct css_selector { LIST_HEAD(struct css_selector); /* This defines relation between this selector fragment and its * parent in the selector tree. */ enum css_selector_relation { CSR_ROOT, /* First class stylesheet member. */ CSR_SPECIFITY, /* Narrowing-down, i.e. the "x" in "foo#x". */ CSR_ANCESTOR, /* Ancestor, i.e. the "p" in "p a". */ CSR_PARENT, /* Direct parent, i.e. the "div" in "div>img". */ } relation; struct list_head leaves; /* -> struct css_selector */ enum css_selector_type { CST_ELEMENT, CST_ID, CST_CLASS, CST_PSEUDO, CST_INVALID, /* Auxiliary for the parser */ } type; unsigned char *name; struct list_head properties; /* -> struct css_property */ }; struct css_stylesheet; typedef void (*css_stylesheet_importer_T)(struct css_stylesheet *, struct uri *, unsigned char *url, int urllen); /* The {struct css_stylesheet} describes all the useful data that was extracted * from the CSS source. Currently we don't cache anything but the default user * stylesheet so it can contain stuff from both