qcssparser.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qcssparser.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10using namespace QCss;-
11-
12struct QCssKnownValue-
13{-
14 const char name[28];-
15 quint64 id;-
16};-
17-
18static const QCssKnownValue properties[NumProperties - 1] = {-
19 { "-qt-background-role", QtBackgroundRole },-
20 { "-qt-block-indent", QtBlockIndent },-
21 { "-qt-line-height-type", QtLineHeightType },-
22 { "-qt-list-indent", QtListIndent },-
23 { "-qt-list-number-prefix", QtListNumberPrefix },-
24 { "-qt-list-number-suffix", QtListNumberSuffix },-
25 { "-qt-paragraph-type", QtParagraphType },-
26 { "-qt-style-features", QtStyleFeatures },-
27 { "-qt-table-type", QtTableType },-
28 { "-qt-user-state", QtUserState },-
29 { "alternate-background-color", QtAlternateBackground },-
30 { "background", Background },-
31 { "background-attachment", BackgroundAttachment },-
32 { "background-clip", BackgroundClip },-
33 { "background-color", BackgroundColor },-
34 { "background-image", BackgroundImage },-
35 { "background-origin", BackgroundOrigin },-
36 { "background-position", BackgroundPosition },-
37 { "background-repeat", BackgroundRepeat },-
38 { "border", Border },-
39 { "border-bottom", BorderBottom },-
40 { "border-bottom-color", BorderBottomColor },-
41 { "border-bottom-left-radius", BorderBottomLeftRadius },-
42 { "border-bottom-right-radius", BorderBottomRightRadius },-
43 { "border-bottom-style", BorderBottomStyle },-
44 { "border-bottom-width", BorderBottomWidth },-
45 { "border-color", BorderColor },-
46 { "border-image", BorderImage },-
47 { "border-left", BorderLeft },-
48 { "border-left-color", BorderLeftColor },-
49 { "border-left-style", BorderLeftStyle },-
50 { "border-left-width", BorderLeftWidth },-
51 { "border-radius", BorderRadius },-
52 { "border-right", BorderRight },-
53 { "border-right-color", BorderRightColor },-
54 { "border-right-style", BorderRightStyle },-
55 { "border-right-width", BorderRightWidth },-
56 { "border-style", BorderStyles },-
57 { "border-top", BorderTop },-
58 { "border-top-color", BorderTopColor },-
59 { "border-top-left-radius", BorderTopLeftRadius },-
60 { "border-top-right-radius", BorderTopRightRadius },-
61 { "border-top-style", BorderTopStyle },-
62 { "border-top-width", BorderTopWidth },-
63 { "border-width", BorderWidth },-
64 { "bottom", Bottom },-
65 { "color", Color },-
66 { "float", Float },-
67 { "font", Font },-
68 { "font-family", FontFamily },-
69 { "font-size", FontSize },-
70 { "font-style", FontStyle },-
71 { "font-variant", FontVariant },-
72 { "font-weight", FontWeight },-
73 { "height", Height },-
74 { "image", QtImage },-
75 { "image-position", QtImageAlignment },-
76 { "left", Left },-
77 { "line-height", LineHeight },-
78 { "list-style", ListStyle },-
79 { "list-style-type", ListStyleType },-
80 { "margin" , Margin },-
81 { "margin-bottom", MarginBottom },-
82 { "margin-left", MarginLeft },-
83 { "margin-right", MarginRight },-
84 { "margin-top", MarginTop },-
85 { "max-height", MaximumHeight },-
86 { "max-width", MaximumWidth },-
87 { "min-height", MinimumHeight },-
88 { "min-width", MinimumWidth },-
89 { "outline", Outline },-
90 { "outline-bottom-left-radius", OutlineBottomLeftRadius },-
91 { "outline-bottom-right-radius", OutlineBottomRightRadius },-
92 { "outline-color", OutlineColor },-
93 { "outline-offset", OutlineOffset },-
94 { "outline-radius", OutlineRadius },-
95 { "outline-style", OutlineStyle },-
96 { "outline-top-left-radius", OutlineTopLeftRadius },-
97 { "outline-top-right-radius", OutlineTopRightRadius },-
98 { "outline-width", OutlineWidth },-
99 { "padding", Padding },-
100 { "padding-bottom", PaddingBottom },-
101 { "padding-left", PaddingLeft },-
102 { "padding-right", PaddingRight },-
103 { "padding-top", PaddingTop },-
104 { "page-break-after", PageBreakAfter },-
105 { "page-break-before", PageBreakBefore },-
106 { "position", Position },-
107 { "right", Right },-
108 { "selection-background-color", QtSelectionBackground },-
109 { "selection-color", QtSelectionForeground },-
110 { "spacing", QtSpacing },-
111 { "subcontrol-origin", QtOrigin },-
112 { "subcontrol-position", QtPosition },-
113 { "text-align", TextAlignment },-
114 { "text-decoration", TextDecoration },-
115 { "text-indent", TextIndent },-
116 { "text-transform", TextTransform },-
117 { "text-underline-style", TextUnderlineStyle },-
118 { "top", Top },-
119 { "vertical-align", VerticalAlignment },-
120 { "white-space", Whitespace },-
121 { "width", Width }-
122};-
123-
124static const QCssKnownValue values[NumKnownValues - 1] = {-
125 { "active", Value_Active },-
126 { "alternate-base", Value_AlternateBase },-
127 { "always", Value_Always },-
128 { "auto", Value_Auto },-
129 { "base", Value_Base },-
130 { "bold", Value_Bold },-
131 { "bottom", Value_Bottom },-
132 { "bright-text", Value_BrightText },-
133 { "button", Value_Button },-
134 { "button-text", Value_ButtonText },-
135 { "center", Value_Center },-
136 { "circle", Value_Circle },-
137 { "dark", Value_Dark },-
138 { "dashed", Value_Dashed },-
139 { "decimal", Value_Decimal },-
140 { "disabled", Value_Disabled },-
141 { "disc", Value_Disc },-
142 { "dot-dash", Value_DotDash },-
143 { "dot-dot-dash", Value_DotDotDash },-
144 { "dotted", Value_Dotted },-
145 { "double", Value_Double },-
146 { "groove", Value_Groove },-
147 { "highlight", Value_Highlight },-
148 { "highlighted-text", Value_HighlightedText },-
149 { "inset", Value_Inset },-
150 { "italic", Value_Italic },-
151 { "large", Value_Large },-
152 { "left", Value_Left },-
153 { "light", Value_Light },-
154 { "line-through", Value_LineThrough },-
155 { "link", Value_Link },-
156 { "link-visited", Value_LinkVisited },-
157 { "lower-alpha", Value_LowerAlpha },-
158 { "lower-roman", Value_LowerRoman },-
159 { "lowercase", Value_Lowercase },-
160 { "medium", Value_Medium },-
161 { "mid", Value_Mid },-
162 { "middle", Value_Middle },-
163 { "midlight", Value_Midlight },-
164 { "native", Value_Native },-
165 { "none", Value_None },-
166 { "normal", Value_Normal },-
167 { "nowrap", Value_NoWrap },-
168 { "oblique", Value_Oblique },-
169 { "off", Value_Off },-
170 { "on", Value_On },-
171 { "outset", Value_Outset },-
172 { "overline", Value_Overline },-
173 { "pre", Value_Pre },-
174 { "pre-wrap", Value_PreWrap },-
175 { "ridge", Value_Ridge },-
176 { "right", Value_Right },-
177 { "selected", Value_Selected },-
178 { "shadow", Value_Shadow },-
179 { "small" , Value_Small },-
180 { "small-caps", Value_SmallCaps },-
181 { "solid", Value_Solid },-
182 { "square", Value_Square },-
183 { "sub", Value_Sub },-
184 { "super", Value_Super },-
185 { "text", Value_Text },-
186 { "top", Value_Top },-
187 { "transparent", Value_Transparent },-
188 { "underline", Value_Underline },-
189 { "upper-alpha", Value_UpperAlpha },-
190 { "upper-roman", Value_UpperRoman },-
191 { "uppercase", Value_Uppercase },-
192 { "wave", Value_Wave },-
193 { "window", Value_Window },-
194 { "window-text", Value_WindowText },-
195 { "x-large", Value_XLarge },-
196 { "xx-large", Value_XXLarge }-
197};-
198-
199-
200static const short indexOfId[NumKnownValues] = { 0, 41, 48, 42, 49, 54, 35, 26, 70, 71, 25, 43, 5, 63, 47,-
201 29, 58, 59, 27, 51, 61, 6, 10, 39, 56, 19, 13, 17, 18, 20, 21, 50, 24, 46, 67, 37, 3, 2, 40, 62, 16,-
202 11, 57, 14, 32, 64, 33, 65, 55, 66, 34, 69, 8, 28, 38, 12, 36, 60, 7, 9, 4, 68, 53, 22, 23, 30, 31,-
203 1, 15, 0, 52, 45, 44 };-
204-
205QString Value::toString() const-
206{-
207 if (type == KnownIdentifier
type == KnownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
208 return
never executed: return QLatin1String(values[indexOfId[variant.toInt()]].name);
QLatin1String(values[indexOfId[variant.toInt()]].name);
never executed: return QLatin1String(values[indexOfId[variant.toInt()]].name);
0
209 } else {-
210 return
never executed: return variant.toString();
variant.toString();
never executed: return variant.toString();
0
211 }-
212}-
213-
214static const QCssKnownValue pseudos[NumPseudos - 1] = {-
215 { "active", PseudoClass_Active },-
216 { "adjoins-item", PseudoClass_Item },-
217 { "alternate", PseudoClass_Alternate },-
218 { "bottom", PseudoClass_Bottom },-
219 { "checked", PseudoClass_Checked },-
220 { "closable", PseudoClass_Closable },-
221 { "closed", PseudoClass_Closed },-
222 { "default", PseudoClass_Default },-
223 { "disabled", PseudoClass_Disabled },-
224 { "edit-focus", PseudoClass_EditFocus },-
225 { "editable", PseudoClass_Editable },-
226 { "enabled", PseudoClass_Enabled },-
227 { "exclusive", PseudoClass_Exclusive },-
228 { "first", PseudoClass_First },-
229 { "flat", PseudoClass_Flat },-
230 { "floatable", PseudoClass_Floatable },-
231 { "focus", PseudoClass_Focus },-
232 { "has-children", PseudoClass_Children },-
233 { "has-siblings", PseudoClass_Sibling },-
234 { "horizontal", PseudoClass_Horizontal },-
235 { "hover", PseudoClass_Hover },-
236 { "indeterminate" , PseudoClass_Indeterminate },-
237 { "last", PseudoClass_Last },-
238 { "left", PseudoClass_Left },-
239 { "maximized", PseudoClass_Maximized },-
240 { "middle", PseudoClass_Middle },-
241 { "minimized", PseudoClass_Minimized },-
242 { "movable", PseudoClass_Movable },-
243 { "next-selected", PseudoClass_NextSelected },-
244 { "no-frame", PseudoClass_Frameless },-
245 { "non-exclusive", PseudoClass_NonExclusive },-
246 { "off", PseudoClass_Unchecked },-
247 { "on", PseudoClass_Checked },-
248 { "only-one", PseudoClass_OnlyOne },-
249 { "open", PseudoClass_Open },-
250 { "pressed", PseudoClass_Pressed },-
251 { "previous-selected", PseudoClass_PreviousSelected },-
252 { "read-only", PseudoClass_ReadOnly },-
253 { "right", PseudoClass_Right },-
254 { "selected", PseudoClass_Selected },-
255 { "top", PseudoClass_Top },-
256 { "unchecked" , PseudoClass_Unchecked },-
257 { "vertical", PseudoClass_Vertical },-
258 { "window", PseudoClass_Window }-
259};-
260-
261static const QCssKnownValue origins[NumKnownOrigins - 1] = {-
262 { "border", Origin_Border },-
263 { "content", Origin_Content },-
264 { "margin", Origin_Margin },-
265 { "padding", Origin_Padding }-
266};-
267-
268static const QCssKnownValue repeats[NumKnownRepeats - 1] = {-
269 { "no-repeat", Repeat_None },-
270 { "repeat-x", Repeat_X },-
271 { "repeat-xy", Repeat_XY },-
272 { "repeat-y", Repeat_Y }-
273};-
274-
275static const QCssKnownValue tileModes[NumKnownTileModes - 1] = {-
276 { "repeat", TileMode_Repeat },-
277 { "round", TileMode_Round },-
278 { "stretch", TileMode_Stretch },-
279};-
280-
281static const QCssKnownValue positions[NumKnownPositionModes - 1] = {-
282 { "absolute", PositionMode_Absolute },-
283 { "fixed", PositionMode_Fixed },-
284 { "relative", PositionMode_Relative },-
285 { "static", PositionMode_Static }-
286};-
287-
288static const QCssKnownValue attachments[NumKnownAttachments - 1] = {-
289 { "fixed", Attachment_Fixed },-
290 { "scroll", Attachment_Scroll }-
291};-
292-
293static const QCssKnownValue styleFeatures[NumKnownStyleFeatures - 1] = {-
294 { "background-color", StyleFeature_BackgroundColor },-
295 { "background-gradient", StyleFeature_BackgroundGradient },-
296 { "none", StyleFeature_None }-
297};-
298static bool operator<(const QString &name, const QCssKnownValue &prop)-
299{-
300 return
never executed: return QString::compare(name, QLatin1String(prop.name), Qt::CaseInsensitive) < 0;
QString::compare(name, QLatin1String(prop.name), Qt::CaseInsensitive) < 0;
never executed: return QString::compare(name, QLatin1String(prop.name), Qt::CaseInsensitive) < 0;
0
301}-
302-
303static bool operator<(const QCssKnownValue &prop, const QString &name)-
304{-
305 return
never executed: return QString::compare(QLatin1String(prop.name), name, Qt::CaseInsensitive) < 0;
QString::compare(QLatin1String(prop.name), name, Qt::CaseInsensitive) < 0;
never executed: return QString::compare(QLatin1String(prop.name), name, Qt::CaseInsensitive) < 0;
0
306}-
307-
308static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, int numValues)-
309{-
310 const QCssKnownValue *end = &start[numValues - 1];-
311 const QCssKnownValue *prop = std::lower_bound(start, end, name);-
312 if ((
(prop == end)Description
TRUEnever evaluated
FALSEnever evaluated
prop == end)
(prop == end)Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(name < *prop)Description
TRUEnever evaluated
FALSEnever evaluated
name < *prop)
(name < *prop)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
313 return
never executed: return 0;
0;
never executed: return 0;
0
314 return
never executed: return prop->id;
prop->id;
never executed: return prop->id;
0
315}-
316-
317static inline bool isInheritable(Property propertyId)-
318{-
319 switch (propertyId) {-
320 case
never executed: case Font:
Font:
never executed: case Font:
0
321 case
never executed: case FontFamily:
FontFamily:
never executed: case FontFamily:
0
322 case
never executed: case FontSize:
FontSize:
never executed: case FontSize:
0
323 case
never executed: case FontStyle:
FontStyle:
never executed: case FontStyle:
0
324 case
never executed: case FontWeight:
FontWeight:
never executed: case FontWeight:
0
325 case
never executed: case TextIndent:
TextIndent:
never executed: case TextIndent:
0
326 case
never executed: case Whitespace:
Whitespace:
never executed: case Whitespace:
0
327 case
never executed: case ListStyleType:
ListStyleType:
never executed: case ListStyleType:
0
328 case
never executed: case ListStyle:
ListStyle:
never executed: case ListStyle:
0
329 case
never executed: case TextAlignment:
TextAlignment:
never executed: case TextAlignment:
0
330 case
never executed: case FontVariant:
FontVariant:
never executed: case FontVariant:
0
331 case
never executed: case TextTransform:
TextTransform:
never executed: case TextTransform:
0
332 case
never executed: case LineHeight:
LineHeight:
never executed: case LineHeight:
0
333 return
never executed: return true;
true;
never executed: return true;
0
334 default
never executed: default:
:
never executed: default:
0
335 break;
never executed: break;
0
336 }-
337 return
never executed: return false;
false;
never executed: return false;
0
338}-
339-
340-
341-
342ValueExtractor::ValueExtractor(const QVector<Declaration> &decls, const QPalette &pal)-
343: declarations(decls), adjustment(0), fontExtracted(false), pal(pal)-
344{-
345}
never executed: end of block
0
346-
347LengthData ValueExtractor::lengthValue(const Value& v)-
348{-
349 QString s = v.variant.toString();-
350 s.reserve(s.length());-
351 LengthData data;-
352 data.unit = LengthData::None;-
353 if (s.endsWith(QLatin1String("px"), Qt::CaseInsensitive)
s.endsWith(QLa...seInsensitive)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
354 data.unit = LengthData::Px;
never executed: data.unit = LengthData::Px;
0
355 else if (s.endsWith(QLatin1String("ex"), Qt::CaseInsensitive)
s.endsWith(QLa...seInsensitive)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
356 data.unit = LengthData::Ex;
never executed: data.unit = LengthData::Ex;
0
357 else if (s.endsWith(QLatin1String("em"), Qt::CaseInsensitive)
s.endsWith(QLa...seInsensitive)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
358 data.unit = LengthData::Em;
never executed: data.unit = LengthData::Em;
0
359-
360 if (data.unit != LengthData::None
data.unit != LengthData::NoneDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
361 s.chop(2);
never executed: s.chop(2);
0
362-
363 data.number = s.toDouble();-
364 return
never executed: return data;
data;
never executed: return data;
0
365}-
366-
367static int lengthValueFromData(const LengthData& data, const QFont& f)-
368{-
369 if (data.unit == LengthData::Ex
data.unit == LengthData::ExDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
370 return
never executed: return qRound(QFontMetrics(f).xHeight() * data.number);
qRound(QFontMetrics(f).xHeight() * data.number);
never executed: return qRound(QFontMetrics(f).xHeight() * data.number);
0
371 else if (data.unit == LengthData::Em
data.unit == LengthData::EmDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
372 return
never executed: return qRound(QFontMetrics(f).height() * data.number);
qRound(QFontMetrics(f).height() * data.number);
never executed: return qRound(QFontMetrics(f).height() * data.number);
0
373 return
never executed: return qRound(data.number);
qRound(data.number);
never executed: return qRound(data.number);
0
374}-
375-
376int ValueExtractor::lengthValue(const Declaration &decl)-
377{-
378 if (decl.d->parsed.isValid()
decl.d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
379 return
never executed: return lengthValueFromData(qvariant_cast<LengthData>(decl.d->parsed), f);
lengthValueFromData(qvariant_cast<LengthData>(decl.d->parsed), f);
never executed: return lengthValueFromData(qvariant_cast<LengthData>(decl.d->parsed), f);
0
380 if (decl.d->values.count() < 1
decl.d->values.count() < 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
381 return
never executed: return 0;
0;
never executed: return 0;
0
382 LengthData data = lengthValue(decl.d->values.at(0));-
383 decl.d->parsed = QVariant::fromValue<LengthData>(data);-
384 return
never executed: return lengthValueFromData(data,f);
lengthValueFromData(data,f);
never executed: return lengthValueFromData(data,f);
0
385}-
386-
387void ValueExtractor::lengthValues(const Declaration &decl, int *m)-
388{-
389 if (decl.d->parsed.isValid()
decl.d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
390 QList<QVariant> v = decl.d->parsed.toList();-
391 for (int i = 0; i < 4
i < 4Description
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
392 m[i] = lengthValueFromData(qvariant_cast<LengthData>(v.at(i)), f);
never executed: m[i] = lengthValueFromData(qvariant_cast<LengthData>(v.at(i)), f);
0
393 return;
never executed: return;
0
394 }-
395-
396 LengthData datas[4];-
397 int i;-
398 for (i = 0; i < qMin(decl.d->values.count(), 4)
i < qMin(decl....es.count(), 4)Description
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
399 datas[i] = lengthValue(decl.d->values[i]);
never executed: datas[i] = lengthValue(decl.d->values[i]);
0
400-
401 if (i == 0
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
402 LengthData zero = {0.0, LengthData::None};-
403 datas[0] = datas[1] = datas[2] = datas[3] = zero;-
404 }
never executed: end of block
else if (i == 1
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
405 datas[3] = datas[2] = datas[1] = datas[0];-
406 }
never executed: end of block
else if (i == 2
i == 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
407 datas[2] = datas[0];-
408 datas[3] = datas[1];-
409 }
never executed: end of block
else if (i == 3
i == 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
410 datas[3] = datas[1];-
411 }
never executed: end of block
0
412-
413 QList<QVariant> v;-
414 v.reserve(4);-
415 for (i = 0; i < 4
i < 4Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
416 v += QVariant::fromValue<LengthData>(datas[i]);-
417 m[i] = lengthValueFromData(datas[i], f);-
418 }
never executed: end of block
0
419 decl.d->parsed = v;-
420}
never executed: end of block
0
421-
422bool ValueExtractor::extractGeometry(int *w, int *h, int *minw, int *minh, int *maxw, int *maxh)-
423{-
424 extractFont();-
425 bool hit = false;-
426 for (int i = 0; i < declarations.count()
i < declarations.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
427 const Declaration &decl = declarations.at(i);-
428 switch (decl.d->propertyId) {-
429 case
never executed: case Width:
Width:
never executed: case Width:
*w = lengthValue(decl); break;
never executed: break;
0
430 case
never executed: case Height:
Height:
never executed: case Height:
*h = lengthValue(decl); break;
never executed: break;
0
431 case
never executed: case MinimumWidth:
MinimumWidth:
never executed: case MinimumWidth:
*minw = lengthValue(decl); break;
never executed: break;
0
432 case
never executed: case MinimumHeight:
MinimumHeight:
never executed: case MinimumHeight:
*minh = lengthValue(decl); break;
never executed: break;
0
433 case
never executed: case MaximumWidth:
MaximumWidth:
never executed: case MaximumWidth:
*maxw = lengthValue(decl); break;
never executed: break;
0
434 case
never executed: case MaximumHeight:
MaximumHeight:
never executed: case MaximumHeight:
*maxh = lengthValue(decl); break;
never executed: break;
0
435 default
never executed: default:
:
never executed: default:
continue;
never executed: continue;
0
436 }-
437 hit = true;-
438 }
never executed: end of block
0
439-
440 return
never executed: return hit;
hit;
never executed: return hit;
0
441}-
442-
443bool ValueExtractor::extractPosition(int *left, int *top, int *right, int *bottom, QCss::Origin *origin,-
444 Qt::Alignment *position, QCss::PositionMode *mode, Qt::Alignment *textAlignment)-
445{-
446 extractFont();-
447 bool hit = false;-
448 for (int i = 0; i < declarations.count()
i < declarations.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
449 const Declaration &decl = declarations.at(i);-
450 switch (decl.d->propertyId) {-
451 case
never executed: case Left:
Left:
never executed: case Left:
*left = lengthValue(decl); break;
never executed: break;
0
452 case
never executed: case Top:
Top:
never executed: case Top:
*top = lengthValue(decl); break;
never executed: break;
0
453 case
never executed: case Right:
Right:
never executed: case Right:
*right = lengthValue(decl); break;
never executed: break;
0
454 case
never executed: case Bottom:
Bottom:
never executed: case Bottom:
*bottom = lengthValue(decl); break;
never executed: break;
0
455 case
never executed: case QtOrigin:
QtOrigin:
never executed: case QtOrigin:
*origin = decl.originValue(); break;
never executed: break;
0
456 case
never executed: case QtPosition:
QtPosition:
never executed: case QtPosition:
*position = decl.alignmentValue(); break;
never executed: break;
0
457 case
never executed: case TextAlignment:
TextAlignment:
never executed: case TextAlignment:
*textAlignment = decl.alignmentValue(); break;
never executed: break;
0
458 case
never executed: case Position:
Position:
never executed: case Position:
*mode = decl.positionValue(); break;
never executed: break;
0
459 default
never executed: default:
:
never executed: default:
continue;
never executed: continue;
0
460 }-
461 hit = true;-
462 }
never executed: end of block
0
463-
464 return
never executed: return hit;
hit;
never executed: return hit;
0
465}-
466-
467bool ValueExtractor::extractBox(int *margins, int *paddings, int *spacing)-
468{-
469 extractFont();-
470 bool hit = false;-
471 for (int i = 0; i < declarations.count()
i < declarations.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
472 const Declaration &decl = declarations.at(i);-
473 switch (decl.d->propertyId) {-
474 case
never executed: case PaddingLeft:
PaddingLeft:
never executed: case PaddingLeft:
paddings[LeftEdge] = lengthValue(decl); break;
never executed: break;
0
475 case
never executed: case PaddingRight:
PaddingRight:
never executed: case PaddingRight:
paddings[RightEdge] = lengthValue(decl); break;
never executed: break;
0
476 case
never executed: case PaddingTop:
PaddingTop:
never executed: case PaddingTop:
paddings[TopEdge] = lengthValue(decl); break;
never executed: break;
0
477 case
never executed: case PaddingBottom:
PaddingBottom:
never executed: case PaddingBottom:
paddings[BottomEdge] = lengthValue(decl); break;
never executed: break;
0
478 case
never executed: case Padding:
Padding:
never executed: case Padding:
lengthValues(decl, paddings); break;
never executed: break;
0
479-
480 case
never executed: case MarginLeft:
MarginLeft:
never executed: case MarginLeft:
margins[LeftEdge] = lengthValue(decl); break;
never executed: break;
0
481 case
never executed: case MarginRight:
MarginRight:
never executed: case MarginRight:
margins[RightEdge] = lengthValue(decl); break;
never executed: break;
0
482 case
never executed: case MarginTop:
MarginTop:
never executed: case MarginTop:
margins[TopEdge] = lengthValue(decl); break;
never executed: break;
0
483 case
never executed: case MarginBottom:
MarginBottom:
never executed: case MarginBottom:
margins[BottomEdge] = lengthValue(decl); break;
never executed: break;
0
484 case
never executed: case Margin:
Margin:
never executed: case Margin:
lengthValues(decl, margins); break;
never executed: break;
0
485 case
never executed: case QtSpacing:
QtSpacing:
never executed: case QtSpacing:
if (spacing
spacingDescription
TRUEnever evaluated
FALSEnever evaluated
) *
never executed: *spacing = lengthValue(decl);
spacing = lengthValue(decl);
never executed: *spacing = lengthValue(decl);
break;
never executed: break;
0
486-
487 default
never executed: default:
:
never executed: default:
continue;
never executed: continue;
0
488 }-
489 hit = true;-
490 }
never executed: end of block
0
491-
492 return
never executed: return hit;
hit;
never executed: return hit;
0
493}-
494-
495int ValueExtractor::extractStyleFeatures()-
496{-
497 int features = StyleFeature_None;-
498 for (int i = 0; i < declarations.count()
i < declarations.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
499 const Declaration &decl = declarations.at(i);-
500 if (decl.d->propertyId == QtStyleFeatures
decl.d->proper...tStyleFeaturesDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
501 features = decl.styleFeaturesValue();
never executed: features = decl.styleFeaturesValue();
0
502 }
never executed: end of block
0
503 return
never executed: return features;
features;
never executed: return features;
0
504}-
505-
506QSize ValueExtractor::sizeValue(const Declaration &decl)-
507{-
508 if (decl.d->parsed.isValid()
decl.d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
509 QList<QVariant> v = decl.d->parsed.toList();-
510 return
never executed: return QSize(lengthValueFromData(qvariant_cast<LengthData>(v.at(0)), f), lengthValueFromData(qvariant_cast<LengthData>(v.at(1)), f));
QSize(lengthValueFromData(qvariant_cast<LengthData>(v.at(0)), f),
never executed: return QSize(lengthValueFromData(qvariant_cast<LengthData>(v.at(0)), f), lengthValueFromData(qvariant_cast<LengthData>(v.at(1)), f));
0
511 lengthValueFromData(qvariant_cast<LengthData>(v.at(1)), f));
never executed: return QSize(lengthValueFromData(qvariant_cast<LengthData>(v.at(0)), f), lengthValueFromData(qvariant_cast<LengthData>(v.at(1)), f));
0
512 }-
513-
514 LengthData x[2] = { {0, LengthData::None }, {0, LengthData::None} };-
515 if (decl.d->values.count() > 0
decl.d->values.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
516 x[0] = lengthValue(decl.d->values.at(0));
never executed: x[0] = lengthValue(decl.d->values.at(0));
0
517 if (decl.d->values.count() > 1
decl.d->values.count() > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
518 x[1] = lengthValue(decl.d->values.at(1));
never executed: x[1] = lengthValue(decl.d->values.at(1));
0
519 else-
520 x[1] = x[0];
never executed: x[1] = x[0];
0
521 QList<QVariant> v;-
522 v << QVariant::fromValue<LengthData>(x[0]) << QVariant::fromValue<LengthData>(x[1]);-
523 decl.d->parsed = v;-
524 return
never executed: return QSize(lengthValueFromData(x[0], f), lengthValueFromData(x[1], f));
QSize(lengthValueFromData(x[0], f), lengthValueFromData(x[1], f));
never executed: return QSize(lengthValueFromData(x[0], f), lengthValueFromData(x[1], f));
0
525}-
526-
527void ValueExtractor::sizeValues(const Declaration &decl, QSize *radii)-
528{-
529 radii[0] = sizeValue(decl);-
530 for (int i = 1; i < 4
i < 4Description
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
531 radii[i] = radii[0];
never executed: radii[i] = radii[0];
0
532}
never executed: end of block
0
533-
534bool ValueExtractor::extractBorder(int *borders, QBrush *colors, BorderStyle *styles,-
535 QSize *radii)-
536{-
537 extractFont();-
538 bool hit = false;-
539 for (int i = 0; i < declarations.count()
i < declarations.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
540 const Declaration &decl = declarations.at(i);-
541 switch (decl.d->propertyId) {-
542 case
never executed: case BorderLeftWidth:
BorderLeftWidth:
never executed: case BorderLeftWidth:
borders[LeftEdge] = lengthValue(decl); break;
never executed: break;
0
543 case
never executed: case BorderRightWidth:
BorderRightWidth:
never executed: case BorderRightWidth:
borders[RightEdge] = lengthValue(decl); break;
never executed: break;
0
544 case
never executed: case BorderTopWidth:
BorderTopWidth:
never executed: case BorderTopWidth:
borders[TopEdge] = lengthValue(decl); break;
never executed: break;
0
545 case
never executed: case BorderBottomWidth:
BorderBottomWidth:
never executed: case BorderBottomWidth:
borders[BottomEdge] = lengthValue(decl); break;
never executed: break;
0
546 case
never executed: case BorderWidth:
BorderWidth:
never executed: case BorderWidth:
lengthValues(decl, borders); break;
never executed: break;
0
547-
548 case
never executed: case BorderLeftColor:
BorderLeftColor:
never executed: case BorderLeftColor:
colors[LeftEdge] = decl.brushValue(pal); break;
never executed: break;
0
549 case
never executed: case BorderRightColor:
BorderRightColor:
never executed: case BorderRightColor:
colors[RightEdge] = decl.brushValue(pal); break;
never executed: break;
0
550 case
never executed: case BorderTopColor:
BorderTopColor:
never executed: case BorderTopColor:
colors[TopEdge] = decl.brushValue(pal); break;
never executed: break;
0
551 case
never executed: case BorderBottomColor:
BorderBottomColor:
never executed: case BorderBottomColor:
colors[BottomEdge] = decl.brushValue(pal); break;
never executed: break;
0
552 case
never executed: case BorderColor:
BorderColor:
never executed: case BorderColor:
decl.brushValues(colors, pal); break;
never executed: break;
0
553-
554 case
never executed: case BorderTopStyle:
BorderTopStyle:
never executed: case BorderTopStyle:
styles[TopEdge] = decl.styleValue(); break;
never executed: break;
0
555 case
never executed: case BorderBottomStyle:
BorderBottomStyle:
never executed: case BorderBottomStyle:
styles[BottomEdge] = decl.styleValue(); break;
never executed: break;
0
556 case
never executed: case BorderLeftStyle:
BorderLeftStyle:
never executed: case BorderLeftStyle:
styles[LeftEdge] = decl.styleValue(); break;
never executed: break;
0
557 case
never executed: case BorderRightStyle:
BorderRightStyle:
never executed: case BorderRightStyle:
styles[RightEdge] = decl.styleValue(); break;
never executed: break;
0
558 case
never executed: case BorderStyles:
BorderStyles:
never executed: case BorderStyles:
decl.styleValues(styles); break;
never executed: break;
0
559-
560-
561 case
never executed: case BorderTopLeftRadius:
BorderTopLeftRadius:
never executed: case BorderTopLeftRadius:
radii[0] = sizeValue(decl); break;
never executed: break;
0
562-
563-
564-
565 case
never executed: case BorderTopRightRadius:
BorderTopRightRadius:
never executed: case BorderTopRightRadius:
radii[1] = sizeValue(decl); break;
never executed: break;
0
566 case
never executed: case BorderBottomLeftRadius:
BorderBottomLeftRadius:
never executed: case BorderBottomLeftRadius:
radii[2] = sizeValue(decl); break;
never executed: break;
0
567 case
never executed: case BorderBottomRightRadius:
BorderBottomRightRadius:
never executed: case BorderBottomRightRadius:
radii[3] = sizeValue(decl); break;
never executed: break;
0
568 case
never executed: case BorderRadius:
BorderRadius:
never executed: case BorderRadius:
sizeValues(decl, radii); break;
never executed: break;
0
569-
570 case
never executed: case BorderLeft:
BorderLeft:
never executed: case BorderLeft:
0
571 borderValue(decl, &borders[LeftEdge], &styles[LeftEdge], &colors[LeftEdge]);-
572 break;
never executed: break;
0
573 case
never executed: case BorderTop:
BorderTop:
never executed: case BorderTop:
0
574 borderValue(decl, &borders[TopEdge], &styles[TopEdge], &colors[TopEdge]);-
575 break;
never executed: break;
0
576 case
never executed: case BorderRight:
BorderRight:
never executed: case BorderRight:
0
577 borderValue(decl, &borders[RightEdge], &styles[RightEdge], &colors[RightEdge]);-
578 break;
never executed: break;
0
579 case
never executed: case BorderBottom:
BorderBottom:
never executed: case BorderBottom:
0
580 borderValue(decl, &borders[BottomEdge], &styles[BottomEdge], &colors[BottomEdge]);-
581 break;
never executed: break;
0
582 case
never executed: case Border:
Border:
never executed: case Border:
0
583 borderValue(decl, &borders[LeftEdge], &styles[LeftEdge], &colors[LeftEdge]);-
584 borders[TopEdge] = borders[RightEdge] = borders[BottomEdge] = borders[LeftEdge];-
585 styles[TopEdge] = styles[RightEdge] = styles[BottomEdge] = styles[LeftEdge];-
586 colors[TopEdge] = colors[RightEdge] = colors[BottomEdge] = colors[LeftEdge];-
587 break;
never executed: break;
0
588-
589 default
never executed: default:
:
never executed: default:
continue;
never executed: continue;
0
590 }-
591 hit = true;-
592 }
never executed: end of block
0
593-
594 return
never executed: return hit;
hit;
never executed: return hit;
0
595}-
596-
597bool ValueExtractor::extractOutline(int *borders, QBrush *colors, BorderStyle *styles,-
598 QSize *radii, int *offsets)-
599{-
600 extractFont();-
601 bool hit = false;-
602 for (int i = 0; i < declarations.count()
i < declarations.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
603 const Declaration &decl = declarations.at(i);-
604 switch (decl.d->propertyId) {-
605 case
never executed: case OutlineWidth:
OutlineWidth:
never executed: case OutlineWidth:
lengthValues(decl, borders); break;
never executed: break;
0
606 case
never executed: case OutlineColor:
OutlineColor:
never executed: case OutlineColor:
decl.brushValues(colors, pal); break;
never executed: break;
0
607 case
never executed: case OutlineStyle:
OutlineStyle:
never executed: case OutlineStyle:
decl.styleValues(styles); break;
never executed: break;
0
608-
609 case
never executed: case OutlineTopLeftRadius:
OutlineTopLeftRadius:
never executed: case OutlineTopLeftRadius:
radii[0] = sizeValue(decl); break;
never executed: break;
0
610 case
never executed: case OutlineTopRightRadius:
OutlineTopRightRadius:
never executed: case OutlineTopRightRadius:
radii[1] = sizeValue(decl); break;
never executed: break;
0
611 case
never executed: case OutlineBottomLeftRadius:
OutlineBottomLeftRadius:
never executed: case OutlineBottomLeftRadius:
radii[2] = sizeValue(decl); break;
never executed: break;
0
612 case
never executed: case OutlineBottomRightRadius:
OutlineBottomRightRadius:
never executed: case OutlineBottomRightRadius:
radii[3] = sizeValue(decl); break;
never executed: break;
0
613 case
never executed: case OutlineRadius:
OutlineRadius:
never executed: case OutlineRadius:
sizeValues(decl, radii); break;
never executed: break;
0
614 case
never executed: case OutlineOffset:
OutlineOffset:
never executed: case OutlineOffset:
lengthValues(decl, offsets); break;
never executed: break;
0
615-
616 case
never executed: case Outline:
Outline:
never executed: case Outline:
0
617 borderValue(decl, &borders[LeftEdge], &styles[LeftEdge], &colors[LeftEdge]);-
618 borders[TopEdge] = borders[RightEdge] = borders[BottomEdge] = borders[LeftEdge];-
619 styles[TopEdge] = styles[RightEdge] = styles[BottomEdge] = styles[LeftEdge];-
620 colors[TopEdge] = colors[RightEdge] = colors[BottomEdge] = colors[LeftEdge];-
621 break;
never executed: break;
0
622-
623 default
never executed: default:
:
never executed: default:
continue;
never executed: continue;
0
624 }-
625 hit = true;-
626 }
never executed: end of block
0
627-
628 return
never executed: return hit;
hit;
never executed: return hit;
0
629}-
630-
631static Qt::Alignment parseAlignment(const QCss::Value *values, int count)-
632{-
633 Qt::Alignment a[2] = { 0, 0 };-
634 for (int i = 0; i < qMin(2, count)
i < qMin(2, count)Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
635 if (values[i].type != Value::KnownIdentifier
values[i].type...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
636 break;
never executed: break;
0
637 switch (values[i].variant.toInt()) {-
638 case
never executed: case Value_Left:
Value_Left:
never executed: case Value_Left:
a[i] = Qt::AlignLeft; break;
never executed: break;
0
639 case
never executed: case Value_Right:
Value_Right:
never executed: case Value_Right:
a[i] = Qt::AlignRight; break;
never executed: break;
0
640 case
never executed: case Value_Top:
Value_Top:
never executed: case Value_Top:
a[i] = Qt::AlignTop; break;
never executed: break;
0
641 case
never executed: case Value_Bottom:
Value_Bottom:
never executed: case Value_Bottom:
a[i] = Qt::AlignBottom; break;
never executed: break;
0
642 case
never executed: case Value_Center:
Value_Center:
never executed: case Value_Center:
a[i] = Qt::AlignCenter; break;
never executed: break;
0
643 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
644 }-
645 }-
646-
647 if (a[0] == Qt::AlignCenter
a[0] == Qt::AlignCenterDescription
TRUEnever evaluated
FALSEnever evaluated
&& a[1] != 0
a[1] != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& a[1] != Qt::AlignCenter
a[1] != Qt::AlignCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
648 a[0] = (a[1] == Qt::AlignLeft
a[1] == Qt::AlignLeftDescription
TRUEnever evaluated
FALSEnever evaluated
|| a[1] == Qt::AlignRight
a[1] == Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
) ? Qt::AlignVCenter : Qt::AlignHCenter;
never executed: a[0] = (a[1] == Qt::AlignLeft || a[1] == Qt::AlignRight) ? Qt::AlignVCenter : Qt::AlignHCenter;
0
649 if ((a[1] == 0
a[1] == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| a[1] == Qt::AlignCenter
a[1] == Qt::AlignCenterDescription
TRUEnever evaluated
FALSEnever evaluated
) && a[0] != Qt::AlignCenter
a[0] != Qt::AlignCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
650 a[1] = (a[0] == Qt::AlignLeft
a[0] == Qt::AlignLeftDescription
TRUEnever evaluated
FALSEnever evaluated
|| a[0] == Qt::AlignRight
a[0] == Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
) ? Qt::AlignVCenter : Qt::AlignHCenter;
never executed: a[1] = (a[0] == Qt::AlignLeft || a[0] == Qt::AlignRight) ? Qt::AlignVCenter : Qt::AlignHCenter;
0
651 return
never executed: return a[0] | a[1];
a[0] | a[1];
never executed: return a[0] | a[1];
0
652}-
653-
654static ColorData parseColorValue(QCss::Value v)-
655{-
656 if (v.type == Value::Identifier
v.type == Value::IdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
|| v.type == Value::String
v.type == Value::StringDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
657 v.variant.convert(QVariant::Color);-
658 v.type = Value::Color;-
659 }
never executed: end of block
0
660-
661 if (v.type == Value::Color
v.type == Value::ColorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
662 return
never executed: return qvariant_cast<QColor>(v.variant);
qvariant_cast<QColor>(v.variant);
never executed: return qvariant_cast<QColor>(v.variant);
0
663-
664 if (v.type == Value::KnownIdentifier
v.type == Valu...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
&& v.variant.toInt() == Value_Transparent
v.variant.toIn...ue_TransparentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
665 return
never executed: return QColor(Qt::transparent);
QColor(Qt::transparent);
never executed: return QColor(Qt::transparent);
0
666-
667 if (v.type != Value::Function
v.type != Value::FunctionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
668 return
never executed: return ColorData();
ColorData();
never executed: return ColorData();
0
669-
670 QStringList lst = v.variant.toStringList();-
671 if (lst.count() != 2
lst.count() != 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
672 return
never executed: return ColorData();
ColorData();
never executed: return ColorData();
0
673-
674 if ((
(lst.at(0).com...nsitive)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
lst.at(0).compare(QLatin1String("palette"), Qt::CaseInsensitive)) == 0
(lst.at(0).com...nsitive)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
675 int role = findKnownValue(lst.at(1).trimmed(), values, NumKnownValues);-
676 if (role >= Value_FirstColorRole
role >= Value_FirstColorRoleDescription
TRUEnever evaluated
FALSEnever evaluated
&& role <= Value_LastColorRole
role <= Value_LastColorRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
677 return
never executed: return (QPalette::ColorRole)(role-Value_FirstColorRole);
(QPalette::ColorRole)(role-Value_FirstColorRole);
never executed: return (QPalette::ColorRole)(role-Value_FirstColorRole);
0
678-
679 return
never executed: return ColorData();
ColorData();
never executed: return ColorData();
0
680 }-
681-
682 bool rgb = lst.at(0).startsWith(QLatin1String("rgb"));-
683 bool rgba = lst.at(0).startsWith(QLatin1String("rgba"));-
684-
685 Parser p(lst.at(1));-
686 if (!p.testExpr()
!p.testExpr()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
687 return
never executed: return ColorData();
ColorData();
never executed: return ColorData();
0
688-
689 QVector<QCss::Value> colorDigits;-
690 if (!p.parseExpr(&colorDigits)
!p.parseExpr(&colorDigits)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
691 return
never executed: return ColorData();
ColorData();
never executed: return ColorData();
0
692 const int tokenCount = colorDigits.count();-
693-
694 for (int i = 0; i < qMin(tokenCount, 7)
i < qMin(tokenCount, 7)Description
TRUEnever evaluated
FALSEnever evaluated
; i += 2) {
0
695 if (colorDigits.at(i).type == Value::Percentage
colorDigits.at...ue::PercentageDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
696 colorDigits[i].variant = colorDigits.at(i).variant.toReal() * (255. / 100.);-
697 colorDigits[i].type = Value::Number;-
698 }
never executed: end of block
else if (colorDigits.at(i).type != Value::Number
colorDigits.at... Value::NumberDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
699 return
never executed: return ColorData();
ColorData();
never executed: return ColorData();
0
700 }-
701 }
never executed: end of block
0
702-
703-
704 if (tokenCount < 5
tokenCount < 5Description
TRUEnever evaluated
FALSEnever evaluated
)
0
705 return
never executed: return ColorData();
ColorData();
never executed: return ColorData();
0
706-
707 int v1 = colorDigits.at(0).variant.toInt();-
708 int v2 = colorDigits.at(2).variant.toInt();-
709 int v3 = colorDigits.at(4).variant.toInt();-
710 int alpha = 255;-
711 if (tokenCount >= 7
tokenCount >= 7Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
712 int alphaValue = colorDigits.at(6).variant.toInt();-
713 if (rgba
rgbaDescription
TRUEnever evaluated
FALSEnever evaluated
&& alphaValue <= 1
alphaValue <= 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
714 alpha = colorDigits.at(6).variant.toReal() * 255.;
never executed: alpha = colorDigits.at(6).variant.toReal() * 255.;
0
715 else-
716 alpha = alphaValue;
never executed: alpha = alphaValue;
0
717 }-
718-
719 return
never executed: return rgb ? QColor::fromRgb(v1, v2, v3, alpha) : QColor::fromHsv(v1, v2, v3, alpha);
rgb ? QColor::fromRgb(v1, v2, v3, alpha)
never executed: return rgb ? QColor::fromRgb(v1, v2, v3, alpha) : QColor::fromHsv(v1, v2, v3, alpha);
0
720 : QColor::fromHsv(v1, v2, v3, alpha);
never executed: return rgb ? QColor::fromRgb(v1, v2, v3, alpha) : QColor::fromHsv(v1, v2, v3, alpha);
0
721}-
722-
723static QColor colorFromData(const ColorData& c, const QPalette &pal)-
724{-
725 if (c.type == ColorData::Color
c.type == ColorData::ColorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
726 return
never executed: return c.color;
c.color;
never executed: return c.color;
0
727 } else if (c.type == ColorData::Role
c.type == ColorData::RoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
728 return
never executed: return pal.color(c.role);
pal.color(c.role);
never executed: return pal.color(c.role);
0
729 }-
730 return
never executed: return QColor();
QColor();
never executed: return QColor();
0
731}-
732-
733static BrushData parseBrushValue(const QCss::Value &v, const QPalette &pal)-
734{-
735 ColorData c = parseColorValue(v);-
736 if (c.type == ColorData::Color
c.type == ColorData::ColorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
737 return
never executed: return QBrush(c.color);
QBrush(c.color);
never executed: return QBrush(c.color);
0
738 } else if (c.type == ColorData::Role
c.type == ColorData::RoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
739 return
never executed: return c.role;
c.role;
never executed: return c.role;
0
740 }-
741-
742 if (v.type != Value::Function
v.type != Value::FunctionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
743 return
never executed: return BrushData();
BrushData();
never executed: return BrushData();
0
744-
745 QStringList lst = v.variant.toStringList();-
746 if (lst.count() != 2
lst.count() != 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
747 return
never executed: return BrushData();
BrushData();
never executed: return BrushData();
0
748-
749 QStringList gradFuncs;-
750 gradFuncs << QLatin1String("qlineargradient") << QLatin1String("qradialgradient") << QLatin1String("qconicalgradient") << QLatin1String("qgradient");-
751 int gradType = -1;-
752-
753 if ((
(gradType = gr...ower())) == -1Description
TRUEnever evaluated
FALSEnever evaluated
gradType = gradFuncs.indexOf(lst.at(0).toLower())) == -1
(gradType = gr...ower())) == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
754 return
never executed: return BrushData();
BrushData();
never executed: return BrushData();
0
755-
756 QHash<QString, qreal> vars;-
757 QVector<QGradientStop> stops;-
758-
759 int spread = -1;-
760 QStringList spreads;-
761 spreads << QLatin1String("pad") << QLatin1String("reflect") << QLatin1String("repeat");-
762-
763 bool dependsOnThePalette = false;-
764 Parser parser(lst.at(1));-
765 while (parser.hasNext()
parser.hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
766 parser.skipSpace();-
767 if (!parser.test(IDENT)
!parser.test(IDENT)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
768 return
never executed: return BrushData();
BrushData();
never executed: return BrushData();
0
769 QString attr = parser.lexem();-
770 parser.skipSpace();-
771 if (!parser.test(COLON)
!parser.test(COLON)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
772 return
never executed: return BrushData();
BrushData();
never executed: return BrushData();
0
773 parser.skipSpace();-
774 if (attr.compare(QLatin1String("stop"), Qt::CaseInsensitive) == 0
attr.compare(Q...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
775 QCss::Value stop, color;-
776 parser.next();-
777 if (!parser.parseTerm(&stop)
!parser.parseTerm(&stop)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return BrushData();
BrushData();
never executed: return BrushData();
0
778 parser.skipSpace();-
779 parser.next();-
780 if (!parser.parseTerm(&color)
!parser.parseTerm(&color)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return BrushData();
BrushData();
never executed: return BrushData();
0
781 ColorData cd = parseColorValue(color);-
782 if(cd.type == ColorData::Role
cd.type == ColorData::RoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
783 dependsOnThePalette = true;
never executed: dependsOnThePalette = true;
0
784 stops.append(QGradientStop(stop.variant.toReal(), colorFromData(cd, pal)));-
785 }
never executed: end of block
else {
0
786 parser.next();-
787 QCss::Value value;-
788 (void)parser.parseTerm(&value);-
789 if (attr.compare(QLatin1String("spread"), Qt::CaseInsensitive) == 0
attr.compare(Q...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
790 spread = spreads.indexOf(value.variant.toString());-
791 }
never executed: end of block
else {
0
792 vars[attr] = value.variant.toReal();-
793 }
never executed: end of block
0
794 }-
795 parser.skipSpace();-
796 (void)parser.test(COMMA);-
797 }
never executed: end of block
0
798-
799 if (gradType == 0
gradType == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
800 QLinearGradient lg(vars.value(QLatin1String("x1")), vars.value(QLatin1String("y1")),-
801 vars.value(QLatin1String("x2")), vars.value(QLatin1String("y2")));-
802 lg.setCoordinateMode(QGradient::ObjectBoundingMode);-
803 lg.setStops(stops);-
804 if (spread != -1
spread != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
805 lg.setSpread(QGradient::Spread(spread));
never executed: lg.setSpread(QGradient::Spread(spread));
0
806 BrushData bd = QBrush(lg);-
807 if (dependsOnThePalette
dependsOnThePaletteDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
808 bd.type = BrushData::DependsOnThePalette;
never executed: bd.type = BrushData::DependsOnThePalette;
0
809 return
never executed: return bd;
bd;
never executed: return bd;
0
810 }-
811-
812 if (gradType == 1
gradType == 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
813 QRadialGradient rg(vars.value(QLatin1String("cx")), vars.value(QLatin1String("cy")),-
814 vars.value(QLatin1String("radius")), vars.value(QLatin1String("fx")),-
815 vars.value(QLatin1String("fy")));-
816 rg.setCoordinateMode(QGradient::ObjectBoundingMode);-
817 rg.setStops(stops);-
818 if (spread != -1
spread != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
819 rg.setSpread(QGradient::Spread(spread));
never executed: rg.setSpread(QGradient::Spread(spread));
0
820 BrushData bd = QBrush(rg);-
821 if (dependsOnThePalette
dependsOnThePaletteDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
822 bd.type = BrushData::DependsOnThePalette;
never executed: bd.type = BrushData::DependsOnThePalette;
0
823 return
never executed: return bd;
bd;
never executed: return bd;
0
824 }-
825-
826 if (gradType == 2
gradType == 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
827 QConicalGradient cg(vars.value(QLatin1String("cx")), vars.value(QLatin1String("cy")),-
828 vars.value(QLatin1String("angle")));-
829 cg.setCoordinateMode(QGradient::ObjectBoundingMode);-
830 cg.setStops(stops);-
831 if (spread != -1
spread != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
832 cg.setSpread(QGradient::Spread(spread));
never executed: cg.setSpread(QGradient::Spread(spread));
0
833 BrushData bd = QBrush(cg);-
834 if (dependsOnThePalette
dependsOnThePaletteDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
835 bd.type = BrushData::DependsOnThePalette;
never executed: bd.type = BrushData::DependsOnThePalette;
0
836 return
never executed: return bd;
bd;
never executed: return bd;
0
837 }-
838-
839 return
never executed: return BrushData();
BrushData();
never executed: return BrushData();
0
840}-
841-
842static QBrush brushFromData(const BrushData& c, const QPalette &pal)-
843{-
844 if (c.type == BrushData::Role
c.type == BrushData::RoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
845 return
never executed: return pal.color(c.role);
pal.color(c.role);
never executed: return pal.color(c.role);
0
846 } else {-
847 return
never executed: return c.brush;
c.brush;
never executed: return c.brush;
0
848 }-
849}-
850-
851static BorderStyle parseStyleValue(QCss::Value v)-
852{-
853 if (v.type == Value::KnownIdentifier
v.type == Valu...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
854 switch (v.variant.toInt()) {-
855 case
never executed: case Value_None:
Value_None:
never executed: case Value_None:
0
856 return
never executed: return BorderStyle_None;
BorderStyle_None;
never executed: return BorderStyle_None;
0
857 case
never executed: case Value_Dotted:
Value_Dotted:
never executed: case Value_Dotted:
0
858 return
never executed: return BorderStyle_Dotted;
BorderStyle_Dotted;
never executed: return BorderStyle_Dotted;
0
859 case
never executed: case Value_Dashed:
Value_Dashed:
never executed: case Value_Dashed:
0
860 return
never executed: return BorderStyle_Dashed;
BorderStyle_Dashed;
never executed: return BorderStyle_Dashed;
0
861 case
never executed: case Value_Solid:
Value_Solid:
never executed: case Value_Solid:
0
862 return
never executed: return BorderStyle_Solid;
BorderStyle_Solid;
never executed: return BorderStyle_Solid;
0
863 case
never executed: case Value_Double:
Value_Double:
never executed: case Value_Double:
0
864 return
never executed: return BorderStyle_Double;
BorderStyle_Double;
never executed: return BorderStyle_Double;
0
865 case
never executed: case Value_DotDash:
Value_DotDash:
never executed: case Value_DotDash:
0
866 return
never executed: return BorderStyle_DotDash;
BorderStyle_DotDash;
never executed: return BorderStyle_DotDash;
0
867 case
never executed: case Value_DotDotDash:
Value_DotDotDash:
never executed: case Value_DotDotDash:
0
868 return
never executed: return BorderStyle_DotDotDash;
BorderStyle_DotDotDash;
never executed: return BorderStyle_DotDotDash;
0
869 case
never executed: case Value_Groove:
Value_Groove:
never executed: case Value_Groove:
0
870 return
never executed: return BorderStyle_Groove;
BorderStyle_Groove;
never executed: return BorderStyle_Groove;
0
871 case
never executed: case Value_Ridge:
Value_Ridge:
never executed: case Value_Ridge:
0
872 return
never executed: return BorderStyle_Ridge;
BorderStyle_Ridge;
never executed: return BorderStyle_Ridge;
0
873 case
never executed: case Value_Inset:
Value_Inset:
never executed: case Value_Inset:
0
874 return
never executed: return BorderStyle_Inset;
BorderStyle_Inset;
never executed: return BorderStyle_Inset;
0
875 case
never executed: case Value_Outset:
Value_Outset:
never executed: case Value_Outset:
0
876 return
never executed: return BorderStyle_Outset;
BorderStyle_Outset;
never executed: return BorderStyle_Outset;
0
877 case
never executed: case Value_Native:
Value_Native:
never executed: case Value_Native:
0
878 return
never executed: return BorderStyle_Native;
BorderStyle_Native;
never executed: return BorderStyle_Native;
0
879 default
never executed: default:
:
never executed: default:
0
880 break;
never executed: break;
0
881 }-
882 }-
883-
884 return
never executed: return BorderStyle_Unknown;
BorderStyle_Unknown;
never executed: return BorderStyle_Unknown;
0
885}-
886-
887void ValueExtractor::borderValue(const Declaration &decl, int *width, QCss::BorderStyle *style, QBrush *color)-
888{-
889 if (decl.d->parsed.isValid()
decl.d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
890 BorderData data = qvariant_cast<BorderData>(decl.d->parsed);-
891 *width = lengthValueFromData(data.width, f);-
892 *style = data.style;-
893 *color = data.color.type != BrushData::Invalid
data.color.typ...hData::InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
? brushFromData(data.color, pal) : QBrush(QColor());
0
894 return;
never executed: return;
0
895 }-
896-
897 *width = 0;-
898 *style = BorderStyle_None;-
899 *color = QColor();-
900-
901 if (decl.d->values.isEmpty()
decl.d->values.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
902 return;
never executed: return;
0
903-
904 BorderData data;-
905 data.width.number = 0;-
906 data.width.unit = LengthData::None;-
907 data.style = BorderStyle_None;-
908-
909 int i = 0;-
910 if (decl.d->values.at(i).type == Value::Length
decl.d->values... Value::LengthDescription
TRUEnever evaluated
FALSEnever evaluated
|| decl.d->values.at(i).type == Value::Number
decl.d->values... Value::NumberDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
911 data.width = lengthValue(decl.d->values.at(i));-
912 *width = lengthValueFromData(data.width, f);-
913 if (++
++i >= decl.d->values.count()Description
TRUEnever evaluated
FALSEnever evaluated
i >= decl.d->values.count()
++i >= decl.d->values.count()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
914 decl.d->parsed = QVariant::fromValue<BorderData>(data);-
915 return;
never executed: return;
0
916 }-
917 }
never executed: end of block
0
918-
919 data.style = parseStyleValue(decl.d->values.at(i));-
920 if (data.style != BorderStyle_Unknown
data.style != ...rStyle_UnknownDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
921 *style = data.style;-
922 if (++
++i >= decl.d->values.count()Description
TRUEnever evaluated
FALSEnever evaluated
i >= decl.d->values.count()
++i >= decl.d->values.count()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
923 decl.d->parsed = QVariant::fromValue<BorderData>(data);-
924 return;
never executed: return;
0
925 }-
926 }
never executed: end of block
else {
0
927 data.style = BorderStyle_None;-
928 }
never executed: end of block
0
929-
930 data.color = parseBrushValue(decl.d->values.at(i), pal);-
931 *color = brushFromData(data.color, pal);-
932 if (data.color.type != BrushData::DependsOnThePalette
data.color.typ...dsOnThePaletteDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
933 decl.d->parsed = QVariant::fromValue<BorderData>(data);
never executed: decl.d->parsed = QVariant::fromValue<BorderData>(data);
0
934}
never executed: end of block
0
935-
936static void parseShorthandBackgroundProperty(const QVector<QCss::Value> &values, BrushData *brush, QString *image, Repeat *repeat, Qt::Alignment *alignment, const QPalette &pal)-
937{-
938 *brush = BrushData();-
939 *image = QString();-
940 *repeat = Repeat_XY;-
941 *alignment = Qt::AlignTop | Qt::AlignLeft;-
942-
943 for (int i = 0; i < values.count()
i < values.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
944 const QCss::Value &v = values.at(i);-
945 if (v.type == Value::Uri
v.type == Value::UriDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
946 *image = v.variant.toString();-
947 continue;
never executed: continue;
0
948 } else if (v.type == Value::KnownIdentifier
v.type == Valu...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
&& v.variant.toInt() == Value_None
v.variant.toIn... == Value_NoneDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
949 *image = QString();-
950 continue;
never executed: continue;
0
951 } else if (v.type == Value::KnownIdentifier
v.type == Valu...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
&& v.variant.toInt() == Value_Transparent
v.variant.toIn...ue_TransparentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
952 *brush = QBrush(Qt::transparent);-
953 }
never executed: end of block
0
954-
955 Repeat repeatAttempt = static_cast<Repeat>(findKnownValue(v.variant.toString(),-
956 repeats, NumKnownRepeats));-
957 if (repeatAttempt != Repeat_Unknown
repeatAttempt ...Repeat_UnknownDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
958 *repeat = repeatAttempt;-
959 continue;
never executed: continue;
0
960 }-
961-
962 if (v.type == Value::KnownIdentifier
v.type == Valu...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
963 const int start = i;-
964 int count = 1;-
965 if (i < values.count() - 1
i < values.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
966 && values.at(i + 1).type == Value::KnownIdentifier
values.at(i + ...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
967 ++i;-
968 ++count;-
969 }
never executed: end of block
0
970 Qt::Alignment a = parseAlignment(values.constData() + start, count);-
971 if (int(a) != 0
int(a) != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
972 *alignment = a;-
973 continue;
never executed: continue;
0
974 }-
975 i -= count - 1;-
976 }
never executed: end of block
0
977-
978 *brush = parseBrushValue(v, pal);-
979 }
never executed: end of block
0
980}
never executed: end of block
0
981-
982bool ValueExtractor::extractBackground(QBrush *brush, QString *image, Repeat *repeat,-
983 Qt::Alignment *alignment, Origin *origin, Attachment *attachment,-
984 Origin *clip)-
985{-
986 bool hit = false;-
987 for (int i = 0; i < declarations.count()
i < declarations.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
988 const Declaration &decl = declarations.at(i);-
989 if (decl.d->values.isEmpty()
decl.d->values.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
990 continue;
never executed: continue;
0
991 const QCss::Value &val = decl.d->values.at(0);-
992 switch (decl.d->propertyId) {-
993 case
never executed: case BackgroundColor:
BackgroundColor:
never executed: case BackgroundColor:
0
994 *brush = decl.brushValue();-
995 break;
never executed: break;
0
996 case
never executed: case BackgroundImage:
BackgroundImage:
never executed: case BackgroundImage:
0
997 if (val.type == Value::Uri
val.type == Value::UriDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
998 *
never executed: *image = val.variant.toString();
image = val.variant.toString();
never executed: *image = val.variant.toString();
0
999 break;
never executed: break;
0
1000 case
never executed: case BackgroundRepeat:
BackgroundRepeat:
never executed: case BackgroundRepeat:
0
1001 if (decl.d->parsed.isValid()
decl.d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1002 *repeat = static_cast<Repeat>(decl.d->parsed.toInt());-
1003 }
never executed: end of block
else {
0
1004 *repeat = static_cast<Repeat>(findKnownValue(val.variant.toString(),-
1005 repeats, NumKnownRepeats));-
1006 decl.d->parsed = *repeat;-
1007 }
never executed: end of block
0
1008 break;
never executed: break;
0
1009 case
never executed: case BackgroundPosition:
BackgroundPosition:
never executed: case BackgroundPosition:
0
1010 *alignment = decl.alignmentValue();-
1011 break;
never executed: break;
0
1012 case
never executed: case BackgroundOrigin:
BackgroundOrigin:
never executed: case BackgroundOrigin:
0
1013 *origin = decl.originValue();-
1014 break;
never executed: break;
0
1015 case
never executed: case BackgroundClip:
BackgroundClip:
never executed: case BackgroundClip:
0
1016 *clip = decl.originValue();-
1017 break;
never executed: break;
0
1018 case
never executed: case Background:
Background:
never executed: case Background:
0
1019 if (decl.d->parsed.isValid()
decl.d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1020 BackgroundData data = qvariant_cast<BackgroundData>(decl.d->parsed);-
1021 *brush = brushFromData(data.brush, pal);-
1022 *image = data.image;-
1023 *repeat = data.repeat;-
1024 *alignment = data.alignment;-
1025 }
never executed: end of block
else {
0
1026 BrushData brushData;-
1027 parseShorthandBackgroundProperty(decl.d->values, &brushData, image, repeat, alignment, pal);-
1028 *brush = brushFromData(brushData, pal);-
1029 if (brushData.type != BrushData::DependsOnThePalette
brushData.type...dsOnThePaletteDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1030 BackgroundData data = { brushData, *image, *repeat, *alignment };-
1031 decl.d->parsed = QVariant::fromValue<BackgroundData>(data);-
1032 }
never executed: end of block
0
1033 }
never executed: end of block
0
1034 break;
never executed: break;
0
1035 case
never executed: case BackgroundAttachment:
BackgroundAttachment:
never executed: case BackgroundAttachment:
0
1036 *attachment = decl.attachmentValue();-
1037 break;
never executed: break;
0
1038 default
never executed: default:
:
never executed: default:
continue;
never executed: continue;
0
1039 }-
1040 hit = true;-
1041 }
never executed: end of block
0
1042 return
never executed: return hit;
hit;
never executed: return hit;
0
1043}-
1044-
1045static bool setFontSizeFromValue(QCss::Value value, QFont *font, int *fontSizeAdjustment)-
1046{-
1047 if (value.type == Value::KnownIdentifier
value.type == ...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1048 bool valid = true;-
1049 switch (value.variant.toInt()) {-
1050 case
never executed: case Value_Small:
Value_Small:
never executed: case Value_Small:
*fontSizeAdjustment = -1; break;
never executed: break;
0
1051 case
never executed: case Value_Medium:
Value_Medium:
never executed: case Value_Medium:
*fontSizeAdjustment = 0; break;
never executed: break;
0
1052 case
never executed: case Value_Large:
Value_Large:
never executed: case Value_Large:
*fontSizeAdjustment = 1; break;
never executed: break;
0
1053 case
never executed: case Value_XLarge:
Value_XLarge:
never executed: case Value_XLarge:
*fontSizeAdjustment = 2; break;
never executed: break;
0
1054 case
never executed: case Value_XXLarge:
Value_XXLarge:
never executed: case Value_XXLarge:
*fontSizeAdjustment = 3; break;
never executed: break;
0
1055 default
never executed: default:
:
never executed: default:
valid = false; break;
never executed: break;
0
1056 }-
1057 return
never executed: return valid;
valid;
never executed: return valid;
0
1058 }-
1059 if (value.type != Value::Length
value.type != Value::LengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1060 return
never executed: return false;
false;
never executed: return false;
0
1061-
1062 bool valid = false;-
1063 QString s = value.variant.toString();-
1064 if (s.endsWith(QLatin1String("pt"), Qt::CaseInsensitive)
s.endsWith(QLa...seInsensitive)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1065 s.chop(2);-
1066 value.variant = s;-
1067 if (value.variant.convert((QVariant::Type)qMetaTypeId<qreal>())
value.variant....peId<qreal>())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1068 font->setPointSizeF(value.variant.toReal());-
1069 valid = true;-
1070 }
never executed: end of block
0
1071 }
never executed: end of block
else if (s.endsWith(QLatin1String("px"), Qt::CaseInsensitive)
s.endsWith(QLa...seInsensitive)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1072 s.chop(2);-
1073 value.variant = s;-
1074 if (value.variant.convert(QVariant::Int)
value.variant....QVariant::Int)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1075 font->setPixelSize(value.variant.toInt());-
1076 valid = true;-
1077 }
never executed: end of block
0
1078 }
never executed: end of block
0
1079 return
never executed: return valid;
valid;
never executed: return valid;
0
1080}-
1081-
1082static bool setFontStyleFromValue(const QCss::Value &value, QFont *font)-
1083{-
1084 if (value.type != Value::KnownIdentifier
value.type != ...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1085 return
never executed: return false ;
false ;
never executed: return false ;
0
1086 switch (value.variant.toInt()) {-
1087 case
never executed: case Value_Normal:
Value_Normal:
never executed: case Value_Normal:
font->setStyle(QFont::StyleNormal); return
never executed: return true;
true;
never executed: return true;
0
1088 case
never executed: case Value_Italic:
Value_Italic:
never executed: case Value_Italic:
font->setStyle(QFont::StyleItalic); return
never executed: return true;
true;
never executed: return true;
0
1089 case
never executed: case Value_Oblique:
Value_Oblique:
never executed: case Value_Oblique:
font->setStyle(QFont::StyleOblique); return
never executed: return true;
true;
never executed: return true;
0
1090 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
1091 }-
1092 return
never executed: return false;
false;
never executed: return false;
0
1093}-
1094-
1095static bool setFontWeightFromValue(const QCss::Value &value, QFont *font)-
1096{-
1097 if (value.type == Value::KnownIdentifier
value.type == ...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1098 switch (value.variant.toInt()) {-
1099 case
never executed: case Value_Normal:
Value_Normal:
never executed: case Value_Normal:
font->setWeight(QFont::Normal); return
never executed: return true;
true;
never executed: return true;
0
1100 case
never executed: case Value_Bold:
Value_Bold:
never executed: case Value_Bold:
font->setWeight(QFont::Bold); return
never executed: return true;
true;
never executed: return true;
0
1101 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
1102 }-
1103 return
never executed: return false;
false;
never executed: return false;
0
1104 }-
1105 if (value.type != Value::Number
value.type != Value::NumberDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1106 return
never executed: return false;
false;
never executed: return false;
0
1107 font->setWeight(qMin(value.variant.toInt() / 8, 99));-
1108 return
never executed: return true;
true;
never executed: return true;
0
1109}-
1110-
1111-
1112-
1113-
1114-
1115-
1116static bool setFontFamilyFromValues(const QVector<QCss::Value> &values, QFont *font, int start = 0)-
1117{-
1118 QString family;-
1119 bool shouldAddSpace = false;-
1120 for (int i = start; i < values.count()
i < values.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1121 const QCss::Value &v = values.at(i);-
1122 if (v.type == Value::TermOperatorComma
v.type == Valu...mOperatorCommaDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1123 family += QLatin1Char(',');-
1124 shouldAddSpace = false;-
1125 continue;
never executed: continue;
0
1126 }-
1127 const QString str = v.variant.toString();-
1128 if (str.isEmpty()
str.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1129 break;
never executed: break;
0
1130 if (shouldAddSpace
shouldAddSpaceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1131 family += QLatin1Char(' ');
never executed: family += QLatin1Char(' ');
0
1132 family += str;-
1133 shouldAddSpace = true;-
1134 }
never executed: end of block
0
1135 if (family.isEmpty()
family.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1136 return
never executed: return false;
false;
never executed: return false;
0
1137 font->setFamily(family);-
1138 return
never executed: return true;
true;
never executed: return true;
0
1139}-
1140-
1141static void setTextDecorationFromValues(const QVector<QCss::Value> &values, QFont *font)-
1142{-
1143 for (int i = 0; i < values.count()
i < values.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1144 if (values.at(i).type != Value::KnownIdentifier
values.at(i).t...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1145 continue;
never executed: continue;
0
1146 switch (values.at(i).variant.toInt()) {-
1147 case
never executed: case Value_Underline:
Value_Underline:
never executed: case Value_Underline:
font->setUnderline(true); break;
never executed: break;
0
1148 case
never executed: case Value_Overline:
Value_Overline:
never executed: case Value_Overline:
font->setOverline(true); break;
never executed: break;
0
1149 case
never executed: case Value_LineThrough:
Value_LineThrough:
never executed: case Value_LineThrough:
font->setStrikeOut(true); break;
never executed: break;
0
1150 case
never executed: case Value_None:
Value_None:
never executed: case Value_None:
0
1151 font->setUnderline(false);-
1152 font->setOverline(false);-
1153 font->setStrikeOut(false);-
1154 break;
never executed: break;
0
1155 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
1156 }-
1157 }-
1158}
never executed: end of block
0
1159-
1160static void parseShorthandFontProperty(const QVector<QCss::Value> &values, QFont *font, int *fontSizeAdjustment)-
1161{-
1162 font->setStyle(QFont::StyleNormal);-
1163 font->setWeight(QFont::Normal);-
1164 *fontSizeAdjustment = -255;-
1165-
1166 int i = 0;-
1167 while (i < values.count()
i < values.count()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1168 if (setFontStyleFromValue(values.at(i), font)
setFontStyleFr...s.at(i), font)Description
TRUEnever evaluated
FALSEnever evaluated
0
1169 || setFontWeightFromValue(values.at(i), font)
setFontWeightF...s.at(i), font)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1170 ++
never executed: ++i;
i;
never executed: ++i;
0
1171 else-
1172 break;
never executed: break;
0
1173 }-
1174-
1175 if (i < values.count()
i < values.count()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1176 setFontSizeFromValue(values.at(i), font, fontSizeAdjustment);-
1177 ++i;-
1178 }
never executed: end of block
0
1179-
1180 if (i < values.count()
i < values.count()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1181 setFontFamilyFromValues(values, font, i);-
1182 }
never executed: end of block
0
1183}
never executed: end of block
0
1184-
1185static void setFontVariantFromValue(const QCss::Value &value, QFont *font)-
1186{-
1187 if (value.type == Value::KnownIdentifier
value.type == ...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1188 switch (value.variant.toInt()) {-
1189 case
never executed: case Value_Normal:
Value_Normal:
never executed: case Value_Normal:
font->setCapitalization(QFont::MixedCase); break;
never executed: break;
0
1190 case
never executed: case Value_SmallCaps:
Value_SmallCaps:
never executed: case Value_SmallCaps:
font->setCapitalization(QFont::SmallCaps); break;
never executed: break;
0
1191 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
1192 }-
1193 }-
1194}
never executed: end of block
0
1195-
1196static void setTextTransformFromValue(const QCss::Value &value, QFont *font)-
1197{-
1198 if (value.type == Value::KnownIdentifier
value.type == ...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1199 switch (value.variant.toInt()) {-
1200 case
never executed: case Value_None:
Value_None:
never executed: case Value_None:
font->setCapitalization(QFont::MixedCase); break;
never executed: break;
0
1201 case
never executed: case Value_Uppercase:
Value_Uppercase:
never executed: case Value_Uppercase:
font->setCapitalization(QFont::AllUppercase); break;
never executed: break;
0
1202 case
never executed: case Value_Lowercase:
Value_Lowercase:
never executed: case Value_Lowercase:
font->setCapitalization(QFont::AllLowercase); break;
never executed: break;
0
1203 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
1204 }-
1205 }-
1206}
never executed: end of block
0
1207-
1208bool ValueExtractor::extractFont(QFont *font, int *fontSizeAdjustment)-
1209{-
1210 if (fontExtracted
fontExtractedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1211 *font = f;-
1212 *fontSizeAdjustment = adjustment;-
1213 return
never executed: return fontExtracted == 1;
fontExtracted == 1;
never executed: return fontExtracted == 1;
0
1214 }-
1215-
1216 bool hit = false;-
1217 for (int i = 0; i < declarations.count()
i < declarations.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1218 const Declaration &decl = declarations.at(i);-
1219 if (decl.d->values.isEmpty()
decl.d->values.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1220 continue;
never executed: continue;
0
1221 const QCss::Value &val = decl.d->values.at(0);-
1222 switch (decl.d->propertyId) {-
1223 case
never executed: case FontSize:
FontSize:
never executed: case FontSize:
setFontSizeFromValue(val, font, fontSizeAdjustment); break;
never executed: break;
0
1224 case
never executed: case FontStyle:
FontStyle:
never executed: case FontStyle:
setFontStyleFromValue(val, font); break;
never executed: break;
0
1225 case
never executed: case FontWeight:
FontWeight:
never executed: case FontWeight:
setFontWeightFromValue(val, font); break;
never executed: break;
0
1226 case
never executed: case FontFamily:
FontFamily:
never executed: case FontFamily:
setFontFamilyFromValues(decl.d->values, font); break;
never executed: break;
0
1227 case
never executed: case TextDecoration:
TextDecoration:
never executed: case TextDecoration:
setTextDecorationFromValues(decl.d->values, font); break;
never executed: break;
0
1228 case
never executed: case Font:
Font:
never executed: case Font:
parseShorthandFontProperty(decl.d->values, font, fontSizeAdjustment); break;
never executed: break;
0
1229 case
never executed: case FontVariant:
FontVariant:
never executed: case FontVariant:
setFontVariantFromValue(val, font); break;
never executed: break;
0
1230 case
never executed: case TextTransform:
TextTransform:
never executed: case TextTransform:
setTextTransformFromValue(val, font); break;
never executed: break;
0
1231 default
never executed: default:
:
never executed: default:
continue;
never executed: continue;
0
1232 }-
1233 hit = true;-
1234 }
never executed: end of block
0
1235-
1236 f = *font;-
1237 adjustment = *fontSizeAdjustment;-
1238 fontExtracted = hit
hitDescription
TRUEnever evaluated
FALSEnever evaluated
? 1 : 2;
0
1239 return
never executed: return hit;
hit;
never executed: return hit;
0
1240}-
1241-
1242bool ValueExtractor::extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg)-
1243{-
1244 bool hit = false;-
1245 for (int i = 0; i < declarations.count()
i < declarations.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1246 const Declaration &decl = declarations.at(i);-
1247 switch (decl.d->propertyId) {-
1248 case
never executed: case Color:
Color:
never executed: case Color:
*fg = decl.brushValue(pal); break;
never executed: break;
0
1249 case
never executed: case QtSelectionForeground:
QtSelectionForeground:
never executed: case QtSelectionForeground:
*sfg = decl.brushValue(pal); break;
never executed: break;
0
1250 case
never executed: case QtSelectionBackground:
QtSelectionBackground:
never executed: case QtSelectionBackground:
*sbg = decl.brushValue(pal); break;
never executed: break;
0
1251 case
never executed: case QtAlternateBackground:
QtAlternateBackground:
never executed: case QtAlternateBackground:
*abg = decl.brushValue(pal); break;
never executed: break;
0
1252 default
never executed: default:
:
never executed: default:
continue;
never executed: continue;
0
1253 }-
1254 hit = true;-
1255 }
never executed: end of block
0
1256 return
never executed: return hit;
hit;
never executed: return hit;
0
1257}-
1258-
1259void ValueExtractor::extractFont()-
1260{-
1261 if (fontExtracted
fontExtractedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1262 return;
never executed: return;
0
1263 int dummy = -255;-
1264 extractFont(&f, &dummy);-
1265}
never executed: end of block
0
1266-
1267bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size)-
1268{-
1269 bool hit = false;-
1270 for (int i = 0; i < declarations.count()
i < declarations.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1271 const Declaration &decl = declarations.at(i);-
1272 switch (decl.d->propertyId) {-
1273 case
never executed: case QtImage:
QtImage:
never executed: case QtImage:
0
1274 *icon = decl.iconValue();-
1275 if (decl.d->values.count() > 0
decl.d->values.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& decl.d->values.at(0).type == Value::Uri
decl.d->values... == Value::UriDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1276-
1277 QImageReader imageReader(decl.d->values.at(0).variant.toString());-
1278 if ((*
(*size = image...ze()).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
size = imageReader.size()).isNull()
(*size = image...ze()).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1279-
1280-
1281 *size = imageReader.read().size();-
1282 }
never executed: end of block
0
1283 }
never executed: end of block
0
1284 break;
never executed: break;
0
1285 case
never executed: case QtImageAlignment:
QtImageAlignment:
never executed: case QtImageAlignment:
*a = decl.alignmentValue(); break;
never executed: break;
0
1286 default
never executed: default:
:
never executed: default:
continue;
never executed: continue;
0
1287 }-
1288 hit = true;-
1289 }
never executed: end of block
0
1290 return
never executed: return hit;
hit;
never executed: return hit;
0
1291}-
1292-
1293-
1294-
1295QColor Declaration::colorValue(const QPalette &pal) const-
1296{-
1297 if (d->values.count() != 1
d->values.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1298 return
never executed: return QColor();
QColor();
never executed: return QColor();
0
1299-
1300 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1301 if (d->parsed.type() == QVariant::Color
d->parsed.type...Variant::ColorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1302 return
never executed: return qvariant_cast<QColor>(d->parsed);
qvariant_cast<QColor>(d->parsed);
never executed: return qvariant_cast<QColor>(d->parsed);
0
1303 if (d->parsed.type() == QVariant::Int
d->parsed.type... QVariant::IntDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1304 return
never executed: return pal.color((QPalette::ColorRole)(d->parsed.toInt()));
pal.color((QPalette::ColorRole)(d->parsed.toInt()));
never executed: return pal.color((QPalette::ColorRole)(d->parsed.toInt()));
0
1305 }
never executed: end of block
0
1306-
1307 ColorData color = parseColorValue(d->values.at(0));-
1308 if(color.type == ColorData::Role
color.type == ColorData::RoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1309 d->parsed = QVariant::fromValue<int>(color.role);-
1310 return
never executed: return pal.color((QPalette::ColorRole)(color.role));
pal.color((QPalette::ColorRole)(color.role));
never executed: return pal.color((QPalette::ColorRole)(color.role));
0
1311 } else {-
1312 d->parsed = QVariant::fromValue<QColor>(color.color);-
1313 return
never executed: return color.color;
color.color;
never executed: return color.color;
0
1314 }-
1315}-
1316-
1317QBrush Declaration::brushValue(const QPalette &pal) const-
1318{-
1319 if (d->values.count() != 1
d->values.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1320 return
never executed: return QBrush();
QBrush();
never executed: return QBrush();
0
1321-
1322 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1323 if (d->parsed.type() == QVariant::Brush
d->parsed.type...Variant::BrushDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1324 return
never executed: return qvariant_cast<QBrush>(d->parsed);
qvariant_cast<QBrush>(d->parsed);
never executed: return qvariant_cast<QBrush>(d->parsed);
0
1325 if (d->parsed.type() == QVariant::Int
d->parsed.type... QVariant::IntDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1326 return
never executed: return pal.color((QPalette::ColorRole)(d->parsed.toInt()));
pal.color((QPalette::ColorRole)(d->parsed.toInt()));
never executed: return pal.color((QPalette::ColorRole)(d->parsed.toInt()));
0
1327 }
never executed: end of block
0
1328-
1329 BrushData data = parseBrushValue(d->values.at(0), pal);-
1330-
1331 if(data.type == BrushData::Role
data.type == BrushData::RoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1332 d->parsed = QVariant::fromValue<int>(data.role);-
1333 return
never executed: return pal.color((QPalette::ColorRole)(data.role));
pal.color((QPalette::ColorRole)(data.role));
never executed: return pal.color((QPalette::ColorRole)(data.role));
0
1334 } else {-
1335 if (data.type != BrushData::DependsOnThePalette
data.type != B...dsOnThePaletteDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1336 d->parsed = QVariant::fromValue<QBrush>(data.brush);
never executed: d->parsed = QVariant::fromValue<QBrush>(data.brush);
0
1337 return
never executed: return data.brush;
data.brush;
never executed: return data.brush;
0
1338 }-
1339}-
1340-
1341void Declaration::brushValues(QBrush *c, const QPalette &pal) const-
1342{-
1343 int needParse = 0x1f;-
1344-
1345 int i = 0;-
1346 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1347 needParse = 0;-
1348 QList<QVariant> v = d->parsed.toList();-
1349 for (i = 0; i < qMin(v.count(), 4)
i < qMin(v.count(), 4)Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1350 if (v.at(i).type() == QVariant::Brush
v.at(i).type()...Variant::BrushDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1351 c[i] = qvariant_cast<QBrush>(v.at(i));-
1352 }
never executed: end of block
else if (v.at(i).type() == QVariant::Int
v.at(i).type()... QVariant::IntDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1353 c[i] = pal.color((QPalette::ColorRole)(v.at(i).toInt()));-
1354 }
never executed: end of block
else {
0
1355 needParse |= (1<<i);-
1356 }
never executed: end of block
0
1357 }-
1358 }
never executed: end of block
0
1359 if (needParse != 0
needParse != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1360 QList<QVariant> v;-
1361 for (i = 0; i < qMin(d->values.count(), 4)
i < qMin(d->values.count(), 4)Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1362 if (!(needParse & (1<<i))
!(needParse & (1<<i))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1363 continue;
never executed: continue;
0
1364 BrushData data = parseBrushValue(d->values.at(i), pal);-
1365 if(data.type == BrushData::Role
data.type == BrushData::RoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1366 v += QVariant::fromValue<int>(data.role);-
1367 c[i] = pal.color((QPalette::ColorRole)(data.role));-
1368 }
never executed: end of block
else {
0
1369 if (data.type != BrushData::DependsOnThePalette
data.type != B...dsOnThePaletteDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1370 v += QVariant::fromValue<QBrush>(data.brush);-
1371 }
never executed: end of block
else {
0
1372 v += QVariant();-
1373 }
never executed: end of block
0
1374 c[i] = data.brush;-
1375 }
never executed: end of block
0
1376 }-
1377 if (needParse & 0x10
needParse & 0x10Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1378 d->parsed = v;
never executed: d->parsed = v;
0
1379 }
never executed: end of block
0
1380 if (i == 0
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
) c[0] = c[1] = c[2] = c[3] = QBrush();
never executed: c[0] = c[1] = c[2] = c[3] = QBrush();
0
1381 else if (i == 1
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
) c[3] = c[2] = c[1] = c[0];
never executed: c[3] = c[2] = c[1] = c[0];
0
1382 else if (i == 2
i == 2Description
TRUEnever evaluated
FALSEnever evaluated
) c[2] = c[0], c[3] = c[1];
never executed: c[2] = c[0], c[3] = c[1];
0
1383 else if (i == 3
i == 3Description
TRUEnever evaluated
FALSEnever evaluated
) c[3] = c[1];
never executed: c[3] = c[1];
0
1384}
never executed: end of block
0
1385-
1386bool Declaration::realValue(qreal *real, const char *unit) const-
1387{-
1388 if (d->values.count() != 1
d->values.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1389 return
never executed: return false;
false;
never executed: return false;
0
1390 const Value &v = d->values.at(0);-
1391 if (unit
unitDescription
TRUEnever evaluated
FALSEnever evaluated
&& v.type != Value::Length
v.type != Value::LengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1392 return
never executed: return false;
false;
never executed: return false;
0
1393 QString s = v.variant.toString();-
1394 if (unit
unitDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1395 if (!s.endsWith(QLatin1String(unit), Qt::CaseInsensitive)
!s.endsWith(QL...seInsensitive)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1396 return
never executed: return false;
false;
never executed: return false;
0
1397 s.chop(qstrlen(unit));-
1398 }
never executed: end of block
0
1399 bool ok = false;-
1400 qreal val = s.toDouble(&ok);-
1401 if (ok
okDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1402 *
never executed: *real = val;
real = val;
never executed: *real = val;
0
1403 return
never executed: return ok;
ok;
never executed: return ok;
0
1404}-
1405-
1406static bool intValueHelper(const QCss::Value &v, int *i, const char *unit)-
1407{-
1408 if (unit
unitDescription
TRUEnever evaluated
FALSEnever evaluated
&& v.type != Value::Length
v.type != Value::LengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1409 return
never executed: return false;
false;
never executed: return false;
0
1410 QString s = v.variant.toString();-
1411 if (unit
unitDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1412 if (!s.endsWith(QLatin1String(unit), Qt::CaseInsensitive)
!s.endsWith(QL...seInsensitive)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1413 return
never executed: return false;
false;
never executed: return false;
0
1414 s.chop(qstrlen(unit));-
1415 }
never executed: end of block
0
1416 bool ok = false;-
1417 int val = s.toInt(&ok);-
1418 if (ok
okDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1419 *
never executed: *i = val;
i = val;
never executed: *i = val;
0
1420 return
never executed: return ok;
ok;
never executed: return ok;
0
1421}-
1422-
1423bool Declaration::intValue(int *i, const char *unit) const-
1424{-
1425 if (d->values.count() != 1
d->values.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1426 return
never executed: return false;
false;
never executed: return false;
0
1427 return
never executed: return intValueHelper(d->values.at(0), i, unit);
intValueHelper(d->values.at(0), i, unit);
never executed: return intValueHelper(d->values.at(0), i, unit);
0
1428}-
1429-
1430QSize Declaration::sizeValue() const-
1431{-
1432 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1433 return
never executed: return qvariant_cast<QSize>(d->parsed);
qvariant_cast<QSize>(d->parsed);
never executed: return qvariant_cast<QSize>(d->parsed);
0
1434-
1435 int x[2] = { 0, 0 };-
1436 if (d->values.count() > 0
d->values.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1437 intValueHelper(d->values.at(0), &x[0], "px");
never executed: intValueHelper(d->values.at(0), &x[0], "px");
0
1438 if (d->values.count() > 1
d->values.count() > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1439 intValueHelper(d->values.at(1), &x[1], "px");
never executed: intValueHelper(d->values.at(1), &x[1], "px");
0
1440 else-
1441 x[1] = x[0];
never executed: x[1] = x[0];
0
1442 QSize size(x[0], x[1]);-
1443 d->parsed = QVariant::fromValue<QSize>(size);-
1444 return
never executed: return size;
size;
never executed: return size;
0
1445}-
1446-
1447QRect Declaration::rectValue() const-
1448{-
1449 if (d->values.count() != 1
d->values.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1450 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
1451-
1452 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1453 return
never executed: return qvariant_cast<QRect>(d->parsed);
qvariant_cast<QRect>(d->parsed);
never executed: return qvariant_cast<QRect>(d->parsed);
0
1454-
1455 const QCss::Value &v = d->values.at(0);-
1456 if (v.type != Value::Function
v.type != Value::FunctionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1457 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
1458 const QStringList func = v.variant.toStringList();-
1459 if (func.count() != 2
func.count() != 2Description
TRUEnever evaluated
FALSEnever evaluated
|| func.at(0).compare(QLatin1String("rect")) != 0
func.at(0).com...("rect")) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1460 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
1461 const auto args = func[1].splitRef(QLatin1Char(' '), QString::SkipEmptyParts);-
1462 if (args.count() != 4
args.count() != 4Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1463 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
1464 QRect rect(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt());-
1465 d->parsed = QVariant::fromValue<QRect>(rect);-
1466 return
never executed: return rect;
rect;
never executed: return rect;
0
1467}-
1468-
1469void Declaration::colorValues(QColor *c, const QPalette &pal) const-
1470{-
1471 int i;-
1472 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1473 QList<QVariant> v = d->parsed.toList();-
1474 for (i = 0; i < qMin(d->values.count(), 4)
i < qMin(d->values.count(), 4)Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1475 if (v.at(i).type() == QVariant::Color
v.at(i).type()...Variant::ColorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1476 c[i] = qvariant_cast<QColor>(v.at(i));-
1477 }
never executed: end of block
else {
0
1478 c[i] = pal.color((QPalette::ColorRole)(v.at(i).toInt()));-
1479 }
never executed: end of block
0
1480 }-
1481 }
never executed: end of block
else {
0
1482 QList<QVariant> v;-
1483 for (i = 0; i < qMin(d->values.count(), 4)
i < qMin(d->values.count(), 4)Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1484 ColorData color = parseColorValue(d->values.at(i));-
1485 if(color.type == ColorData::Role
color.type == ColorData::RoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1486 v += QVariant::fromValue<int>(color.role);-
1487 c[i] = pal.color((QPalette::ColorRole)(color.role));-
1488 }
never executed: end of block
else {
0
1489 v += QVariant::fromValue<QColor>(color.color);-
1490 c[i] = color.color;-
1491 }
never executed: end of block
0
1492 }-
1493 d->parsed = v;-
1494 }
never executed: end of block
0
1495-
1496 if (i == 0
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
) c[0] = c[1] = c[2] = c[3] = QColor();
never executed: c[0] = c[1] = c[2] = c[3] = QColor();
0
1497 else if (i == 1
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
) c[3] = c[2] = c[1] = c[0];
never executed: c[3] = c[2] = c[1] = c[0];
0
1498 else if (i == 2
i == 2Description
TRUEnever evaluated
FALSEnever evaluated
) c[2] = c[0], c[3] = c[1];
never executed: c[2] = c[0], c[3] = c[1];
0
1499 else if (i == 3
i == 3Description
TRUEnever evaluated
FALSEnever evaluated
) c[3] = c[1];
never executed: c[3] = c[1];
0
1500}
never executed: end of block
0
1501-
1502BorderStyle Declaration::styleValue() const-
1503{-
1504 if (d->values.count() != 1
d->values.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1505 return
never executed: return BorderStyle_None;
BorderStyle_None;
never executed: return BorderStyle_None;
0
1506 return
never executed: return parseStyleValue(d->values.at(0));
parseStyleValue(d->values.at(0));
never executed: return parseStyleValue(d->values.at(0));
0
1507}-
1508-
1509void Declaration::styleValues(BorderStyle *s) const-
1510{-
1511 int i;-
1512 for (i = 0; i < qMin(d->values.count(), 4)
i < qMin(d->values.count(), 4)Description
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
1513 s[i] = parseStyleValue(d->values.at(i));
never executed: s[i] = parseStyleValue(d->values.at(i));
0
1514 if (i == 0
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
) s[0] = s[1] = s[2] = s[3] = BorderStyle_None;
never executed: s[0] = s[1] = s[2] = s[3] = BorderStyle_None;
0
1515 else if (i == 1
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
) s[3] = s[2] = s[1] = s[0];
never executed: s[3] = s[2] = s[1] = s[0];
0
1516 else if (i == 2
i == 2Description
TRUEnever evaluated
FALSEnever evaluated
) s[2] = s[0], s[3] = s[1];
never executed: s[2] = s[0], s[3] = s[1];
0
1517 else if (i == 3
i == 3Description
TRUEnever evaluated
FALSEnever evaluated
) s[3] = s[1];
never executed: s[3] = s[1];
0
1518}
never executed: end of block
0
1519-
1520Repeat Declaration::repeatValue() const-
1521{-
1522 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1523 return
never executed: return static_cast<Repeat>(d->parsed.toInt());
static_cast<Repeat>(d->parsed.toInt());
never executed: return static_cast<Repeat>(d->parsed.toInt());
0
1524 if (d->values.count() != 1
d->values.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1525 return
never executed: return Repeat_Unknown;
Repeat_Unknown;
never executed: return Repeat_Unknown;
0
1526 int v = findKnownValue(d->values.at(0).variant.toString(),-
1527 repeats, NumKnownRepeats);-
1528 d->parsed = v;-
1529 return
never executed: return static_cast<Repeat>(v);
static_cast<Repeat>(v);
never executed: return static_cast<Repeat>(v);
0
1530}-
1531-
1532Origin Declaration::originValue() const-
1533{-
1534 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1535 return
never executed: return static_cast<Origin>(d->parsed.toInt());
static_cast<Origin>(d->parsed.toInt());
never executed: return static_cast<Origin>(d->parsed.toInt());
0
1536 if (d->values.count() != 1
d->values.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1537 return
never executed: return Origin_Unknown;
Origin_Unknown;
never executed: return Origin_Unknown;
0
1538 int v = findKnownValue(d->values.at(0).variant.toString(),-
1539 origins, NumKnownOrigins);-
1540 d->parsed = v;-
1541 return
never executed: return static_cast<Origin>(v);
static_cast<Origin>(v);
never executed: return static_cast<Origin>(v);
0
1542}-
1543-
1544PositionMode Declaration::positionValue() const-
1545{-
1546 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1547 return
never executed: return static_cast<PositionMode>(d->parsed.toInt());
static_cast<PositionMode>(d->parsed.toInt());
never executed: return static_cast<PositionMode>(d->parsed.toInt());
0
1548 if (d->values.count() != 1
d->values.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1549 return
never executed: return PositionMode_Unknown;
PositionMode_Unknown;
never executed: return PositionMode_Unknown;
0
1550 int v = findKnownValue(d->values.at(0).variant.toString(),-
1551 positions, NumKnownPositionModes);-
1552 d->parsed = v;-
1553 return
never executed: return static_cast<PositionMode>(v);
static_cast<PositionMode>(v);
never executed: return static_cast<PositionMode>(v);
0
1554}-
1555-
1556Attachment Declaration::attachmentValue() const-
1557{-
1558 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1559 return
never executed: return static_cast<Attachment>(d->parsed.toInt());
static_cast<Attachment>(d->parsed.toInt());
never executed: return static_cast<Attachment>(d->parsed.toInt());
0
1560 if (d->values.count() != 1
d->values.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1561 return
never executed: return Attachment_Unknown;
Attachment_Unknown;
never executed: return Attachment_Unknown;
0
1562 int v = findKnownValue(d->values.at(0).variant.toString(),-
1563 attachments, NumKnownAttachments);-
1564 d->parsed = v;-
1565 return
never executed: return static_cast<Attachment>(v);
static_cast<Attachment>(v);
never executed: return static_cast<Attachment>(v);
0
1566}-
1567-
1568int Declaration::styleFeaturesValue() const-
1569{-
1570 ((!(d->propertyId == QtStyleFeatures)) ? qt_assert("d->propertyId == QtStyleFeatures",__FILE__,1627) : qt_noop());-
1571 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1572 return
never executed: return d->parsed.toInt();
d->parsed.toInt();
never executed: return d->parsed.toInt();
0
1573 int features = StyleFeature_None;-
1574 for (int i = 0; i < d->values.count()
i < d->values.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1575 features |= static_cast<int>(findKnownValue(d->values.value(i).variant.toString(),-
1576 styleFeatures, NumKnownStyleFeatures));-
1577 }
never executed: end of block
0
1578 d->parsed = features;-
1579 return
never executed: return features;
features;
never executed: return features;
0
1580}-
1581-
1582QString Declaration::uriValue() const-
1583{-
1584 if (d->values.isEmpty()
d->values.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| d->values.at(0).type != Value::Uri
d->values.at(0... != Value::UriDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1585 return
never executed: return QString();
QString();
never executed: return QString();
0
1586 return
never executed: return d->values.at(0).variant.toString();
d->values.at(0).variant.toString();
never executed: return d->values.at(0).variant.toString();
0
1587}-
1588-
1589Qt::Alignment Declaration::alignmentValue() const-
1590{-
1591 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1592 return
never executed: return Qt::Alignment(d->parsed.toInt());
Qt::Alignment(d->parsed.toInt());
never executed: return Qt::Alignment(d->parsed.toInt());
0
1593 if (d->values.isEmpty()
d->values.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| d->values.count() > 2
d->values.count() > 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1594 return
never executed: return Qt::AlignLeft | Qt::AlignTop;
Qt::AlignLeft | Qt::AlignTop;
never executed: return Qt::AlignLeft | Qt::AlignTop;
0
1595-
1596 Qt::Alignment v = parseAlignment(d->values.constData(), d->values.count());-
1597 d->parsed = int(v);-
1598 return
never executed: return v;
v;
never executed: return v;
0
1599}-
1600-
1601void Declaration::borderImageValue(QString *image, int *cuts,-
1602 TileMode *h, TileMode *v) const-
1603{-
1604 const DeclarationData *d = this->d.data();-
1605 *image = uriValue();-
1606 for (int i = 0; i < 4
i < 4Description
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
1607 cuts[i] = -1;
never executed: cuts[i] = -1;
0
1608 *h = *v = TileMode_Stretch;-
1609-
1610 if (d->values.count() < 2
d->values.count() < 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1611 return;
never executed: return;
0
1612-
1613 if (d->values.at(1).type == Value::Number
d->values.at(1... Value::NumberDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1614 int i;-
1615 for (i = 0; i < qMin(d->values.count()-1, 4)
i < qMin(d->va....count()-1, 4)Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1616 const Value& v = d->values.at(i+1);-
1617 if (v.type != Value::Number
v.type != Value::NumberDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1618 break;
never executed: break;
0
1619 cuts[i] = v.variant.toString().toInt();-
1620 }
never executed: end of block
0
1621 if (i == 0
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
) cuts[0] = cuts[1] = cuts[2] = cuts[3] = 0;
never executed: cuts[0] = cuts[1] = cuts[2] = cuts[3] = 0;
0
1622 else if (i == 1
i == 1Description
TRUEnever evaluated
FALSEnever evaluated
) cuts[3] = cuts[2] = cuts[1] = cuts[0];
never executed: cuts[3] = cuts[2] = cuts[1] = cuts[0];
0
1623 else if (i == 2
i == 2Description
TRUEnever evaluated
FALSEnever evaluated
) cuts[2] = cuts[0], cuts[3] = cuts[1];
never executed: cuts[2] = cuts[0], cuts[3] = cuts[1];
0
1624 else if (i == 3
i == 3Description
TRUEnever evaluated
FALSEnever evaluated
) cuts[3] = cuts[1];
never executed: cuts[3] = cuts[1];
0
1625 }
never executed: end of block
0
1626-
1627 if (d->values.last().type == Value::Identifier
d->values.last...ue::IdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1628 *v = static_cast<TileMode>(findKnownValue(d->values.last().variant.toString(),-
1629 tileModes, NumKnownTileModes));-
1630 }
never executed: end of block
0
1631 if (d->values[d->values.count() - 2].type == Value::Identifier
d->values[d->v...ue::IdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1632 *h = static_cast<TileMode>-
1633 (findKnownValue(d->values[d->values.count()-2].variant.toString(),-
1634 tileModes, NumKnownTileModes));-
1635 }
never executed: end of block
else
0
1636 *
never executed: *h = *v;
h = *v;
never executed: *h = *v;
0
1637}-
1638-
1639QIcon Declaration::iconValue() const-
1640{-
1641 if (d->parsed.isValid()
d->parsed.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1642 return
never executed: return qvariant_cast<QIcon>(d->parsed);
qvariant_cast<QIcon>(d->parsed);
never executed: return qvariant_cast<QIcon>(d->parsed);
0
1643-
1644 QIcon icon;-
1645 for (int i = 0; i < d->values.count()
i < d->values.count()Description
TRUEnever evaluated
FALSEnever evaluated
;) {
0
1646 const Value &value = d->values.at(i++);-
1647 if (value.type != Value::Uri
value.type != Value::UriDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1648 break;
never executed: break;
0
1649 QString uri = value.variant.toString();-
1650 QIcon::Mode mode = QIcon::Normal;-
1651 QIcon::State state = QIcon::Off;-
1652 for (int j = 0; j < 2
j < 2Description
TRUEnever evaluated
FALSEnever evaluated
; j++) {
0
1653 if (i != d->values.count()
i != d->values.count()Description
TRUEnever evaluated
FALSEnever evaluated
&& d->values.at(i).type == Value::KnownIdentifier
d->values.at(i...nownIdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1654 switch (d->values.at(i).variant.toInt()) {-
1655 case
never executed: case Value_Disabled:
Value_Disabled:
never executed: case Value_Disabled:
mode = QIcon::Disabled; break;
never executed: break;
0
1656 case
never executed: case Value_Active:
Value_Active:
never executed: case Value_Active:
mode = QIcon::Active; break;
never executed: break;
0
1657 case
never executed: case Value_Selected:
Value_Selected:
never executed: case Value_Selected:
mode = QIcon::Selected; break;
never executed: break;
0
1658 case
never executed: case Value_Normal:
Value_Normal:
never executed: case Value_Normal:
mode = QIcon::Normal; break;
never executed: break;
0
1659 case
never executed: case Value_On:
Value_On:
never executed: case Value_On:
state = QIcon::On; break;
never executed: break;
0
1660 case
never executed: case Value_Off:
Value_Off:
never executed: case Value_Off:
state = QIcon::Off; break;
never executed: break;
0
1661 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
1662 }-
1663 ++i;-
1664 }
never executed: end of block
else {
0
1665 break;
never executed: break;
0
1666 }-
1667 }-
1668-
1669-
1670 if (icon.isNull()
icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1671 icon = QIcon(uri);
never executed: icon = QIcon(uri);
0
1672 else-
1673 icon.addPixmap(uri, mode, state);
never executed: icon.addPixmap(uri, mode, state);
0
1674-
1675 if (i == d->values.count()
i == d->values.count()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1676 break;
never executed: break;
0
1677-
1678 if (d->values.at(i).type == Value::TermOperatorComma
d->values.at(i...mOperatorCommaDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1679 i++;
never executed: i++;
0
1680 }
never executed: end of block
0
1681-
1682 d->parsed = QVariant::fromValue<QIcon>(icon);-
1683 return
never executed: return icon;
icon;
never executed: return icon;
0
1684}-
1685-
1686-
1687-
1688int Selector::specificity() const-
1689{-
1690 int val = 0;-
1691 for (int i = 0; i < basicSelectors.count()
i < basicSelectors.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1692 const BasicSelector &sel = basicSelectors.at(i);-
1693 if (!sel.elementName.isEmpty()
!sel.elementName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1694 val += 1;
never executed: val += 1;
0
1695-
1696 val += (sel.pseudos.count() + sel.attributeSelectors.count()) * 0x10;-
1697 val += sel.ids.count() * 0x100;-
1698 }
never executed: end of block
0
1699 return
never executed: return val;
val;
never executed: return val;
0
1700}-
1701-
1702QString Selector::pseudoElement() const-
1703{-
1704 const BasicSelector& bs = basicSelectors.last();-
1705 if (!bs.pseudos.isEmpty()
!bs.pseudos.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& bs.pseudos.at(0).type == PseudoClass_Unknown
bs.pseudos.at(...oClass_UnknownDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1706 return
never executed: return bs.pseudos.at(0).name;
bs.pseudos.at(0).name;
never executed: return bs.pseudos.at(0).name;
0
1707 return
never executed: return QString();
QString();
never executed: return QString();
0
1708}-
1709-
1710quint64 Selector::pseudoClass(quint64 *negated) const-
1711{-
1712 const BasicSelector& bs = basicSelectors.last();-
1713 if (bs.pseudos.isEmpty()
bs.pseudos.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1714 return
never executed: return PseudoClass_Unspecified;
PseudoClass_Unspecified;
never executed: return PseudoClass_Unspecified;
0
1715 quint64 pc = PseudoClass_Unknown;-
1716 for (int i = !pseudoElement().isEmpty(); i < bs.pseudos.count()
i < bs.pseudos.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1717 const Pseudo &pseudo = bs.pseudos.at(i);-
1718 if (pseudo.type == PseudoClass_Unknown
pseudo.type ==...oClass_UnknownDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1719 return
never executed: return PseudoClass_Unknown;
PseudoClass_Unknown;
never executed: return PseudoClass_Unknown;
0
1720 if (!pseudo.negated
!pseudo.negatedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1721 pc |= pseudo.type;
never executed: pc |= pseudo.type;
0
1722 else if (negated
negatedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1723 *
never executed: *negated |= pseudo.type;
negated |= pseudo.type;
never executed: *negated |= pseudo.type;
0
1724 }
never executed: end of block
0
1725 return
never executed: return pc;
pc;
never executed: return pc;
0
1726}-
1727-
1728-
1729-
1730void StyleSheet::buildIndexes(Qt::CaseSensitivity nameCaseSensitivity)-
1731{-
1732 QVector<StyleRule> universals;-
1733 for (int i = 0; i < styleRules.count()
i < styleRules.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1734 const StyleRule &rule = styleRules.at(i);-
1735 QVector<Selector> universalsSelectors;-
1736 for (int j = 0; j < rule.selectors.count()
j < rule.selectors.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
1737 const Selector& selector = rule.selectors.at(j);-
1738-
1739 if (selector.basicSelectors.isEmpty()
selector.basic...tors.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1740 continue;
never executed: continue;
0
1741-
1742 if (selector.basicSelectors.at(0).relationToNext == BasicSelector::NoRelation
selector.basic...or::NoRelationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1743 if (selector.basicSelectors.count() != 1
selector.basic...s.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1744 continue;
never executed: continue;
0
1745 }
never executed: end of block
else if (selector.basicSelectors.count() <= 1
selector.basic...s.count() <= 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1746 continue;
never executed: continue;
0
1747 }-
1748-
1749 const BasicSelector &sel = selector.basicSelectors.at(selector.basicSelectors.count() - 1);-
1750-
1751 if (!sel.ids.isEmpty()
!sel.ids.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1752 StyleRule nr;-
1753 nr.selectors += selector;-
1754 nr.declarations = rule.declarations;-
1755 nr.order = i;-
1756 idIndex.insert(sel.ids.at(0), nr);-
1757 }
never executed: end of block
else if (!sel.elementName.isEmpty()
!sel.elementName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1758 StyleRule nr;-
1759 nr.selectors += selector;-
1760 nr.declarations = rule.declarations;-
1761 nr.order = i;-
1762 QString name = sel.elementName;-
1763 if (nameCaseSensitivity == Qt::CaseInsensitive
nameCaseSensit...aseInsensitiveDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1764 name=name.toLower();
never executed: name=name.toLower();
0
1765 nameIndex.insert(name, nr);-
1766 }
never executed: end of block
else {
0
1767 universalsSelectors += selector;-
1768 }
never executed: end of block
0
1769 }-
1770 if (!universalsSelectors.isEmpty()
!universalsSelectors.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1771 StyleRule nr;-
1772 nr.selectors = universalsSelectors;-
1773 nr.declarations = rule.declarations;-
1774 nr.order = i;-
1775 universals << nr;-
1776 }
never executed: end of block
0
1777 }
never executed: end of block
0
1778 styleRules = universals;-
1779}
never executed: end of block
0
1780-
1781-
1782-
1783StyleSelector::~StyleSelector()-
1784{-
1785}-
1786-
1787bool StyleSelector::nodeNameEquals(NodePtr node, const QString& nodeName) const-
1788{-
1789 return
never executed: return nodeNames(node).contains(nodeName, nameCaseSensitivity);
nodeNames(node).contains(nodeName, nameCaseSensitivity);
never executed: return nodeNames(node).contains(nodeName, nameCaseSensitivity);
0
1790}-
1791-
1792QStringList StyleSelector::nodeIds(NodePtr node) const-
1793{-
1794 return
never executed: return QStringList(attribute(node, QLatin1String("id")));
QStringList(attribute(node, QLatin1String("id")));
never executed: return QStringList(attribute(node, QLatin1String("id")));
0
1795}-
1796-
1797bool StyleSelector::selectorMatches(const Selector &selector, NodePtr node)-
1798{-
1799 if (selector.basicSelectors.isEmpty()
selector.basic...tors.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1800 return
never executed: return false;
false;
never executed: return false;
0
1801-
1802 if (selector.basicSelectors.at(0).relationToNext == BasicSelector::NoRelation
selector.basic...or::NoRelationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1803 if (selector.basicSelectors.count() != 1
selector.basic...s.count() != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1804 return
never executed: return false;
false;
never executed: return false;
0
1805 return
never executed: return basicSelectorMatches(selector.basicSelectors.at(0), node);
basicSelectorMatches(selector.basicSelectors.at(0), node);
never executed: return basicSelectorMatches(selector.basicSelectors.at(0), node);
0
1806 }-
1807 if (selector.basicSelectors.count() <= 1
selector.basic...s.count() <= 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1808 return
never executed: return false;
false;
never executed: return false;
0
1809-
1810 int i = selector.basicSelectors.count() - 1;-
1811 node = duplicateNode(node);-
1812 bool match = true;-
1813-
1814 BasicSelector sel = selector.basicSelectors.at(i);-
1815 do {-
1816 match = basicSelectorMatches(sel, node);-
1817 if (!match
!matchDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1818 if (sel.relationToNext == BasicSelector::MatchNextSelectorIfParent
sel.relationTo...lectorIfParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1819 || i == selector.basicSelectors.count() - 1
i == selector....rs.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1820 break;
never executed: break;
0
1821 }
never executed: end of block
0
1822-
1823 if (match
matchDescription
TRUEnever evaluated
FALSEnever evaluated
|| sel.relationToNext != BasicSelector::MatchNextSelectorIfAncestor
sel.relationTo...ctorIfAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1824 --
never executed: --i;
i;
never executed: --i;
0
1825-
1826 if (i < 0
i < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1827 break;
never executed: break;
0
1828-
1829 sel = selector.basicSelectors.at(i);-
1830 if (sel.relationToNext == BasicSelector::MatchNextSelectorIfAncestor
sel.relationTo...ctorIfAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1831 || sel.relationToNext == BasicSelector::MatchNextSelectorIfParent
sel.relationTo...lectorIfParentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1832-
1833 NodePtr nextParent = parentNode(node);-
1834 freeNode(node);-
1835 node = nextParent;-
1836 }
never executed: end of block
else if (sel.relationToNext == BasicSelector::MatchNextSelectorIfPreceeds
sel.relationTo...ctorIfPreceedsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1837 NodePtr previousSibling = previousSiblingNode(node);-
1838 freeNode(node);-
1839 node = previousSibling;-
1840 }
never executed: end of block
0
1841 if (isNullNode(node)
isNullNode(node)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1842 match = false;-
1843 break;
never executed: break;
0
1844 }-
1845 }
never executed: end of block
while (i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& (match
matchDescription
TRUEnever evaluated
FALSEnever evaluated
|| sel.relationToNext == BasicSelector::MatchNextSelectorIfAncestor
sel.relationTo...ctorIfAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
));
0
1846-
1847 freeNode(node);-
1848-
1849 return
never executed: return match;
match;
never executed: return match;
0
1850}-
1851-
1852bool StyleSelector::basicSelectorMatches(const BasicSelector &sel, NodePtr node)-
1853{-
1854 if (!sel.attributeSelectors.isEmpty()
!sel.attribute...tors.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1855 if (!hasAttributes(node)
!hasAttributes(node)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1856 return
never executed: return false;
false;
never executed: return false;
0
1857-
1858 for (int i = 0; i < sel.attributeSelectors.count()
i < sel.attrib...ectors.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1859 const QCss::AttributeSelector &a = sel.attributeSelectors.at(i);-
1860-
1861 const QString attrValue = attribute(node, a.name);-
1862 if (attrValue.isNull()
attrValue.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1863 return
never executed: return false;
false;
never executed: return false;
0
1864-
1865 if (a.valueMatchCriterium == QCss::AttributeSelector::MatchContains
a.valueMatchCr...:MatchContainsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1866 const auto lst = attrValue.splitRef(QLatin1Char(' '));-
1867 if (!lst.contains(QStringRef(&a.value))
!lst.contains(...Ref(&a.value))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1868 return
never executed: return false;
false;
never executed: return false;
0
1869 }
never executed: end of block
else if (
0
1870 (a.valueMatchCriterium == QCss::AttributeSelector::MatchEqual
a.valueMatchCr...or::MatchEqualDescription
TRUEnever evaluated
FALSEnever evaluated
0
1871 && attrValue != a.value
attrValue != a.valueDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1872 ||-
1873 (a.valueMatchCriterium == QCss::AttributeSelector::MatchBeginsWith
a.valueMatchCr...atchBeginsWithDescription
TRUEnever evaluated
FALSEnever evaluated
0
1874 && !attrValue.startsWith(a.value)
!attrValue.startsWith(a.value)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1875 )-
1876 return
never executed: return false;
false;
never executed: return false;
0
1877 }
never executed: end of block
0
1878 }
never executed: end of block
0
1879-
1880 if (!sel.elementName.isEmpty()
!sel.elementName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1881 && !nodeNameEquals(node, sel.elementName)
!nodeNameEqual...l.elementName)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1882 return
never executed: return false;
false;
never executed: return false;
0
1883-
1884 if (!sel.ids.isEmpty()
!sel.ids.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1885 && sel.ids != nodeIds(node)
sel.ids != nodeIds(node)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1886 return
never executed: return false;
false;
never executed: return false;
0
1887-
1888 return
never executed: return true;
true;
never executed: return true;
0
1889}-
1890-
1891void StyleSelector::matchRule(NodePtr node, const StyleRule &rule, StyleSheetOrigin origin,-
1892 int depth, QMap<uint, StyleRule> *weightedRules)-
1893{-
1894 for (int j = 0; j < rule.selectors.count()
j < rule.selectors.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
1895 const Selector& selector = rule.selectors.at(j);-
1896 if (selectorMatches(selector, node)
selectorMatche...elector, node)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1897 uint weight = rule.order-
1898 + selector.specificity() *0x100-
1899 + (uint(origin) + depth)*0x100000;-
1900 StyleRule newRule = rule;-
1901 if(rule.selectors.count() > 1
rule.selectors.count() > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1902 newRule.selectors.resize(1);-
1903 newRule.selectors[0] = selector;-
1904 }
never executed: end of block
0
1905-
1906 weightedRules->insertMulti(weight, newRule);-
1907 }
never executed: end of block
0
1908 }
never executed: end of block
0
1909}
never executed: end of block
0
1910-
1911-
1912-
1913QVector<StyleRule> StyleSelector::styleRulesForNode(NodePtr node)-
1914{-
1915 QVector<StyleRule> rules;-
1916 if (styleSheets.isEmpty()
styleSheets.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1917 return
never executed: return rules;
rules;
never executed: return rules;
0
1918-
1919 QMap<uint, StyleRule> weightedRules;-
1920-
1921-
1922 for (int sheetIdx = 0; sheetIdx < styleSheets.count()
sheetIdx < styleSheets.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++sheetIdx) {
0
1923 const StyleSheet &styleSheet = styleSheets.at(sheetIdx);-
1924 for (int i = 0; i < styleSheet.styleRules.count()
i < styleSheet...eRules.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1925 matchRule(node, styleSheet.styleRules.at(i), styleSheet.origin, styleSheet.depth, &weightedRules);-
1926 }
never executed: end of block
0
1927-
1928 if (!styleSheet.idIndex.isEmpty()
!styleSheet.idIndex.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1929 QStringList ids = nodeIds(node);-
1930 for (int i = 0; i < ids.count()
i < ids.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1931 const QString &key = ids.at(i);-
1932 QMultiHash<QString, StyleRule>::const_iterator it = styleSheet.idIndex.constFind(key);-
1933 while (it != styleSheet.idIndex.constEnd()
it != styleShe...dex.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
&& it.key() == key
it.key() == keyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1934 matchRule(node, it.value(), styleSheet.origin, styleSheet.depth, &weightedRules);-
1935 ++it;-
1936 }
never executed: end of block
0
1937 }
never executed: end of block
0
1938 }
never executed: end of block
0
1939 if (!styleSheet.nameIndex.isEmpty()
!styleSheet.na...ndex.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1940 QStringList names = nodeNames(node);-
1941 for (int i = 0; i < names.count()
i < names.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1942 QString name = names.at(i);-
1943 if (nameCaseSensitivity == Qt::CaseInsensitive
nameCaseSensit...aseInsensitiveDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1944 name = name.toLower();
never executed: name = name.toLower();
0
1945 QMultiHash<QString, StyleRule>::const_iterator it = styleSheet.nameIndex.constFind(name);-
1946 while (it != styleSheet.nameIndex.constEnd()
it != styleShe...dex.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
&& it.key() == name
it.key() == nameDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1947 matchRule(node, it.value(), styleSheet.origin, styleSheet.depth, &weightedRules);-
1948 ++it;-
1949 }
never executed: end of block
0
1950 }
never executed: end of block
0
1951 }
never executed: end of block
0
1952 if (!medium.isEmpty()
!medium.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1953 for (int i = 0; i < styleSheet.mediaRules.count()
i < styleSheet...aRules.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1954 if (styleSheet.mediaRules.at(i).media.contains(medium, Qt::CaseInsensitive)
styleSheet.med...seInsensitive)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1955 for (int j = 0; j < styleSheet.mediaRules.at(i).styleRules.count()
j < styleSheet...eRules.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
1956 matchRule(node, styleSheet.mediaRules.at(i).styleRules.at(j), styleSheet.origin,-
1957 styleSheet.depth, &weightedRules);-
1958 }
never executed: end of block
0
1959 }
never executed: end of block
0
1960 }
never executed: end of block
0
1961 }
never executed: end of block
0
1962 }
never executed: end of block
0
1963-
1964 rules.reserve(weightedRules.count());-
1965 QMap<uint, StyleRule>::const_iterator it = weightedRules.constBegin();-
1966 for ( ; it != weightedRules.constEnd()
it != weightedRules.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it)
0
1967 rules += *it;
never executed: rules += *it;
0
1968-
1969 return
never executed: return rules;
rules;
never executed: return rules;
0
1970}-
1971-
1972-
1973-
1974QVector<Declaration> StyleSelector::declarationsForNode(NodePtr node, const char *extraPseudo)-
1975{-
1976 QVector<Declaration> decls;-
1977 QVector<StyleRule> rules = styleRulesForNode(node);-
1978 for (int i = 0; i < rules.count()
i < rules.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1979 const Selector& selector = rules.at(i).selectors.at(0);-
1980 const QString pseudoElement = selector.pseudoElement();-
1981-
1982 if (extraPseudo
extraPseudoDescription
TRUEnever evaluated
FALSEnever evaluated
&& pseudoElement == QLatin1String(extraPseudo)
pseudoElement ...g(extraPseudo)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1983 decls += rules.at(i).declarations;-
1984 continue;
never executed: continue;
0
1985 }-
1986-
1987 if (!pseudoElement.isEmpty()
!pseudoElement.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1988 continue;
never executed: continue;
0
1989 quint64 pseudoClass = selector.pseudoClass();-
1990 if (pseudoClass == PseudoClass_Enabled
pseudoClass ==...oClass_EnabledDescription
TRUEnever evaluated
FALSEnever evaluated
|| pseudoClass == PseudoClass_Unspecified
pseudoClass ==...ss_UnspecifiedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1991 decls += rules.at(i).declarations;
never executed: decls += rules.at(i).declarations;
0
1992 }
never executed: end of block
0
1993 return
never executed: return decls;
decls;
never executed: return decls;
0
1994}-
1995-
1996static inline bool isHexDigit(const char c)-
1997{-
1998 return
never executed: return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') ;
(c >= '0' && c <= '9')
never executed: return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') ;
0
1999 || (c >= 'a' && c <= 'f')
never executed: return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') ;
0
2000 || (c >= 'A' && c <= 'F')
never executed: return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') ;
0
2001 ;
never executed: return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') ;
0
2002}-
2003-
2004QString Scanner::preprocess(const QString &input, bool *hasEscapeSequences)-
2005{-
2006 QString output = input;-
2007-
2008 if (hasEscapeSequences
hasEscapeSequencesDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2009 *
never executed: *hasEscapeSequences = false;
hasEscapeSequences = false;
never executed: *hasEscapeSequences = false;
0
2010-
2011 int i = 0;-
2012 while (i < output.size()
i < output.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2013 if (output.at(i) == QLatin1Char('\\')
output.at(i) =...tin1Char('\\')Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2014-
2015 ++i;-
2016-
2017 int hexCount = 0;-
2018 const int hexStart = i;-
2019 while (i < output.size()
i < output.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2020 && isHexDigit(output.at(i).toLatin1())
isHexDigit(out...i).toLatin1())Description
TRUEnever evaluated
FALSEnever evaluated
0
2021 && hexCount < 7
hexCount < 7Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2022 ++hexCount;-
2023 ++i;-
2024 }
never executed: end of block
0
2025 if (hexCount == 0
hexCount == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2026 if (hasEscapeSequences
hasEscapeSequencesDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2027 *
never executed: *hasEscapeSequences = true;
hasEscapeSequences = true;
never executed: *hasEscapeSequences = true;
0
2028 continue;
never executed: continue;
0
2029 }-
2030-
2031 hexCount = qMin(hexCount, 6);-
2032 bool ok = false;-
2033 ushort code = output.mid(hexStart, hexCount).toUShort(&ok, 16);-
2034 if (ok
okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2035 output.replace(hexStart - 1, hexCount + 1, QChar(code));-
2036 i = hexStart;-
2037 }
never executed: end of block
else {
0
2038 i = hexStart;-
2039 }
never executed: end of block
0
2040 } else {-
2041 ++i;-
2042 }
never executed: end of block
0
2043 }-
2044 return
never executed: return output;
output;
never executed: return output;
0
2045}-
2046-
2047int QCssScanner_Generated::handleCommentStart()-
2048{-
2049 while (pos < input.size() - 1
pos < input.size() - 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2050 if (input.at(pos) == QLatin1Char('*')
input.at(pos) ...atin1Char('*')Description
TRUEnever evaluated
FALSEnever evaluated
0
2051 && input.at(pos + 1) == QLatin1Char('/')
input.at(pos +...atin1Char('/')Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2052 pos += 2;-
2053 break;
never executed: break;
0
2054 }-
2055 ++pos;-
2056 }
never executed: end of block
0
2057 return
never executed: return S;
S;
never executed: return S;
0
2058}-
2059-
2060void Scanner::scan(const QString &preprocessedInput, QVector<Symbol> *symbols)-
2061{-
2062 QCssScanner_Generated scanner(preprocessedInput);-
2063 Symbol sym;-
2064 int tok = scanner.lex();-
2065 while (tok != -1
tok != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2066 sym.token = static_cast<QCss::TokenType>(tok);-
2067 sym.text = scanner.input;-
2068 sym.start = scanner.lexemStart;-
2069 sym.len = scanner.lexemLength;-
2070 symbols->append(sym);-
2071 tok = scanner.lex();-
2072 }
never executed: end of block
0
2073}
never executed: end of block
0
2074-
2075QString Symbol::lexem() const-
2076{-
2077 QString result;-
2078 if (len > 0
len > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2079 result.reserve(len);
never executed: result.reserve(len);
0
2080 for (int i = 0; i < len
i < lenDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2081 if (text.at(start + i) == QLatin1Char('\\')
text.at(start ...tin1Char('\\')Description
TRUEnever evaluated
FALSEnever evaluated
&& i < len - 1
i < len - 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2082 ++
never executed: ++i;
i;
never executed: ++i;
0
2083 result += text.at(start + i);-
2084 }
never executed: end of block
0
2085 return
never executed: return result;
result;
never executed: return result;
0
2086}-
2087-
2088Parser::Parser(const QString &css, bool isFile)-
2089{-
2090 init(css, isFile);-
2091}
never executed: end of block
0
2092-
2093Parser::Parser()-
2094{-
2095 index = 0;-
2096 errorIndex = -1;-
2097 hasEscapeSequences = false;-
2098}
never executed: end of block
0
2099-
2100void Parser::init(const QString &css, bool isFile)-
2101{-
2102 QString styleSheet = css;-
2103 if (isFile
isFileDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2104 QFile file(css);-
2105 if (file.open(QFile::ReadOnly)
file.open(QFile::ReadOnly)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2106 sourcePath = QFileInfo(styleSheet).absolutePath() + QLatin1Char('/');-
2107 QTextStream stream(&file);-
2108 styleSheet = stream.readAll();-
2109 }
never executed: end of block
else {
0
2110 QMessageLogger(__FILE__, 2167, __PRETTY_FUNCTION__).warning() << "QCss::Parser - Failed to load file " << css;-
2111 styleSheet.clear();-
2112 }
never executed: end of block
0
2113 } else {-
2114 sourcePath.clear();-
2115 }
never executed: end of block
0
2116-
2117 hasEscapeSequences = false;-
2118 symbols.clear();-
2119 symbols.reserve(8);-
2120 Scanner::scan(Scanner::preprocess(styleSheet, &hasEscapeSequences), &symbols);-
2121 index = 0;-
2122 errorIndex = -1;-
2123}
never executed: end of block
0
2124-
2125bool Parser::parse(StyleSheet *styleSheet, Qt::CaseSensitivity nameCaseSensitivity)-
2126{-
2127 if (testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("charset"))
testTokenAndEn...ng("charset"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2128 while (test(S)
test(S)Description
TRUEnever evaluated
FALSEnever evaluated
|| test(CDO)
test(CDO)Description
TRUEnever evaluated
FALSEnever evaluated
|| test(CDC)
test(CDC)Description
TRUEnever evaluated
FALSEnever evaluated
) {}
never executed: end of block
0
2129 if (!next(STRING)
!next(STRING)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2130 if (!next(SEMICOLON)
!next(SEMICOLON)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2131 }
never executed: end of block
0
2132-
2133 while (test(S)
test(S)Description
TRUEnever evaluated
FALSEnever evaluated
|| test(CDO)
test(CDO)Description
TRUEnever evaluated
FALSEnever evaluated
|| test(CDC)
test(CDC)Description
TRUEnever evaluated
FALSEnever evaluated
) {}
never executed: end of block
0
2134-
2135 while (testImport()
testImport()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2136 ImportRule rule;-
2137 if (!parseImport(&rule)
!parseImport(&rule)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2138 styleSheet->importRules.append(rule);-
2139 while (test(S)
test(S)Description
TRUEnever evaluated
FALSEnever evaluated
|| test(CDO)
test(CDO)Description
TRUEnever evaluated
FALSEnever evaluated
|| test(CDC)
test(CDC)Description
TRUEnever evaluated
FALSEnever evaluated
) {}
never executed: end of block
0
2140 }
never executed: end of block
0
2141-
2142 do {-
2143 if (testMedia()
testMedia()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2144 MediaRule rule;-
2145 if (!parseMedia(&rule)
!parseMedia(&rule)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2146 styleSheet->mediaRules.append(rule);-
2147 }
never executed: end of block
else if (testPage()
testPage()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2148 PageRule rule;-
2149 if (!parsePage(&rule)
!parsePage(&rule)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2150 styleSheet->pageRules.append(rule);-
2151 }
never executed: end of block
else if (testRuleset()
testRuleset()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2152 StyleRule rule;-
2153 if (!parseRuleset(&rule)
!parseRuleset(&rule)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2154 styleSheet->styleRules.append(rule);-
2155 }
never executed: end of block
else if (test(ATKEYWORD_SYM)
test(ATKEYWORD_SYM)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2156 if (!until(RBRACE)
!until(RBRACE)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2157 }
never executed: end of block
else if (hasNext()
hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2158 return
never executed: return false;
false;
never executed: return false;
0
2159 }-
2160 while (test(S)
test(S)Description
TRUEnever evaluated
FALSEnever evaluated
|| test(CDO)
test(CDO)Description
TRUEnever evaluated
FALSEnever evaluated
|| test(CDC)
test(CDC)Description
TRUEnever evaluated
FALSEnever evaluated
) {}
never executed: end of block
0
2161 }
never executed: end of block
while (hasNext()
hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
);
0
2162 styleSheet->buildIndexes(nameCaseSensitivity);-
2163 return
never executed: return true;
true;
never executed: return true;
0
2164}-
2165-
2166Symbol Parser::errorSymbol()-
2167{-
2168 if (errorIndex == -1
errorIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return Symbol();
Symbol();
never executed: return Symbol();
0
2169 return
never executed: return symbols.at(errorIndex);
symbols.at(errorIndex);
never executed: return symbols.at(errorIndex);
0
2170}-
2171-
2172static inline void removeOptionalQuotes(QString *str)-
2173{-
2174 if (!str->startsWith(QLatin1Char('\''))
!str->startsWi...in1Char('\''))Description
TRUEnever evaluated
FALSEnever evaluated
0
2175 && !str->startsWith(QLatin1Char('\"'))
!str->startsWi...in1Char('\"'))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2176 return;
never executed: return;
0
2177 str->remove(0, 1);-
2178 str->chop(1);-
2179}
never executed: end of block
0
2180-
2181bool Parser::parseImport(ImportRule *importRule)-
2182{-
2183 skipSpace();-
2184-
2185 if (test(STRING)
test(STRING)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2186 importRule->href = lexem();-
2187 }
never executed: end of block
else {
0
2188 if (!testAndParseUri(&importRule->href)
!testAndParseU...ortRule->href)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2189 }
never executed: end of block
0
2190 removeOptionalQuotes(&importRule->href);-
2191-
2192 skipSpace();-
2193-
2194 if (testMedium()
testMedium()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2195 if (!parseMedium(&importRule->media)
!parseMedium(&...rtRule->media)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2196-
2197 while (test(COMMA)
test(COMMA)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2198 skipSpace();-
2199 if (!parseNextMedium(&importRule->media)
!parseNextMedi...rtRule->media)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2200 }
never executed: end of block
0
2201 }
never executed: end of block
0
2202-
2203 if (!next(SEMICOLON)
!next(SEMICOLON)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2204-
2205 skipSpace();-
2206 return
never executed: return true;
true;
never executed: return true;
0
2207}-
2208-
2209bool Parser::parseMedia(MediaRule *mediaRule)-
2210{-
2211 do {-
2212 skipSpace();-
2213 if (!parseNextMedium(&mediaRule->media)
!parseNextMedi...iaRule->media)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2214 }
never executed: end of block
while (test(COMMA)
test(COMMA)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
2215-
2216 if (!next(LBRACE)
!next(LBRACE)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2217 skipSpace();-
2218-
2219 while (testRuleset()
testRuleset()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2220 StyleRule rule;-
2221 if (!parseRuleset(&rule)
!parseRuleset(&rule)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2222 mediaRule->styleRules.append(rule);-
2223 }
never executed: end of block
0
2224-
2225 if (!next(RBRACE)
!next(RBRACE)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2226 skipSpace();-
2227 return
never executed: return true;
true;
never executed: return true;
0
2228}-
2229-
2230bool Parser::parseMedium(QStringList *media)-
2231{-
2232 media->append(lexem());-
2233 skipSpace();-
2234 return
never executed: return true;
true;
never executed: return true;
0
2235}-
2236-
2237bool Parser::parsePage(PageRule *pageRule)-
2238{-
2239 skipSpace();-
2240-
2241 if (testPseudoPage()
testPseudoPage()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2242 if (!parsePseudoPage(&pageRule->selector)
!parsePseudoPa...ule->selector)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2243-
2244 skipSpace();-
2245 if (!next(LBRACE)
!next(LBRACE)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2246-
2247 do {-
2248 skipSpace();-
2249 Declaration decl;-
2250 if (!parseNextDeclaration(&decl)
!parseNextDeclaration(&decl)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2251 if (!decl.isEmpty()
!decl.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2252 pageRule->declarations.append(decl);
never executed: pageRule->declarations.append(decl);
0
2253 }
never executed: end of block
while (test(SEMICOLON)
test(SEMICOLON)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
2254-
2255 if (!next(RBRACE)
!next(RBRACE)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2256 skipSpace();-
2257 return
never executed: return true;
true;
never executed: return true;
0
2258}-
2259-
2260bool Parser::parsePseudoPage(QString *selector)-
2261{-
2262 if (!next(IDENT)
!next(IDENT)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2263 *selector = lexem();-
2264 return
never executed: return true;
true;
never executed: return true;
0
2265}-
2266-
2267bool Parser::parseNextOperator(Value *value)-
2268{-
2269 if (!hasNext()
!hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return true;
true;
never executed: return true;
0
2270 switch (next()) {-
2271 case
never executed: case SLASH:
SLASH:
never executed: case SLASH:
value->type = Value::TermOperatorSlash; skipSpace(); break;
never executed: break;
0
2272 case
never executed: case COMMA:
COMMA:
never executed: case COMMA:
value->type = Value::TermOperatorComma; skipSpace(); break;
never executed: break;
0
2273 default
never executed: default:
:
never executed: default:
prev(); break;
never executed: break;
0
2274 }-
2275 return
never executed: return true;
true;
never executed: return true;
0
2276}-
2277-
2278bool Parser::parseCombinator(BasicSelector::Relation *relation)-
2279{-
2280 *relation = BasicSelector::NoRelation;-
2281 if (lookup() == S
lookup() == SDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2282 *relation = BasicSelector::MatchNextSelectorIfAncestor;-
2283 skipSpace();-
2284 }
never executed: end of block
else {
0
2285 prev();-
2286 }
never executed: end of block
0
2287 if (test(PLUS)
test(PLUS)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2288 *relation = BasicSelector::MatchNextSelectorIfPreceeds;-
2289 }
never executed: end of block
else if (test(GREATER)
test(GREATER)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2290 *relation = BasicSelector::MatchNextSelectorIfParent;-
2291 }
never executed: end of block
0
2292 skipSpace();-
2293 return
never executed: return true;
true;
never executed: return true;
0
2294}-
2295-
2296bool Parser::parseProperty(Declaration *decl)-
2297{-
2298 decl->d->property = lexem();-
2299 decl->d->propertyId = static_cast<Property>(findKnownValue(decl->d->property, properties, NumProperties));-
2300 decl->d->inheritable = isInheritable(decl->d->propertyId);-
2301 skipSpace();-
2302 return
never executed: return true;
true;
never executed: return true;
0
2303}-
2304-
2305bool Parser::parseRuleset(StyleRule *styleRule)-
2306{-
2307 Selector sel;-
2308 if (!parseSelector(&sel)
!parseSelector(&sel)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2309 styleRule->selectors.append(sel);-
2310-
2311 while (test(COMMA)
test(COMMA)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2312 skipSpace();-
2313 Selector sel;-
2314 if (!parseNextSelector(&sel)
!parseNextSelector(&sel)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2315 styleRule->selectors.append(sel);-
2316 }
never executed: end of block
0
2317-
2318 skipSpace();-
2319 if (!next(LBRACE)
!next(LBRACE)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2320 const int declarationStart = index;-
2321-
2322 do {-
2323 skipSpace();-
2324 Declaration decl;-
2325 const int rewind = index;-
2326 if (!parseNextDeclaration(&decl)
!parseNextDeclaration(&decl)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2327 index = rewind;-
2328 const bool foundSemicolon = until(SEMICOLON);-
2329 const int semicolonIndex = index;-
2330-
2331 index = declarationStart;-
2332 const bool foundRBrace = until(RBRACE);-
2333-
2334 if (foundSemicolon
foundSemicolonDescription
TRUEnever evaluated
FALSEnever evaluated
&& semicolonIndex < index
semicolonIndex < indexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2335 decl = Declaration();-
2336 index = semicolonIndex - 1;-
2337 }
never executed: end of block
else {
0
2338 skipSpace();-
2339 return
never executed: return foundRBrace;
foundRBrace;
never executed: return foundRBrace;
0
2340 }-
2341 }-
2342 if (!decl.isEmpty()
!decl.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2343 styleRule->declarations.append(decl);
never executed: styleRule->declarations.append(decl);
0
2344 }
never executed: end of block
while (test(SEMICOLON)
test(SEMICOLON)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
2345-
2346 if (!next(RBRACE)
!next(RBRACE)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2347 skipSpace();-
2348 return
never executed: return true;
true;
never executed: return true;
0
2349}-
2350-
2351bool Parser::parseSelector(Selector *sel)-
2352{-
2353 BasicSelector basicSel;-
2354 if (!parseSimpleSelector(&basicSel)
!parseSimpleSe...tor(&basicSel)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2355 while (testCombinator()
testCombinator()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2356 if (!parseCombinator(&basicSel.relationToNext)
!parseCombinat...elationToNext)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2357-
2358 if (!testSimpleSelector()
!testSimpleSelector()Description
TRUEnever evaluated
FALSEnever evaluated
) break;
never executed: break;
0
2359 sel->basicSelectors.append(basicSel);-
2360-
2361 basicSel = BasicSelector();-
2362 if (!parseSimpleSelector(&basicSel)
!parseSimpleSe...tor(&basicSel)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2363 }
never executed: end of block
0
2364 sel->basicSelectors.append(basicSel);-
2365 return
never executed: return true;
true;
never executed: return true;
0
2366}-
2367-
2368bool Parser::parseSimpleSelector(BasicSelector *basicSel)-
2369{-
2370 int minCount = 0;-
2371 if (lookupElementName()
lookupElementName()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2372 if (!parseElementName(&basicSel->elementName)
!parseElementN...->elementName)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2373 }
never executed: end of block
else {
0
2374 prev();-
2375 minCount = 1;-
2376 }
never executed: end of block
0
2377 bool onceMore;-
2378 int count = 0;-
2379 do {-
2380 onceMore = false;-
2381 if (test(HASH)
test(HASH)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2382 QString theid = lexem();-
2383-
2384 theid.remove(0, 1);-
2385 basicSel->ids.append(theid);-
2386 onceMore = true;-
2387 }
never executed: end of block
else if (testClass()
testClass()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2388 onceMore = true;-
2389 AttributeSelector a;-
2390 a.name = QLatin1String("class");-
2391 a.valueMatchCriterium = AttributeSelector::MatchContains;-
2392 if (!parseClass(&a.value)
!parseClass(&a.value)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2393 basicSel->attributeSelectors.append(a);-
2394 }
never executed: end of block
else if (testAttrib()
testAttrib()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2395 onceMore = true;-
2396 AttributeSelector a;-
2397 if (!parseAttrib(&a)
!parseAttrib(&a)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2398 basicSel->attributeSelectors.append(a);-
2399 }
never executed: end of block
else if (testPseudo()
testPseudo()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2400 onceMore = true;-
2401 Pseudo ps;-
2402 if (!parsePseudo(&ps)
!parsePseudo(&ps)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2403 basicSel->pseudos.append(ps);-
2404 }
never executed: end of block
0
2405 if (onceMore
onceMoreDescription
TRUEnever evaluated
FALSEnever evaluated
) ++
never executed: ++count;
count;
never executed: ++count;
0
2406 }
never executed: end of block
while (onceMore
onceMoreDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
2407 return
never executed: return count >= minCount;
count >= minCount;
never executed: return count >= minCount;
0
2408}-
2409-
2410bool Parser::parseClass(QString *name)-
2411{-
2412 if (!next(IDENT)
!next(IDENT)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2413 *name = lexem();-
2414 return
never executed: return true;
true;
never executed: return true;
0
2415}-
2416-
2417bool Parser::parseElementName(QString *name)-
2418{-
2419 switch (lookup()) {-
2420 case
never executed: case STAR:
STAR:
never executed: case STAR:
name->clear(); break;
never executed: break;
0
2421 case
never executed: case IDENT:
IDENT:
never executed: case IDENT:
*name = lexem(); break;
never executed: break;
0
2422 default
never executed: default:
:
never executed: default:
return
never executed: return false;
false;
never executed: return false;
0
2423 }-
2424 return
never executed: return true;
true;
never executed: return true;
0
2425}-
2426-
2427bool Parser::parseAttrib(AttributeSelector *attr)-
2428{-
2429 skipSpace();-
2430 if (!next(IDENT)
!next(IDENT)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2431 attr->name = lexem();-
2432 skipSpace();-
2433-
2434 if (test(EQUAL)
test(EQUAL)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2435 attr->valueMatchCriterium = AttributeSelector::MatchEqual;-
2436 }
never executed: end of block
else if (test(INCLUDES)
test(INCLUDES)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2437 attr->valueMatchCriterium = AttributeSelector::MatchContains;-
2438 }
never executed: end of block
else if (test(DASHMATCH)
test(DASHMATCH)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2439 attr->valueMatchCriterium = AttributeSelector::MatchBeginsWith;-
2440 }
never executed: end of block
else {
0
2441 return
never executed: return next(RBRACKET);
next(RBRACKET);
never executed: return next(RBRACKET);
0
2442 }-
2443-
2444 skipSpace();-
2445-
2446 if (!test(IDENT)
!test(IDENT)Description
TRUEnever evaluated
FALSEnever evaluated
&& !test(STRING)
!test(STRING)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2447 attr->value = unquotedLexem();-
2448-
2449 skipSpace();-
2450 return
never executed: return next(RBRACKET);
next(RBRACKET);
never executed: return next(RBRACKET);
0
2451}-
2452-
2453bool Parser::parsePseudo(Pseudo *pseudo)-
2454{-
2455 (void)test(COLON);-
2456 pseudo->negated = test(EXCLAMATION_SYM);-
2457 if (test(IDENT)
test(IDENT)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2458 pseudo->name = lexem();-
2459 pseudo->type = static_cast<quint64>(findKnownValue(pseudo->name, pseudos, NumPseudos));-
2460 return
never executed: return true;
true;
never executed: return true;
0
2461 }-
2462 if (!next(FUNCTION)
!next(FUNCTION)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2463 pseudo->function = lexem();-
2464-
2465 pseudo->function.chop(1);-
2466 skipSpace();-
2467 if (!test(IDENT)
!test(IDENT)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2468 pseudo->name = lexem();-
2469 skipSpace();-
2470 return
never executed: return next(RPAREN);
next(RPAREN);
never executed: return next(RPAREN);
0
2471}-
2472-
2473bool Parser::parseNextDeclaration(Declaration *decl)-
2474{-
2475 if (!testProperty()
!testProperty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2476 return
never executed: return true;
true;
never executed: return true;
0
2477 if (!parseProperty(decl)
!parseProperty(decl)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2478 if (!next(COLON)
!next(COLON)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2479 skipSpace();-
2480 if (!parseNextExpr(&decl->d->values)
!parseNextExpr...cl->d->values)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2481 if (testPrio()
testPrio()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2482 if (!parsePrio(decl)
!parsePrio(decl)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2483 return
never executed: return true;
true;
never executed: return true;
0
2484}-
2485-
2486bool Parser::testPrio()-
2487{-
2488 const int rewind = index;-
2489 if (!test(EXCLAMATION_SYM)
!test(EXCLAMATION_SYM)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2490 skipSpace();-
2491 if (!test(IDENT)
!test(IDENT)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2492 index = rewind;-
2493 return
never executed: return false;
false;
never executed: return false;
0
2494 }-
2495 if (lexem().compare(QLatin1String("important"), Qt::CaseInsensitive) != 0
lexem().compar...ensitive) != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2496 index = rewind;-
2497 return
never executed: return false;
false;
never executed: return false;
0
2498 }-
2499 return
never executed: return true;
true;
never executed: return true;
0
2500}-
2501-
2502bool Parser::parsePrio(Declaration *declaration)-
2503{-
2504 declaration->d->important = true;-
2505 skipSpace();-
2506 return
never executed: return true;
true;
never executed: return true;
0
2507}-
2508-
2509bool Parser::parseExpr(QVector<Value> *values)-
2510{-
2511 Value val;-
2512 if (!parseTerm(&val)
!parseTerm(&val)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2513 values->append(val);-
2514 bool onceMore;-
2515 do {-
2516 onceMore = false;-
2517 val = Value();-
2518 if (!parseNextOperator(&val)
!parseNextOperator(&val)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2519 if (val.type != QCss::Value::Unknown
val.type != QC...Value::UnknownDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2520 values->append(val);
never executed: values->append(val);
0
2521 if (testTerm()
testTerm()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2522 onceMore = true;-
2523 val = Value();-
2524 if (!parseTerm(&val)
!parseTerm(&val)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2525 values->append(val);-
2526 }
never executed: end of block
0
2527 }
never executed: end of block
while (onceMore
onceMoreDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
2528 return
never executed: return true;
true;
never executed: return true;
0
2529}-
2530-
2531bool Parser::testTerm()-
2532{-
2533 return
never executed: return test(PLUS) || test(MINUS) || test(NUMBER) || test(PERCENTAGE) || test(LENGTH) || test(STRING) || test(IDENT) || testHexColor() || testFunction();
test(PLUS) || test(MINUS)
never executed: return test(PLUS) || test(MINUS) || test(NUMBER) || test(PERCENTAGE) || test(LENGTH) || test(STRING) || test(IDENT) || testHexColor() || testFunction();
0
2534 || test(NUMBER)
never executed: return test(PLUS) || test(MINUS) || test(NUMBER) || test(PERCENTAGE) || test(LENGTH) || test(STRING) || test(IDENT) || testHexColor() || testFunction();
0
2535 || test(PERCENTAGE)
never executed: return test(PLUS) || test(MINUS) || test(NUMBER) || test(PERCENTAGE) || test(LENGTH) || test(STRING) || test(IDENT) || testHexColor() || testFunction();
0
2536 || test(LENGTH)
never executed: return test(PLUS) || test(MINUS) || test(NUMBER) || test(PERCENTAGE) || test(LENGTH) || test(STRING) || test(IDENT) || testHexColor() || testFunction();
0
2537 || test(STRING)
never executed: return test(PLUS) || test(MINUS) || test(NUMBER) || test(PERCENTAGE) || test(LENGTH) || test(STRING) || test(IDENT) || testHexColor() || testFunction();
0
2538 || test(IDENT)
never executed: return test(PLUS) || test(MINUS) || test(NUMBER) || test(PERCENTAGE) || test(LENGTH) || test(STRING) || test(IDENT) || testHexColor() || testFunction();
0
2539 || testHexColor()
never executed: return test(PLUS) || test(MINUS) || test(NUMBER) || test(PERCENTAGE) || test(LENGTH) || test(STRING) || test(IDENT) || testHexColor() || testFunction();
0
2540 || testFunction();
never executed: return test(PLUS) || test(MINUS) || test(NUMBER) || test(PERCENTAGE) || test(LENGTH) || test(STRING) || test(IDENT) || testHexColor() || testFunction();
0
2541}-
2542-
2543bool Parser::parseTerm(Value *value)-
2544{-
2545 QString str = lexem();-
2546 bool haveUnary = false;-
2547 if (lookup() == PLUS
lookup() == PLUSDescription
TRUEnever evaluated
FALSEnever evaluated
|| lookup() == MINUS
lookup() == MINUSDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2548 haveUnary = true;-
2549 if (!hasNext()
!hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2550 next();-
2551 str += lexem();-
2552 }
never executed: end of block
0
2553-
2554 value->variant = str;-
2555 value->type = QCss::Value::String;-
2556 switch (lookup()) {-
2557 case
never executed: case NUMBER:
NUMBER:
never executed: case NUMBER:
0
2558 value->type = Value::Number;-
2559 value->variant.convert(QVariant::Double);-
2560 break;
never executed: break;
0
2561 case
never executed: case PERCENTAGE:
PERCENTAGE:
never executed: case PERCENTAGE:
0
2562 value->type = Value::Percentage;-
2563 str.chop(1);-
2564 value->variant = str;-
2565 break;
never executed: break;
0
2566 case
never executed: case LENGTH:
LENGTH:
never executed: case LENGTH:
0
2567 value->type = Value::Length;-
2568 break;
never executed: break;
0
2569-
2570 case
never executed: case STRING:
STRING:
never executed: case STRING:
0
2571 if (haveUnary
haveUnaryDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2572 value->type = Value::String;-
2573 str.chop(1);-
2574 str.remove(0, 1);-
2575 value->variant = str;-
2576 break;
never executed: break;
0
2577 case
never executed: case IDENT:
IDENT:
never executed: case IDENT:
{
0
2578 if (haveUnary
haveUnaryDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2579 value->type = Value::Identifier;-
2580 const int theid = findKnownValue(str, values, NumKnownValues);-
2581 if (theid != 0
theid != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2582 value->type = Value::KnownIdentifier;-
2583 value->variant = theid;-
2584 }
never executed: end of block
0
2585 break;
never executed: break;
0
2586 }-
2587 default
never executed: default:
:
never executed: default:
{
0
2588 if (haveUnary
haveUnaryDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2589 prev();-
2590 if (testHexColor()
testHexColor()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2591 QColor col;-
2592 if (!parseHexColor(&col)
!parseHexColor(&col)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2593 value->type = Value::Color;-
2594 value->variant = col;-
2595 }
never executed: end of block
else if (testFunction()
testFunction()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2596 QString name, args;-
2597 if (!parseFunction(&name, &args)
!parseFunction(&name, &args)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2598 if (name == QLatin1String("url")
name == QLatin1String("url")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2599 value->type = Value::Uri;-
2600 removeOptionalQuotes(&args);-
2601 if (QFileInfo(args).isRelative()
QFileInfo(args).isRelative()Description
TRUEnever evaluated
FALSEnever evaluated
&& !sourcePath.isEmpty()
!sourcePath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2602 args.prepend(sourcePath);-
2603 }
never executed: end of block
0
2604 value->variant = args;-
2605 }
never executed: end of block
else {
0
2606 value->type = Value::Function;-
2607 value->variant = QStringList() << name << args;-
2608 }
never executed: end of block
0
2609 } else {-
2610 return
never executed: return recordError();
recordError();
never executed: return recordError();
0
2611 }-
2612 return
never executed: return true;
true;
never executed: return true;
0
2613 }-
2614 }-
2615 skipSpace();-
2616 return
never executed: return true;
true;
never executed: return true;
0
2617}-
2618-
2619bool Parser::parseFunction(QString *name, QString *args)-
2620{-
2621 *name = lexem();-
2622 name->chop(1);-
2623 skipSpace();-
2624 const int start = index;-
2625 if (!until(RPAREN)
!until(RPAREN)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2626 for (int i = start; i < index - 1
i < index - 1Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
2627 args->append(symbols.at(i).lexem());
never executed: args->append(symbols.at(i).lexem());
0
2628-
2629-
2630-
2631-
2632 skipSpace();-
2633 return
never executed: return true;
true;
never executed: return true;
0
2634}-
2635-
2636bool Parser::parseHexColor(QColor *col)-
2637{-
2638 col->setNamedColor(lexem());-
2639 if (!col->isValid()
!col->isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2640 QMessageLogger(__FILE__, 2697, __PRETTY_FUNCTION__).warning("QCssParser::parseHexColor: Unknown color name '%s'",lexem().toLatin1().constData());-
2641 return
never executed: return false;
false;
never executed: return false;
0
2642 }-
2643 skipSpace();-
2644 return
never executed: return true;
true;
never executed: return true;
0
2645}-
2646-
2647bool Parser::testAndParseUri(QString *uri)-
2648{-
2649 const int rewind = index;-
2650 if (!testFunction()
!testFunction()Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2651-
2652 QString name, args;-
2653 if (!parseFunction(&name, &args)
!parseFunction(&name, &args)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2654 index = rewind;-
2655 return
never executed: return false;
false;
never executed: return false;
0
2656 }-
2657 if (name.toLower() != QLatin1String("url")
name.toLower()...1String("url")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2658 index = rewind;-
2659 return
never executed: return false;
false;
never executed: return false;
0
2660 }-
2661 *uri = args;-
2662 removeOptionalQuotes(uri);-
2663 return
never executed: return true;
true;
never executed: return true;
0
2664}-
2665-
2666bool Parser::testSimpleSelector()-
2667{-
2668 return
never executed: return testElementName() || (test(HASH)) || testClass() || testAttrib() || testPseudo();
testElementName()
never executed: return testElementName() || (test(HASH)) || testClass() || testAttrib() || testPseudo();
0
2669 || (test(HASH))
never executed: return testElementName() || (test(HASH)) || testClass() || testAttrib() || testPseudo();
0
2670 || testClass()
never executed: return testElementName() || (test(HASH)) || testClass() || testAttrib() || testPseudo();
0
2671 || testAttrib()
never executed: return testElementName() || (test(HASH)) || testClass() || testAttrib() || testPseudo();
0
2672 || testPseudo();
never executed: return testElementName() || (test(HASH)) || testClass() || testAttrib() || testPseudo();
0
2673}-
2674-
2675bool Parser::next(QCss::TokenType t)-
2676{-
2677 if (hasNext()
hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
&& next() == t
next() == tDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2678 return
never executed: return true;
true;
never executed: return true;
0
2679 return
never executed: return recordError();
recordError();
never executed: return recordError();
0
2680}-
2681-
2682bool Parser::test(QCss::TokenType t)-
2683{-
2684 if (index >= symbols.count()
index >= symbols.count()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2685 return
never executed: return false;
false;
never executed: return false;
0
2686 if (symbols.at(index).token == t
symbols.at(index).token == tDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2687 ++index;-
2688 return
never executed: return true;
true;
never executed: return true;
0
2689 }-
2690 return
never executed: return false;
false;
never executed: return false;
0
2691}-
2692-
2693QString Parser::unquotedLexem() const-
2694{-
2695 QString s = lexem();-
2696 if (lookup() == STRING
lookup() == STRINGDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2697 s.chop(1);-
2698 s.remove(0, 1);-
2699 }
never executed: end of block
0
2700 return
never executed: return s;
s;
never executed: return s;
0
2701}-
2702-
2703QString Parser::lexemUntil(QCss::TokenType t)-
2704{-
2705 QString lexem;-
2706 while (hasNext()
hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
&& next() != t
next() != tDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2707 lexem += symbol().lexem();
never executed: lexem += symbol().lexem();
0
2708 return
never executed: return lexem;
lexem;
never executed: return lexem;
0
2709}-
2710-
2711bool Parser::until(QCss::TokenType target, QCss::TokenType target2)-
2712{-
2713 int braceCount = 0;-
2714 int brackCount = 0;-
2715 int parenCount = 0;-
2716 if (index
indexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2717 switch(symbols.at(index-1).token) {-
2718 case
never executed: case LBRACE:
LBRACE:
never executed: case LBRACE:
++braceCount; break;
never executed: break;
0
2719 case
never executed: case LBRACKET:
LBRACKET:
never executed: case LBRACKET:
++brackCount; break;
never executed: break;
0
2720 case
never executed: case FUNCTION:
FUNCTION:
never executed: case FUNCTION:
0
2721 case
never executed: case LPAREN:
LPAREN:
never executed: case LPAREN:
++parenCount; break;
never executed: break;
0
2722 default
never executed: default:
:
never executed: default:
;
0
2723 }
never executed: end of block
0
2724 }-
2725 while (index < symbols.size()
index < symbols.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2726 QCss::TokenType t = symbols.at(index++).token;-
2727 switch (t) {-
2728 case
never executed: case LBRACE:
LBRACE:
never executed: case LBRACE:
++braceCount; break;
never executed: break;
0
2729 case
never executed: case RBRACE:
RBRACE:
never executed: case RBRACE:
--braceCount; break;
never executed: break;
0
2730 case
never executed: case LBRACKET:
LBRACKET:
never executed: case LBRACKET:
++brackCount; break;
never executed: break;
0
2731 case
never executed: case RBRACKET:
RBRACKET:
never executed: case RBRACKET:
--brackCount; break;
never executed: break;
0
2732 case
never executed: case FUNCTION:
FUNCTION:
never executed: case FUNCTION:
0
2733 case
never executed: case LPAREN:
LPAREN:
never executed: case LPAREN:
++parenCount; break;
never executed: break;
0
2734 case
never executed: case RPAREN:
RPAREN:
never executed: case RPAREN:
--parenCount; break;
never executed: break;
0
2735 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
2736 }-
2737 if ((t == target
t == targetDescription
TRUEnever evaluated
FALSEnever evaluated
|| (target2 != NONE
target2 != NONEDescription
TRUEnever evaluated
FALSEnever evaluated
&& t == target2
t == target2Description
TRUEnever evaluated
FALSEnever evaluated
))
0
2738 && braceCount <= 0
braceCount <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2739 && brackCount <= 0
brackCount <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2740 && parenCount <= 0
parenCount <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2741 return
never executed: return true;
true;
never executed: return true;
0
2742-
2743 if (braceCount < 0
braceCount < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| brackCount < 0
brackCount < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| parenCount < 0
parenCount < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2744 --index;-
2745 break;
never executed: break;
0
2746 }-
2747 }
never executed: end of block
0
2748 return
never executed: return false;
false;
never executed: return false;
0
2749}-
2750-
2751bool Parser::testTokenAndEndsWith(QCss::TokenType t, QLatin1String str)-
2752{-
2753 if (!test(t)
!test(t)Description
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
2754 if (!lexem().endsWith(str, Qt::CaseInsensitive)
!lexem().endsW...seInsensitive)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2755 prev();-
2756 return
never executed: return false;
false;
never executed: return false;
0
2757 }-
2758 return
never executed: return true;
true;
never executed: return true;
0
2759}-
2760-
2761-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9