painting/qcssutil.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qcssutil_p.h" -
43#include "private/qcssparser_p.h" -
44#include "qpainter.h" -
45#include <qmath.h> -
46 -
47#ifndef QT_NO_CSSPARSER -
48 -
49QT_BEGIN_NAMESPACE -
50 -
51using namespace QCss; -
52 -
53static QPen qPenFromStyle(const QBrush& b, qreal width, BorderStyle s) -
54{ -
55 Qt::PenStyle ps = Qt::NoPen;
never executed (the execution status of this line is deduced): Qt::PenStyle ps = Qt::NoPen;
-
56 -
57 switch (s) { -
58 case BorderStyle_Dotted: -
59 ps = Qt::DotLine;
never executed (the execution status of this line is deduced): ps = Qt::DotLine;
-
60 break;
never executed: break;
0
61 case BorderStyle_Dashed: -
62 ps = width == 1 ? Qt::DotLine : Qt::DashLine;
never evaluated: width == 1
0
63 break;
never executed: break;
0
64 case BorderStyle_DotDash: -
65 ps = Qt::DashDotLine;
never executed (the execution status of this line is deduced): ps = Qt::DashDotLine;
-
66 break;
never executed: break;
0
67 case BorderStyle_DotDotDash: -
68 ps = Qt::DashDotDotLine;
never executed (the execution status of this line is deduced): ps = Qt::DashDotDotLine;
-
69 break;
never executed: break;
0
70 case BorderStyle_Inset: -
71 case BorderStyle_Outset: -
72 case BorderStyle_Solid: -
73 ps = Qt::SolidLine;
never executed (the execution status of this line is deduced): ps = Qt::SolidLine;
-
74 break;
never executed: break;
0
75 default: -
76 break;
never executed: break;
0
77 } -
78 -
79 return QPen(b, width, ps, Qt::FlatCap);
never executed: return QPen(b, width, ps, Qt::FlatCap);
0
80} -
81 -
82void qDrawRoundedCorners(QPainter *p, qreal x1, qreal y1, qreal x2, qreal y2, -
83 const QSizeF& r1, const QSizeF& r2, -
84 Edge edge, BorderStyle s, QBrush c) -
85{ -
86 const qreal pw = (edge == TopEdge || edge == BottomEdge) ? y2-y1 : x2-x1;
never evaluated: edge == TopEdge
never evaluated: edge == BottomEdge
0
87 if (s == BorderStyle_Double) {
never evaluated: s == BorderStyle_Double
0
88 qreal wby3 = pw/3;
never executed (the execution status of this line is deduced): qreal wby3 = pw/3;
-
89 switch (edge) { -
90 case TopEdge: -
91 case BottomEdge: -
92 qDrawRoundedCorners(p, x1, y1, x2, y1+wby3, r1, r2, edge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1, y1, x2, y1+wby3, r1, r2, edge, BorderStyle_Solid, c);
-
93 qDrawRoundedCorners(p, x1, y2-wby3, x2, y2, r1, r2, edge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1, y2-wby3, x2, y2, r1, r2, edge, BorderStyle_Solid, c);
-
94 break;
never executed: break;
0
95 case LeftEdge: -
96 qDrawRoundedCorners(p, x1, y1+1, x1+wby3, y2, r1, r2, LeftEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1, y1+1, x1+wby3, y2, r1, r2, LeftEdge, BorderStyle_Solid, c);
-
97 qDrawRoundedCorners(p, x2-wby3, y1+1, x2, y2, r1, r2, LeftEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x2-wby3, y1+1, x2, y2, r1, r2, LeftEdge, BorderStyle_Solid, c);
-
98 break;
never executed: break;
0
99 case RightEdge: -
100 qDrawRoundedCorners(p, x1, y1+1, x1+wby3, y2, r1, r2, RightEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1, y1+1, x1+wby3, y2, r1, r2, RightEdge, BorderStyle_Solid, c);
-
101 qDrawRoundedCorners(p, x2-wby3, y1+1, x2, y2, r1, r2, RightEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x2-wby3, y1+1, x2, y2, r1, r2, RightEdge, BorderStyle_Solid, c);
-
102 break;
never executed: break;
0
103 default: -
104 break;
never executed: break;
0
105 } -
106 return;
never executed: return;
0
107 } else if (s == BorderStyle_Ridge || s == BorderStyle_Groove) {
never evaluated: s == BorderStyle_Ridge
never evaluated: s == BorderStyle_Groove
0
108 BorderStyle s1, s2;
never executed (the execution status of this line is deduced): BorderStyle s1, s2;
-
109 if (s == BorderStyle_Groove) {
never evaluated: s == BorderStyle_Groove
0
110 s1 = BorderStyle_Inset;
never executed (the execution status of this line is deduced): s1 = BorderStyle_Inset;
-
111 s2 = BorderStyle_Outset;
never executed (the execution status of this line is deduced): s2 = BorderStyle_Outset;
-
112 } else {
never executed: }
0
113 s1 = BorderStyle_Outset;
never executed (the execution status of this line is deduced): s1 = BorderStyle_Outset;
-
114 s2 = BorderStyle_Inset;
never executed (the execution status of this line is deduced): s2 = BorderStyle_Inset;
-
115 }
never executed: }
0
116 int pwby2 = qRound(pw/2);
never executed (the execution status of this line is deduced): int pwby2 = qRound(pw/2);
-
117 switch (edge) { -
118 case TopEdge: -
119 qDrawRoundedCorners(p, x1, y1, x2, y1 + pwby2, r1, r2, TopEdge, s1, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1, y1, x2, y1 + pwby2, r1, r2, TopEdge, s1, c);
-
120 qDrawRoundedCorners(p, x1, y1 + pwby2, x2, y2, r1, r2, TopEdge, s2, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1, y1 + pwby2, x2, y2, r1, r2, TopEdge, s2, c);
-
121 break;
never executed: break;
0
122 case BottomEdge: -
123 qDrawRoundedCorners(p, x1, y1 + pwby2, x2, y2, r1, r2, BottomEdge, s1, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1, y1 + pwby2, x2, y2, r1, r2, BottomEdge, s1, c);
-
124 qDrawRoundedCorners(p, x1, y1, x2, y2-pwby2, r1, r2, BottomEdge, s2, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1, y1, x2, y2-pwby2, r1, r2, BottomEdge, s2, c);
-
125 break;
never executed: break;
0
126 case LeftEdge: -
127 qDrawRoundedCorners(p, x1, y1, x1 + pwby2, y2, r1, r2, LeftEdge, s1, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1, y1, x1 + pwby2, y2, r1, r2, LeftEdge, s1, c);
-
128 qDrawRoundedCorners(p, x1 + pwby2, y1, x2, y2, r1, r2, LeftEdge, s2, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1 + pwby2, y1, x2, y2, r1, r2, LeftEdge, s2, c);
-
129 break;
never executed: break;
0
130 case RightEdge: -
131 qDrawRoundedCorners(p, x1 + pwby2, y1, x2, y2, r1, r2, RightEdge, s1, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1 + pwby2, y1, x2, y2, r1, r2, RightEdge, s1, c);
-
132 qDrawRoundedCorners(p, x1, y1, x2 - pwby2, y2, r1, r2, RightEdge, s2, c);
never executed (the execution status of this line is deduced): qDrawRoundedCorners(p, x1, y1, x2 - pwby2, y2, r1, r2, RightEdge, s2, c);
-
133 break;
never executed: break;
0
134 default: -
135 break;
never executed: break;
0
136 } -
137 } else if ((s == BorderStyle_Outset && (edge == TopEdge || edge == LeftEdge))
never executed: }
never evaluated: s == BorderStyle_Outset
never evaluated: edge == TopEdge
never evaluated: edge == LeftEdge
0
138 || (s == BorderStyle_Inset && (edge == BottomEdge || edge == RightEdge)))
never evaluated: s == BorderStyle_Inset
never evaluated: edge == BottomEdge
never evaluated: edge == RightEdge
0
139 c = c.color().lighter();
never executed: c = c.color().lighter();
0
140 -
141 p->save();
never executed (the execution status of this line is deduced): p->save();
-
142 qreal pwby2 = pw/2;
never executed (the execution status of this line is deduced): qreal pwby2 = pw/2;
-
143 p->setBrush(Qt::NoBrush);
never executed (the execution status of this line is deduced): p->setBrush(Qt::NoBrush);
-
144 QPen pen = qPenFromStyle(c, pw, s);
never executed (the execution status of this line is deduced): QPen pen = qPenFromStyle(c, pw, s);
-
145 pen.setCapStyle(Qt::SquareCap); // this eliminates the offby1 errors that we might hit below
never executed (the execution status of this line is deduced): pen.setCapStyle(Qt::SquareCap);
-
146 p->setPen(pen);
never executed (the execution status of this line is deduced): p->setPen(pen);
-
147 switch (edge) { -
148 case TopEdge: -
149 if (!r1.isEmpty())
never evaluated: !r1.isEmpty()
0
150 p->drawArc(QRectF(x1 - r1.width() + pwby2, y1 + pwby2,
never executed: p->drawArc(QRectF(x1 - r1.width() + pwby2, y1 + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 135*16, -45*16);
0
151 2*r1.width() - pw, 2*r1.height() - pw), 135*16, -45*16);
never executed: p->drawArc(QRectF(x1 - r1.width() + pwby2, y1 + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 135*16, -45*16);
0
152 if (!r2.isEmpty())
never evaluated: !r2.isEmpty()
0
153 p->drawArc(QRectF(x2 - r2.width() + pwby2, y1 + pwby2,
never executed: p->drawArc(QRectF(x2 - r2.width() + pwby2, y1 + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 45*16, 45*16);
0
154 2*r2.width() - pw, 2*r2.height() - pw), 45*16, 45*16);
never executed: p->drawArc(QRectF(x2 - r2.width() + pwby2, y1 + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 45*16, 45*16);
0
155 break;
never executed: break;
0
156 case BottomEdge: -
157 if (!r1.isEmpty())
never evaluated: !r1.isEmpty()
0
158 p->drawArc(QRectF(x1 - r1.width() + pwby2, y2 - 2*r1.height() + pwby2,
never executed: p->drawArc(QRectF(x1 - r1.width() + pwby2, y2 - 2*r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), -90 * 16, -45 * 16);
0
159 2*r1.width() - pw, 2*r1.height() - pw), -90 * 16, -45 * 16);
never executed: p->drawArc(QRectF(x1 - r1.width() + pwby2, y2 - 2*r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), -90 * 16, -45 * 16);
0
160 if (!r2.isEmpty())
never evaluated: !r2.isEmpty()
0
161 p->drawArc(QRectF(x2 - r2.width() + pwby2, y2 - 2*r2.height() + pwby2,
never executed: p->drawArc(QRectF(x2 - r2.width() + pwby2, y2 - 2*r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), -90 * 16, 45 * 16);
0
162 2*r2.width() - pw, 2*r2.height() - pw), -90 * 16, 45 * 16);
never executed: p->drawArc(QRectF(x2 - r2.width() + pwby2, y2 - 2*r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), -90 * 16, 45 * 16);
0
163 break;
never executed: break;
0
164 case LeftEdge: -
165 if (!r1.isEmpty())
never evaluated: !r1.isEmpty()
0
166 p->drawArc(QRectF(x1 + pwby2, y1 - r1.height() + pwby2,
never executed: p->drawArc(QRectF(x1 + pwby2, y1 - r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 135*16, 45*16);
0
167 2*r1.width() - pw, 2*r1.height() - pw), 135*16, 45*16);
never executed: p->drawArc(QRectF(x1 + pwby2, y1 - r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 135*16, 45*16);
0
168 if (!r2.isEmpty())
never evaluated: !r2.isEmpty()
0
169 p->drawArc(QRectF(x1 + pwby2, y2 - r2.height() + pwby2,
never executed: p->drawArc(QRectF(x1 + pwby2, y2 - r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 180*16, 45*16);
0
170 2*r2.width() - pw, 2*r2.height() - pw), 180*16, 45*16);
never executed: p->drawArc(QRectF(x1 + pwby2, y2 - r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 180*16, 45*16);
0
171 break;
never executed: break;
0
172 case RightEdge: -
173 if (!r1.isEmpty())
never evaluated: !r1.isEmpty()
0
174 p->drawArc(QRectF(x2 - 2*r1.width() + pwby2, y1 - r1.height() + pwby2,
never executed: p->drawArc(QRectF(x2 - 2*r1.width() + pwby2, y1 - r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 45*16, -45*16);
0
175 2*r1.width() - pw, 2*r1.height() - pw), 45*16, -45*16);
never executed: p->drawArc(QRectF(x2 - 2*r1.width() + pwby2, y1 - r1.height() + pwby2, 2*r1.width() - pw, 2*r1.height() - pw), 45*16, -45*16);
0
176 if (!r2.isEmpty())
never evaluated: !r2.isEmpty()
0
177 p->drawArc(QRectF(x2 - 2*r2.width() + pwby2, y2 - r2.height() + pwby2,
never executed: p->drawArc(QRectF(x2 - 2*r2.width() + pwby2, y2 - r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 315*16, 45*16);
0
178 2*r2.width() - pw, 2*r2.height() - pw), 315*16, 45*16);
never executed: p->drawArc(QRectF(x2 - 2*r2.width() + pwby2, y2 - r2.height() + pwby2, 2*r2.width() - pw, 2*r2.height() - pw), 315*16, 45*16);
0
179 break;
never executed: break;
0
180 default: -
181 break;
never executed: break;
0
182 } -
183 p->restore();
never executed (the execution status of this line is deduced): p->restore();
-
184}
never executed: }
0
185 -
186 -
187void qDrawEdge(QPainter *p, qreal x1, qreal y1, qreal x2, qreal y2, qreal dw1, qreal dw2, -
188 QCss::Edge edge, QCss::BorderStyle style, QBrush c) -
189{ -
190 p->save();
executed (the execution status of this line is deduced): p->save();
-
191 const qreal width = (edge == TopEdge || edge == BottomEdge) ? (y2-y1) : (x2-x1);
evaluated: edge == TopEdge
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:180
evaluated: edge == BottomEdge
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:120
60-180
192 -
193 if (width <= 2 && style == BorderStyle_Double)
partially evaluated: width <= 2
TRUEFALSE
yes
Evaluation Count:240
no
Evaluation Count:0
partially evaluated: style == BorderStyle_Double
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:240
0-240
194 style = BorderStyle_Solid;
never executed: style = BorderStyle_Solid;
0
195 -
196 switch (style) { -
197 case BorderStyle_Inset: -
198 case BorderStyle_Outset: -
199 if ((style == BorderStyle_Outset && (edge == TopEdge || edge == LeftEdge))
evaluated: style == BorderStyle_Outset
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:200
evaluated: edge == TopEdge
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:24
evaluated: edge == LeftEdge
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:16
8-200
200 || (style == BorderStyle_Inset && (edge == BottomEdge || edge == RightEdge)))
evaluated: style == BorderStyle_Inset
TRUEFALSE
yes
Evaluation Count:200
yes
Evaluation Count:16
evaluated: edge == BottomEdge
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:150
evaluated: edge == RightEdge
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:100
16-200
201 c = c.color().lighter();
executed: c = c.color().lighter();
Execution Count:116
116
202 // fall through! -
203 case BorderStyle_Solid: { -
204 p->setPen(Qt::NoPen);
executed (the execution status of this line is deduced): p->setPen(Qt::NoPen);
-
205 p->setBrush(c);
executed (the execution status of this line is deduced): p->setBrush(c);
-
206 if (width == 1 || (dw1 == 0 && dw2 == 0)) {
partially evaluated: width == 1
TRUEFALSE
yes
Evaluation Count:240
no
Evaluation Count:0
never evaluated: dw1 == 0
never evaluated: dw2 == 0
0-240
207 p->drawRect(QRectF(x1, y1, x2-x1, y2-y1));
executed (the execution status of this line is deduced): p->drawRect(QRectF(x1, y1, x2-x1, y2-y1));
-
208 } else { // draw trapezoid
executed: }
Execution Count:240
240
209 QPolygonF quad;
never executed (the execution status of this line is deduced): QPolygonF quad;
-
210 switch (edge) { -
211 case TopEdge: -
212 quad << QPointF(x1, y1) << QPointF(x1 + dw1, y2)
never executed (the execution status of this line is deduced): quad << QPointF(x1, y1) << QPointF(x1 + dw1, y2)
-
213 << QPointF(x2 - dw2, y2) << QPointF(x2, y1);
never executed (the execution status of this line is deduced): << QPointF(x2 - dw2, y2) << QPointF(x2, y1);
-
214 break;
never executed: break;
0
215 case BottomEdge: -
216 quad << QPointF(x1 + dw1, y1) << QPointF(x1, y2)
never executed (the execution status of this line is deduced): quad << QPointF(x1 + dw1, y1) << QPointF(x1, y2)
-
217 << QPointF(x2, y2) << QPointF(x2 - dw2, y1);
never executed (the execution status of this line is deduced): << QPointF(x2, y2) << QPointF(x2 - dw2, y1);
-
218 break;
never executed: break;
0
219 case LeftEdge: -
220 quad << QPointF(x1, y1) << QPointF(x1, y2)
never executed (the execution status of this line is deduced): quad << QPointF(x1, y1) << QPointF(x1, y2)
-
221 << QPointF(x2, y2 - dw2) << QPointF(x2, y1 + dw1);
never executed (the execution status of this line is deduced): << QPointF(x2, y2 - dw2) << QPointF(x2, y1 + dw1);
-
222 break;
never executed: break;
0
223 case RightEdge: -
224 quad << QPointF(x1, y1 + dw1) << QPointF(x1, y2 - dw2)
never executed (the execution status of this line is deduced): quad << QPointF(x1, y1 + dw1) << QPointF(x1, y2 - dw2)
-
225 << QPointF(x2, y2) << QPointF(x2, y1);
never executed (the execution status of this line is deduced): << QPointF(x2, y2) << QPointF(x2, y1);
-
226 break;
never executed: break;
0
227 default: -
228 break;
never executed: break;
0
229 } -
230 p->drawConvexPolygon(quad);
never executed (the execution status of this line is deduced): p->drawConvexPolygon(quad);
-
231 }
never executed: }
0
232 break;
executed: break;
Execution Count:240
240
233 } -
234 case BorderStyle_Dotted: -
235 case BorderStyle_Dashed: -
236 case BorderStyle_DotDash: -
237 case BorderStyle_DotDotDash: -
238 p->setPen(qPenFromStyle(c, width, style));
never executed (the execution status of this line is deduced): p->setPen(qPenFromStyle(c, width, style));
-
239 if (width == 1)
never evaluated: width == 1
0
240 p->drawLine(QLineF(x1, y1, x2 - 1, y2 - 1));
never executed: p->drawLine(QLineF(x1, y1, x2 - 1, y2 - 1));
0
241 else if (edge == TopEdge || edge == BottomEdge)
never evaluated: edge == TopEdge
never evaluated: edge == BottomEdge
0
242 p->drawLine(QLineF(x1 + width/2, (y1 + y2)/2, x2 - width/2, (y1 + y2)/2));
never executed: p->drawLine(QLineF(x1 + width/2, (y1 + y2)/2, x2 - width/2, (y1 + y2)/2));
0
243 else -
244 p->drawLine(QLineF((x1+x2)/2, y1 + width/2, (x1+x2)/2, y2 - width/2));
never executed: p->drawLine(QLineF((x1+x2)/2, y1 + width/2, (x1+x2)/2, y2 - width/2));
0
245 break;
never executed: break;
0
246 -
247 case BorderStyle_Double: { -
248 int wby3 = qRound(width/3);
never executed (the execution status of this line is deduced): int wby3 = qRound(width/3);
-
249 int dw1by3 = qRound(dw1/3);
never executed (the execution status of this line is deduced): int dw1by3 = qRound(dw1/3);
-
250 int dw2by3 = qRound(dw2/3);
never executed (the execution status of this line is deduced): int dw2by3 = qRound(dw2/3);
-
251 switch (edge) { -
252 case TopEdge: -
253 qDrawEdge(p, x1, y1, x2, y1 + wby3, dw1by3, dw2by3, TopEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x1, y1, x2, y1 + wby3, dw1by3, dw2by3, TopEdge, BorderStyle_Solid, c);
-
254 qDrawEdge(p, x1 + dw1 - dw1by3, y2 - wby3, x2 - dw2 + dw1by3, y2,
never executed (the execution status of this line is deduced): qDrawEdge(p, x1 + dw1 - dw1by3, y2 - wby3, x2 - dw2 + dw1by3, y2,
-
255 dw1by3, dw2by3, TopEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): dw1by3, dw2by3, TopEdge, BorderStyle_Solid, c);
-
256 break;
never executed: break;
0
257 case LeftEdge: -
258 qDrawEdge(p, x1, y1, x1 + wby3, y2, dw1by3, dw2by3, LeftEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x1, y1, x1 + wby3, y2, dw1by3, dw2by3, LeftEdge, BorderStyle_Solid, c);
-
259 qDrawEdge(p, x2 - wby3, y1 + dw1 - dw1by3, x2, y2 - dw2 + dw2by3, dw1by3, dw2by3,
never executed (the execution status of this line is deduced): qDrawEdge(p, x2 - wby3, y1 + dw1 - dw1by3, x2, y2 - dw2 + dw2by3, dw1by3, dw2by3,
-
260 LeftEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): LeftEdge, BorderStyle_Solid, c);
-
261 break;
never executed: break;
0
262 case BottomEdge: -
263 qDrawEdge(p, x1 + dw1 - dw1by3, y1, x2 - dw2 + dw2by3, y1 + wby3, dw1by3, dw2by3,
never executed (the execution status of this line is deduced): qDrawEdge(p, x1 + dw1 - dw1by3, y1, x2 - dw2 + dw2by3, y1 + wby3, dw1by3, dw2by3,
-
264 BottomEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): BottomEdge, BorderStyle_Solid, c);
-
265 qDrawEdge(p, x1, y2 - wby3, x2, y2, dw1by3, dw2by3, BottomEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x1, y2 - wby3, x2, y2, dw1by3, dw2by3, BottomEdge, BorderStyle_Solid, c);
-
266 break;
never executed: break;
0
267 case RightEdge: -
268 qDrawEdge(p, x2 - wby3, y1, x2, y2, dw1by3, dw2by3, RightEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x2 - wby3, y1, x2, y2, dw1by3, dw2by3, RightEdge, BorderStyle_Solid, c);
-
269 qDrawEdge(p, x1, y1 + dw1 - dw1by3, x1 + wby3, y2 - dw2 + dw2by3, dw1by3, dw2by3,
never executed (the execution status of this line is deduced): qDrawEdge(p, x1, y1 + dw1 - dw1by3, x1 + wby3, y2 - dw2 + dw2by3, dw1by3, dw2by3,
-
270 RightEdge, BorderStyle_Solid, c);
never executed (the execution status of this line is deduced): RightEdge, BorderStyle_Solid, c);
-
271 break;
never executed: break;
0
272 default: -
273 break;
never executed: break;
0
274 } -
275 break;
never executed: break;
0
276 } -
277 case BorderStyle_Ridge: -
278 case BorderStyle_Groove: { -
279 BorderStyle s1, s2;
never executed (the execution status of this line is deduced): BorderStyle s1, s2;
-
280 if (style == BorderStyle_Groove) {
never evaluated: style == BorderStyle_Groove
0
281 s1 = BorderStyle_Inset;
never executed (the execution status of this line is deduced): s1 = BorderStyle_Inset;
-
282 s2 = BorderStyle_Outset;
never executed (the execution status of this line is deduced): s2 = BorderStyle_Outset;
-
283 } else {
never executed: }
0
284 s1 = BorderStyle_Outset;
never executed (the execution status of this line is deduced): s1 = BorderStyle_Outset;
-
285 s2 = BorderStyle_Inset;
never executed (the execution status of this line is deduced): s2 = BorderStyle_Inset;
-
286 }
never executed: }
0
287 int dw1by2 = qFloor(dw1/2), dw2by2 = qFloor(dw2/2);
never executed (the execution status of this line is deduced): int dw1by2 = qFloor(dw1/2), dw2by2 = qFloor(dw2/2);
-
288 int wby2 = qRound(width/2);
never executed (the execution status of this line is deduced): int wby2 = qRound(width/2);
-
289 switch (edge) { -
290 case TopEdge: -
291 qDrawEdge(p, x1, y1, x2, y1 + wby2, dw1by2, dw2by2, TopEdge, s1, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x1, y1, x2, y1 + wby2, dw1by2, dw2by2, TopEdge, s1, c);
-
292 qDrawEdge(p, x1 + dw1by2, y1 + wby2, x2 - dw2by2, y2, dw1by2, dw2by2, TopEdge, s2, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x1 + dw1by2, y1 + wby2, x2 - dw2by2, y2, dw1by2, dw2by2, TopEdge, s2, c);
-
293 break;
never executed: break;
0
294 case BottomEdge: -
295 qDrawEdge(p, x1, y1 + wby2, x2, y2, dw1by2, dw2by2, BottomEdge, s1, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x1, y1 + wby2, x2, y2, dw1by2, dw2by2, BottomEdge, s1, c);
-
296 qDrawEdge(p, x1 + dw1by2, y1, x2 - dw2by2, y1 + wby2, dw1by2, dw2by2, BottomEdge, s2, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x1 + dw1by2, y1, x2 - dw2by2, y1 + wby2, dw1by2, dw2by2, BottomEdge, s2, c);
-
297 break;
never executed: break;
0
298 case LeftEdge: -
299 qDrawEdge(p, x1, y1, x1 + wby2, y2, dw1by2, dw2by2, LeftEdge, s1, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x1, y1, x1 + wby2, y2, dw1by2, dw2by2, LeftEdge, s1, c);
-
300 qDrawEdge(p, x1 + wby2, y1 + dw1by2, x2, y2 - dw2by2, dw1by2, dw2by2, LeftEdge, s2, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x1 + wby2, y1 + dw1by2, x2, y2 - dw2by2, dw1by2, dw2by2, LeftEdge, s2, c);
-
301 break;
never executed: break;
0
302 case RightEdge: -
303 qDrawEdge(p, x1 + wby2, y1, x2, y2, dw1by2, dw2by2, RightEdge, s1, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x1 + wby2, y1, x2, y2, dw1by2, dw2by2, RightEdge, s1, c);
-
304 qDrawEdge(p, x1, y1 + dw1by2, x1 + wby2, y2 - dw2by2, dw1by2, dw2by2, RightEdge, s2, c);
never executed (the execution status of this line is deduced): qDrawEdge(p, x1, y1 + dw1by2, x1 + wby2, y2 - dw2by2, dw1by2, dw2by2, RightEdge, s2, c);
-
305 break;
never executed: break;
0
306 default: -
307 break;
never executed: break;
0
308 } -
309 } -
310 default: -
311 break;
never executed: break;
0
312 } -
313 p->restore();
executed (the execution status of this line is deduced): p->restore();
-
314}
executed: }
Execution Count:240
240
315 -
316void qNormalizeRadii(const QRect &br, const QSize *radii, -
317 QSize *tlr, QSize *trr, QSize *blr, QSize *brr) -
318{ -
319 *tlr = radii[0].expandedTo(QSize(0, 0));
executed (the execution status of this line is deduced): *tlr = radii[0].expandedTo(QSize(0, 0));
-
320 *trr = radii[1].expandedTo(QSize(0, 0));
executed (the execution status of this line is deduced): *trr = radii[1].expandedTo(QSize(0, 0));
-
321 *blr = radii[2].expandedTo(QSize(0, 0));
executed (the execution status of this line is deduced): *blr = radii[2].expandedTo(QSize(0, 0));
-
322 *brr = radii[3].expandedTo(QSize(0, 0));
executed (the execution status of this line is deduced): *brr = radii[3].expandedTo(QSize(0, 0));
-
323 if (tlr->width() + trr->width() > br.width())
partially evaluated: tlr->width() + trr->width() > br.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
324 *tlr = *trr = QSize(0, 0);
never executed: *tlr = *trr = QSize(0, 0);
0
325 if (blr->width() + brr->width() > br.width())
partially evaluated: blr->width() + brr->width() > br.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
326 *blr = *brr = QSize(0, 0);
never executed: *blr = *brr = QSize(0, 0);
0
327 if (tlr->height() + blr->height() > br.height())
partially evaluated: tlr->height() + blr->height() > br.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
328 *tlr = *blr = QSize(0, 0);
never executed: *tlr = *blr = QSize(0, 0);
0
329 if (trr->height() + brr->height() > br.height())
partially evaluated: trr->height() + brr->height() > br.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
330 *trr = *brr = QSize(0, 0);
never executed: *trr = *brr = QSize(0, 0);
0
331}
executed: }
Execution Count:2
2
332 -
333// Determines if Edge e1 draws over Edge e2. Depending on this trapezoids or rectanges are drawn -
334static bool paintsOver(const QCss::BorderStyle *styles, const QBrush *colors, QCss::Edge e1, QCss::Edge e2) -
335{ -
336 QCss::BorderStyle s1 = styles[e1];
executed (the execution status of this line is deduced): QCss::BorderStyle s1 = styles[e1];
-
337 QCss::BorderStyle s2 = styles[e2];
executed (the execution status of this line is deduced): QCss::BorderStyle s2 = styles[e2];
-
338 -
339 if (s2 == BorderStyle_None || colors[e2] == Qt::transparent)
partially evaluated: s2 == BorderStyle_None
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
partially evaluated: colors[e2] == Qt::transparent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
340 return true;
never executed: return true;
0
341 -
342 if ((s1 == BorderStyle_Solid && s2 == BorderStyle_Solid) && (colors[e1] == colors[e2]))
partially evaluated: s1 == BorderStyle_Solid
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
partially evaluated: s2 == BorderStyle_Solid
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
partially evaluated: (colors[e1] == colors[e2])
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
343 return true;
executed: return true;
Execution Count:16
16
344 -
345 return false;
never executed: return false;
0
346} -
347 -
348void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles, -
349 const int *borders, const QBrush *colors, const QSize *radii) -
350{ -
351 const QRectF br(rect);
executed (the execution status of this line is deduced): const QRectF br(rect);
-
352 QSize tlr, trr, blr, brr;
executed (the execution status of this line is deduced): QSize tlr, trr, blr, brr;
-
353 qNormalizeRadii(rect, radii, &tlr, &trr, &blr, &brr);
executed (the execution status of this line is deduced): qNormalizeRadii(rect, radii, &tlr, &trr, &blr, &brr);
-
354 -
355 // Drawn in increasing order of precendence -
356 if (styles[BottomEdge] != BorderStyle_None && borders[BottomEdge] > 0) {
partially evaluated: styles[BottomEdge] != BorderStyle_None
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: borders[BottomEdge] > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
357 qreal dw1 = (blr.width() || paintsOver(styles, colors, BottomEdge, LeftEdge)) ? 0 : borders[LeftEdge];
partially evaluated: blr.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: paintsOver(styles, colors, BottomEdge, LeftEdge)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
358 qreal dw2 = (brr.width() || paintsOver(styles, colors, BottomEdge, RightEdge)) ? 0 : borders[RightEdge];
partially evaluated: brr.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: paintsOver(styles, colors, BottomEdge, RightEdge)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
359 qreal x1 = br.x() + blr.width();
executed (the execution status of this line is deduced): qreal x1 = br.x() + blr.width();
-
360 qreal y1 = br.y() + br.height() - borders[BottomEdge];
executed (the execution status of this line is deduced): qreal y1 = br.y() + br.height() - borders[BottomEdge];
-
361 qreal x2 = br.x() + br.width() - brr.width();
executed (the execution status of this line is deduced): qreal x2 = br.x() + br.width() - brr.width();
-
362 qreal y2 = br.y() + br.height() ;
executed (the execution status of this line is deduced): qreal y2 = br.y() + br.height() ;
-
363 -
364 qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, BottomEdge, styles[BottomEdge], colors[BottomEdge]);
executed (the execution status of this line is deduced): qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, BottomEdge, styles[BottomEdge], colors[BottomEdge]);
-
365 if (blr.width() || brr.width())
partially evaluated: blr.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: brr.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
366 qDrawRoundedCorners(p, x1, y1, x2, y2, blr, brr, BottomEdge, styles[BottomEdge], colors[BottomEdge]);
never executed: qDrawRoundedCorners(p, x1, y1, x2, y2, blr, brr, BottomEdge, styles[BottomEdge], colors[BottomEdge]);
0
367 }
executed: }
Execution Count:2
2
368 if (styles[RightEdge] != BorderStyle_None && borders[RightEdge] > 0) {
partially evaluated: styles[RightEdge] != BorderStyle_None
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: borders[RightEdge] > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
369 qreal dw1 = (trr.height() || paintsOver(styles, colors, RightEdge, TopEdge)) ? 0 : borders[TopEdge];
partially evaluated: trr.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: paintsOver(styles, colors, RightEdge, TopEdge)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
370 qreal dw2 = (brr.height() || paintsOver(styles, colors, RightEdge, BottomEdge)) ? 0 : borders[BottomEdge];
partially evaluated: brr.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: paintsOver(styles, colors, RightEdge, BottomEdge)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
371 qreal x1 = br.x() + br.width() - borders[RightEdge];
executed (the execution status of this line is deduced): qreal x1 = br.x() + br.width() - borders[RightEdge];
-
372 qreal y1 = br.y() + trr.height();
executed (the execution status of this line is deduced): qreal y1 = br.y() + trr.height();
-
373 qreal x2 = br.x() + br.width();
executed (the execution status of this line is deduced): qreal x2 = br.x() + br.width();
-
374 qreal y2 = br.y() + br.height() - brr.height();
executed (the execution status of this line is deduced): qreal y2 = br.y() + br.height() - brr.height();
-
375 -
376 qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, RightEdge, styles[RightEdge], colors[RightEdge]);
executed (the execution status of this line is deduced): qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, RightEdge, styles[RightEdge], colors[RightEdge]);
-
377 if (trr.height() || brr.height())
partially evaluated: trr.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: brr.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
378 qDrawRoundedCorners(p, x1, y1, x2, y2, trr, brr, RightEdge, styles[RightEdge], colors[RightEdge]);
never executed: qDrawRoundedCorners(p, x1, y1, x2, y2, trr, brr, RightEdge, styles[RightEdge], colors[RightEdge]);
0
379 }
executed: }
Execution Count:2
2
380 if (styles[LeftEdge] != BorderStyle_None && borders[LeftEdge] > 0) {
partially evaluated: styles[LeftEdge] != BorderStyle_None
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: borders[LeftEdge] > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
381 qreal dw1 = (tlr.height() || paintsOver(styles, colors, LeftEdge, TopEdge)) ? 0 : borders[TopEdge];
partially evaluated: tlr.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: paintsOver(styles, colors, LeftEdge, TopEdge)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
382 qreal dw2 = (blr.height() || paintsOver(styles, colors, LeftEdge, BottomEdge)) ? 0 : borders[BottomEdge];
partially evaluated: blr.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: paintsOver(styles, colors, LeftEdge, BottomEdge)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
383 qreal x1 = br.x();
executed (the execution status of this line is deduced): qreal x1 = br.x();
-
384 qreal y1 = br.y() + tlr.height();
executed (the execution status of this line is deduced): qreal y1 = br.y() + tlr.height();
-
385 qreal x2 = br.x() + borders[LeftEdge];
executed (the execution status of this line is deduced): qreal x2 = br.x() + borders[LeftEdge];
-
386 qreal y2 = br.y() + br.height() - blr.height();
executed (the execution status of this line is deduced): qreal y2 = br.y() + br.height() - blr.height();
-
387 -
388 qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, LeftEdge, styles[LeftEdge], colors[LeftEdge]);
executed (the execution status of this line is deduced): qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, LeftEdge, styles[LeftEdge], colors[LeftEdge]);
-
389 if (tlr.height() || blr.height())
partially evaluated: tlr.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: blr.height()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
390 qDrawRoundedCorners(p, x1, y1, x2, y2, tlr, blr, LeftEdge, styles[LeftEdge], colors[LeftEdge]);
never executed: qDrawRoundedCorners(p, x1, y1, x2, y2, tlr, blr, LeftEdge, styles[LeftEdge], colors[LeftEdge]);
0
391 }
executed: }
Execution Count:2
2
392 if (styles[TopEdge] != BorderStyle_None && borders[TopEdge] > 0) {
partially evaluated: styles[TopEdge] != BorderStyle_None
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: borders[TopEdge] > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
393 qreal dw1 = (tlr.width() || paintsOver(styles, colors, TopEdge, LeftEdge)) ? 0 : borders[LeftEdge];
partially evaluated: tlr.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: paintsOver(styles, colors, TopEdge, LeftEdge)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
394 qreal dw2 = (trr.width() || paintsOver(styles, colors, TopEdge, RightEdge)) ? 0 : borders[RightEdge];
partially evaluated: trr.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: paintsOver(styles, colors, TopEdge, RightEdge)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
395 qreal x1 = br.x() + tlr.width();
executed (the execution status of this line is deduced): qreal x1 = br.x() + tlr.width();
-
396 qreal y1 = br.y();
executed (the execution status of this line is deduced): qreal y1 = br.y();
-
397 qreal x2 = br.left() + br.width() - trr.width();
executed (the execution status of this line is deduced): qreal x2 = br.left() + br.width() - trr.width();
-
398 qreal y2 = br.y() + borders[TopEdge];
executed (the execution status of this line is deduced): qreal y2 = br.y() + borders[TopEdge];
-
399 -
400 qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, TopEdge, styles[TopEdge], colors[TopEdge]);
executed (the execution status of this line is deduced): qDrawEdge(p, x1, y1, x2, y2, dw1, dw2, TopEdge, styles[TopEdge], colors[TopEdge]);
-
401 if (tlr.width() || trr.width())
partially evaluated: tlr.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: trr.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
402 qDrawRoundedCorners(p, x1, y1, x2, y2, tlr, trr, TopEdge, styles[TopEdge], colors[TopEdge]);
never executed: qDrawRoundedCorners(p, x1, y1, x2, y2, tlr, trr, TopEdge, styles[TopEdge], colors[TopEdge]);
0
403 }
executed: }
Execution Count:2
2
404}
executed: }
Execution Count:2
2
405 -
406#endif //QT_NO_CSSPARSER -
407 -
408QT_END_NAMESPACE -
409 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial