annotate src/css.hh @ 2048:5060d415a85a

clickable menu items (even those introducing submenus) MUST have callbacks I clicked on the "Panel size" item itself instead of any of the options in its submenu, and: Segfault!
author corvid <corvid@lavabit.com>
date Thu, 26 May 2011 02:51:18 +0000
parents 4779a3d891a1
children 5b8e5855ab8e
rev   line source
498
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
1 #ifndef __CSS_HH__
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
2 #define __CSS_HH__
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
3
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
4 #include "dw/core.hh"
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
5 #include "doctree.hh"
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
6
568
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
7 /* Origin and weight. Used only internally.*/
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
8 typedef enum {
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
9 CSS_PRIMARY_USER_AGENT,
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
10 CSS_PRIMARY_USER,
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
11 CSS_PRIMARY_AUTHOR,
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
12 CSS_PRIMARY_AUTHOR_IMPORTANT,
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
13 CSS_PRIMARY_USER_IMPORTANT,
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
14 CSS_PRIMARY_LAST,
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
15 } CssPrimaryOrder;
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
16
912
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
17 typedef enum {
1003
8c75ee03cd4e move CssOrigin definition to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1000
diff changeset
18 CSS_ORIGIN_USER_AGENT,
8c75ee03cd4e move CssOrigin definition to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1000
diff changeset
19 CSS_ORIGIN_USER,
8c75ee03cd4e move CssOrigin definition to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1000
diff changeset
20 CSS_ORIGIN_AUTHOR,
8c75ee03cd4e move CssOrigin definition to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1000
diff changeset
21 } CssOrigin;
8c75ee03cd4e move CssOrigin definition to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1000
diff changeset
22
8c75ee03cd4e move CssOrigin definition to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1000
diff changeset
23 typedef enum {
912
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
24 CSS_TYPE_INTEGER, /* This type is only used internally, for x-*
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
25 properties. */
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
26 CSS_TYPE_ENUM, /* Value is i, if represented by
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
27 enum_symbols[i]. */
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
28 CSS_TYPE_MULTI_ENUM, /* For all enum_symbols[i], 1 << i are
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
29 combined. */
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
30 CSS_TYPE_LENGTH_PERCENTAGE, /* <length> or <percentage>. Represented by
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
31 CssLength. */
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
32 CSS_TYPE_LENGTH, /* <length>, represented as CssLength.
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
33 Note: In some cases, CSS_TYPE_LENGTH is used
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
34 instead of CSS_TYPE_LENGTH_PERCENTAGE,
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
35 only because Dw cannot handle percentages
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
36 in this particular case (e.g.
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
37 'margin-*-width'). */
1017
181a53d66446 allow negative values for specific CSS properties only
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1003
diff changeset
38 CSS_TYPE_SIGNED_LENGTH, /* As CSS_TYPE_LENGTH but may be negative. */
1641
7fb512621d23 add CSS_TYPE_LENGTH_PERCENTAGE_NUMBER
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1472
diff changeset
39 CSS_TYPE_LENGTH_PERCENTAGE_NUMBER, /* <length> or <percentage>, or <number> */
912
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
40 CSS_TYPE_COLOR, /* Represented as integer. */
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
41 CSS_TYPE_FONT_WEIGHT, /* this very special and only used by
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
42 'font-weight' */
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
43 CSS_TYPE_STRING, /* <string> */
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
44 CSS_TYPE_SYMBOL, /* Symbols, which are directly copied (as
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
45 opposed to CSS_TYPE_ENUM and
912
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
46 CSS_TYPE_MULTI_ENUM). Used for
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
47 'font-family'. */
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
48 CSS_TYPE_UNUSED /* Not yet used. Will itself get unused some
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
49 day. */
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
50 } CssValueType;
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
51
574
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
52 /*
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
53 * Lengths are represented as int in the following way:
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
54 *
1211
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
55 * | <------ integer value ------> |
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
56 *
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
57 * +---+ - - - +---+---+- - - - - -+---+---+---+---+
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
58 * | integer part | type |
574
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
59 * +---+ - - - +---+---+- - - - - -+---+---+---+---+
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
60 * | integer part | decimal fraction | type |
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
61 * +---+ - - - +---+---+- - - - - -+---+---+---+---+
1211
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
62 * n-1 15 14 3 2 1 0
574
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
63 *
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
64 * | <------ fixed point value ------> |
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
65 *
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
66 * where type is one of the CSS_LENGTH_TYPE_* values.
1354
76f015643536 represent millimeter values as fractions in CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1350
diff changeset
67 * CSS_LENGTH_TYPE_PX values are stored as
1211
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
68 * 29 bit signed integer, all other types as fixed point values.
574
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
69 */
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
70
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
71 typedef int CssLength;
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
72
1000
e9718df7942c replace CSS_LENGTH_* macros with inline functions
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
73 typedef enum {
1641
7fb512621d23 add CSS_TYPE_LENGTH_PERCENTAGE_NUMBER
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1472
diff changeset
74 CSS_LENGTH_TYPE_NONE,
574
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
75 CSS_LENGTH_TYPE_PX,
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
76 CSS_LENGTH_TYPE_MM, /* "cm", "in", "pt" and "pc" are converted into
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
77 millimeters. */
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
78 CSS_LENGTH_TYPE_EM,
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
79 CSS_LENGTH_TYPE_EX,
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
80 CSS_LENGTH_TYPE_PERCENTAGE,
658
ea961706be66 use CssLength type
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 635
diff changeset
81 CSS_LENGTH_TYPE_RELATIVE, /* This does not exist in CSS but
ea961706be66 use CssLength type
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 635
diff changeset
82 is used in HTML */
574
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
83 CSS_LENGTH_TYPE_AUTO /* This can be used as a simple value. */
1000
e9718df7942c replace CSS_LENGTH_* macros with inline functions
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
84 } CssLengthType;
574
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
85
1000
e9718df7942c replace CSS_LENGTH_* macros with inline functions
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
86 inline CssLength CSS_CREATE_LENGTH (float v, CssLengthType t) {
1211
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
87 static const int CSS_LENGTH_FRAC_MAX = (1 << (32 - 15 - 1)) - 1;
1213
d805df86cc98 Added parenthesis to math expression
Jorge Arellano Cid <jcid@dillo.org>
parents: 1211
diff changeset
88 static const int CSS_LENGTH_INT_MAX = (1 << (32 - 4)) - 1;
1211
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
89 int iv;
1000
e9718df7942c replace CSS_LENGTH_* macros with inline functions
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
90
1211
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
91 switch (t) {
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
92 case CSS_LENGTH_TYPE_PX:
1693
a9a11a23d707 add lout::misc::roundInt() for double -> int conversion
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1660
diff changeset
93 iv = lout::misc::roundInt(v);
1211
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
94 if (iv > CSS_LENGTH_INT_MAX)
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
95 iv = CSS_LENGTH_INT_MAX;
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
96 else if (iv < -CSS_LENGTH_INT_MAX)
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
97 iv = -CSS_LENGTH_INT_MAX;
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
98 return iv << 3 | t;
1641
7fb512621d23 add CSS_TYPE_LENGTH_PERCENTAGE_NUMBER
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1472
diff changeset
99 case CSS_LENGTH_TYPE_NONE:
1354
76f015643536 represent millimeter values as fractions in CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1350
diff changeset
100 case CSS_LENGTH_TYPE_MM:
1211
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
101 case CSS_LENGTH_TYPE_EM:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
102 case CSS_LENGTH_TYPE_EX:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
103 case CSS_LENGTH_TYPE_PERCENTAGE:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
104 case CSS_LENGTH_TYPE_RELATIVE:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
105 if (v > CSS_LENGTH_FRAC_MAX)
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
106 v = CSS_LENGTH_FRAC_MAX;
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
107 else if (v < -CSS_LENGTH_FRAC_MAX)
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
108 v = -CSS_LENGTH_FRAC_MAX;
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
109 return ((int) (v * (1 << 15)) & ~7 ) | t;
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
110 case CSS_LENGTH_TYPE_AUTO:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
111 return t;
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
112 default:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
113 assert(false);
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
114 return CSS_LENGTH_TYPE_AUTO;
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
115 }
1000
e9718df7942c replace CSS_LENGTH_* macros with inline functions
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
116 }
e9718df7942c replace CSS_LENGTH_* macros with inline functions
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
117
e9718df7942c replace CSS_LENGTH_* macros with inline functions
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
118 inline CssLengthType CSS_LENGTH_TYPE (CssLength l) {
e9718df7942c replace CSS_LENGTH_* macros with inline functions
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
119 return (CssLengthType) (l & 7);
e9718df7942c replace CSS_LENGTH_* macros with inline functions
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
120 }
574
8a7400997d83 move CssLength stuff to css.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 568
diff changeset
121
1211
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
122 inline float CSS_LENGTH_VALUE (CssLength l) {
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
123 switch (CSS_LENGTH_TYPE(l)) {
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
124 case CSS_LENGTH_TYPE_PX:
1354
76f015643536 represent millimeter values as fractions in CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1350
diff changeset
125 return (float) (l >> 3);
1641
7fb512621d23 add CSS_TYPE_LENGTH_PERCENTAGE_NUMBER
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1472
diff changeset
126 case CSS_LENGTH_TYPE_NONE:
1211
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
127 case CSS_LENGTH_TYPE_MM:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
128 case CSS_LENGTH_TYPE_EM:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
129 case CSS_LENGTH_TYPE_EX:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
130 case CSS_LENGTH_TYPE_PERCENTAGE:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
131 case CSS_LENGTH_TYPE_RELATIVE:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
132 return ((float)(l & ~7)) / (1 << 15);
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
133 case CSS_LENGTH_TYPE_AUTO:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
134 return 0.0;
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
135 default:
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
136 assert(false);
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
137 return 0.0;
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
138 }
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
139 }
1627935e9320 adjust CssLength
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1048
diff changeset
140
910
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
141 typedef enum {
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
142 CSS_PROPERTY_BACKGROUND_ATTACHMENT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
143 CSS_PROPERTY_BACKGROUND_COLOR,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
144 CSS_PROPERTY_BACKGROUND_IMAGE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
145 CSS_PROPERTY_BACKGROUND_POSITION,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
146 CSS_PROPERTY_BACKGROUND_REPEAT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
147 CSS_PROPERTY_BORDER_BOTTOM_COLOR,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
148 CSS_PROPERTY_BORDER_BOTTOM_STYLE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
149 CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
150 CSS_PROPERTY_BORDER_COLLAPSE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
151 CSS_PROPERTY_BORDER_LEFT_COLOR,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
152 CSS_PROPERTY_BORDER_LEFT_STYLE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
153 CSS_PROPERTY_BORDER_LEFT_WIDTH,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
154 CSS_PROPERTY_BORDER_RIGHT_COLOR,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
155 CSS_PROPERTY_BORDER_RIGHT_STYLE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
156 CSS_PROPERTY_BORDER_RIGHT_WIDTH,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
157 CSS_PROPERTY_BORDER_SPACING,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
158 CSS_PROPERTY_BORDER_TOP_COLOR,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
159 CSS_PROPERTY_BORDER_TOP_STYLE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
160 CSS_PROPERTY_BORDER_TOP_WIDTH,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
161 CSS_PROPERTY_BOTTOM,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
162 CSS_PROPERTY_CAPTION_SIDE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
163 CSS_PROPERTY_CLEAR,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
164 CSS_PROPERTY_CLIP,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
165 CSS_PROPERTY_COLOR,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
166 CSS_PROPERTY_CONTENT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
167 CSS_PROPERTY_COUNTER_INCREMENT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
168 CSS_PROPERTY_COUNTER_RESET,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
169 CSS_PROPERTY_CURSOR,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
170 CSS_PROPERTY_DIRECTION,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
171 CSS_PROPERTY_DISPLAY,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
172 CSS_PROPERTY_EMPTY_CELLS,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
173 CSS_PROPERTY_FLOAT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
174 CSS_PROPERTY_FONT_FAMILY,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
175 CSS_PROPERTY_FONT_SIZE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
176 CSS_PROPERTY_FONT_SIZE_ADJUST,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
177 CSS_PROPERTY_FONT_STRETCH,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
178 CSS_PROPERTY_FONT_STYLE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
179 CSS_PROPERTY_FONT_VARIANT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
180 CSS_PROPERTY_FONT_WEIGHT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
181 CSS_PROPERTY_HEIGHT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
182 CSS_PROPERTY_LEFT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
183 CSS_PROPERTY_LETTER_SPACING,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
184 CSS_PROPERTY_LINE_HEIGHT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
185 CSS_PROPERTY_LIST_STYLE_IMAGE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
186 CSS_PROPERTY_LIST_STYLE_POSITION,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
187 CSS_PROPERTY_LIST_STYLE_TYPE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
188 CSS_PROPERTY_MARGIN_BOTTOM,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
189 CSS_PROPERTY_MARGIN_LEFT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
190 CSS_PROPERTY_MARGIN_RIGHT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
191 CSS_PROPERTY_MARGIN_TOP,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
192 CSS_PROPERTY_MARKER_OFFSET,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
193 CSS_PROPERTY_MARKS,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
194 CSS_PROPERTY_MAX_HEIGHT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
195 CSS_PROPERTY_MAX_WIDTH,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
196 CSS_PROPERTY_MIN_HEIGHT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
197 CSS_PROPERTY_MIN_WIDTH,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
198 CSS_PROPERTY_OUTLINE_COLOR,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
199 CSS_PROPERTY_OUTLINE_STYLE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
200 CSS_PROPERTY_OUTLINE_WIDTH,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
201 CSS_PROPERTY_OVERFLOW,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
202 CSS_PROPERTY_PADDING_BOTTOM,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
203 CSS_PROPERTY_PADDING_LEFT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
204 CSS_PROPERTY_PADDING_RIGHT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
205 CSS_PROPERTY_PADDING_TOP,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
206 CSS_PROPERTY_POSITION,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
207 CSS_PROPERTY_QUOTES,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
208 CSS_PROPERTY_RIGHT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
209 CSS_PROPERTY_TEXT_ALIGN,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
210 CSS_PROPERTY_TEXT_DECORATION,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
211 CSS_PROPERTY_TEXT_INDENT,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
212 CSS_PROPERTY_TEXT_SHADOW,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
213 CSS_PROPERTY_TEXT_TRANSFORM,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
214 CSS_PROPERTY_TOP,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
215 CSS_PROPERTY_UNICODE_BIDI,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
216 CSS_PROPERTY_VERTICAL_ALIGN,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
217 CSS_PROPERTY_VISIBILITY,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
218 CSS_PROPERTY_WHITE_SPACE,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
219 CSS_PROPERTY_WIDTH,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
220 CSS_PROPERTY_WORD_SPACING,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
221 CSS_PROPERTY_Z_INDEX,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
222 CSS_PROPERTY_X_LINK,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
223 CSS_PROPERTY_X_COLSPAN,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
224 CSS_PROPERTY_X_ROWSPAN,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
225 PROPERTY_X_LINK,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
226 PROPERTY_X_IMG,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
227 PROPERTY_X_TOOLTIP,
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
228 CSS_PROPERTY_LAST
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
229 } CssPropertyName;
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
230
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
231 typedef union {
1234
938249c22d26 Fix an implicit int cast error when int != int32_t
Jorge Arellano Cid <jcid@dillo.org>
parents: 1219
diff changeset
232 int32_t intVal;
910
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
233 char *strVal;
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
234 } CssPropertyValue;
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
235
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
236 typedef enum {
1472
6ed936726b50 support border-width: thin | medium | thick
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1354
diff changeset
237 CSS_BORDER_WIDTH_THIN,
6ed936726b50 support border-width: thin | medium | thick
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1354
diff changeset
238 CSS_BORDER_WIDTH_MEDIUM,
6ed936726b50 support border-width: thin | medium | thick
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1354
diff changeset
239 CSS_BORDER_WIDTH_THICK,
6ed936726b50 support border-width: thin | medium | thick
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1354
diff changeset
240 } CssBorderWidthExtensions;
6ed936726b50 support border-width: thin | medium | thick
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1354
diff changeset
241
6ed936726b50 support border-width: thin | medium | thick
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1354
diff changeset
242 typedef enum {
914
81370e1971df switch font-weight handling to new multi type system
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 912
diff changeset
243 CSS_FONT_WEIGHT_BOLD,
81370e1971df switch font-weight handling to new multi type system
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 912
diff changeset
244 CSS_FONT_WEIGHT_BOLDER,
81370e1971df switch font-weight handling to new multi type system
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 912
diff changeset
245 CSS_FONT_WEIGHT_LIGHT,
81370e1971df switch font-weight handling to new multi type system
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 912
diff changeset
246 CSS_FONT_WEIGHT_LIGHTER,
81370e1971df switch font-weight handling to new multi type system
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 912
diff changeset
247 CSS_FONT_WEIGHT_NORMAL,
910
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
248 } CssFontWeightExtensions;
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
249
918
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
250 typedef enum {
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
251 CSS_FONT_SIZE_LARGE,
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
252 CSS_FONT_SIZE_LARGER,
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
253 CSS_FONT_SIZE_MEDIUM,
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
254 CSS_FONT_SIZE_SMALL,
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
255 CSS_FONT_SIZE_SMALLER,
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
256 CSS_FONT_SIZE_XX_LARGE,
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
257 CSS_FONT_SIZE_XX_SMALL,
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
258 CSS_FONT_SIZE_X_LARGE,
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
259 CSS_FONT_SIZE_X_SMALL,
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
260 } CssFontSizeExtensions;
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
261
1350
0fb1bd0e94a9 add letter-spacing support to CSS subsystem
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1234
diff changeset
262 typedef enum {
0fb1bd0e94a9 add letter-spacing support to CSS subsystem
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1234
diff changeset
263 CSS_LETTER_SPACING_NORMAL
0fb1bd0e94a9 add letter-spacing support to CSS subsystem
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1234
diff changeset
264 } CssLetterSpacingExtensions;
0fb1bd0e94a9 add letter-spacing support to CSS subsystem
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1234
diff changeset
265
1650
ef996982334c css word-spacing property
corvid <corvid@lavabit.com>
parents: 1641
diff changeset
266 typedef enum {
ef996982334c css word-spacing property
corvid <corvid@lavabit.com>
parents: 1641
diff changeset
267 CSS_WORD_SPACING_NORMAL
ef996982334c css word-spacing property
corvid <corvid@lavabit.com>
parents: 1641
diff changeset
268 } CssWordSpacingExtensions;
ef996982334c css word-spacing property
corvid <corvid@lavabit.com>
parents: 1641
diff changeset
269
918
fa79176adf1a support font-size enum values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 914
diff changeset
270
601
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
271 /**
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
272 * \brief This class holds a CSS property and value pair.
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
273 */
500
c049012b8b74 flesh out CssProperty
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 499
diff changeset
274 class CssProperty {
c049012b8b74 flesh out CssProperty
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 499
diff changeset
275 public:
534
7e141578b8c6 support CSS_FONT_WEIGHT_LIGHTER and CSS_FONT_WEIGHT_BOLDER
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 533
diff changeset
276
909
73260c7da32e add CssProperty::type
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 858
diff changeset
277 short name;
73260c7da32e add CssProperty::type
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 858
diff changeset
278 short type;
910
ca7c689d3873 move CssProperty::Name and CssProperty::Value out of CssProperty class
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 909
diff changeset
279 CssPropertyValue value;
513
850c23b07f91 introduce CssPropertySet
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 510
diff changeset
280
852
22d56c4176f5 inline some CSS methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 850
diff changeset
281 inline void free () {
920
30705c82cb71 free CSS values based on type
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 918
diff changeset
282 switch (type) {
30705c82cb71 free CSS values based on type
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 918
diff changeset
283 case CSS_TYPE_STRING:
30705c82cb71 free CSS values based on type
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 918
diff changeset
284 case CSS_TYPE_SYMBOL:
846
c3bbd1c1ad11 free font names when replacing them
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 838
diff changeset
285 dFree (value.strVal);
c3bbd1c1ad11 free font names when replacing them
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 838
diff changeset
286 break;
c3bbd1c1ad11 free font names when replacing them
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 838
diff changeset
287 default:
c3bbd1c1ad11 free font names when replacing them
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 838
diff changeset
288 break;
c3bbd1c1ad11 free font names when replacing them
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 838
diff changeset
289 }
c3bbd1c1ad11 free font names when replacing them
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 838
diff changeset
290 }
568
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
291 void print ();
513
850c23b07f91 introduce CssPropertySet
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 510
diff changeset
292 };
850c23b07f91 introduce CssPropertySet
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 510
diff changeset
293
601
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
294 /**
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
295 * \brief A list of CssProperty objects.
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 928
diff changeset
296 */
505
a3b15690d2f4 apply to CssPropertyList instead of styleAttrs
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
297 class CssPropertyList : public lout::misc::SimpleVector <CssProperty> {
838
f325b1232d1c make sure strings from CSS parser are freed
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 829
diff changeset
298 int refCount;
f325b1232d1c make sure strings from CSS parser are freed
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 829
diff changeset
299 bool ownerOfStrings;
543
74c07ade1edc convert table code to new style handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 538
diff changeset
300
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
301 public:
852
22d56c4176f5 inline some CSS methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 850
diff changeset
302 inline CssPropertyList(bool ownerOfStrings = false) :
838
f325b1232d1c make sure strings from CSS parser are freed
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 829
diff changeset
303 lout::misc::SimpleVector <CssProperty> (1) {
543
74c07ade1edc convert table code to new style handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 538
diff changeset
304 refCount = 0;
838
f325b1232d1c make sure strings from CSS parser are freed
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 829
diff changeset
305 this->ownerOfStrings = ownerOfStrings;
543
74c07ade1edc convert table code to new style handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 538
diff changeset
306 };
1744
49340e0f3414 no need to inline CssPropertyList copy constructor
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1739
diff changeset
307 CssPropertyList(const CssPropertyList &p, bool deep = false);
838
f325b1232d1c make sure strings from CSS parser are freed
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 829
diff changeset
308 ~CssPropertyList ();
505
a3b15690d2f4 apply to CssPropertyList instead of styleAttrs
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
309
912
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
310 void set (CssPropertyName name, CssValueType type,
91b4b4e04280 add type to CSS properties
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 910
diff changeset
311 CssPropertyValue value);
505
a3b15690d2f4 apply to CssPropertyList instead of styleAttrs
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
312 void apply (CssPropertyList *props);
568
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
313 void print ();
543
74c07ade1edc convert table code to new style handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 538
diff changeset
314 inline void ref () { refCount++; }
928
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 920
diff changeset
315 inline void unref () { if (--refCount == 0) delete this; }
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
316 };
500
c049012b8b74 flesh out CssProperty
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 499
diff changeset
317
616
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
318 class CssSimpleSelector {
1218
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
319 private:
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
320 int element;
1219
bb6f3d734fdb allow multiple class strings in CssSimpleSelector
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1218
diff changeset
321 char *pseudo, *id;
bb6f3d734fdb allow multiple class strings in CssSimpleSelector
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1218
diff changeset
322 lout::misc::SimpleVector <char *> *klass;
1218
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
323
616
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
324 public:
622
49dbc743a281 factor out Css_parse_simple_selector()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 616
diff changeset
325 enum {
49dbc743a281 factor out Css_parse_simple_selector()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 616
diff changeset
326 ELEMENT_NONE = -1,
49dbc743a281 factor out Css_parse_simple_selector()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 616
diff changeset
327 ELEMENT_ANY = -2,
49dbc743a281 factor out Css_parse_simple_selector()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 616
diff changeset
328 };
49dbc743a281 factor out Css_parse_simple_selector()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 616
diff changeset
329
1218
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
330 typedef enum {
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
331 SELECT_NONE,
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
332 SELECT_CLASS,
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
333 SELECT_PSEUDO_CLASS,
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
334 SELECT_ID,
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
335 } SelectType;
616
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
336
815
e8d905aef58f allocate/deallocate CssSimpleSelector properly
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 799
diff changeset
337 CssSimpleSelector ();
e8d905aef58f allocate/deallocate CssSimpleSelector properly
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 799
diff changeset
338 ~CssSimpleSelector ();
1218
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
339 inline void setElement (int e) { element = e; };
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
340 void setSelect (SelectType t, const char *v);
1219
bb6f3d734fdb allow multiple class strings in CssSimpleSelector
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1218
diff changeset
341 inline lout::misc::SimpleVector <char *> *getClass () { return klass; };
1218
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
342 inline const char *getPseudoClass () { return pseudo; };
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
343 inline const char *getId () { return id; };
d95366c01e57 make CssSimpleSelector members private
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1213
diff changeset
344 inline int getElement () { return element; };
616
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
345 bool match (const DoctreeNode *node);
856
7b36a12e4089 add CssSelector::specificity()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 852
diff changeset
346 int specificity ();
616
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
347 void print ();
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
348 };
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
349
601
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
350 /**
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
351 * \brief CSS selector class.
1048
52ca66a9a69c comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1017
diff changeset
352 *
601
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
353 * \todo Implement missing selector options.
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
354 */
499
ae0a18aa6f2a add klass parameter
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 498
diff changeset
355 class CssSelector {
616
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
356 public:
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
357 typedef enum {
829
85f1a49396d1 descendent -> descendant (noticed by corvid)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 815
diff changeset
358 DESCENDANT,
616
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
359 CHILD,
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
360 ADJACENT_SIBLING,
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
361 } Combinator;
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
362
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
363 private:
635
577052a5f381 streamline CssSelector a bit
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 622
diff changeset
364 struct CombinatorAndSelector {
763
df8153796f48 initial implementation of a CSS selector matching optimization
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 713
diff changeset
365 int notMatchingBefore; // used for optimizing CSS selector matching
635
577052a5f381 streamline CssSelector a bit
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 622
diff changeset
366 Combinator combinator;
815
e8d905aef58f allocate/deallocate CssSimpleSelector properly
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 799
diff changeset
367 CssSimpleSelector *selector;
635
577052a5f381 streamline CssSelector a bit
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 622
diff changeset
368 };
577052a5f381 streamline CssSelector a bit
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 622
diff changeset
369
583
a78eb45c8721 add reference counting for CssPropertyList and CssSelector
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 574
diff changeset
370 int refCount;
635
577052a5f381 streamline CssSelector a bit
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 622
diff changeset
371 lout::misc::SimpleVector <struct CombinatorAndSelector> *selectorList;
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
372
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
373 public:
795
0d838b3dc1a6 simplify CssSelector a bit
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 765
diff changeset
374 CssSelector ();
688
2fe5c35b22e0 add CssSelector destructor
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 686
diff changeset
375 ~CssSelector ();
795
0d838b3dc1a6 simplify CssSelector a bit
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 765
diff changeset
376 void addSimpleSelector (Combinator c);
616
f6ee95a3f49a make CssSelector a list of CssSimpleSelector objects
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 605
diff changeset
377 inline CssSimpleSelector *top () {
815
e8d905aef58f allocate/deallocate CssSimpleSelector properly
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 799
diff changeset
378 return selectorList->getRef (selectorList->size () - 1)->selector;
508
61d1a4c74690 add static parse method dummies
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 507
diff changeset
379 };
798
831ddf188e77 move assert from CssSelector::match() to CssRule constructor
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 795
diff changeset
380 inline int size () { return selectorList->size (); };
799
9484cf6acee2 don't call docTree->top() over and over
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 798
diff changeset
381 bool match (Doctree *dt, const DoctreeNode *node);
856
7b36a12e4089 add CssSelector::specificity()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 852
diff changeset
382 int specificity ();
568
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
383 void print ();
583
a78eb45c8721 add reference counting for CssPropertyList and CssSelector
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 574
diff changeset
384 inline void ref () { refCount++; }
928
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 920
diff changeset
385 inline void unref () { if (--refCount == 0) delete this; }
499
ae0a18aa6f2a add klass parameter
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 498
diff changeset
386 };
ae0a18aa6f2a add klass parameter
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 498
diff changeset
387
601
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
388 /**
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
389 * \brief A CssSelector CssPropertyList pair.
1048
52ca66a9a69c comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1017
diff changeset
390 *
601
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
391 * The CssPropertyList is applied if the CssSelector matches.
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
392 */
498
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
393 class CssRule {
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
394 private:
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
395 CssPropertyList *props;
1660
3accd3e00cd2 use CSS rule position when specificity is equal
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1650
diff changeset
396 int spec, pos;
498
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
397
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
398 public:
686
b444363e189b speed up CSS selector matching
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 685
diff changeset
399 CssSelector *selector;
b444363e189b speed up CSS selector matching
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 685
diff changeset
400
1660
3accd3e00cd2 use CSS rule position when specificity is equal
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1650
diff changeset
401 CssRule (CssSelector *selector, CssPropertyList *props, int pos);
498
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
402 ~CssRule ();
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
403
799
9484cf6acee2 don't call docTree->top() over and over
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 798
diff changeset
404 void apply (CssPropertyList *props,
9484cf6acee2 don't call docTree->top() over and over
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 798
diff changeset
405 Doctree *docTree, const DoctreeNode *node);
857
f5d838239b01 add CssRule::specificity
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 856
diff changeset
406 inline int specificity () { return spec; };
1660
3accd3e00cd2 use CSS rule position when specificity is equal
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1650
diff changeset
407 inline int position () { return pos; };
568
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
408 void print ();
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
409 };
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
410
601
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
411 /**
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
412 * \brief A list of CssRules.
1048
52ca66a9a69c comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1017
diff changeset
413 *
601
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
414 * In apply () all matching rules are applied.
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
415 */
686
b444363e189b speed up CSS selector matching
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 685
diff changeset
416 class CssStyleSheet {
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
417 private:
762
993dc1a85abb whitespace
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 761
diff changeset
418 class RuleList : public lout::misc::SimpleVector <CssRule*>,
993dc1a85abb whitespace
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 761
diff changeset
419 public lout::object::Object {
756
4a195f273396 initial implementation of hashmap based CSS selector matching
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 713
diff changeset
420 public:
761
cf81d9652d4a add RuleList class to implement proper memory management
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 760
diff changeset
421 RuleList () : lout::misc::SimpleVector <CssRule*> (1) {};
cf81d9652d4a add RuleList class to implement proper memory management
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 760
diff changeset
422 ~RuleList () {
cf81d9652d4a add RuleList class to implement proper memory management
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 760
diff changeset
423 for (int i = 0; i < size (); i++)
cf81d9652d4a add RuleList class to implement proper memory management
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 760
diff changeset
424 delete get (i);
cf81d9652d4a add RuleList class to implement proper memory management
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 760
diff changeset
425 };
cf81d9652d4a add RuleList class to implement proper memory management
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 760
diff changeset
426
858
731b07b19687 insert rules in correct order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 857
diff changeset
427 void insert (CssRule *rule);
928
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 920
diff changeset
428 inline bool equals (lout::object::Object *other) {
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 920
diff changeset
429 return this == other;
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 920
diff changeset
430 };
852
22d56c4176f5 inline some CSS methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 850
diff changeset
431 inline int hashValue () { return (intptr_t) this; };
761
cf81d9652d4a add RuleList class to implement proper memory management
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 760
diff changeset
432 };
cf81d9652d4a add RuleList class to implement proper memory management
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 760
diff changeset
433
762
993dc1a85abb whitespace
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 761
diff changeset
434 class RuleMap : public lout::container::typed::HashTable
993dc1a85abb whitespace
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 761
diff changeset
435 <lout::object::ConstString, RuleList > {
761
cf81d9652d4a add RuleList class to implement proper memory management
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 760
diff changeset
436 public:
762
993dc1a85abb whitespace
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 761
diff changeset
437 RuleMap () : lout::container::typed::HashTable
928
7771cf243ca6 's/if(/if (/g' 's/for(/for (/g' 's/while(/while (/g', and indentation.
Jorge Arellano Cid <jcid@dillo.org>
parents: 920
diff changeset
438 <lout::object::ConstString, RuleList > (true, true, 256) {};
756
4a195f273396 initial implementation of hashmap based CSS selector matching
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 713
diff changeset
439 };
4a195f273396 initial implementation of hashmap based CSS selector matching
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 713
diff changeset
440
686
b444363e189b speed up CSS selector matching
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 685
diff changeset
441 static const int ntags = 90; // \todo replace 90
761
cf81d9652d4a add RuleList class to implement proper memory management
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 760
diff changeset
442 RuleList *elementTable[ntags];
756
4a195f273396 initial implementation of hashmap based CSS selector matching
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 713
diff changeset
443
4a195f273396 initial implementation of hashmap based CSS selector matching
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 713
diff changeset
444 RuleMap *idTable;
4a195f273396 initial implementation of hashmap based CSS selector matching
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 713
diff changeset
445 RuleMap *classTable;
761
cf81d9652d4a add RuleList class to implement proper memory management
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 760
diff changeset
446 RuleList *anyTable;
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
447
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
448 public:
686
b444363e189b speed up CSS selector matching
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 685
diff changeset
449 CssStyleSheet();
583
a78eb45c8721 add reference counting for CssPropertyList and CssSelector
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 574
diff changeset
450 ~CssStyleSheet();
568
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
451 void addRule (CssRule *rule);
799
9484cf6acee2 don't call docTree->top() over and over
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 798
diff changeset
452 void apply (CssPropertyList *props,
9484cf6acee2 don't call docTree->top() over and over
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 798
diff changeset
453 Doctree *docTree, const DoctreeNode *node);
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
454 };
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
455
601
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
456 /**
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
457 * \brief A set of CssStyleSheets.
f4d2c33472b4 add comments
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 591
diff changeset
458 */
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
459 class CssContext {
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
460 private:
514
18e895f547c5 fill userAgentStyle with test values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 510
diff changeset
461 static CssStyleSheet *userAgentStyle;
18e895f547c5 fill userAgentStyle with test values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 510
diff changeset
462 static CssStyleSheet *userStyle;
18e895f547c5 fill userAgentStyle with test values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 510
diff changeset
463 static CssStyleSheet *userImportantStyle;
18e895f547c5 fill userAgentStyle with test values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 510
diff changeset
464 CssStyleSheet *sheet[CSS_PRIMARY_USER_IMPORTANT + 1];
1770
4779a3d891a1 trim some spaces
corvid <corvid@lavabit.com>
parents: 1744
diff changeset
465 int pos;
514
18e895f547c5 fill userAgentStyle with test values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 510
diff changeset
466
568
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
467 void buildUserAgentStyle ();
532277951457 support more CSS_PROPERTY_MARGIN* props; fix primary order
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 566
diff changeset
468 void buildUserStyle ();
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
469
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 500
diff changeset
470 public:
514
18e895f547c5 fill userAgentStyle with test values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 510
diff changeset
471 CssContext ();
18e895f547c5 fill userAgentStyle with test values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 510
diff changeset
472 ~CssContext ();
18e895f547c5 fill userAgentStyle with test values
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 510
diff changeset
473
850
384d52e29991 CssContext::addRule(): only add rules with nonempty property list
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 849
diff changeset
474 void addRule (CssSelector *sel, CssPropertyList *props,
384d52e29991 CssContext::addRule(): only add rules with nonempty property list
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 849
diff changeset
475 CssPrimaryOrder order);
505
a3b15690d2f4 apply to CssPropertyList instead of styleAttrs
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
476 void apply (CssPropertyList *props,
1737
31d490fe7e0a allow to apply CssContext to an arbitrary node in the docTree
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1733
diff changeset
477 Doctree *docTree, DoctreeNode *node,
590
eb1072890045 setNonCssProperties() -> setNonCssHints()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 583
diff changeset
478 CssPropertyList *tagStyle, CssPropertyList *nonCssHints);
498
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
479 };
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
480
80382646fb75 readd css.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
481 #endif