8 prop_type_invalid
, // indicates "not found" condition in style::get_property
9 prop_type_inherit
, // "inherit" was specified as the value of this property
12 prop_type_enum_item_vector
,
14 prop_type_length_vector
,
18 prop_type_string_vector
,
19 prop_type_size_vector
,
21 prop_type_var
, // also string, but needs further parsing because of var()
32 int_vector m_enum_item_vector
;
34 length_vector m_length_vector
;
38 string_vector m_string_vector
;
39 size_vector m_size_vector
;
43 : m_type(prop_type_invalid
)
46 property_value(bool important
, property_type type
)
47 : m_type(type
), m_important(important
)
50 property_value(const string
& str
, bool important
, property_type type
= prop_type_string
)
51 : m_string(str
), m_type(type
), m_important(important
)
54 property_value(const string_vector
& vec
, bool important
)
55 : m_string_vector(vec
), m_type(prop_type_string_vector
), m_important(important
)
58 property_value(const css_length
& length
, bool important
)
59 : m_length(length
), m_type(prop_type_length
), m_important(important
)
62 property_value(const length_vector
& vec
, bool important
)
63 : m_length_vector(vec
), m_type(prop_type_length_vector
), m_important(important
)
66 property_value(float number
, bool important
)
67 : m_number(number
), m_type(prop_type_number
), m_important(important
)
70 property_value(int enum_item
, bool important
)
71 : m_enum_item(enum_item
), m_type(prop_type_enum_item
), m_important(important
)
74 property_value(const int_vector
& vec
, bool important
)
75 : m_enum_item_vector(vec
), m_type(prop_type_enum_item_vector
), m_important(important
)
78 property_value(web_color color
, bool important
)
79 : m_color(color
), m_type(prop_type_color
), m_important(important
)
82 property_value(const size_vector
& vec
, bool important
)
83 : m_size_vector(vec
), m_type(prop_type_size_vector
), m_important(important
)
90 case prop_type_string
:
94 case prop_type_string_vector
:
95 m_string_vector
.~string_vector();
97 case prop_type_length
:
98 m_length
.~css_length();
100 case prop_type_length_vector
:
101 m_length_vector
.~length_vector();
103 case prop_type_enum_item_vector
:
104 m_enum_item_vector
.~int_vector();
106 case prop_type_color
:
107 m_color
.~web_color();
109 case prop_type_size_vector
:
110 m_size_vector
.~size_vector();
114 property_value
& operator=(const property_value
& val
)
116 this->~property_value();
120 case prop_type_invalid
:
121 new(this) property_value();
123 case prop_type_inherit
:
124 new(this) property_value(val
.m_important
, val
.m_type
);
126 case prop_type_string
:
128 new(this) property_value(val
.m_string
, val
.m_important
, val
.m_type
);
130 case prop_type_string_vector
:
131 new(this) property_value(val
.m_string_vector
, val
.m_important
);
133 case prop_type_enum_item
:
134 new(this) property_value(val
.m_enum_item
, val
.m_important
);
136 case prop_type_enum_item_vector
:
137 new(this) property_value(val
.m_enum_item_vector
, val
.m_important
);
139 case prop_type_length
:
140 new(this) property_value(val
.m_length
, val
.m_important
);
142 case prop_type_length_vector
:
143 new(this) property_value(val
.m_length_vector
, val
.m_important
);
145 case prop_type_number
:
146 new(this) property_value(val
.m_number
, val
.m_important
);
148 case prop_type_color
:
149 new(this) property_value(val
.m_color
, val
.m_important
);
151 case prop_type_size_vector
:
152 new(this) property_value(val
.m_size_vector
, val
.m_important
);
160 typedef std::map
<string_id
, property_value
> props_map
;
165 typedef std::shared_ptr
<style
> ptr
;
166 typedef std::vector
<style::ptr
> vector
;
168 props_map m_properties
;
169 static std::map
<string_id
, string
> m_valid_values
;
171 void add(const string
& txt
, const string
& baseurl
= "", document_container
* container
= nullptr)
173 parse(txt
, baseurl
, container
);
176 void add_property(string_id name
, const string
& val
, const string
& baseurl
= "", bool important
= false, document_container
* container
= nullptr);
178 const property_value
& get_property(string_id name
) const;
180 void combine(const style
& src
);
183 m_properties
.clear();
186 void subst_vars(const element
* el
);
189 void parse_property(const string
& txt
, const string
& baseurl
, document_container
* container
);
190 void parse(const string
& txt
, const string
& baseurl
, document_container
* container
);
191 void parse_background(const string
& val
, const string
& baseurl
, bool important
, document_container
* container
);
192 bool parse_one_background(const string
& val
, document_container
* container
, background
& bg
);
193 void parse_background_image(const string
& val
, const string
& baseurl
, bool important
);
194 // parse comma-separated list of keywords
195 void parse_keyword_comma_list(string_id name
, const string
& val
, bool important
);
196 void parse_background_position(const string
& val
, bool important
);
197 bool parse_one_background_position(const string
& val
, css_length
& x
, css_length
& y
);
198 void parse_background_size(const string
& val
, bool important
);
199 bool parse_one_background_size(const string
& val
, css_size
& size
);
200 void parse_font(const string
& val
, bool important
);
201 void parse_flex(const string
& val
, bool important
);
202 void parse_align_self(string_id name
, const string
& val
, bool important
);
203 static css_length
parse_border_width(const string
& str
);
204 static void parse_two_lengths(const string
& str
, css_length len
[2]);
205 static int parse_four_lengths(const string
& str
, css_length len
[4]);
206 static void subst_vars_(string
& str
, const element
* el
);
208 void add_parsed_property(string_id name
, const property_value
& propval
);
209 void remove_property(string_id name
, bool important
);