OpenCoverage

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() <