text/qcssparser.cpp

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

Generated by Squish Coco Non-Commercial