qcssparser.cpp

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

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