blob: d01093b02d6ee4a406945412b492b2b606ba2335 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/*
* File: css.cc
*
* Copyright 2008 Jorge Arellano Cid <jcid@dillo.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*/
#include <stdio.h>
#include "css.hh"
void CssProperty::apply (dw::core::style::StyleAttrs *styleAttrs) {
switch (name) {
default:
break;
}
}
void CssPropertyList::apply (dw::core::style::StyleAttrs *styleAttrs) {
for (int i = 0; i < size (); i++)
get (i)->apply (styleAttrs);
}
bool CssSelector::match (Doctree *docTree) {
return tagIndex < 0 || tagIndex == docTree->top ()->tagIndex;
}
void CssRule::apply (dw::core::style::StyleAttrs *styleAttrs,
Doctree *docTree) {
if (selector->match (docTree))
props->apply (styleAttrs);
}
void CssStyleSheet::apply (dw::core::style::StyleAttrs *styleAttrs,
Doctree *docTree) {
for (int i = 0; i < size (); i++)
get (i)->apply (styleAttrs, docTree);
}
void CssContext::addRule (CssRule *rule, PrimaryOrder order) {
sheet[order].increase ();
sheet[order].set (sheet[order].size () - 1, rule);
};
void CssContext::apply (dw::core::style::StyleAttrs *styleAttrs,
Doctree *docTree,
CssPropertyList *tagStyle, CssPropertyList *nonCss) {
sheet[USER_AGENT].apply (styleAttrs, docTree);
if (nonCss)
nonCss->apply (styleAttrs);
for (int o = USER; o <= USER_IMPORTANT; o++)
sheet[o].apply (styleAttrs, docTree);
if (tagStyle)
nonCss->apply (styleAttrs);
}
|