1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
elinks/src/document/css/stylesheet.c

325 lines
7.2 KiB
C
Raw Normal View History

/* CSS stylesheet handling */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "elinks.h"
#include "document/css/property.h"
#include "document/css/stylesheet.h"
#include "util/error.h"
#include "util/lists.h"
#include "util/memory.h"
#include "util/string.h"
/* You can find some mysterious functions commented out here. I planned to use
* them for various smart things (well they all report to
* merge_css_stylesheets()), but it turns out it makes no sense to merge
* stylesheets now (and maybe it won't in the future neither...). But maybe you
* will find them useful at some time, so... Dunno. --pasky */
struct css_selector *
2007-07-15 13:04:39 -04:00
find_css_selector(struct css_selector_set *sels, enum css_selector_type type,
enum css_selector_relation rel,
const unsigned char *name, int namelen)
{
struct css_selector *selector;
assert(sels && name);
2007-07-15 13:04:39 -04:00
foreach_css_selector (selector, sels) {
if (type != selector->type || rel != selector->relation)
continue;
if (strlcasecmp(name, namelen, selector->name, -1))
continue;
return selector;
}
return NULL;
}
struct css_selector *
CSS bug 766: Scan ancestor elements only if needed. time elinks -no-connect -no-home 'http://rss.slashdot.org/Slashdot/slashdot/to?m=5878' Wait until finished loading, then press q and Enter. before 6.45user 0.17system 0:11.34elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3387minor)pagefaults 0swaps after 5.51user 0.14system 0:09.85elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3469minor)pagefaults 0swaps before 5.86user 0.17system 0:10.58elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3504minor)pagefaults 0swaps after 5.50user 0.15system 0:10.96elapsed 51%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3645minor)pagefaults 0swaps before 6.40user 0.14system 0:11.85elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3640minor)pagefaults 0swaps after 6.17user 0.12system 0:10.80elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3378minor)pagefaults 0swaps before 5.80user 0.14system 0:10.29elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3632minor)pagefaults 0swaps after 5.56user 0.16system 0:10.08elapsed 56%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3569minor)pagefaults 0swaps before 5.92user 0.14system 0:10.54elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3570minor)pagefaults 0swaps after 5.52user 0.13system 0:10.10elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3515minor)pagefaults 0swaps All in all, it is doubtful whether this change is worth the complexity. Please go ahead and revert if you think it isn't.
2007-07-15 14:53:35 -04:00
init_css_selector(struct css_selector_set *sels,
enum css_selector_type type,
enum css_selector_relation relation,
unsigned char *name, int namelen)
{
struct css_selector *selector;
selector = mem_calloc(1, sizeof(*selector));
if (!selector) return NULL;
CSS bug 766: Scan ancestor elements only if needed. time elinks -no-connect -no-home 'http://rss.slashdot.org/Slashdot/slashdot/to?m=5878' Wait until finished loading, then press q and Enter. before 6.45user 0.17system 0:11.34elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3387minor)pagefaults 0swaps after 5.51user 0.14system 0:09.85elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3469minor)pagefaults 0swaps before 5.86user 0.17system 0:10.58elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3504minor)pagefaults 0swaps after 5.50user 0.15system 0:10.96elapsed 51%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3645minor)pagefaults 0swaps before 6.40user 0.14system 0:11.85elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3640minor)pagefaults 0swaps after 6.17user 0.12system 0:10.80elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3378minor)pagefaults 0swaps before 5.80user 0.14system 0:10.29elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3632minor)pagefaults 0swaps after 5.56user 0.16system 0:10.08elapsed 56%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3569minor)pagefaults 0swaps before 5.92user 0.14system 0:10.54elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3570minor)pagefaults 0swaps after 5.52user 0.13system 0:10.10elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3515minor)pagefaults 0swaps All in all, it is doubtful whether this change is worth the complexity. Please go ahead and revert if you think it isn't.
2007-07-15 14:53:35 -04:00
selector->relation = relation;
2007-07-15 13:04:39 -04:00
init_css_selector_set(&selector->leaves);
selector->type = type;
init_list(selector->properties);
if (name) {
if (namelen < 0)
namelen = strlen(name);
selector->name = memacpy(name, namelen);
if (!selector->name) {
2007-07-15 13:04:39 -04:00
done_css_selector_set(&selector->leaves);
mem_free(selector);
return NULL;
}
set_mem_comment(selector, name, namelen);
}
if (sels) {
2007-07-15 13:04:39 -04:00
add_css_selector_to_set(selector, sels);
}
return selector;
}
CSS bug 766: Scan ancestor elements only if needed. time elinks -no-connect -no-home 'http://rss.slashdot.org/Slashdot/slashdot/to?m=5878' Wait until finished loading, then press q and Enter. before 6.45user 0.17system 0:11.34elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3387minor)pagefaults 0swaps after 5.51user 0.14system 0:09.85elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3469minor)pagefaults 0swaps before 5.86user 0.17system 0:10.58elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3504minor)pagefaults 0swaps after 5.50user 0.15system 0:10.96elapsed 51%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3645minor)pagefaults 0swaps before 6.40user 0.14system 0:11.85elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3640minor)pagefaults 0swaps after 6.17user 0.12system 0:10.80elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3378minor)pagefaults 0swaps before 5.80user 0.14system 0:10.29elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3632minor)pagefaults 0swaps after 5.56user 0.16system 0:10.08elapsed 56%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3569minor)pagefaults 0swaps before 5.92user 0.14system 0:10.54elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3570minor)pagefaults 0swaps after 5.52user 0.13system 0:10.10elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3515minor)pagefaults 0swaps All in all, it is doubtful whether this change is worth the complexity. Please go ahead and revert if you think it isn't.
2007-07-15 14:53:35 -04:00
void
set_css_selector_relation(struct css_selector *selector,
enum css_selector_relation relation)
{
/* Changing the relation after the selector is in a set might
* require setting css_relation_set.may_contain_rel_ancestor,
* but we don't have a pointer to the set here. */
assert(!css_selector_is_in_set(selector));
selector->relation = relation;
}
struct css_selector *
2007-07-15 13:04:39 -04:00
get_css_selector(struct css_selector_set *sels, enum css_selector_type type,
enum css_selector_relation rel,
unsigned char *name, int namelen)
{
struct css_selector *selector = NULL;
if (sels && name && namelen) {
selector = find_css_selector(sels, type, rel, name, namelen);
if (selector)
return selector;
}
CSS bug 766: Scan ancestor elements only if needed. time elinks -no-connect -no-home 'http://rss.slashdot.org/Slashdot/slashdot/to?m=5878' Wait until finished loading, then press q and Enter. before 6.45user 0.17system 0:11.34elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3387minor)pagefaults 0swaps after 5.51user 0.14system 0:09.85elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3469minor)pagefaults 0swaps before 5.86user 0.17system 0:10.58elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3504minor)pagefaults 0swaps after 5.50user 0.15system 0:10.96elapsed 51%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3645minor)pagefaults 0swaps before 6.40user 0.14system 0:11.85elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3640minor)pagefaults 0swaps after 6.17user 0.12system 0:10.80elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3378minor)pagefaults 0swaps before 5.80user 0.14system 0:10.29elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3632minor)pagefaults 0swaps after 5.56user 0.16system 0:10.08elapsed 56%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3569minor)pagefaults 0swaps before 5.92user 0.14system 0:10.54elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3570minor)pagefaults 0swaps after 5.52user 0.13system 0:10.10elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3515minor)pagefaults 0swaps All in all, it is doubtful whether this change is worth the complexity. Please go ahead and revert if you think it isn't.
2007-07-15 14:53:35 -04:00
return init_css_selector(sels, type, rel, name, namelen);
}
static struct css_selector *
copy_css_selector(struct css_stylesheet *css, struct css_selector *orig)
{
struct css_selector *copy;
assert(css && orig);
CSS bug 766: Scan ancestor elements only if needed. time elinks -no-connect -no-home 'http://rss.slashdot.org/Slashdot/slashdot/to?m=5878' Wait until finished loading, then press q and Enter. before 6.45user 0.17system 0:11.34elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3387minor)pagefaults 0swaps after 5.51user 0.14system 0:09.85elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3469minor)pagefaults 0swaps before 5.86user 0.17system 0:10.58elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3504minor)pagefaults 0swaps after 5.50user 0.15system 0:10.96elapsed 51%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3645minor)pagefaults 0swaps before 6.40user 0.14system 0:11.85elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3640minor)pagefaults 0swaps after 6.17user 0.12system 0:10.80elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3378minor)pagefaults 0swaps before 5.80user 0.14system 0:10.29elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3632minor)pagefaults 0swaps after 5.56user 0.16system 0:10.08elapsed 56%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3569minor)pagefaults 0swaps before 5.92user 0.14system 0:10.54elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3570minor)pagefaults 0swaps after 5.52user 0.13system 0:10.10elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3515minor)pagefaults 0swaps All in all, it is doubtful whether this change is worth the complexity. Please go ahead and revert if you think it isn't.
2007-07-15 14:53:35 -04:00
assert(orig->relation == CSR_ROOT);
CSS bug 766: Scan ancestor elements only if needed. time elinks -no-connect -no-home 'http://rss.slashdot.org/Slashdot/slashdot/to?m=5878' Wait until finished loading, then press q and Enter. before 6.45user 0.17system 0:11.34elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3387minor)pagefaults 0swaps after 5.51user 0.14system 0:09.85elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3469minor)pagefaults 0swaps before 5.86user 0.17system 0:10.58elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3504minor)pagefaults 0swaps after 5.50user 0.15system 0:10.96elapsed 51%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3645minor)pagefaults 0swaps before 6.40user 0.14system 0:11.85elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3640minor)pagefaults 0swaps after 6.17user 0.12system 0:10.80elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3378minor)pagefaults 0swaps before 5.80user 0.14system 0:10.29elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3632minor)pagefaults 0swaps after 5.56user 0.16system 0:10.08elapsed 56%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3569minor)pagefaults 0swaps before 5.92user 0.14system 0:10.54elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3570minor)pagefaults 0swaps after 5.52user 0.13system 0:10.10elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3515minor)pagefaults 0swaps All in all, it is doubtful whether this change is worth the complexity. Please go ahead and revert if you think it isn't.
2007-07-15 14:53:35 -04:00
copy = init_css_selector(&css->selectors, orig->type, CSR_ROOT,
orig->name, strlen(orig->name));
if (!copy)
return NULL;
return copy;
}
static void
add_selector_property(struct css_selector *selector, struct css_property *prop)
{
struct css_property *newprop = mem_alloc(sizeof(*newprop));
if (newprop) {
copy_struct(newprop, prop);
add_to_list(selector->properties, newprop);
}
}
void
add_selector_properties(struct css_selector *selector,
struct list_head *properties)
{
struct css_property *prop;
foreach (prop, *properties) {
add_selector_property(selector, prop);
}
}
static struct css_selector *
clone_css_selector(struct css_stylesheet *css, struct css_selector *orig)
{
struct css_selector *copy;
assert(css && orig);
copy = copy_css_selector(css, orig);
if (!copy)
return NULL;
add_selector_properties(copy, &orig->properties);
return copy;
}
void
merge_css_selectors(struct css_selector *sel1, struct css_selector *sel2)
{
struct css_property *prop;
foreach (prop, sel2->properties) {
struct css_property *origprop;
foreach (origprop, sel1->properties)
if (origprop->type == prop->type) {
del_from_list(origprop);
mem_free(origprop);
break;
}
/* Not there yet, let's add it. */
add_selector_property(sel1, prop);
}
}
void
done_css_selector(struct css_selector *selector)
{
2007-07-15 13:04:39 -04:00
done_css_selector_set(&selector->leaves);
2007-07-15 13:04:39 -04:00
if (css_selector_is_in_set(selector))
del_css_selector_from_set(selector);
free_list(selector->properties);
mem_free_if(selector->name);
mem_free(selector);
}
CSS bug 766: Scan ancestor elements only if needed. time elinks -no-connect -no-home 'http://rss.slashdot.org/Slashdot/slashdot/to?m=5878' Wait until finished loading, then press q and Enter. before 6.45user 0.17system 0:11.34elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3387minor)pagefaults 0swaps after 5.51user 0.14system 0:09.85elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3469minor)pagefaults 0swaps before 5.86user 0.17system 0:10.58elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3504minor)pagefaults 0swaps after 5.50user 0.15system 0:10.96elapsed 51%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3645minor)pagefaults 0swaps before 6.40user 0.14system 0:11.85elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3640minor)pagefaults 0swaps after 6.17user 0.12system 0:10.80elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3378minor)pagefaults 0swaps before 5.80user 0.14system 0:10.29elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3632minor)pagefaults 0swaps after 5.56user 0.16system 0:10.08elapsed 56%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3569minor)pagefaults 0swaps before 5.92user 0.14system 0:10.54elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3570minor)pagefaults 0swaps after 5.52user 0.13system 0:10.10elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3515minor)pagefaults 0swaps All in all, it is doubtful whether this change is worth the complexity. Please go ahead and revert if you think it isn't.
2007-07-15 14:53:35 -04:00
void
init_css_selector_set(struct css_selector_set *set)
{
set->may_contain_rel_ancestor = 0;
init_list(set->list);
}
2007-07-15 13:04:39 -04:00
void
done_css_selector_set(struct css_selector_set *set)
{
while (!css_selector_set_empty(set)) {
done_css_selector(css_selector_set_front(set));
}
}
CSS bug 766: Scan ancestor elements only if needed. time elinks -no-connect -no-home 'http://rss.slashdot.org/Slashdot/slashdot/to?m=5878' Wait until finished loading, then press q and Enter. before 6.45user 0.17system 0:11.34elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3387minor)pagefaults 0swaps after 5.51user 0.14system 0:09.85elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3469minor)pagefaults 0swaps before 5.86user 0.17system 0:10.58elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3504minor)pagefaults 0swaps after 5.50user 0.15system 0:10.96elapsed 51%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3645minor)pagefaults 0swaps before 6.40user 0.14system 0:11.85elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3640minor)pagefaults 0swaps after 6.17user 0.12system 0:10.80elapsed 58%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3378minor)pagefaults 0swaps before 5.80user 0.14system 0:10.29elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3632minor)pagefaults 0swaps after 5.56user 0.16system 0:10.08elapsed 56%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3569minor)pagefaults 0swaps before 5.92user 0.14system 0:10.54elapsed 57%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3570minor)pagefaults 0swaps after 5.52user 0.13system 0:10.10elapsed 55%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+3515minor)pagefaults 0swaps All in all, it is doubtful whether this change is worth the complexity. Please go ahead and revert if you think it isn't.
2007-07-15 14:53:35 -04:00
void
add_css_selector_to_set(struct css_selector *selector,
struct css_selector_set *set)
{
assert(!css_selector_is_in_set(selector));
add_to_list(set->list, selector);
if (selector->relation == CSR_ANCESTOR)
set->may_contain_rel_ancestor = 1;
}
void
del_css_selector_from_set(struct css_selector *selector)
{
del_from_list(selector);
selector->next = NULL;
selector->prev = NULL;
}
#ifdef DEBUG_CSS
void
2007-07-15 13:04:39 -04:00
dump_css_selector_tree_iter(struct css_selector_set *sels, int level)
{
struct css_selector *sel;
2007-07-15 13:04:39 -04:00
foreach_css_selector (sel, sels) {
struct css_property *prop;
fprintf(stderr, "%*s +- [%s] type %d rel %d props",
level * 4, " ",
sel->name, sel->type, sel->relation);
foreach (prop, sel->properties) {
fprintf(stderr, " [%d]", prop->type);
}
fprintf(stderr, "\n");
dump_css_selector_tree_iter(&sel->leaves, level + 1);
}
}
void
2007-07-15 13:04:39 -04:00
dump_css_selector_tree(struct css_selector_set *sels)
{
dump_css_selector_tree_iter(sels, 0);
}
#endif
struct css_stylesheet *
init_css_stylesheet(css_stylesheet_importer_T importer, void *import_data)
{
struct css_stylesheet *css;
css = mem_calloc(1, sizeof(*css));
if (!css)
return NULL;
css->import = importer;
css->import_data = import_data;
2007-07-15 13:04:39 -04:00
init_css_selector_set(&css->selectors);
return css;
}
void
mirror_css_stylesheet(struct css_stylesheet *css1, struct css_stylesheet *css2)
{
struct css_selector *selector;
2007-07-15 13:04:39 -04:00
foreach_css_selector (selector, &css1->selectors) {
clone_css_selector(css2, selector);
}
}
#if 0
struct css_stylesheet *
clone_css_stylesheet(struct css_stylesheet *orig)
{
struct css_stylesheet *copy;
struct css_selector *selector;
copy = init_css_stylesheet(orig->import, orig->import_data);
if (!copy)
return NULL;
mirror_css_stylesheet(orig, copy);
return copy;
}
void
merge_css_stylesheets(struct css_stylesheet *css1,
struct css_stylesheet *css2)
{
struct css_selector *selector;
assert(css1 && css2);
/* This is 100% evil. And gonna be a huge bottleneck. Essentially
* O(N^2) where we could be much smarter (ie. sort it once and then
* always be O(N)). */
2007-07-15 13:04:39 -04:00
foreach_css_selector (selector, &css2->selectors) {
struct css_selector *origsel;
origsel = find_css_selector(&css1->selectors, selector->name,
strlen(selector->name));
if (!origsel) {
clone_css_selector(css1, selector);
} else {
merge_css_selectors(origsel, selector);
}
}
}
#endif
void
done_css_stylesheet(struct css_stylesheet *css)
{
2007-07-15 13:04:39 -04:00
done_css_selector_set(&css->selectors);
}