text/qtexthtmlparser.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 "qtexthtmlparser_p.h" -
43 -
44#include <qbytearray.h> -
45#include <qtextcodec.h> -
46#include <qstack.h> -
47#include <qdebug.h> -
48#include <qthread.h> -
49#include <qcoreapplication.h> -
50 -
51#include "qtextdocument.h" -
52#include "qtextformat_p.h" -
53#include "qtextdocument_p.h" -
54#include "qtextcursor.h" -
55#include "qfont_p.h" -
56#include "private/qfunctions_p.h" -
57 -
58#ifndef QT_NO_TEXTHTMLPARSER -
59 -
60QT_BEGIN_NAMESPACE -
61 -
62// see also tst_qtextdocumentfragment.cpp -
63#define MAX_ENTITY 258 -
64static const struct QTextHtmlEntity { const char *name; quint16 code; } entities[MAX_ENTITY]= { -
65 { "AElig", 0x00c6 }, -
66 { "AMP", 38 }, -
67 { "Aacute", 0x00c1 }, -
68 { "Acirc", 0x00c2 }, -
69 { "Agrave", 0x00c0 }, -
70 { "Alpha", 0x0391 }, -
71 { "Aring", 0x00c5 }, -
72 { "Atilde", 0x00c3 }, -
73 { "Auml", 0x00c4 }, -
74 { "Beta", 0x0392 }, -
75 { "Ccedil", 0x00c7 }, -
76 { "Chi", 0x03a7 }, -
77 { "Dagger", 0x2021 }, -
78 { "Delta", 0x0394 }, -
79 { "ETH", 0x00d0 }, -
80 { "Eacute", 0x00c9 }, -
81 { "Ecirc", 0x00ca }, -
82 { "Egrave", 0x00c8 }, -
83 { "Epsilon", 0x0395 }, -
84 { "Eta", 0x0397 }, -
85 { "Euml", 0x00cb }, -
86 { "GT", 62 }, -
87 { "Gamma", 0x0393 }, -
88 { "Iacute", 0x00cd }, -
89 { "Icirc", 0x00ce }, -
90 { "Igrave", 0x00cc }, -
91 { "Iota", 0x0399 }, -
92 { "Iuml", 0x00cf }, -
93 { "Kappa", 0x039a }, -
94 { "LT", 60 }, -
95 { "Lambda", 0x039b }, -
96 { "Mu", 0x039c }, -
97 { "Ntilde", 0x00d1 }, -
98 { "Nu", 0x039d }, -
99 { "OElig", 0x0152 }, -
100 { "Oacute", 0x00d3 }, -
101 { "Ocirc", 0x00d4 }, -
102 { "Ograve", 0x00d2 }, -
103 { "Omega", 0x03a9 }, -
104 { "Omicron", 0x039f }, -
105 { "Oslash", 0x00d8 }, -
106 { "Otilde", 0x00d5 }, -
107 { "Ouml", 0x00d6 }, -
108 { "Phi", 0x03a6 }, -
109 { "Pi", 0x03a0 }, -
110 { "Prime", 0x2033 }, -
111 { "Psi", 0x03a8 }, -
112 { "QUOT", 34 }, -
113 { "Rho", 0x03a1 }, -
114 { "Scaron", 0x0160 }, -
115 { "Sigma", 0x03a3 }, -
116 { "THORN", 0x00de }, -
117 { "Tau", 0x03a4 }, -
118 { "Theta", 0x0398 }, -
119 { "Uacute", 0x00da }, -
120 { "Ucirc", 0x00db }, -
121 { "Ugrave", 0x00d9 }, -
122 { "Upsilon", 0x03a5 }, -
123 { "Uuml", 0x00dc }, -
124 { "Xi", 0x039e }, -
125 { "Yacute", 0x00dd }, -
126 { "Yuml", 0x0178 }, -
127 { "Zeta", 0x0396 }, -
128 { "aacute", 0x00e1 }, -
129 { "acirc", 0x00e2 }, -
130 { "acute", 0x00b4 }, -
131 { "aelig", 0x00e6 }, -
132 { "agrave", 0x00e0 }, -
133 { "alefsym", 0x2135 }, -
134 { "alpha", 0x03b1 }, -
135 { "amp", 38 }, -
136 { "and", 0x22a5 }, -
137 { "ang", 0x2220 }, -
138 { "apos", 0x0027 }, -
139 { "aring", 0x00e5 }, -
140 { "asymp", 0x2248 }, -
141 { "atilde", 0x00e3 }, -
142 { "auml", 0x00e4 }, -
143 { "bdquo", 0x201e }, -
144 { "beta", 0x03b2 }, -
145 { "brvbar", 0x00a6 }, -
146 { "bull", 0x2022 }, -
147 { "cap", 0x2229 }, -
148 { "ccedil", 0x00e7 }, -
149 { "cedil", 0x00b8 }, -
150 { "cent", 0x00a2 }, -
151 { "chi", 0x03c7 }, -
152 { "circ", 0x02c6 }, -
153 { "clubs", 0x2663 }, -
154 { "cong", 0x2245 }, -
155 { "copy", 0x00a9 }, -
156 { "crarr", 0x21b5 }, -
157 { "cup", 0x222a }, -
158 { "curren", 0x00a4 }, -
159 { "dArr", 0x21d3 }, -
160 { "dagger", 0x2020 }, -
161 { "darr", 0x2193 }, -
162 { "deg", 0x00b0 }, -
163 { "delta", 0x03b4 }, -
164 { "diams", 0x2666 }, -
165 { "divide", 0x00f7 }, -
166 { "eacute", 0x00e9 }, -
167 { "ecirc", 0x00ea }, -
168 { "egrave", 0x00e8 }, -
169 { "empty", 0x2205 }, -
170 { "emsp", 0x2003 }, -
171 { "ensp", 0x2002 }, -
172 { "epsilon", 0x03b5 }, -
173 { "equiv", 0x2261 }, -
174 { "eta", 0x03b7 }, -
175 { "eth", 0x00f0 }, -
176 { "euml", 0x00eb }, -
177 { "euro", 0x20ac }, -
178 { "exist", 0x2203 }, -
179 { "fnof", 0x0192 }, -
180 { "forall", 0x2200 }, -
181 { "frac12", 0x00bd }, -
182 { "frac14", 0x00bc }, -
183 { "frac34", 0x00be }, -
184 { "frasl", 0x2044 }, -
185 { "gamma", 0x03b3 }, -
186 { "ge", 0x2265 }, -
187 { "gt", 62 }, -
188 { "hArr", 0x21d4 }, -
189 { "harr", 0x2194 }, -
190 { "hearts", 0x2665 }, -
191 { "hellip", 0x2026 }, -
192 { "iacute", 0x00ed }, -
193 { "icirc", 0x00ee }, -
194 { "iexcl", 0x00a1 }, -
195 { "igrave", 0x00ec }, -
196 { "image", 0x2111 }, -
197 { "infin", 0x221e }, -
198 { "int", 0x222b }, -
199 { "iota", 0x03b9 }, -
200 { "iquest", 0x00bf }, -
201 { "isin", 0x2208 }, -
202 { "iuml", 0x00ef }, -
203 { "kappa", 0x03ba }, -
204 { "lArr", 0x21d0 }, -
205 { "lambda", 0x03bb }, -
206 { "lang", 0x2329 }, -
207 { "laquo", 0x00ab }, -
208 { "larr", 0x2190 }, -
209 { "lceil", 0x2308 }, -
210 { "ldquo", 0x201c }, -
211 { "le", 0x2264 }, -
212 { "lfloor", 0x230a }, -
213 { "lowast", 0x2217 }, -
214 { "loz", 0x25ca }, -
215 { "lrm", 0x200e }, -
216 { "lsaquo", 0x2039 }, -
217 { "lsquo", 0x2018 }, -
218 { "lt", 60 }, -
219 { "macr", 0x00af }, -
220 { "mdash", 0x2014 }, -
221 { "micro", 0x00b5 }, -
222 { "middot", 0x00b7 }, -
223 { "minus", 0x2212 }, -
224 { "mu", 0x03bc }, -
225 { "nabla", 0x2207 }, -
226 { "nbsp", 0x00a0 }, -
227 { "ndash", 0x2013 }, -
228 { "ne", 0x2260 }, -
229 { "ni", 0x220b }, -
230 { "not", 0x00ac }, -
231 { "notin", 0x2209 }, -
232 { "nsub", 0x2284 }, -
233 { "ntilde", 0x00f1 }, -
234 { "nu", 0x03bd }, -
235 { "oacute", 0x00f3 }, -
236 { "ocirc", 0x00f4 }, -
237 { "oelig", 0x0153 }, -
238 { "ograve", 0x00f2 }, -
239 { "oline", 0x203e }, -
240 { "omega", 0x03c9 }, -
241 { "omicron", 0x03bf }, -
242 { "oplus", 0x2295 }, -
243 { "or", 0x22a6 }, -
244 { "ordf", 0x00aa }, -
245 { "ordm", 0x00ba }, -
246 { "oslash", 0x00f8 }, -
247 { "otilde", 0x00f5 }, -
248 { "otimes", 0x2297 }, -
249 { "ouml", 0x00f6 }, -
250 { "para", 0x00b6 }, -
251 { "part", 0x2202 }, -
252 { "percnt", 0x0025 }, -
253 { "permil", 0x2030 }, -
254 { "perp", 0x22a5 }, -
255 { "phi", 0x03c6 }, -
256 { "pi", 0x03c0 }, -
257 { "piv", 0x03d6 }, -
258 { "plusmn", 0x00b1 }, -
259 { "pound", 0x00a3 }, -
260 { "prime", 0x2032 }, -
261 { "prod", 0x220f }, -
262 { "prop", 0x221d }, -
263 { "psi", 0x03c8 }, -
264 { "quot", 34 }, -
265 { "rArr", 0x21d2 }, -
266 { "radic", 0x221a }, -
267 { "rang", 0x232a }, -
268 { "raquo", 0x00bb }, -
269 { "rarr", 0x2192 }, -
270 { "rceil", 0x2309 }, -
271 { "rdquo", 0x201d }, -
272 { "real", 0x211c }, -
273 { "reg", 0x00ae }, -
274 { "rfloor", 0x230b }, -
275 { "rho", 0x03c1 }, -
276 { "rlm", 0x200f }, -
277 { "rsaquo", 0x203a }, -
278 { "rsquo", 0x2019 }, -
279 { "sbquo", 0x201a }, -
280 { "scaron", 0x0161 }, -
281 { "sdot", 0x22c5 }, -
282 { "sect", 0x00a7 }, -
283 { "shy", 0x00ad }, -
284 { "sigma", 0x03c3 }, -
285 { "sigmaf", 0x03c2 }, -
286 { "sim", 0x223c }, -
287 { "spades", 0x2660 }, -
288 { "sub", 0x2282 }, -
289 { "sube", 0x2286 }, -
290 { "sum", 0x2211 }, -
291 { "sup", 0x2283 }, -
292 { "sup1", 0x00b9 }, -
293 { "sup2", 0x00b2 }, -
294 { "sup3", 0x00b3 }, -
295 { "supe", 0x2287 }, -
296 { "szlig", 0x00df }, -
297 { "tau", 0x03c4 }, -
298 { "there4", 0x2234 }, -
299 { "theta", 0x03b8 }, -
300 { "thetasym", 0x03d1 }, -
301 { "thinsp", 0x2009 }, -
302 { "thorn", 0x00fe }, -
303 { "tilde", 0x02dc }, -
304 { "times", 0x00d7 }, -
305 { "trade", 0x2122 }, -
306 { "uArr", 0x21d1 }, -
307 { "uacute", 0x00fa }, -
308 { "uarr", 0x2191 }, -
309 { "ucirc", 0x00fb }, -
310 { "ugrave", 0x00f9 }, -
311 { "uml", 0x00a8 }, -
312 { "upsih", 0x03d2 }, -
313 { "upsilon", 0x03c5 }, -
314 { "uuml", 0x00fc }, -
315 { "weierp", 0x2118 }, -
316 { "xi", 0x03be }, -
317 { "yacute", 0x00fd }, -
318 { "yen", 0x00a5 }, -
319 { "yuml", 0x00ff }, -
320 { "zeta", 0x03b6 }, -
321 { "zwj", 0x200d }, -
322 { "zwnj", 0x200c } -
323}; -
324 -
325Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &entityStr, const QTextHtmlEntity &entity) -
326{ -
327 return entityStr < QLatin1String(entity.name);
executed: return entityStr < QLatin1String(entity.name);
Execution Count:296
296
328} -
329 -
330Q_STATIC_GLOBAL_OPERATOR bool operator<(const QTextHtmlEntity &entity, const QString &entityStr) -
331{ -
332 return QLatin1String(entity.name) < entityStr;
executed: return QLatin1String(entity.name) < entityStr;
Execution Count:2408
2408
333} -
334 -
335static QChar resolveEntity(const QString &entity) -
336{ -
337 const QTextHtmlEntity *start = &entities[0];
executed (the execution status of this line is deduced): const QTextHtmlEntity *start = &entities[0];
-
338 const QTextHtmlEntity *end = &entities[MAX_ENTITY];
executed (the execution status of this line is deduced): const QTextHtmlEntity *end = &entities[258];
-
339 const QTextHtmlEntity *e = qBinaryFind(start, end, entity);
executed (the execution status of this line is deduced): const QTextHtmlEntity *e = qBinaryFind(start, end, entity);
-
340 if (e == end)
evaluated: e == end
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:262
34-262
341 return QChar();
executed: return QChar();
Execution Count:34
34
342 return e->code;
executed: return e->code;
Execution Count:262
262
343} -
344 -
345static const ushort windowsLatin1ExtendedCharacters[0xA0 - 0x80] = { -
346 0x20ac, // 0x80 -
347 0x0081, // 0x81 direct mapping -
348 0x201a, // 0x82 -
349 0x0192, // 0x83 -
350 0x201e, // 0x84 -
351 0x2026, // 0x85 -
352 0x2020, // 0x86 -
353 0x2021, // 0x87 -
354 0x02C6, // 0x88 -
355 0x2030, // 0x89 -
356 0x0160, // 0x8A -
357 0x2039, // 0x8B -
358 0x0152, // 0x8C -
359 0x008D, // 0x8D direct mapping -
360 0x017D, // 0x8E -
361 0x008F, // 0x8F directmapping -
362 0x0090, // 0x90 directmapping -
363 0x2018, // 0x91 -
364 0x2019, // 0x92 -
365 0x201C, // 0x93 -
366 0X201D, // 0x94 -
367 0x2022, // 0x95 -
368 0x2013, // 0x96 -
369 0x2014, // 0x97 -
370 0x02DC, // 0x98 -
371 0x2122, // 0x99 -
372 0x0161, // 0x9A -
373 0x203A, // 0x9B -
374 0x0153, // 0x9C -
375 0x009D, // 0x9D direct mapping -
376 0x017E, // 0x9E -
377 0x0178 // 0x9F -
378}; -
379 -
380// the displayMode value is according to the what are blocks in the piecetable, not -
381// what the w3c defines. -
382static const QTextHtmlElement elements[Html_NumElements]= { -
383 { "a", Html_a, QTextHtmlElement::DisplayInline }, -
384 { "address", Html_address, QTextHtmlElement::DisplayInline }, -
385 { "b", Html_b, QTextHtmlElement::DisplayInline }, -
386 { "big", Html_big, QTextHtmlElement::DisplayInline }, -
387 { "blockquote", Html_blockquote, QTextHtmlElement::DisplayBlock }, -
388 { "body", Html_body, QTextHtmlElement::DisplayBlock }, -
389 { "br", Html_br, QTextHtmlElement::DisplayInline }, -
390 { "caption", Html_caption, QTextHtmlElement::DisplayBlock }, -
391 { "center", Html_center, QTextHtmlElement::DisplayBlock }, -
392 { "cite", Html_cite, QTextHtmlElement::DisplayInline }, -
393 { "code", Html_code, QTextHtmlElement::DisplayInline }, -
394 { "dd", Html_dd, QTextHtmlElement::DisplayBlock }, -
395 { "dfn", Html_dfn, QTextHtmlElement::DisplayInline }, -
396 { "div", Html_div, QTextHtmlElement::DisplayBlock }, -
397 { "dl", Html_dl, QTextHtmlElement::DisplayBlock }, -
398 { "dt", Html_dt, QTextHtmlElement::DisplayBlock }, -
399 { "em", Html_em, QTextHtmlElement::DisplayInline }, -
400 { "font", Html_font, QTextHtmlElement::DisplayInline }, -
401 { "h1", Html_h1, QTextHtmlElement::DisplayBlock }, -
402 { "h2", Html_h2, QTextHtmlElement::DisplayBlock }, -
403 { "h3", Html_h3, QTextHtmlElement::DisplayBlock }, -
404 { "h4", Html_h4, QTextHtmlElement::DisplayBlock }, -
405 { "h5", Html_h5, QTextHtmlElement::DisplayBlock }, -
406 { "h6", Html_h6, QTextHtmlElement::DisplayBlock }, -
407 { "head", Html_head, QTextHtmlElement::DisplayNone }, -
408 { "hr", Html_hr, QTextHtmlElement::DisplayBlock }, -
409 { "html", Html_html, QTextHtmlElement::DisplayInline }, -
410 { "i", Html_i, QTextHtmlElement::DisplayInline }, -
411 { "img", Html_img, QTextHtmlElement::DisplayInline }, -
412 { "kbd", Html_kbd, QTextHtmlElement::DisplayInline }, -
413 { "li", Html_li, QTextHtmlElement::DisplayBlock }, -
414 { "link", Html_link, QTextHtmlElement::DisplayNone }, -
415 { "meta", Html_meta, QTextHtmlElement::DisplayNone }, -
416 { "nobr", Html_nobr, QTextHtmlElement::DisplayInline }, -
417 { "ol", Html_ol, QTextHtmlElement::DisplayBlock }, -
418 { "p", Html_p, QTextHtmlElement::DisplayBlock }, -
419 { "pre", Html_pre, QTextHtmlElement::DisplayBlock }, -
420 { "qt", Html_body /*deliberate mapping*/, QTextHtmlElement::DisplayBlock }, -
421 { "s", Html_s, QTextHtmlElement::DisplayInline }, -
422 { "samp", Html_samp, QTextHtmlElement::DisplayInline }, -
423 { "script", Html_script, QTextHtmlElement::DisplayNone }, -
424 { "small", Html_small, QTextHtmlElement::DisplayInline }, -
425 { "span", Html_span, QTextHtmlElement::DisplayInline }, -
426 { "strong", Html_strong, QTextHtmlElement::DisplayInline }, -
427 { "style", Html_style, QTextHtmlElement::DisplayNone }, -
428 { "sub", Html_sub, QTextHtmlElement::DisplayInline }, -
429 { "sup", Html_sup, QTextHtmlElement::DisplayInline }, -
430 { "table", Html_table, QTextHtmlElement::DisplayTable }, -
431 { "tbody", Html_tbody, QTextHtmlElement::DisplayTable }, -
432 { "td", Html_td, QTextHtmlElement::DisplayBlock }, -
433 { "tfoot", Html_tfoot, QTextHtmlElement::DisplayTable }, -
434 { "th", Html_th, QTextHtmlElement::DisplayBlock }, -
435 { "thead", Html_thead, QTextHtmlElement::DisplayTable }, -
436 { "title", Html_title, QTextHtmlElement::DisplayNone }, -
437 { "tr", Html_tr, QTextHtmlElement::DisplayTable }, -
438 { "tt", Html_tt, QTextHtmlElement::DisplayInline }, -
439 { "u", Html_u, QTextHtmlElement::DisplayInline }, -
440 { "ul", Html_ul, QTextHtmlElement::DisplayBlock }, -
441 { "var", Html_var, QTextHtmlElement::DisplayInline }, -
442}; -
443 -
444 -
445Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &str, const QTextHtmlElement &e) -
446{ -
447 return str < QLatin1String(e.name);
executed: return str < QLatin1String(e.name);
Execution Count:1606
1606
448} -
449 -
450Q_STATIC_GLOBAL_OPERATOR bool operator<(const QTextHtmlElement &e, const QString &str) -
451{ -
452 return QLatin1String(e.name) < str;
executed: return QLatin1String(e.name) < str;
Execution Count:9596
9596
453} -
454 -
455static const QTextHtmlElement *lookupElementHelper(const QString &element) -
456{ -
457 const QTextHtmlElement *start = &elements[0];
executed (the execution status of this line is deduced): const QTextHtmlElement *start = &elements[0];
-
458 const QTextHtmlElement *end = &elements[Html_NumElements];
executed (the execution status of this line is deduced): const QTextHtmlElement *end = &elements[Html_NumElements];
-
459 const QTextHtmlElement *e = qBinaryFind(start, end, element);
executed (the execution status of this line is deduced): const QTextHtmlElement *e = qBinaryFind(start, end, element);
-
460 if (e == end)
evaluated: e == end
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1594
12-1594
461 return 0;
executed: return 0;
Execution Count:12
12
462 return e;
executed: return e;
Execution Count:1594
1594
463} -
464 -
465int QTextHtmlParser::lookupElement(const QString &element) -
466{ -
467 const QTextHtmlElement *e = lookupElementHelper(element);
executed (the execution status of this line is deduced): const QTextHtmlElement *e = lookupElementHelper(element);
-
468 if (!e)
partially evaluated: !e
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
469 return -1;
never executed: return -1;
0
470 return e->id;
executed: return e->id;
Execution Count:13
13
471} -
472 -
473// quotes newlines as "\\n" -
474static QString quoteNewline(const QString &s) -
475{ -
476 QString n = s;
never executed (the execution status of this line is deduced): QString n = s;
-
477 n.replace(QLatin1Char('\n'), QLatin1String("\\n"));
never executed (the execution status of this line is deduced): n.replace(QLatin1Char('\n'), QLatin1String("\\n"));
-
478 return n;
never executed: return n;
0
479} -
480 -
481QTextHtmlParserNode::QTextHtmlParserNode() -
482 : parent(0), id(Html_unknown), -
483 cssFloat(QTextFrameFormat::InFlow), hasOwnListStyle(false), -
484 hasCssListIndent(false), isEmptyParagraph(false), isTextFrame(false), isRootFrame(false), -
485 displayMode(QTextHtmlElement::DisplayInline), hasHref(false), -
486 listStyle(QTextListFormat::ListStyleUndefined), imageWidth(-1), imageHeight(-1), tableBorder(0), -
487 tableCellRowSpan(1), tableCellColSpan(1), tableCellSpacing(2), tableCellPadding(0), -
488 borderBrush(Qt::darkGray), borderStyle(QTextFrameFormat::BorderStyle_Outset), -
489 userState(-1), cssListIndent(0), wsm(WhiteSpaceModeUndefined) -
490{ -
491 margin[QTextHtmlParser::MarginLeft] = 0;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginLeft] = 0;
-
492 margin[QTextHtmlParser::MarginRight] = 0;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginRight] = 0;
-
493 margin[QTextHtmlParser::MarginTop] = 0;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 0;
-
494 margin[QTextHtmlParser::MarginBottom] = 0;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 0;
-
495}
executed: }
Execution Count:3070
3070
496 -
497void QTextHtmlParser::dumpHtml() -
498{ -
499 for (int i = 0; i < count(); ++i) {
never evaluated: i < count()
0
500 qDebug().nospace() << qPrintable(QString(depth(i)*4, QLatin1Char(' ')))
never executed (the execution status of this line is deduced): QMessageLogger("text/qtexthtmlparser.cpp", 500, __PRETTY_FUNCTION__).debug().nospace() << QString(QString(depth(i)*4, QLatin1Char(' '))).toLocal8Bit().constData()
-
501 << qPrintable(at(i).tag) << ':'
never executed (the execution status of this line is deduced): << QString(at(i).tag).toLocal8Bit().constData() << ':'
-
502 << quoteNewline(at(i).text);
never executed (the execution status of this line is deduced): << quoteNewline(at(i).text);
-
503 ; -
504 }
never executed: }
0
505}
never executed: }
0
506 -
507QTextHtmlParserNode *QTextHtmlParser::newNode(int parent) -
508{ -
509 QTextHtmlParserNode *lastNode = &nodes.last();
executed (the execution status of this line is deduced): QTextHtmlParserNode *lastNode = &nodes.last();
-
510 QTextHtmlParserNode *newNode = 0;
executed (the execution status of this line is deduced): QTextHtmlParserNode *newNode = 0;
-
511 -
512 bool reuseLastNode = true;
executed (the execution status of this line is deduced): bool reuseLastNode = true;
-
513 -
514 if (nodes.count() == 1) {
evaluated: nodes.count() == 1
TRUEFALSE
yes
Evaluation Count:679
yes
Evaluation Count:2289
679-2289
515 reuseLastNode = false;
executed (the execution status of this line is deduced): reuseLastNode = false;
-
516 } else if (lastNode->tag.isEmpty()) {
executed: }
Execution Count:679
evaluated: lastNode->tag.isEmpty()
TRUEFALSE
yes
Evaluation Count:771
yes
Evaluation Count:1518
679-1518
517 -
518 if (lastNode->text.isEmpty()) {
evaluated: lastNode->text.isEmpty()
TRUEFALSE
yes
Evaluation Count:523
yes
Evaluation Count:248
248-523
519 reuseLastNode = true;
executed (the execution status of this line is deduced): reuseLastNode = true;
-
520 } else { // last node is a text node (empty tag) with some text
executed: }
Execution Count:523
523
521 -
522 if (lastNode->text.length() == 1 && lastNode->text.at(0).isSpace()) {
evaluated: lastNode->text.length() == 1
TRUEFALSE
yes
Evaluation Count:99
yes
Evaluation Count:149
evaluated: lastNode->text.at(0).isSpace()
TRUEFALSE
yes
Evaluation Count:93
yes
Evaluation Count:6
6-149
523 -
524 int lastSibling = count() - 2;
executed (the execution status of this line is deduced): int lastSibling = count() - 2;
-
525 while (lastSibling
partially evaluated: lastSibling
TRUEFALSE
yes
Evaluation Count:147
no
Evaluation Count:0
0-147
526 && at(lastSibling).parent != lastNode->parent
evaluated: at(lastSibling).parent != lastNode->parent
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:75
72-75
527 && at(lastSibling).displayMode == QTextHtmlElement::DisplayInline) {
evaluated: at(lastSibling).displayMode == QTextHtmlElement::DisplayInline
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:18
18-54
528 lastSibling = at(lastSibling).parent;
executed (the execution status of this line is deduced): lastSibling = at(lastSibling).parent;
-
529 }
executed: }
Execution Count:54
54
530 -
531 if (at(lastSibling).displayMode == QTextHtmlElement::DisplayInline) {
evaluated: at(lastSibling).displayMode == QTextHtmlElement::DisplayInline
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:89
4-89
532 reuseLastNode = false;
executed (the execution status of this line is deduced): reuseLastNode = false;
-
533 } else {
executed: }
Execution Count:4
4
534 reuseLastNode = true;
executed (the execution status of this line is deduced): reuseLastNode = true;
-
535 }
executed: }
Execution Count:89
89
536 } else { -
537 // text node with real (non-whitespace) text -> nothing to re-use -
538 reuseLastNode = false;
executed (the execution status of this line is deduced): reuseLastNode = false;
-
539 }
executed: }
Execution Count:155
155
540 -
541 } -
542 -
543 } else { -
544 // last node had a proper tag -> nothing to re-use -
545 reuseLastNode = false;
executed (the execution status of this line is deduced): reuseLastNode = false;
-
546 }
executed: }
Execution Count:1518
1518
547 -
548 if (reuseLastNode) {
evaluated: reuseLastNode
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:2356
612-2356
549 newNode = lastNode;
executed (the execution status of this line is deduced): newNode = lastNode;
-
550 newNode->tag.clear();
executed (the execution status of this line is deduced): newNode->tag.clear();
-
551 newNode->text.clear();
executed (the execution status of this line is deduced): newNode->text.clear();
-
552 newNode->id = Html_unknown;
executed (the execution status of this line is deduced): newNode->id = Html_unknown;
-
553 } else {
executed: }
Execution Count:612
612
554 nodes.resize(nodes.size() + 1);
executed (the execution status of this line is deduced): nodes.resize(nodes.size() + 1);
-
555 newNode = &nodes.last();
executed (the execution status of this line is deduced): newNode = &nodes.last();
-
556 }
executed: }
Execution Count:2356
2356
557 -
558 newNode->parent = parent;
executed (the execution status of this line is deduced): newNode->parent = parent;
-
559 return newNode;
executed: return newNode;
Execution Count:2968
2968
560} -
561 -
562void QTextHtmlParser::parse(const QString &text, const QTextDocument *_resourceProvider) -
563{ -
564 nodes.clear();
executed (the execution status of this line is deduced): nodes.clear();
-
565 nodes.resize(1);
executed (the execution status of this line is deduced): nodes.resize(1);
-
566 txt = text;
executed (the execution status of this line is deduced): txt = text;
-
567 pos = 0;
executed (the execution status of this line is deduced): pos = 0;
-
568 len = txt.length();
executed (the execution status of this line is deduced): len = txt.length();
-
569 textEditMode = false;
executed (the execution status of this line is deduced): textEditMode = false;
-
570 resourceProvider = _resourceProvider;
executed (the execution status of this line is deduced): resourceProvider = _resourceProvider;
-
571 parse();
executed (the execution status of this line is deduced): parse();
-
572 //dumpHtml(); -
573}
executed: }
Execution Count:706
706
574 -
575int QTextHtmlParser::depth(int i) const -
576{ -
577 int depth = 0;
executed (the execution status of this line is deduced): int depth = 0;
-
578 while (i) {
evaluated: i
TRUEFALSE
yes
Evaluation Count:4295
yes
Evaluation Count:2318
2318-4295
579 i = at(i).parent;
executed (the execution status of this line is deduced): i = at(i).parent;
-
580 ++depth;
executed (the execution status of this line is deduced): ++depth;
-
581 }
executed: }
Execution Count:4295
4295
582 return depth;
executed: return depth;
Execution Count:2318
2318
583} -
584 -
585int QTextHtmlParser::margin(int i, int mar) const { -
586 int m = 0;
executed (the execution status of this line is deduced): int m = 0;
-
587 const QTextHtmlParserNode *node;
executed (the execution status of this line is deduced): const QTextHtmlParserNode *node;
-
588 if (mar == MarginLeft
evaluated: mar == MarginLeft
TRUEFALSE
yes
Evaluation Count:929
yes
Evaluation Count:929
929
589 || mar == MarginRight) {
partially evaluated: mar == MarginRight
TRUEFALSE
yes
Evaluation Count:929
no
Evaluation Count:0
0-929
590 while (i) {
evaluated: i
TRUEFALSE
yes
Evaluation Count:2588
yes
Evaluation Count:1192
1192-2588
591 node = &at(i);
executed (the execution status of this line is deduced): node = &at(i);
-
592 if (!node->isBlock() && node->id != Html_table)
evaluated: !node->isBlock()
TRUEFALSE
yes
Evaluation Count:474
yes
Evaluation Count:2114
evaluated: node->id != Html_table
TRUEFALSE
yes
Evaluation Count:320
yes
Evaluation Count:154
154-2114
593 break;
executed: break;
Execution Count:320
320
594 if (node->isTableCell())
evaluated: node->isTableCell()
TRUEFALSE
yes
Evaluation Count:346
yes
Evaluation Count:1922
346-1922
595 break;
executed: break;
Execution Count:346
346
596 m += node->margin[mar];
executed (the execution status of this line is deduced): m += node->margin[mar];
-
597 i = node->parent;
executed (the execution status of this line is deduced): i = node->parent;
-
598 }
executed: }
Execution Count:1922
1922
599 }
executed: }
Execution Count:1858
1858
600 return m;
executed: return m;
Execution Count:1858
1858
601} -
602 -
603int QTextHtmlParser::topMargin(int i) const -
604{ -
605 if (!i)
partially evaluated: !i
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:971
0-971
606 return 0;
never executed: return 0;
0
607 return at(i).margin[MarginTop];
executed: return at(i).margin[MarginTop];
Execution Count:971
971
608} -
609 -
610int QTextHtmlParser::bottomMargin(int i) const -
611{ -
612 if (!i)
partially evaluated: !i
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:972
0-972
613 return 0;
never executed: return 0;
0
614 return at(i).margin[MarginBottom];
executed: return at(i).margin[MarginBottom];
Execution Count:972
972
615} -
616 -
617void QTextHtmlParser::eatSpace() -
618{ -
619 while (pos < len && txt.at(pos).isSpace() && txt.at(pos) != QChar::ParagraphSeparator)
partially evaluated: pos < len
TRUEFALSE
yes
Evaluation Count:5109
no
Evaluation Count:0
evaluated: txt.at(pos).isSpace()
TRUEFALSE
yes
Evaluation Count:529
yes
Evaluation Count:4580
partially evaluated: txt.at(pos) != QChar::ParagraphSeparator
TRUEFALSE
yes
Evaluation Count:529
no
Evaluation Count:0
0-5109
620 pos++;
executed: pos++;
Execution Count:529
529
621}
executed: }
Execution Count:4580
4580
622 -
623void QTextHtmlParser::parse() -
624{ -
625 while (pos < len) {
evaluated: pos < len
TRUEFALSE
yes
Evaluation Count:307340
yes
Evaluation Count:706
706-307340
626 QChar c = txt.at(pos++);
executed (the execution status of this line is deduced): QChar c = txt.at(pos++);
-
627 if (c == QLatin1Char('<')) {
evaluated: c == QLatin1Char('<')
TRUEFALSE
yes
Evaluation Count:2803
yes
Evaluation Count:304537
2803-304537
628 parseTag();
executed (the execution status of this line is deduced): parseTag();
-
629 } else if (c == QLatin1Char('&')) {
executed: }
Execution Count:2803
evaluated: c == QLatin1Char('&')
TRUEFALSE
yes
Evaluation Count:296
yes
Evaluation Count:304241
296-304241
630 nodes.last().text += parseEntity();
executed (the execution status of this line is deduced): nodes.last().text += parseEntity();
-
631 } else {
executed: }
Execution Count:296
296
632 nodes.last().text += c;
executed (the execution status of this line is deduced): nodes.last().text += c;
-
633 }
executed: }
Execution Count:304241
304241
634 } -
635}
executed: }
Execution Count:706
706
636 -
637// parses a tag after "<" -
638void QTextHtmlParser::parseTag() -
639{ -
640 eatSpace();
executed (the execution status of this line is deduced): eatSpace();
-
641 -
642 // handle comments and other exclamation mark declarations -
643 if (hasPrefix(QLatin1Char('!'))) {
evaluated: hasPrefix(QLatin1Char('!'))
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:2789
14-2789
644 parseExclamationTag();
executed (the execution status of this line is deduced): parseExclamationTag();
-
645 if (nodes.last().wsm != QTextHtmlParserNode::WhiteSpacePre
partially evaluated: nodes.last().wsm != QTextHtmlParserNode::WhiteSpacePre
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
646 && nodes.last().wsm != QTextHtmlParserNode::WhiteSpacePreWrap
partially evaluated: nodes.last().wsm != QTextHtmlParserNode::WhiteSpacePreWrap
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
647 && !textEditMode)
evaluated: !textEditMode
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:3
3-11
648 eatSpace();
executed: eatSpace();
Execution Count:11
11
649 return;
executed: return;
Execution Count:14
14
650 } -
651 -
652 // if close tag just close -
653 if (hasPrefix(QLatin1Char('/'))) {
evaluated: hasPrefix(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:1196
yes
Evaluation Count:1593
1196-1593
654 if (nodes.last().id == Html_style) {
evaluated: nodes.last().id == Html_style
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:1159
37-1159
655#ifndef QT_NO_CSSPARSER -
656 QCss::Parser parser(nodes.last().text);
executed (the execution status of this line is deduced): QCss::Parser parser(nodes.last().text);
-
657 QCss::StyleSheet sheet;
executed (the execution status of this line is deduced): QCss::StyleSheet sheet;
-
658 sheet.origin = QCss::StyleSheetOrigin_Author;
executed (the execution status of this line is deduced): sheet.origin = QCss::StyleSheetOrigin_Author;
-
659 parser.parse(&sheet, Qt::CaseInsensitive);
executed (the execution status of this line is deduced): parser.parse(&sheet, Qt::CaseInsensitive);
-
660 inlineStyleSheets.append(sheet);
executed (the execution status of this line is deduced): inlineStyleSheets.append(sheet);
-
661 resolveStyleSheetImports(sheet);
executed (the execution status of this line is deduced): resolveStyleSheetImports(sheet);
-
662#endif -
663 }
executed: }
Execution Count:37
37
664 parseCloseTag();
executed (the execution status of this line is deduced): parseCloseTag();
-
665 return;
executed: return;
Execution Count:1196
1196
666 } -
667 -
668 int p = last();
executed (the execution status of this line is deduced): int p = last();
-
669 while (p && at(p).tag.size() == 0)
evaluated: p
TRUEFALSE
yes
Evaluation Count:1192
yes
Evaluation Count:763
evaluated: at(p).tag.size() == 0
TRUEFALSE
yes
Evaluation Count:362
yes
Evaluation Count:830
362-1192
670 p = at(p).parent;
executed: p = at(p).parent;
Execution Count:362
362
671 -
672 QTextHtmlParserNode *node = newNode(p);
executed (the execution status of this line is deduced): QTextHtmlParserNode *node = newNode(p);
-
673 -
674 // parse tag name -
675 node->tag = parseWord().toLower();
executed (the execution status of this line is deduced): node->tag = parseWord().toLower();
-
676 -
677 const QTextHtmlElement *elem = lookupElementHelper(node->tag);
executed (the execution status of this line is deduced): const QTextHtmlElement *elem = lookupElementHelper(node->tag);
-
678 if (elem) {
evaluated: elem
TRUEFALSE
yes
Evaluation Count:1581
yes
Evaluation Count:12
12-1581
679 node->id = elem->id;
executed (the execution status of this line is deduced): node->id = elem->id;
-
680 node->displayMode = elem->displayMode;
executed (the execution status of this line is deduced): node->displayMode = elem->displayMode;
-
681 } else {
executed: }
Execution Count:1581
1581
682 node->id = Html_unknown;
executed (the execution status of this line is deduced): node->id = Html_unknown;
-
683 }
executed: }
Execution Count:12
12
684 -
685 node->attributes.clear();
executed (the execution status of this line is deduced): node->attributes.clear();
-
686 // _need_ at least one space after the tag name, otherwise there can't be attributes -
687 if (pos < len && txt.at(pos).isSpace())
partially evaluated: pos < len
TRUEFALSE
yes
Evaluation Count:1593
no
Evaluation Count:0
evaluated: txt.at(pos).isSpace()
TRUEFALSE
yes
Evaluation Count:418
yes
Evaluation Count:1175
0-1593
688 node->attributes = parseAttributes();
executed: node->attributes = parseAttributes();
Execution Count:418
418
689 -
690 // resolveParent() may have to change the order in the tree and -
691 // insert intermediate nodes for buggy HTML, so re-initialize the 'node' -
692 // pointer through the return value -
693 node = resolveParent();
executed (the execution status of this line is deduced): node = resolveParent();
-
694 resolveNode();
executed (the execution status of this line is deduced): resolveNode();
-
695 -
696 const int nodeIndex = nodes.count() - 1; // this new node is always the last
executed (the execution status of this line is deduced): const int nodeIndex = nodes.count() - 1;
-
697#ifndef QT_NO_CSSPARSER -
698 node->applyCssDeclarations(declarationsForNode(nodeIndex), resourceProvider);
executed (the execution status of this line is deduced): node->applyCssDeclarations(declarationsForNode(nodeIndex), resourceProvider);
-
699#endif -
700 applyAttributes(node->attributes);
executed (the execution status of this line is deduced): applyAttributes(node->attributes);
-
701 -
702 // finish tag -
703 bool tagClosed = false;
executed (the execution status of this line is deduced): bool tagClosed = false;
-
704 while (pos < len && txt.at(pos) != QLatin1Char('>')) {
evaluated: pos < len
TRUEFALSE
yes
Evaluation Count:1689
yes
Evaluation Count:1
evaluated: txt.at(pos) != QLatin1Char('>')
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:1592
1-1689
705 if (txt.at(pos) == QLatin1Char('/'))
evaluated: txt.at(pos) == QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:81
yes
Evaluation Count:16
16-81
706 tagClosed = true;
executed: tagClosed = true;
Execution Count:81
81
707 -
708 pos++;
executed (the execution status of this line is deduced): pos++;
-
709 }
executed: }
Execution Count:97
97
710 pos++;
executed (the execution status of this line is deduced): pos++;
-
711 -
712 // in a white-space preserving environment strip off a initial newline -
713 // since the element itself already generates a newline -
714 if ((node->wsm == QTextHtmlParserNode::WhiteSpacePre
evaluated: node->wsm == QTextHtmlParserNode::WhiteSpacePre
TRUEFALSE
yes
Evaluation Count:402
yes
Evaluation Count:1191
402-1191
715 || node->wsm == QTextHtmlParserNode::WhiteSpacePreWrap)
evaluated: node->wsm == QTextHtmlParserNode::WhiteSpacePreWrap
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:1147
44-1147
716 && node->isBlock()) {
evaluated: node->isBlock()
TRUEFALSE
yes
Evaluation Count:312
yes
Evaluation Count:134
134-312
717 if (pos < len - 1 && txt.at(pos) == QLatin1Char('\n'))
partially evaluated: pos < len - 1
TRUEFALSE
yes
Evaluation Count:312
no
Evaluation Count:0
evaluated: txt.at(pos) == QLatin1Char('\n')
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:304
0-312
718 ++pos;
executed: ++pos;
Execution Count:8
8
719 }
executed: }
Execution Count:312
312
720 -
721 if (node->mayNotHaveChildren() || tagClosed) {
evaluated: node->mayNotHaveChildren()
TRUEFALSE
yes
Evaluation Count:175
yes
Evaluation Count:1418
evaluated: tagClosed
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1403
15-1418
722 newNode(node->parent);
executed (the execution status of this line is deduced): newNode(node->parent);
-
723 resolveNode();
executed (the execution status of this line is deduced): resolveNode();
-
724 }
executed: }
Execution Count:190
190
725}
executed: }
Execution Count:1593
1593
726 -
727// parses a tag beginning with "/" -
728void QTextHtmlParser::parseCloseTag() -
729{ -
730 ++pos;
executed (the execution status of this line is deduced): ++pos;
-
731 QString tag = parseWord().toLower().trimmed();
executed (the execution status of this line is deduced): QString tag = parseWord().toLower().trimmed();
-
732 while (pos < len) {
evaluated: pos < len
TRUEFALSE
yes
Evaluation Count:1195
yes
Evaluation Count:1
1-1195
733 QChar c = txt.at(pos++);
executed (the execution status of this line is deduced): QChar c = txt.at(pos++);
-
734 if (c == QLatin1Char('>'))
partially evaluated: c == QLatin1Char('>')
TRUEFALSE
yes
Evaluation Count:1195
no
Evaluation Count:0
0-1195
735 break;
executed: break;
Execution Count:1195
1195
736 }
never executed: }
0
737 -
738 // find corresponding open node -
739 int p = last();
executed (the execution status of this line is deduced): int p = last();
-
740 if (p > 0
partially evaluated: p > 0
TRUEFALSE
yes
Evaluation Count:1196
no
Evaluation Count:0
0-1196
741 && at(p - 1).tag == tag
evaluated: at(p - 1).tag == tag
TRUEFALSE
yes
Evaluation Count:93
yes
Evaluation Count:1103
93-1103
742 && at(p - 1).mayNotHaveChildren())
evaluated: at(p - 1).mayNotHaveChildren()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:91
2-91
743 p--;
executed: p--;
Execution Count:2
2
744 -
745 while (p && at(p).tag != tag)
evaluated: p
TRUEFALSE
yes
Evaluation Count:1644
yes
Evaluation Count:11
evaluated: at(p).tag != tag
TRUEFALSE
yes
Evaluation Count:459
yes
Evaluation Count:1185
11-1644
746 p = at(p).parent;
executed: p = at(p).parent;
Execution Count:459
459
747 -
748 // simply ignore the tag if we can't find -
749 // a corresponding open node, for broken -
750 // html such as <font>blah</font></font> -
751 if (!p)
evaluated: !p
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1185
11-1185
752 return;
executed: return;
Execution Count:11
11
753 -
754 // in a white-space preserving environment strip off a trailing newline -
755 // since the closing of the opening block element will automatically result -
756 // in a new block for elements following the <pre> -
757 // ...foo\n</pre><p>blah -> foo</pre><p>blah -
758 if ((at(p).wsm == QTextHtmlParserNode::WhiteSpacePre
evaluated: at(p).wsm == QTextHtmlParserNode::WhiteSpacePre
TRUEFALSE
yes
Evaluation Count:271
yes
Evaluation Count:914
271-914
759 || at(p).wsm == QTextHtmlParserNode::WhiteSpacePreWrap)
evaluated: at(p).wsm == QTextHtmlParserNode::WhiteSpacePreWrap
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:870
44-870
760 && at(p).isBlock()) {
evaluated: at(p).isBlock()
TRUEFALSE
yes
Evaluation Count:308
yes
Evaluation Count:7
7-308
761 if (at(last()).text.endsWith(QLatin1Char('\n')))
evaluated: at(last()).text.endsWith(QLatin1Char('\n'))
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:301
7-301
762 nodes[last()].text.chop(1);
executed: nodes[last()].text.chop(1);
Execution Count:7
7
763 }
executed: }
Execution Count:308
308
764 -
765 newNode(at(p).parent);
executed (the execution status of this line is deduced): newNode(at(p).parent);
-
766 resolveNode();
executed (the execution status of this line is deduced): resolveNode();
-
767}
executed: }
Execution Count:1185
1185
768 -
769// parses a tag beginning with "!" -
770void QTextHtmlParser::parseExclamationTag() -
771{ -
772 ++pos;
executed (the execution status of this line is deduced): ++pos;
-
773 if (hasPrefix(QLatin1Char('-'),1) && hasPrefix(QLatin1Char('-'),2)) {
evaluated: hasPrefix(QLatin1Char('-'),1)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:8
partially evaluated: hasPrefix(QLatin1Char('-'),2)
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-8
774 pos += 3;
executed (the execution status of this line is deduced): pos += 3;
-
775 // eat comments -
776 int end = txt.indexOf(QLatin1String("-->"), pos);
executed (the execution status of this line is deduced): int end = txt.indexOf(QLatin1String("-->"), pos);
-
777 pos = (end >= 0 ? end + 3 : len);
partially evaluated: end >= 0
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
778 } else {
executed: }
Execution Count:6
6
779 // eat internal tags -
780 while (pos < len) {
partially evaluated: pos < len
TRUEFALSE
yes
Evaluation Count:736
no
Evaluation Count:0
0-736
781 QChar c = txt.at(pos++);
executed (the execution status of this line is deduced): QChar c = txt.at(pos++);
-
782 if (c == QLatin1Char('>'))
evaluated: c == QLatin1Char('>')
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:728
8-728
783 break;
executed: break;
Execution Count:8
8
784 }
executed: }
Execution Count:728
728
785 }
executed: }
Execution Count:8
8
786} -
787 -
788// parses an entity after "&", and returns it -
789QString QTextHtmlParser::parseEntity() -
790{ -
791 int recover = pos;
executed (the execution status of this line is deduced): int recover = pos;
-
792 QString entity;
executed (the execution status of this line is deduced): QString entity;
-
793 while (pos < len) {
partially evaluated: pos < len
TRUEFALSE
yes
Evaluation Count:1633
no
Evaluation Count:0
0-1633
794 QChar c = txt.at(pos++);
executed (the execution status of this line is deduced): QChar c = txt.at(pos++);
-
795 if (c.isSpace() || pos - recover > 9) {
partially evaluated: c.isSpace()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1633
partially evaluated: pos - recover > 9
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1633
0-1633
796 goto error;
never executed: goto error;
0
797 } -
798 if (c == QLatin1Char(';'))
evaluated: c == QLatin1Char(';')
TRUEFALSE
yes
Evaluation Count:296
yes
Evaluation Count:1337
296-1337
799 break;
executed: break;
Execution Count:296
296
800 entity += c;
executed (the execution status of this line is deduced): entity += c;
-
801 }
executed: }
Execution Count:1337
1337
802 { -
803 QChar resolved = resolveEntity(entity);
executed (the execution status of this line is deduced): QChar resolved = resolveEntity(entity);
-
804 if (!resolved.isNull())
evaluated: !resolved.isNull()
TRUEFALSE
yes
Evaluation Count:262
yes
Evaluation Count:34
34-262
805 return QString(resolved);
executed: return QString(resolved);
Execution Count:262
262
806 } -
807 if (entity.length() > 1 && entity.at(0) == QLatin1Char('#')) {
partially evaluated: entity.length() > 1
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
partially evaluated: entity.at(0) == QLatin1Char('#')
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-34
808 entity.remove(0, 1); // removing leading #
executed (the execution status of this line is deduced): entity.remove(0, 1);
-
809 -
810 int base = 10;
executed (the execution status of this line is deduced): int base = 10;
-
811 bool ok = false;
executed (the execution status of this line is deduced): bool ok = false;
-
812 -
813 if (entity.at(0).toLower() == QLatin1Char('x')) { // hex entity?
evaluated: entity.at(0).toLower() == QLatin1Char('x')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:33
1-33
814 entity.remove(0, 1);
executed (the execution status of this line is deduced): entity.remove(0, 1);
-
815 base = 16;
executed (the execution status of this line is deduced): base = 16;
-
816 }
executed: }
Execution Count:1
1
817 -
818 uint uc = entity.toUInt(&ok, base);
executed (the execution status of this line is deduced): uint uc = entity.toUInt(&ok, base);
-
819 if (ok) {
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-34
820 if (uc >= 0x80 && uc < 0x80 + (sizeof(windowsLatin1ExtendedCharacters)/sizeof(windowsLatin1ExtendedCharacters[0])))
evaluated: uc >= 0x80
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:2
partially evaluated: uc < 0x80 + (sizeof(windowsLatin1ExtendedCharacters)/sizeof(windowsLatin1ExtendedCharacters[0]))
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
821 uc = windowsLatin1ExtendedCharacters[uc - 0x80];
executed: uc = windowsLatin1ExtendedCharacters[uc - 0x80];
Execution Count:32
32
822 QString str;
executed (the execution status of this line is deduced): QString str;
-
823 if (QChar::requiresSurrogates(uc)) {
partially evaluated: QChar::requiresSurrogates(uc)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
0-34
824 str += QChar(QChar::highSurrogate(uc));
never executed (the execution status of this line is deduced): str += QChar(QChar::highSurrogate(uc));
-
825 str += QChar(QChar::lowSurrogate(uc));
never executed (the execution status of this line is deduced): str += QChar(QChar::lowSurrogate(uc));
-
826 } else {
never executed: }
0
827 str = QChar(uc);
executed (the execution status of this line is deduced): str = QChar(uc);
-
828 }
executed: }
Execution Count:34
34
829 return str;
executed: return str;
Execution Count:34
34
830 } -
831 }
never executed: }
0
832error:
code before this statement never executed: error:
0
833 pos = recover;
never executed (the execution status of this line is deduced): pos = recover;
-
834 return QLatin1String("&");
never executed: return QLatin1String("&");
0
835} -
836 -
837// parses one word, possibly quoted, and returns it -
838QString QTextHtmlParser::parseWord() -
839{ -
840 QString word;
executed (the execution status of this line is deduced): QString word;
-
841 if (hasPrefix(QLatin1Char('\"'))) { // double quotes
evaluated: hasPrefix(QLatin1Char('\"'))
TRUEFALSE
yes
Evaluation Count:363
yes
Evaluation Count:3323
363-3323
842 ++pos;
executed (the execution status of this line is deduced): ++pos;
-
843 while (pos < len) {
partially evaluated: pos < len
TRUEFALSE
yes
Evaluation Count:10000
no
Evaluation Count:0
0-10000
844 QChar c = txt.at(pos++);
executed (the execution status of this line is deduced): QChar c = txt.at(pos++);
-
845 if (c == QLatin1Char('\"'))
evaluated: c == QLatin1Char('\"')
TRUEFALSE
yes
Evaluation Count:363
yes
Evaluation Count:9637
363-9637
846 break;
executed: break;
Execution Count:363
363
847 else if (c == QLatin1Char('&'))
partially evaluated: c == QLatin1Char('&')
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9637
0-9637
848 word += parseEntity();
never executed: word += parseEntity();
0
849 else -
850 word += c;
executed: word += c;
Execution Count:9637
9637
851 } -
852 } else if (hasPrefix(QLatin1Char('\''))) { // single quotes
executed: }
Execution Count:363
evaluated: hasPrefix(QLatin1Char('\''))
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:3302
21-3302
853 ++pos;
executed (the execution status of this line is deduced): ++pos;
-
854 while (pos < len) {
partially evaluated: pos < len
TRUEFALSE
yes
Evaluation Count:465
no
Evaluation Count:0
0-465
855 QChar c = txt.at(pos++);
executed (the execution status of this line is deduced): QChar c = txt.at(pos++);
-
856 if (c == QLatin1Char('\''))
evaluated: c == QLatin1Char('\'')
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:444
21-444
857 break;
executed: break;
Execution Count:21
21
858 else -
859 word += c;
executed: word += c;
Execution Count:444
444
860 } -
861 } else { // normal text
executed: }
Execution Count:21
21
862 while (pos < len) {
evaluated: pos < len
TRUEFALSE
yes
Evaluation Count:13135
yes
Evaluation Count:1
1-13135
863 QChar c = txt.at(pos++);
executed (the execution status of this line is deduced): QChar c = txt.at(pos++);
-
864 if (c == QLatin1Char('>')
evaluated: c == QLatin1Char('>')
TRUEFALSE
yes
Evaluation Count:2400
yes
Evaluation Count:10735
2400-10735
865 || (c == QLatin1Char('/') && hasPrefix(QLatin1Char('>'), 1))
evaluated: c == QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:10725
partially evaluated: hasPrefix(QLatin1Char('>'), 1)
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10725
866 || c == QLatin1Char('<')
evaluated: c == QLatin1Char('<')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:10723
2-10723
867 || c == QLatin1Char('=')
evaluated: c == QLatin1Char('=')
TRUEFALSE
yes
Evaluation Count:446
yes
Evaluation Count:10277
446-10277
868 || c.isSpace()) {
evaluated: c.isSpace()
TRUEFALSE
yes
Evaluation Count:443
yes
Evaluation Count:9834
443-9834
869 --pos;
executed (the execution status of this line is deduced): --pos;
-
870 break;
executed: break;
Execution Count:3301
3301
871 } -
872 if (c == QLatin1Char('&'))
partially evaluated: c == QLatin1Char('&')
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9834
0-9834
873 word += parseEntity();
never executed: word += parseEntity();
0
874 else -
875 word += c;
executed: word += c;
Execution Count:9834
9834
876 } -
877 }
executed: }
Execution Count:3302
3302
878 return word;
executed: return word;
Execution Count:3686
3686
879} -
880 -
881// gives the new node the right parent -
882QTextHtmlParserNode *QTextHtmlParser::resolveParent() -
883{ -
884 QTextHtmlParserNode *node = &nodes.last();
executed (the execution status of this line is deduced): QTextHtmlParserNode *node = &nodes.last();
-
885 -
886 int p = node->parent;
executed (the execution status of this line is deduced): int p = node->parent;
-
887 -
888 // Excel gives us buggy HTML with just tr without surrounding table tags -
889 // or with just td tags -
890 -
891 if (node->id == Html_td) {
evaluated: node->id == Html_td
TRUEFALSE
yes
Evaluation Count:153
yes
Evaluation Count:1440
153-1440
892 int n = p;
executed (the execution status of this line is deduced): int n = p;
-
893 while (n && at(n).id != Html_tr)
evaluated: n
TRUEFALSE
yes
Evaluation Count:160
yes
Evaluation Count:3
evaluated: at(n).id != Html_tr
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:150
3-160
894 n = at(n).parent;
executed: n = at(n).parent;
Execution Count:10
10
895 -
896 if (!n) {
evaluated: !n
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:150
3-150
897 nodes.insert(nodes.count() - 1, QTextHtmlParserNode());
executed (the execution status of this line is deduced): nodes.insert(nodes.count() - 1, QTextHtmlParserNode());
-
898 nodes.insert(nodes.count() - 1, QTextHtmlParserNode());
executed (the execution status of this line is deduced): nodes.insert(nodes.count() - 1, QTextHtmlParserNode());
-
899 -
900 QTextHtmlParserNode *table = &nodes[nodes.count() - 3];
executed (the execution status of this line is deduced): QTextHtmlParserNode *table = &nodes[nodes.count() - 3];
-
901 table->parent = p;
executed (the execution status of this line is deduced): table->parent = p;
-
902 table->id = Html_table;
executed (the execution status of this line is deduced): table->id = Html_table;
-
903 table->tag = QLatin1String("table");
executed (the execution status of this line is deduced): table->tag = QLatin1String("table");
-
904 table->children.append(nodes.count() - 2); // add row as child
executed (the execution status of this line is deduced): table->children.append(nodes.count() - 2);
-
905 -
906 QTextHtmlParserNode *row = &nodes[nodes.count() - 2];
executed (the execution status of this line is deduced): QTextHtmlParserNode *row = &nodes[nodes.count() - 2];
-
907 row->parent = nodes.count() - 3; // table as parent
executed (the execution status of this line is deduced): row->parent = nodes.count() - 3;
-
908 row->id = Html_tr;
executed (the execution status of this line is deduced): row->id = Html_tr;
-
909 row->tag = QLatin1String("tr");
executed (the execution status of this line is deduced): row->tag = QLatin1String("tr");
-
910 -
911 p = nodes.count() - 2;
executed (the execution status of this line is deduced): p = nodes.count() - 2;
-
912 node = &nodes.last(); // re-initialize pointer
executed (the execution status of this line is deduced): node = &nodes.last();
-
913 }
executed: }
Execution Count:3
3
914 }
executed: }
Execution Count:153
153
915 -
916 if (node->id == Html_tr) {
evaluated: node->id == Html_tr
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:1492
101-1492
917 int n = p;
executed (the execution status of this line is deduced): int n = p;
-
918 while (n && at(n).id != Html_table)
evaluated: n
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:2
evaluated: at(n).id != Html_table
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:99
2-111
919 n = at(n).parent;
executed: n = at(n).parent;
Execution Count:12
12
920 -
921 if (!n) {
evaluated: !n
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:99
2-99
922 nodes.insert(nodes.count() - 1, QTextHtmlParserNode());
executed (the execution status of this line is deduced): nodes.insert(nodes.count() - 1, QTextHtmlParserNode());
-
923 QTextHtmlParserNode *table = &nodes[nodes.count() - 2];
executed (the execution status of this line is deduced): QTextHtmlParserNode *table = &nodes[nodes.count() - 2];
-
924 table->parent = p;
executed (the execution status of this line is deduced): table->parent = p;
-
925 table->id = Html_table;
executed (the execution status of this line is deduced): table->id = Html_table;
-
926 table->tag = QLatin1String("table");
executed (the execution status of this line is deduced): table->tag = QLatin1String("table");
-
927 p = nodes.count() - 2;
executed (the execution status of this line is deduced): p = nodes.count() - 2;
-
928 node = &nodes.last(); // re-initialize pointer
executed (the execution status of this line is deduced): node = &nodes.last();
-
929 }
executed: }
Execution Count:2
2
930 }
executed: }
Execution Count:101
101
931 -
932 // permit invalid html by letting block elements be children -
933 // of inline elements with the exception of paragraphs: -
934 // -
935 // a new paragraph closes parent inline elements (while loop), -
936 // unless they themselves are children of a non-paragraph block -
937 // element (if statement) -
938 // -
939 // For example: -
940 // -
941 // <body><p><b>Foo<p>Bar <-- second <p> implicitly closes <b> that -
942 // belongs to the first <p>. The self-nesting -
943 // check further down prevents the second <p> -
944 // from nesting into the first one then. -
945 // so Bar is not bold. -
946 // -
947 // <body><b><p>Foo <-- Foo should be bold. -
948 // -
949 // <body><b><p>Foo<p>Bar <-- Foo and Bar should be bold. -
950 // -
951 if (node->id == Html_p) {
evaluated: node->id == Html_p
TRUEFALSE
yes
Evaluation Count:247
yes
Evaluation Count:1346
247-1346
952 while (p && !at(p).isBlock())
evaluated: p
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:162
evaluated: !at(p).isBlock()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:85
10-162
953 p = at(p).parent;
executed: p = at(p).parent;
Execution Count:10
10
954 -
955 if (!p || at(p).id != Html_p)
evaluated: !p
TRUEFALSE
yes
Evaluation Count:162
yes
Evaluation Count:85
evaluated: at(p).id != Html_p
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:26
26-162
956 p = node->parent;
executed: p = node->parent;
Execution Count:221
221
957 }
executed: }
Execution Count:247
247
958 -
959 // some elements are not self nesting -
960 if (node->id == at(p).id
evaluated: node->id == at(p).id
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:1535
58-1535
961 && node->isNotSelfNesting())
evaluated: node->isNotSelfNesting()
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:31
27-31
962 p = at(p).parent;
executed: p = at(p).parent;
Execution Count:27
27
963 -
964 // some elements are not allowed in certain contexts -
965 while ((p && !node->allowedInContext(at(p).id))
evaluated: p
TRUEFALSE
yes
Evaluation Count:839
yes
Evaluation Count:780
evaluated: !node->allowedInContext(at(p).id)
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:813
26-839
966 // ### make new styles aware of empty tags
executed (the execution status of this line is deduced):
-
967 || at(p).mayNotHaveChildren()
partially evaluated: at(p).mayNotHaveChildren()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1593
0-1593
968 ) { -
969 p = at(p).parent;
executed (the execution status of this line is deduced): p = at(p).parent;
-
970 }
executed: }
Execution Count:26
26
971 -
972 node->parent = p;
executed (the execution status of this line is deduced): node->parent = p;
-
973 -
974 // makes it easier to traverse the tree, later -
975 nodes[p].children.append(nodes.count() - 1);
executed (the execution status of this line is deduced): nodes[p].children.append(nodes.count() - 1);
-
976 return node;
executed: return node;
Execution Count:1593
1593
977} -
978 -
979// sets all properties on the new node -
980void QTextHtmlParser::resolveNode() -
981{ -
982 QTextHtmlParserNode *node = &nodes.last();
executed (the execution status of this line is deduced): QTextHtmlParserNode *node = &nodes.last();
-
983 const QTextHtmlParserNode *parent = &nodes.at(node->parent);
executed (the execution status of this line is deduced): const QTextHtmlParserNode *parent = &nodes.at(node->parent);
-
984 node->initializeProperties(parent, this);
executed (the execution status of this line is deduced): node->initializeProperties(parent, this);
-
985}
executed: }
Execution Count:2968
2968
986 -
987bool QTextHtmlParserNode::isNestedList(const QTextHtmlParser *parser) const -
988{ -
989 if (!isListStart())
partially evaluated: !isListStart()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:40
0-40
990 return false;
never executed: return false;
0
991 -
992 int p = parent;
executed (the execution status of this line is deduced): int p = parent;
-
993 while (p) {
evaluated: p
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:32
24-32
994 if (parser->at(p).isListStart())
evaluated: parser->at(p).isListStart()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:16
8-16
995 return true;
executed: return true;
Execution Count:8
8
996 p = parser->at(p).parent;
executed (the execution status of this line is deduced): p = parser->at(p).parent;
-
997 }
executed: }
Execution Count:16
16
998 return false;
executed: return false;
Execution Count:32
32
999} -
1000 -
1001void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent, const QTextHtmlParser *parser) -
1002{ -
1003 // inherit properties from parent element -
1004 charFormat = parent->charFormat;
executed (the execution status of this line is deduced): charFormat = parent->charFormat;
-
1005 -
1006 if (id == Html_html)
evaluated: id == Html_html
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:2904
64-2904
1007 blockFormat.setLayoutDirection(Qt::LeftToRight); // HTML default
executed: blockFormat.setLayoutDirection(Qt::LeftToRight);
Execution Count:64
64
1008 else if (parent->blockFormat.hasProperty(QTextFormat::LayoutDirection))
evaluated: parent->blockFormat.hasProperty(QTextFormat::LayoutDirection)
TRUEFALSE
yes
Evaluation Count:800
yes
Evaluation Count:2104
800-2104
1009 blockFormat.setLayoutDirection(parent->blockFormat.layoutDirection());
executed: blockFormat.setLayoutDirection(parent->blockFormat.layoutDirection());
Execution Count:800
800
1010 -
1011 if (parent->displayMode == QTextHtmlElement::DisplayNone)
evaluated: parent->displayMode == QTextHtmlElement::DisplayNone
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:2897
71-2897
1012 displayMode = QTextHtmlElement::DisplayNone;
executed: displayMode = QTextHtmlElement::DisplayNone;
Execution Count:71
71
1013 -
1014 if (parent->id != Html_table || id == Html_caption) {
evaluated: parent->id != Html_table
TRUEFALSE
yes
Evaluation Count:2768
yes
Evaluation Count:200
evaluated: id == Html_caption
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:199
1-2768
1015 if (parent->blockFormat.hasProperty(QTextFormat::BlockAlignment))
evaluated: parent->blockFormat.hasProperty(QTextFormat::BlockAlignment)
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:2717
52-2717
1016 blockFormat.setAlignment(parent->blockFormat.alignment());
executed: blockFormat.setAlignment(parent->blockFormat.alignment());
Execution Count:52
52
1017 else -
1018 blockFormat.clearProperty(QTextFormat::BlockAlignment);
executed: blockFormat.clearProperty(QTextFormat::BlockAlignment);
Execution Count:2717
2717
1019 } -
1020 // we don't paint per-row background colors, yet. so as an -
1021 // exception inherit the background color here -
1022 // we also inherit the background between inline elements -
1023 if ((parent->id != Html_tr || !isTableCell())
evaluated: parent->id != Html_tr
TRUEFALSE
yes
Evaluation Count:2677
yes
Evaluation Count:291
evaluated: !isTableCell()
TRUEFALSE
yes
Evaluation Count:133
yes
Evaluation Count:158
133-2677
1024 && (displayMode != QTextHtmlElement::DisplayInline || parent->displayMode != QTextHtmlElement::DisplayInline)) {
evaluated: displayMode != QTextHtmlElement::DisplayInline
TRUEFALSE
yes
Evaluation Count:1087
yes
Evaluation Count:1723
evaluated: parent->displayMode != QTextHtmlElement::DisplayInline
TRUEFALSE
yes
Evaluation Count:601
yes
Evaluation Count:1122
601-1723
1025 charFormat.clearProperty(QTextFormat::BackgroundBrush);
executed (the execution status of this line is deduced): charFormat.clearProperty(QTextFormat::BackgroundBrush);
-
1026 }
executed: }
Execution Count:1688
1688
1027 -
1028 listStyle = parent->listStyle;
executed (the execution status of this line is deduced): listStyle = parent->listStyle;
-
1029 // makes no sense to inherit that property, a named anchor is a single point -
1030 // in the document, which is set by the DocumentFragment -
1031 charFormat.clearProperty(QTextFormat::AnchorName);
executed (the execution status of this line is deduced): charFormat.clearProperty(QTextFormat::AnchorName);
-
1032 wsm = parent->wsm;
executed (the execution status of this line is deduced): wsm = parent->wsm;
-
1033 -
1034 // initialize remaining properties -
1035 margin[QTextHtmlParser::MarginLeft] = 0;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginLeft] = 0;
-
1036 margin[QTextHtmlParser::MarginRight] = 0;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginRight] = 0;
-
1037 margin[QTextHtmlParser::MarginTop] = 0;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 0;
-
1038 margin[QTextHtmlParser::MarginBottom] = 0;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 0;
-
1039 cssFloat = QTextFrameFormat::InFlow;
executed (the execution status of this line is deduced): cssFloat = QTextFrameFormat::InFlow;
-
1040 -
1041 for (int i = 0; i < 4; ++i)
evaluated: i < 4
TRUEFALSE
yes
Evaluation Count:11872
yes
Evaluation Count:2968
2968-11872
1042 padding[i] = -1;
executed: padding[i] = -1;
Execution Count:11872
11872
1043 -
1044 // set element specific attributes -
1045 switch (id) { -
1046 case Html_a: -
1047 charFormat.setAnchor(true);
executed (the execution status of this line is deduced): charFormat.setAnchor(true);
-
1048 for (int i = 0; i < attributes.count(); i += 2) {
evaluated: i < attributes.count()
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:67
67
1049 const QString key = attributes.at(i);
executed (the execution status of this line is deduced): const QString key = attributes.at(i);
-
1050 if (key.compare(QLatin1String("href"), Qt::CaseInsensitive) == 0
evaluated: key.compare(QLatin1String("href"), Qt::CaseInsensitive) == 0
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:21
21-46
1051 && !attributes.at(i + 1).isEmpty()) {
partially evaluated: !attributes.at(i + 1).isEmpty()
TRUEFALSE
yes
Evaluation Count:46
no
Evaluation Count:0
0-46
1052 hasHref = true;
executed (the execution status of this line is deduced): hasHref = true;
-
1053 charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
executed (the execution status of this line is deduced): charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
-
1054 charFormat.setForeground(Qt::blue);
executed (the execution status of this line is deduced): charFormat.setForeground(Qt::blue);
-
1055 }
executed: }
Execution Count:46
46
1056 }
executed: }
Execution Count:67
67
1057 -
1058 break;
executed: break;
Execution Count:67
67
1059 case Html_em: -
1060 case Html_i: -
1061 case Html_cite: -
1062 case Html_address: -
1063 case Html_var: -
1064 case Html_dfn: -
1065 charFormat.setFontItalic(true);
executed (the execution status of this line is deduced): charFormat.setFontItalic(true);
-
1066 break;
executed: break;
Execution Count:6
6
1067 case Html_big: -
1068 charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(1));
never executed (the execution status of this line is deduced): charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(1));
-
1069 break;
never executed: break;
0
1070 case Html_small: -
1071 charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(-1));
never executed (the execution status of this line is deduced): charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(-1));
-
1072 break;
never executed: break;
0
1073 case Html_strong: -
1074 case Html_b: -
1075 charFormat.setFontWeight(QFont::Bold);
executed (the execution status of this line is deduced): charFormat.setFontWeight(QFont::Bold);
-
1076 break;
executed: break;
Execution Count:36
36
1077 case Html_h1: -
1078 charFormat.setFontWeight(QFont::Bold);
executed (the execution status of this line is deduced): charFormat.setFontWeight(QFont::Bold);
-
1079 charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(3));
executed (the execution status of this line is deduced): charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(3));
-
1080 margin[QTextHtmlParser::MarginTop] = 18;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 18;
-
1081 margin[QTextHtmlParser::MarginBottom] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 12;
-
1082 break;
executed: break;
Execution Count:3
3
1083 case Html_h2: -
1084 charFormat.setFontWeight(QFont::Bold);
never executed (the execution status of this line is deduced): charFormat.setFontWeight(QFont::Bold);
-
1085 charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(2));
never executed (the execution status of this line is deduced): charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(2));
-
1086 margin[QTextHtmlParser::MarginTop] = 16;
never executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 16;
-
1087 margin[QTextHtmlParser::MarginBottom] = 12;
never executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 12;
-
1088 break;
never executed: break;
0
1089 case Html_h3: -
1090 charFormat.setFontWeight(QFont::Bold);
executed (the execution status of this line is deduced): charFormat.setFontWeight(QFont::Bold);
-
1091 charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(1));
executed (the execution status of this line is deduced): charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(1));
-
1092 margin[QTextHtmlParser::MarginTop] = 14;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 14;
-
1093 margin[QTextHtmlParser::MarginBottom] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 12;
-
1094 break;
executed: break;
Execution Count:1
1
1095 case Html_h4: -
1096 charFormat.setFontWeight(QFont::Bold);
executed (the execution status of this line is deduced): charFormat.setFontWeight(QFont::Bold);
-
1097 charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(0));
executed (the execution status of this line is deduced): charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(0));
-
1098 margin[QTextHtmlParser::MarginTop] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 12;
-
1099 margin[QTextHtmlParser::MarginBottom] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 12;
-
1100 break;
executed: break;
Execution Count:1
1
1101 case Html_h5: -
1102 charFormat.setFontWeight(QFont::Bold);
never executed (the execution status of this line is deduced): charFormat.setFontWeight(QFont::Bold);
-
1103 charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(-1));
never executed (the execution status of this line is deduced): charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(-1));
-
1104 margin[QTextHtmlParser::MarginTop] = 12;
never executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 12;
-
1105 margin[QTextHtmlParser::MarginBottom] = 4;
never executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 4;
-
1106 break;
never executed: break;
0
1107 case Html_p: -
1108 margin[QTextHtmlParser::MarginTop] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 12;
-
1109 margin[QTextHtmlParser::MarginBottom] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 12;
-
1110 break;
executed: break;
Execution Count:247
247
1111 case Html_center: -
1112 blockFormat.setAlignment(Qt::AlignCenter);
executed (the execution status of this line is deduced): blockFormat.setAlignment(Qt::AlignCenter);
-
1113 break;
executed: break;
Execution Count:4
4
1114 case Html_ul: -
1115 listStyle = QTextListFormat::ListDisc;
executed (the execution status of this line is deduced): listStyle = QTextListFormat::ListDisc;
-
1116 // nested lists don't have margins, except for the toplevel one -
1117 if (!isNestedList(parser)) {
evaluated: !isNestedList(parser)
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:8
8-27
1118 margin[QTextHtmlParser::MarginTop] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 12;
-
1119 margin[QTextHtmlParser::MarginBottom] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 12;
-
1120 }
executed: }
Execution Count:27
27
1121 // no left margin as we use indenting instead -
1122 break;
executed: break;
Execution Count:35
35
1123 case Html_ol: -
1124 listStyle = QTextListFormat::ListDecimal;
executed (the execution status of this line is deduced): listStyle = QTextListFormat::ListDecimal;
-
1125 // nested lists don't have margins, except for the toplevel one -
1126 if (!isNestedList(parser)) {
partially evaluated: !isNestedList(parser)
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1127 margin[QTextHtmlParser::MarginTop] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 12;
-
1128 margin[QTextHtmlParser::MarginBottom] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 12;
-
1129 }
executed: }
Execution Count:5
5
1130 // no left margin as we use indenting instead -
1131 break;
executed: break;
Execution Count:5
5
1132 case Html_code: -
1133 case Html_tt: -
1134 case Html_kbd: -
1135 case Html_samp: -
1136 charFormat.setFontFamily(QString::fromLatin1("Courier New,courier"));
never executed (the execution status of this line is deduced): charFormat.setFontFamily(QString::fromLatin1("Courier New,courier"));
-
1137 // <tt> uses a fixed font, so set the property -
1138 charFormat.setFontFixedPitch(true);
never executed (the execution status of this line is deduced): charFormat.setFontFixedPitch(true);
-
1139 break;
never executed: break;
0
1140 case Html_br: -
1141 text = QChar(QChar::LineSeparator);
executed (the execution status of this line is deduced): text = QChar(QChar::LineSeparator);
-
1142 wsm = QTextHtmlParserNode::WhiteSpacePre;
executed (the execution status of this line is deduced): wsm = QTextHtmlParserNode::WhiteSpacePre;
-
1143 break;
executed: break;
Execution Count:127
127
1144 // ##### sub / sup -
1145 case Html_pre: -
1146 charFormat.setFontFamily(QString::fromLatin1("Courier New,courier"));
executed (the execution status of this line is deduced): charFormat.setFontFamily(QString::fromLatin1("Courier New,courier"));
-
1147 wsm = WhiteSpacePre;
executed (the execution status of this line is deduced): wsm = WhiteSpacePre;
-
1148 margin[QTextHtmlParser::MarginTop] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 12;
-
1149 margin[QTextHtmlParser::MarginBottom] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 12;
-
1150 // <pre> uses a fixed font -
1151 charFormat.setFontFixedPitch(true);
executed (the execution status of this line is deduced): charFormat.setFontFixedPitch(true);
-
1152 break;
executed: break;
Execution Count:273
273
1153 case Html_blockquote: -
1154 margin[QTextHtmlParser::MarginTop] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 12;
-
1155 margin[QTextHtmlParser::MarginBottom] = 12;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 12;
-
1156 margin[QTextHtmlParser::MarginLeft] = 40;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginLeft] = 40;
-
1157 margin[QTextHtmlParser::MarginRight] = 40;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginRight] = 40;
-
1158 break;
executed: break;
Execution Count:1
1
1159 case Html_dl: -
1160 margin[QTextHtmlParser::MarginTop] = 8;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginTop] = 8;
-
1161 margin[QTextHtmlParser::MarginBottom] = 8;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginBottom] = 8;
-
1162 break;
executed: break;
Execution Count:3
3
1163 case Html_dd: -
1164 margin[QTextHtmlParser::MarginLeft] = 30;
executed (the execution status of this line is deduced): margin[QTextHtmlParser::MarginLeft] = 30;
-
1165 break;
executed: break;
Execution Count:3
3
1166 case Html_u: -
1167 charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
executed (the execution status of this line is deduced): charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
-
1168 break;
executed: break;
Execution Count:1
1
1169 case Html_s: -
1170 charFormat.setFontStrikeOut(true);
never executed (the execution status of this line is deduced): charFormat.setFontStrikeOut(true);
-
1171 break;
never executed: break;
0
1172 case Html_nobr: -
1173 wsm = WhiteSpaceNoWrap;
executed (the execution status of this line is deduced): wsm = WhiteSpaceNoWrap;
-
1174 break;
executed: break;
Execution Count:2
2
1175 case Html_th: -
1176 charFormat.setFontWeight(QFont::Bold);
executed (the execution status of this line is deduced): charFormat.setFontWeight(QFont::Bold);
-
1177 blockFormat.setAlignment(Qt::AlignCenter);
executed (the execution status of this line is deduced): blockFormat.setAlignment(Qt::AlignCenter);
-
1178 break;
executed: break;
Execution Count:5
5
1179 case Html_td: -
1180 blockFormat.setAlignment(Qt::AlignLeft);
executed (the execution status of this line is deduced): blockFormat.setAlignment(Qt::AlignLeft);
-
1181 break;
executed: break;
Execution Count:153
153
1182 case Html_sub: -
1183 charFormat.setVerticalAlignment(QTextCharFormat::AlignSubScript);
executed (the execution status of this line is deduced): charFormat.setVerticalAlignment(QTextCharFormat::AlignSubScript);
-
1184 break;
executed: break;
Execution Count:2
2
1185 case Html_sup: -
1186 charFormat.setVerticalAlignment(QTextCharFormat::AlignSuperScript);
executed (the execution status of this line is deduced): charFormat.setVerticalAlignment(QTextCharFormat::AlignSuperScript);
-
1187 break;
executed: break;
Execution Count:1
1
1188 default: break;
executed: break;
Execution Count:1992
1992
1189 } -
1190}
executed: }
Execution Count:2968
2968
1191 -
1192#ifndef QT_NO_CSSPARSER -
1193void QTextHtmlParserNode::setListStyle(const QVector<QCss::Value> &cssValues) -
1194{ -
1195 for (int i = 0; i < cssValues.count(); ++i) {
evaluated: i < cssValues.count()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:9
9-10
1196 if (cssValues.at(i).type == QCss::Value::KnownIdentifier) {
evaluated: cssValues.at(i).type == QCss::Value::KnownIdentifier
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1
1-9
1197 switch (static_cast<QCss::KnownValue>(cssValues.at(i).variant.toInt())) { -
1198 case QCss::Value_Disc: hasOwnListStyle = true; listStyle = QTextListFormat::ListDisc; break;
executed: break;
Execution Count:1
1
1199 case QCss::Value_Square: hasOwnListStyle = true; listStyle = QTextListFormat::ListSquare; break;
executed: break;
Execution Count:1
1
1200 case QCss::Value_Circle: hasOwnListStyle = true; listStyle = QTextListFormat::ListCircle; break;
executed: break;
Execution Count:1
1
1201 case QCss::Value_Decimal: hasOwnListStyle = true; listStyle = QTextListFormat::ListDecimal; break;
executed: break;
Execution Count:2
2
1202 case QCss::Value_LowerAlpha: hasOwnListStyle = true; listStyle = QTextListFormat::ListLowerAlpha; break;
executed: break;
Execution Count:1
1
1203 case QCss::Value_UpperAlpha: hasOwnListStyle = true; listStyle = QTextListFormat::ListUpperAlpha; break;
executed: break;
Execution Count:1
1
1204 case QCss::Value_LowerRoman: hasOwnListStyle = true; listStyle = QTextListFormat::ListLowerRoman; break;
executed: break;
Execution Count:1
1
1205 case QCss::Value_UpperRoman: hasOwnListStyle = true; listStyle = QTextListFormat::ListUpperRoman; break;
executed: break;
Execution Count:1
1
1206 default: break;
never executed: break;
0
1207 } -
1208 }
executed: }
Execution Count:9
9
1209 }
executed: }
Execution Count:10
10
1210 // allow individual list items to override the style -
1211 if (id == Html_li && hasOwnListStyle)
partially evaluated: id == Html_li
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
never evaluated: hasOwnListStyle
0-9
1212 blockFormat.setProperty(QTextFormat::ListStyle, listStyle);
never executed: blockFormat.setProperty(QTextFormat::ListStyle, listStyle);
0
1213}
executed: }
Execution Count:9
9
1214 -
1215void QTextHtmlParserNode::applyCssDeclarations(const QVector<QCss::Declaration> &declarations, const QTextDocument *resourceProvider) -
1216{ -
1217 QCss::ValueExtractor extractor(declarations);
executed (the execution status of this line is deduced): QCss::ValueExtractor extractor(declarations);
-
1218 extractor.extractBox(margin, padding);
executed (the execution status of this line is deduced): extractor.extractBox(margin, padding);
-
1219 -
1220 for (int i = 0; i < declarations.count(); ++i) {
evaluated: i < declarations.count()
TRUEFALSE
yes
Evaluation Count:533
yes
Evaluation Count:1766
533-1766
1221 const QCss::Declaration &decl = declarations.at(i);
executed (the execution status of this line is deduced): const QCss::Declaration &decl = declarations.at(i);
-
1222 if (decl.d->values.isEmpty()) continue;
never executed: continue;
partially evaluated: decl.d->values.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:533
0-533
1223 -
1224 QCss::KnownValue identifier = QCss::UnknownValue;
executed (the execution status of this line is deduced): QCss::KnownValue identifier = QCss::UnknownValue;
-
1225 if (decl.d->values.first().type == QCss::Value::KnownIdentifier)
evaluated: decl.d->values.first().type == QCss::Value::KnownIdentifier
TRUEFALSE
yes
Evaluation Count:100
yes
Evaluation Count:433
100-433
1226 identifier = static_cast<QCss::KnownValue>(decl.d->values.first().variant.toInt());
executed: identifier = static_cast<QCss::KnownValue>(decl.d->values.first().variant.toInt());
Execution Count:100
100
1227 -
1228 switch (decl.d->propertyId) { -
1229 case QCss::BorderColor: borderBrush = QBrush(decl.colorValue()); break;
executed: break;
Execution Count:1
1
1230 case QCss::BorderStyles: -
1231 if (decl.styleValue() != QCss::BorderStyle_Unknown && decl.styleValue() != QCss::BorderStyle_Native)
partially evaluated: decl.styleValue() != QCss::BorderStyle_Unknown
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: decl.styleValue() != QCss::BorderStyle_Native
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1232 borderStyle = static_cast<QTextFrameFormat::BorderStyle>(decl.styleValue() - 1);
executed: borderStyle = static_cast<QTextFrameFormat::BorderStyle>(decl.styleValue() - 1);
Execution Count:1
1
1233 break;
executed: break;
Execution Count:1
1
1234 case QCss::BorderWidth: -
1235 tableBorder = extractor.lengthValue(decl);
executed (the execution status of this line is deduced): tableBorder = extractor.lengthValue(decl);
-
1236 break;
executed: break;
Execution Count:2
2
1237 case QCss::Color: charFormat.setForeground(decl.colorValue()); break;
executed: break;
Execution Count:13
13
1238 case QCss::Float: -
1239 cssFloat = QTextFrameFormat::InFlow;
executed (the execution status of this line is deduced): cssFloat = QTextFrameFormat::InFlow;
-
1240 switch (identifier) { -
1241 case QCss::Value_Left: cssFloat = QTextFrameFormat::FloatLeft; break;
never executed: break;
0
1242 case QCss::Value_Right: cssFloat = QTextFrameFormat::FloatRight; break;
executed: break;
Execution Count:4
4
1243 default: break;
never executed: break;
0
1244 } -
1245 break;
executed: break;
Execution Count:4
4
1246 case QCss::QtBlockIndent: -
1247 blockFormat.setIndent(decl.d->values.first().variant.toInt());
executed (the execution status of this line is deduced): blockFormat.setIndent(decl.d->values.first().variant.toInt());
-
1248 break;
executed: break;
Execution Count:41
41
1249 case QCss::LineHeight: { -
1250 qreal lineHeight;
never executed (the execution status of this line is deduced): qreal lineHeight;
-
1251 if (decl.realValue(&lineHeight, "px")) {
never evaluated: decl.realValue(&lineHeight, "px")
0
1252 blockFormat.setLineHeight(lineHeight, QTextBlockFormat::FixedHeight);
never executed (the execution status of this line is deduced): blockFormat.setLineHeight(lineHeight, QTextBlockFormat::FixedHeight);
-
1253 } else {
never executed: }
0
1254 bool ok;
never executed (the execution status of this line is deduced): bool ok;
-
1255 QString value = decl.d->values.first().toString();
never executed (the execution status of this line is deduced): QString value = decl.d->values.first().toString();
-
1256 lineHeight = value.toDouble(&ok);
never executed (the execution status of this line is deduced): lineHeight = value.toDouble(&ok);
-
1257 if (ok)
never evaluated: ok
0
1258 blockFormat.setLineHeight(lineHeight, QTextBlockFormat::ProportionalHeight);
never executed: blockFormat.setLineHeight(lineHeight, QTextBlockFormat::ProportionalHeight);
0
1259 else -
1260 blockFormat.setLineHeight(0, QTextBlockFormat::SingleHeight);
never executed: blockFormat.setLineHeight(0, QTextBlockFormat::SingleHeight);
0
1261 } -
1262 break; }
never executed: break;
0
1263 case QCss::TextIndent: { -
1264 qreal indent = 0;
executed (the execution status of this line is deduced): qreal indent = 0;
-
1265 if (decl.realValue(&indent, "px"))
partially evaluated: decl.realValue(&indent, "px")
TRUEFALSE
yes
Evaluation Count:41
no
Evaluation Count:0
0-41
1266 blockFormat.setTextIndent(indent);
executed: blockFormat.setTextIndent(indent);
Execution Count:41
41
1267 break; }
executed: break;
Execution Count:41
41
1268 case QCss::QtListIndent: -
1269 if (decl.intValue(&cssListIndent))
partially evaluated: decl.intValue(&cssListIndent)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1270 hasCssListIndent = true;
executed: hasCssListIndent = true;
Execution Count:2
2
1271 break;
executed: break;
Execution Count:2
2
1272 case QCss::QtParagraphType: -
1273 if (decl.d->values.first().variant.toString().compare(QLatin1String("empty"), Qt::CaseInsensitive) == 0)
partially evaluated: decl.d->values.first().variant.toString().compare(QLatin1String("empty"), Qt::CaseInsensitive) == 0
TRUEFALSE
yes
Evaluation Count:33
no
Evaluation Count:0
0-33
1274 isEmptyParagraph = true;
executed: isEmptyParagraph = true;
Execution Count:33
33
1275 break;
executed: break;
Execution Count:33
33
1276 case QCss::QtTableType: -
1277 if (decl.d->values.first().variant.toString().compare(QLatin1String("frame"), Qt::CaseInsensitive) == 0)
evaluated: decl.d->values.first().variant.toString().compare(QLatin1String("frame"), Qt::CaseInsensitive) == 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
1278 isTextFrame = true;
executed: isTextFrame = true;
Execution Count:3
3
1279 else if (decl.d->values.first().variant.toString().compare(QLatin1String("root"), Qt::CaseInsensitive) == 0) {
partially evaluated: decl.d->values.first().variant.toString().compare(QLatin1String("root"), Qt::CaseInsensitive) == 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1280 isTextFrame = true;
executed (the execution status of this line is deduced): isTextFrame = true;
-
1281 isRootFrame = true;
executed (the execution status of this line is deduced): isRootFrame = true;
-
1282 }
executed: }
Execution Count:1
1
1283 break;
executed: break;
Execution Count:4
4
1284 case QCss::QtUserState: -
1285 userState = decl.d->values.first().variant.toInt();
executed (the execution status of this line is deduced): userState = decl.d->values.first().variant.toInt();
-
1286 break;
executed: break;
Execution Count:2
2
1287 case QCss::Whitespace: -
1288 switch (identifier) { -
1289 case QCss::Value_Normal: wsm = QTextHtmlParserNode::WhiteSpaceNormal; break;
never executed: break;
0
1290 case QCss::Value_Pre: wsm = QTextHtmlParserNode::WhiteSpacePre; break;
executed: break;
Execution Count:1
1
1291 case QCss::Value_NoWrap: wsm = QTextHtmlParserNode::WhiteSpaceNoWrap; break;
never executed: break;
0
1292 case QCss::Value_PreWrap: wsm = QTextHtmlParserNode::WhiteSpacePreWrap; break;
executed: break;
Execution Count:40
40
1293 default: break;
never executed: break;
0
1294 } -
1295 break;
executed: break;
Execution Count:41
41
1296 case QCss::VerticalAlignment: -
1297 switch (identifier) { -
1298 case QCss::Value_Sub: charFormat.setVerticalAlignment(QTextCharFormat::AlignSubScript); break;
executed: break;
Execution Count:1
1
1299 case QCss::Value_Super: charFormat.setVerticalAlignment(QTextCharFormat::AlignSuperScript); break;
executed: break;
Execution Count:1
1
1300 case QCss::Value_Middle: charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle); break;
executed: break;
Execution Count:2
2
1301 case QCss::Value_Top: charFormat.setVerticalAlignment(QTextCharFormat::AlignTop); break;
executed: break;
Execution Count:2
2
1302 case QCss::Value_Bottom: charFormat.setVerticalAlignment(QTextCharFormat::AlignBottom); break;
executed: break;
Execution Count:1
1
1303 default: charFormat.setVerticalAlignment(QTextCharFormat::AlignNormal); break;
never executed: break;
0
1304 } -
1305 break;
executed: break;
Execution Count:7
7
1306 case QCss::PageBreakBefore: -
1307 switch (identifier) { -
1308 case QCss::Value_Always: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() | QTextFormat::PageBreak_AlwaysBefore); break;
executed: break;
Execution Count:3
3
1309 case QCss::Value_Auto: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() & ~QTextFormat::PageBreak_AlwaysBefore); break;
never executed: break;
0
1310 default: break;
never executed: break;
0
1311 } -
1312 break;
executed: break;
Execution Count:3
3
1313 case QCss::PageBreakAfter: -
1314 switch (identifier) { -
1315 case QCss::Value_Always: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() | QTextFormat::PageBreak_AlwaysAfter); break;
executed: break;
Execution Count:3
3
1316 case QCss::Value_Auto: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() & ~QTextFormat::PageBreak_AlwaysAfter); break;
never executed: break;
0
1317 default: break;
never executed: break;
0
1318 } -
1319 break;
executed: break;
Execution Count:3
3
1320 case QCss::TextUnderlineStyle: -
1321 switch (identifier) { -
1322 case QCss::Value_None: charFormat.setUnderlineStyle(QTextCharFormat::NoUnderline); break;
executed: break;
Execution Count:1
1
1323 case QCss::Value_Solid: charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); break;
executed: break;
Execution Count:3
3
1324 case QCss::Value_Dashed: charFormat.setUnderlineStyle(QTextCharFormat::DashUnderline); break;
executed: break;
Execution Count:1
1
1325 case QCss::Value_Dotted: charFormat.setUnderlineStyle(QTextCharFormat::DotLine); break;
executed: break;
Execution Count:1
1
1326 case QCss::Value_DotDash: charFormat.setUnderlineStyle(QTextCharFormat::DashDotLine); break;
executed: break;
Execution Count:1
1
1327 case QCss::Value_DotDotDash: charFormat.setUnderlineStyle(QTextCharFormat::DashDotDotLine); break;
executed: break;
Execution Count:1
1
1328 case QCss::Value_Wave: charFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline); break;
executed: break;
Execution Count:1
1
1329 default: break;
never executed: break;
0
1330 } -
1331 break;
executed: break;
Execution Count:9
9
1332 case QCss::ListStyleType: -
1333 case QCss::ListStyle: -
1334 setListStyle(decl.d->values);
executed (the execution status of this line is deduced): setListStyle(decl.d->values);
-
1335 break;
executed: break;
Execution Count:9
9
1336 case QCss::QtListNumberPrefix: -
1337 textListNumberPrefix = decl.d->values.first().variant.toString();
executed (the execution status of this line is deduced): textListNumberPrefix = decl.d->values.first().variant.toString();
-
1338 break;
executed: break;
Execution Count:1
1
1339 case QCss::QtListNumberSuffix: -
1340 textListNumberSuffix = decl.d->values.first().variant.toString();
executed (the execution status of this line is deduced): textListNumberSuffix = decl.d->values.first().variant.toString();
-
1341 break;
executed: break;
Execution Count:1
1
1342 default: break;
executed: break;
Execution Count:315
315
1343 } -
1344 }
executed: }
Execution Count:533
533
1345 -
1346 QFont f;
executed (the execution status of this line is deduced): QFont f;
-
1347 int adjustment = -255;
executed (the execution status of this line is deduced): int adjustment = -255;
-
1348 extractor.extractFont(&f, &adjustment);
executed (the execution status of this line is deduced): extractor.extractFont(&f, &adjustment);
-
1349 if (f.resolve() & QFont::SizeResolved) {
evaluated: f.resolve() & QFont::SizeResolved
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:1745
21-1745
1350 if (f.pointSize() > 0) {
evaluated: f.pointSize() > 0
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:7
7-14
1351 charFormat.setFontPointSize(f.pointSize());
executed (the execution status of this line is deduced): charFormat.setFontPointSize(f.pointSize());
-
1352 } else if (f.pixelSize() > 0) {
executed: }
Execution Count:14
partially evaluated: f.pixelSize() > 0
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-14
1353 charFormat.setProperty(QTextFormat::FontPixelSize, f.pixelSize());
executed (the execution status of this line is deduced): charFormat.setProperty(QTextFormat::FontPixelSize, f.pixelSize());
-
1354 }
executed: }
Execution Count:7
7
1355 } -
1356 if (f.resolve() & QFont::StyleResolved)
evaluated: f.resolve() & QFont::StyleResolved
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:1752
14-1752
1357 charFormat.setFontItalic(f.style() != QFont::StyleNormal);
executed: charFormat.setFontItalic(f.style() != QFont::StyleNormal);
Execution Count:14
14
1358 -
1359 if (f.resolve() & QFont::WeightResolved)
evaluated: f.resolve() & QFont::WeightResolved
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1751
15-1751
1360 charFormat.setFontWeight(f.weight());
executed: charFormat.setFontWeight(f.weight());
Execution Count:15
15
1361 -
1362 if (f.resolve() & QFont::FamilyResolved)
evaluated: f.resolve() & QFont::FamilyResolved
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:1749
17-1749
1363 charFormat.setFontFamily(f.family());
executed: charFormat.setFontFamily(f.family());
Execution Count:17
17
1364 -
1365 if (f.resolve() & QFont::UnderlineResolved)
evaluated: f.resolve() & QFont::UnderlineResolved
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1763
3-1763
1366 charFormat.setUnderlineStyle(f.underline() ? QTextCharFormat::SingleUnderline : QTextCharFormat::NoUnderline);
executed: charFormat.setUnderlineStyle(f.underline() ? QTextCharFormat::SingleUnderline : QTextCharFormat::NoUnderline);
Execution Count:3
3
1367 -
1368 if (f.resolve() & QFont::OverlineResolved)
evaluated: f.resolve() & QFont::OverlineResolved
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1761
5-1761
1369 charFormat.setFontOverline(f.overline());
executed: charFormat.setFontOverline(f.overline());
Execution Count:5
5
1370 -
1371 if (f.resolve() & QFont::StrikeOutResolved)
evaluated: f.resolve() & QFont::StrikeOutResolved
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1763
3-1763
1372 charFormat.setFontStrikeOut(f.strikeOut());
executed: charFormat.setFontStrikeOut(f.strikeOut());
Execution Count:3
3
1373 -
1374 if (f.resolve() & QFont::CapitalizationResolved)
evaluated: f.resolve() & QFont::CapitalizationResolved
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1763
3-1763
1375 charFormat.setFontCapitalization(f.capitalization());
executed: charFormat.setFontCapitalization(f.capitalization());
Execution Count:3
3
1376 -
1377 if (adjustment >= -1)
evaluated: adjustment >= -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1765
1-1765
1378 charFormat.setProperty(QTextFormat::FontSizeAdjustment, adjustment);
executed: charFormat.setProperty(QTextFormat::FontSizeAdjustment, adjustment);
Execution Count:1
1
1379 -
1380 { -
1381 Qt::Alignment ignoredAlignment;
executed (the execution status of this line is deduced): Qt::Alignment ignoredAlignment;
-
1382 QCss::Repeat ignoredRepeat;
executed (the execution status of this line is deduced): QCss::Repeat ignoredRepeat;
-
1383 QString bgImage;
executed (the execution status of this line is deduced): QString bgImage;
-
1384 QBrush bgBrush;
executed (the execution status of this line is deduced): QBrush bgBrush;
-
1385 QCss::Origin ignoredOrigin, ignoredClip;
executed (the execution status of this line is deduced): QCss::Origin ignoredOrigin, ignoredClip;
-
1386 QCss::Attachment ignoredAttachment;
executed (the execution status of this line is deduced): QCss::Attachment ignoredAttachment;
-
1387 extractor.extractBackground(&bgBrush, &bgImage, &ignoredRepeat, &ignoredAlignment,
executed (the execution status of this line is deduced): extractor.extractBackground(&bgBrush, &bgImage, &ignoredRepeat, &ignoredAlignment,
-
1388 &ignoredOrigin, &ignoredAttachment, &ignoredClip);
executed (the execution status of this line is deduced): &ignoredOrigin, &ignoredAttachment, &ignoredClip);
-
1389 -
1390 if (!bgImage.isEmpty() && resourceProvider) {
evaluated: !bgImage.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1763
partially evaluated: resourceProvider
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-1763
1391 applyBackgroundImage(bgImage, resourceProvider);
executed (the execution status of this line is deduced): applyBackgroundImage(bgImage, resourceProvider);
-
1392 } else if (bgBrush.style() != Qt::NoBrush) {
executed: }
Execution Count:3
evaluated: bgBrush.style() != Qt::NoBrush
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:1730
3-1730
1393 charFormat.setBackground(bgBrush);
executed (the execution status of this line is deduced): charFormat.setBackground(bgBrush);
-
1394 }
executed: }
Execution Count:33
33
1395 } -
1396} -
1397 -
1398#endif // QT_NO_CSSPARSER -
1399 -
1400void QTextHtmlParserNode::applyBackgroundImage(const QString &url, const QTextDocument *resourceProvider) -
1401{ -
1402 if (!url.isEmpty() && resourceProvider) {
partially evaluated: !url.isEmpty()
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
partially evaluated: resourceProvider
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
1403 QVariant val = resourceProvider->resource(QTextDocument::ImageResource, url);
executed (the execution status of this line is deduced): QVariant val = resourceProvider->resource(QTextDocument::ImageResource, url);
-
1404 -
1405 if (QCoreApplication::instance()->thread() != QThread::currentThread()) {
partially evaluated: QCoreApplication::instance()->thread() != QThread::currentThread()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
1406 // must use images in non-GUI threads -
1407 if (val.type() == QVariant::Image) {
never evaluated: val.type() == QVariant::Image
0
1408 QImage image = qvariant_cast<QImage>(val);
never executed (the execution status of this line is deduced): QImage image = qvariant_cast<QImage>(val);
-
1409 charFormat.setBackground(image);
never executed (the execution status of this line is deduced): charFormat.setBackground(image);
-
1410 } else if (val.type() == QVariant::ByteArray) {
never executed: }
never evaluated: val.type() == QVariant::ByteArray
0
1411 QImage image;
never executed (the execution status of this line is deduced): QImage image;
-
1412 if (image.loadFromData(val.toByteArray())) {
never evaluated: image.loadFromData(val.toByteArray())
0
1413 charFormat.setBackground(image);
never executed (the execution status of this line is deduced): charFormat.setBackground(image);
-
1414 }
never executed: }
0
1415 }
never executed: }
0
1416 } else { -
1417 if (val.type() == QVariant::Image || val.type() == QVariant::Pixmap) {
partially evaluated: val.type() == QVariant::Image
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
partially evaluated: val.type() == QVariant::Pixmap
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
1418 charFormat.setBackground(qvariant_cast<QPixmap>(val));
executed (the execution status of this line is deduced): charFormat.setBackground(qvariant_cast<QPixmap>(val));
-
1419 } else if (val.type() == QVariant::ByteArray) {
executed: }
Execution Count:9
never evaluated: val.type() == QVariant::ByteArray
0-9
1420 QPixmap pm;
never executed (the execution status of this line is deduced): QPixmap pm;
-
1421 if (pm.loadFromData(val.toByteArray())) {
never evaluated: pm.loadFromData(val.toByteArray())
0
1422 charFormat.setBackground(pm);
never executed (the execution status of this line is deduced): charFormat.setBackground(pm);
-
1423 }
never executed: }
0
1424 }
never executed: }
0
1425 } -
1426 } -
1427 if (!url.isEmpty())
partially evaluated: !url.isEmpty()
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
1428 charFormat.setProperty(QTextFormat::BackgroundImageUrl, url);
executed: charFormat.setProperty(QTextFormat::BackgroundImageUrl, url);
Execution Count:9
9
1429}
executed: }
Execution Count:9
9
1430 -
1431bool QTextHtmlParserNode::hasOnlyWhitespace() const -
1432{ -
1433 for (int i = 0; i < text.count(); ++i)
evaluated: i < text.count()
TRUEFALSE
yes
Evaluation Count:186
yes
Evaluation Count:48
48-186
1434 if (!text.at(i).isSpace() || text.at(i) == QChar::LineSeparator)
evaluated: !text.at(i).isSpace()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:170
evaluated: text.at(i) == QChar::LineSeparator
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:169
1-170
1435 return false;
executed: return false;
Execution Count:17
17
1436 return true;
executed: return true;
Execution Count:48
48
1437} -
1438 -
1439static bool setIntAttribute(int *destination, const QString &value) -
1440{ -
1441 bool ok = false;
executed (the execution status of this line is deduced): bool ok = false;
-
1442 int val = value.toInt(&ok);
executed (the execution status of this line is deduced): int val = value.toInt(&ok);
-
1443 if (ok)
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
1444 *destination = val;
executed: *destination = val;
Execution Count:14
14
1445 -
1446 return ok;
executed: return ok;
Execution Count:14
14
1447} -
1448 -
1449static bool setFloatAttribute(qreal *destination, const QString &value) -
1450{ -
1451 bool ok = false;
executed (the execution status of this line is deduced): bool ok = false;
-
1452 qreal val = value.toDouble(&ok);
executed (the execution status of this line is deduced): qreal val = value.toDouble(&ok);
-
1453 if (ok)
evaluated: ok
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:1
1-27
1454 *destination = val;
executed: *destination = val;
Execution Count:27
27
1455 -
1456 return ok;
executed: return ok;
Execution Count:28
28
1457} -
1458 -
1459static void setWidthAttribute(QTextLength *width, QString value) -
1460{ -
1461 bool ok = false;
executed (the execution status of this line is deduced): bool ok = false;
-
1462 qreal realVal = value.toDouble(&ok);
executed (the execution status of this line is deduced): qreal realVal = value.toDouble(&ok);
-
1463 if (ok) {
evaluated: ok
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:3
3-13
1464 *width = QTextLength(QTextLength::FixedLength, realVal);
executed (the execution status of this line is deduced): *width = QTextLength(QTextLength::FixedLength, realVal);
-
1465 } else {
executed: }
Execution Count:13
13
1466 value = value.trimmed();
executed (the execution status of this line is deduced): value = value.trimmed();
-
1467 if (!value.isEmpty() && value.endsWith(QLatin1Char('%'))) {
partially evaluated: !value.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
partially evaluated: value.endsWith(QLatin1Char('%'))
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1468 value.chop(1);
executed (the execution status of this line is deduced): value.chop(1);
-
1469 realVal = value.toDouble(&ok);
executed (the execution status of this line is deduced): realVal = value.toDouble(&ok);
-
1470 if (ok)
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1471 *width = QTextLength(QTextLength::PercentageLength, realVal);
executed: *width = QTextLength(QTextLength::PercentageLength, realVal);
Execution Count:3
3
1472 }
executed: }
Execution Count:3
3
1473 }
executed: }
Execution Count:3
3
1474} -
1475 -
1476#ifndef QT_NO_CSSPARSER -
1477void QTextHtmlParserNode::parseStyleAttribute(const QString &value, const QTextDocument *resourceProvider) -
1478{ -
1479 QString css = value;
executed (the execution status of this line is deduced): QString css = value;
-
1480 css.prepend(QLatin1String("* {"));
executed (the execution status of this line is deduced): css.prepend(QLatin1String("* {"));
-
1481 css.append(QLatin1Char('}'));
executed (the execution status of this line is deduced): css.append(QLatin1Char('}'));
-
1482 QCss::Parser parser(css);
executed (the execution status of this line is deduced): QCss::Parser parser(css);
-
1483 QCss::StyleSheet sheet;
executed (the execution status of this line is deduced): QCss::StyleSheet sheet;
-
1484 parser.parse(&sheet, Qt::CaseInsensitive);
executed (the execution status of this line is deduced): parser.parse(&sheet, Qt::CaseInsensitive);
-
1485 if (sheet.styleRules.count() != 1) return;
never executed: return;
partially evaluated: sheet.styleRules.count() != 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:173
0-173
1486 applyCssDeclarations(sheet.styleRules.at(0).declarations, resourceProvider);
executed (the execution status of this line is deduced): applyCssDeclarations(sheet.styleRules.at(0).declarations, resourceProvider);
-
1487}
executed: }
Execution Count:173
173
1488#endif -
1489 -
1490QStringList QTextHtmlParser::parseAttributes() -
1491{ -
1492 QStringList attrs;
executed (the execution status of this line is deduced): QStringList attrs;
-
1493 -
1494 while (pos < len) {
partially evaluated: pos < len
TRUEFALSE
yes
Evaluation Count:870
no
Evaluation Count:0
0-870
1495 eatSpace();
executed (the execution status of this line is deduced): eatSpace();
-
1496 if (hasPrefix(QLatin1Char('>')) || hasPrefix(QLatin1Char('/')))
evaluated: hasPrefix(QLatin1Char('>'))
TRUEFALSE
yes
Evaluation Count:346
yes
Evaluation Count:524
evaluated: hasPrefix(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:453
71-524
1497 break;
executed: break;
Execution Count:417
417
1498 QString key = parseWord().toLower();
executed (the execution status of this line is deduced): QString key = parseWord().toLower();
-
1499 QString value = QLatin1String("1");
executed (the execution status of this line is deduced): QString value = QLatin1String("1");
-
1500 if (key.size() == 0)
evaluated: key.size() == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:452
1-452
1501 break;
executed: break;
Execution Count:1
1
1502 eatSpace();
executed (the execution status of this line is deduced): eatSpace();
-
1503 if (hasPrefix(QLatin1Char('='))){
evaluated: hasPrefix(QLatin1Char('='))
TRUEFALSE
yes
Evaluation Count:444
yes
Evaluation Count:8
8-444
1504 pos++;
executed (the execution status of this line is deduced): pos++;
-
1505 eatSpace();
executed (the execution status of this line is deduced): eatSpace();
-
1506 value = parseWord();
executed (the execution status of this line is deduced): value = parseWord();
-
1507 }
executed: }
Execution Count:444
444
1508 if (value.size() == 0)
evaluated: value.size() == 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:450
2-450
1509 continue;
executed: continue;
Execution Count:2
2
1510 attrs << key << value;
executed (the execution status of this line is deduced): attrs << key << value;
-
1511 }
executed: }
Execution Count:450
450
1512 -
1513 return attrs;
executed: return attrs;
Execution Count:418
418
1514} -
1515 -
1516void QTextHtmlParser::applyAttributes(const QStringList &attributes) -
1517{ -
1518 // local state variable for qt3 textedit mode -
1519 bool seenQt3Richtext = false;
executed (the execution status of this line is deduced): bool seenQt3Richtext = false;
-
1520 QString linkHref;
executed (the execution status of this line is deduced): QString linkHref;
-
1521 QString linkType;
executed (the execution status of this line is deduced): QString linkType;
-
1522 -
1523 if (attributes.count() % 2 == 1)
partially evaluated: attributes.count() % 2 == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1593
0-1593
1524 return;
never executed: return;
0
1525 -
1526 QTextHtmlParserNode *node = &nodes.last();
executed (the execution status of this line is deduced): QTextHtmlParserNode *node = &nodes.last();
-
1527 -
1528 for (int i = 0; i < attributes.count(); i += 2) {
evaluated: i < attributes.count()
TRUEFALSE
yes
Evaluation Count:450
yes
Evaluation Count:1593
450-1593
1529 QString key = attributes.at(i);
executed (the execution status of this line is deduced): QString key = attributes.at(i);
-
1530 QString value = attributes.at(i + 1);
executed (the execution status of this line is deduced): QString value = attributes.at(i + 1);
-
1531 -
1532 switch (node->id) { -
1533 case Html_font: -
1534 // the infamous font tag -
1535 if (key == QLatin1String("size") && value.size()) {
evaluated: key == QLatin1String("size")
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
partially evaluated: value.size()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-5
1536 int n = value.toInt();
executed (the execution status of this line is deduced): int n = value.toInt();
-
1537 if (value.at(0) != QLatin1Char('+') && value.at(0) != QLatin1Char('-'))
partially evaluated: value.at(0) != QLatin1Char('+')
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: value.at(0) != QLatin1Char('-')
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1538 n -= 3;
executed: n -= 3;
Execution Count:2
2
1539 node->charFormat.setProperty(QTextFormat::FontSizeAdjustment, n);
executed (the execution status of this line is deduced): node->charFormat.setProperty(QTextFormat::FontSizeAdjustment, n);
-
1540 } else if (key == QLatin1String("face")) {
executed: }
Execution Count:2
evaluated: key == QLatin1String("face")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-4
1541 node->charFormat.setFontFamily(value);
executed (the execution status of this line is deduced): node->charFormat.setFontFamily(value);
-
1542 } else if (key == QLatin1String("color")) {
executed: }
Execution Count:1
partially evaluated: key == QLatin1String("color")
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
1543 QColor c; c.setNamedColor(value);
executed (the execution status of this line is deduced): QColor c; c.setNamedColor(value);
-
1544 if (!c.isValid())
partially evaluated: !c.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1545 qWarning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
never executed: QMessageLogger("text/qtexthtmlparser.cpp", 1545, __PRETTY_FUNCTION__).warning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
0
1546 node->charFormat.setForeground(c);
executed (the execution status of this line is deduced): node->charFormat.setForeground(c);
-
1547 }
executed: }
Execution Count:4
4
1548 break;
executed: break;
Execution Count:7
7
1549 case Html_ol: -
1550 case Html_ul: -
1551 if (key == QLatin1String("type")) {
evaluated: key == QLatin1String("type")
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:11
3-11
1552 node->hasOwnListStyle = true;
executed (the execution status of this line is deduced): node->hasOwnListStyle = true;
-
1553 if (value == QLatin1String("1")) {
partially evaluated: value == QLatin1String("1")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1554 node->listStyle = QTextListFormat::ListDecimal;
never executed (the execution status of this line is deduced): node->listStyle = QTextListFormat::ListDecimal;
-
1555 } else if (value == QLatin1String("a")) {
never executed: }
evaluated: value == QLatin1String("a")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
0-2
1556 node->listStyle = QTextListFormat::ListLowerAlpha;
executed (the execution status of this line is deduced): node->listStyle = QTextListFormat::ListLowerAlpha;
-
1557 } else if (value == QLatin1String("A")) {
executed: }
Execution Count:1
partially evaluated: value == QLatin1String("A")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1558 node->listStyle = QTextListFormat::ListUpperAlpha;
never executed (the execution status of this line is deduced): node->listStyle = QTextListFormat::ListUpperAlpha;
-
1559 } else if (value == QLatin1String("i")) {
never executed: }
partially evaluated: value == QLatin1String("i")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1560 node->listStyle = QTextListFormat::ListLowerRoman;
never executed (the execution status of this line is deduced): node->listStyle = QTextListFormat::ListLowerRoman;
-
1561 } else if (value == QLatin1String("I")) {
never executed: }
partially evaluated: value == QLatin1String("I")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1562 node->listStyle = QTextListFormat::ListUpperRoman;
never executed (the execution status of this line is deduced): node->listStyle = QTextListFormat::ListUpperRoman;
-
1563 } else {
never executed: }
0
1564 value = value.toLower();
executed (the execution status of this line is deduced): value = value.toLower();
-
1565 if (value == QLatin1String("square"))
evaluated: value == QLatin1String("square")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1566 node->listStyle = QTextListFormat::ListSquare;
executed: node->listStyle = QTextListFormat::ListSquare;
Execution Count:1
1
1567 else if (value == QLatin1String("disc"))
partially evaluated: value == QLatin1String("disc")
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1568 node->listStyle = QTextListFormat::ListDisc;
executed: node->listStyle = QTextListFormat::ListDisc;
Execution Count:1
1
1569 else if (value == QLatin1String("circle"))
never evaluated: value == QLatin1String("circle")
0
1570 node->listStyle = QTextListFormat::ListCircle;
never executed: node->listStyle = QTextListFormat::ListCircle;
0
1571 } -
1572 } -
1573 break;
executed: break;
Execution Count:14
14
1574 case Html_a: -
1575 if (key == QLatin1String("href"))
evaluated: key == QLatin1String("href")
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:21
21-46
1576 node->charFormat.setAnchorHref(value);
executed: node->charFormat.setAnchorHref(value);
Execution Count:46
46
1577 else if (key == QLatin1String("name"))
evaluated: key == QLatin1String("name")
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:2
2-19
1578 node->charFormat.setAnchorName(value);
executed: node->charFormat.setAnchorName(value);
Execution Count:19
19
1579 break;
executed: break;
Execution Count:67
67
1580 case Html_img: -
1581 if (key == QLatin1String("src") || key == QLatin1String("source")) {
evaluated: key == QLatin1String("src")
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:18
partially evaluated: key == QLatin1String("source")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-20
1582 node->imageName = value;
executed (the execution status of this line is deduced): node->imageName = value;
-
1583 } else if (key == QLatin1String("width")) {
executed: }
Execution Count:20
evaluated: key == QLatin1String("width")
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:14
4-20
1584 node->imageWidth = -2; // register that there is a value for it.
executed (the execution status of this line is deduced): node->imageWidth = -2;
-
1585 setFloatAttribute(&node->imageWidth, value);
executed (the execution status of this line is deduced): setFloatAttribute(&node->imageWidth, value);
-
1586 } else if (key == QLatin1String("height")) {
executed: }
Execution Count:4
evaluated: key == QLatin1String("height")
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:10
4-10
1587 node->imageHeight = -2; // register that there is a value for it.
executed (the execution status of this line is deduced): node->imageHeight = -2;
-
1588 setFloatAttribute(&node->imageHeight, value);
executed (the execution status of this line is deduced): setFloatAttribute(&node->imageHeight, value);
-
1589 }
executed: }
Execution Count:4
4
1590 break;
executed: break;
Execution Count:38
38
1591 case Html_tr: -
1592 case Html_body: -
1593 if (key == QLatin1String("bgcolor")) {
evaluated: key == QLatin1String("bgcolor")
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:16
10-16
1594 QColor c; c.setNamedColor(value);
executed (the execution status of this line is deduced): QColor c; c.setNamedColor(value);
-
1595 if (!c.isValid())
partially evaluated: !c.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1596 qWarning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
never executed: QMessageLogger("text/qtexthtmlparser.cpp", 1596, __PRETTY_FUNCTION__).warning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
0
1597 node->charFormat.setBackground(c);
executed (the execution status of this line is deduced): node->charFormat.setBackground(c);
-
1598 } else if (key == QLatin1String("background")) {
executed: }
Execution Count:10
evaluated: key == QLatin1String("background")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:15
1-15
1599 node->applyBackgroundImage(value, resourceProvider);
executed (the execution status of this line is deduced): node->applyBackgroundImage(value, resourceProvider);
-
1600 }
executed: }
Execution Count:1
1
1601 break;
executed: break;
Execution Count:26
26
1602 case Html_th: -
1603 case Html_td: -
1604 if (key == QLatin1String("width")) {
evaluated: key == QLatin1String("width")
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:49
10-49
1605 setWidthAttribute(&node->width, value);
executed (the execution status of this line is deduced): setWidthAttribute(&node->width, value);
-
1606 } else if (key == QLatin1String("bgcolor")) {
executed: }
Execution Count:10
evaluated: key == QLatin1String("bgcolor")
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:47
2-47
1607 QColor c; c.setNamedColor(value);
executed (the execution status of this line is deduced): QColor c; c.setNamedColor(value);
-
1608 if (!c.isValid())
partially evaluated: !c.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1609 qWarning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
never executed: QMessageLogger("text/qtexthtmlparser.cpp", 1609, __PRETTY_FUNCTION__).warning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
0
1610 node->charFormat.setBackground(c);
executed (the execution status of this line is deduced): node->charFormat.setBackground(c);
-
1611 } else if (key == QLatin1String("background")) {
executed: }
Execution Count:2
evaluated: key == QLatin1String("background")
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:42
2-42
1612 node->applyBackgroundImage(value, resourceProvider);
executed (the execution status of this line is deduced): node->applyBackgroundImage(value, resourceProvider);
-
1613 } else if (key == QLatin1String("rowspan")) {
executed: }
Execution Count:5
evaluated: key == QLatin1String("rowspan")
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:35
5-35
1614 if (setIntAttribute(&node->tableCellRowSpan, value))
partially evaluated: setIntAttribute(&node->tableCellRowSpan, value)
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
1615 node->tableCellRowSpan = qMax(1, node->tableCellRowSpan);
executed: node->tableCellRowSpan = qMax(1, node->tableCellRowSpan);
Execution Count:7
7
1616 } else if (key == QLatin1String("colspan")) {
executed: }
Execution Count:7
evaluated: key == QLatin1String("colspan")
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:28
7-28
1617 if (setIntAttribute(&node->tableCellColSpan, value))
partially evaluated: setIntAttribute(&node->tableCellColSpan, value)
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
1618 node->tableCellColSpan = qMax(1, node->tableCellColSpan);
executed: node->tableCellColSpan = qMax(1, node->tableCellColSpan);
Execution Count:7
7
1619 }
executed: }
Execution Count:7
7
1620 break;
executed: break;
Execution Count:59
59
1621 case Html_table: -
1622 if (key == QLatin1String("border")) {
evaluated: key == QLatin1String("border")
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:22
18-22
1623 setFloatAttribute(&node->tableBorder, value);
executed (the execution status of this line is deduced): setFloatAttribute(&node->tableBorder, value);
-
1624 } else if (key == QLatin1String("bgcolor")) {
executed: }
Execution Count:18
evaluated: key == QLatin1String("bgcolor")
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:20
2-20
1625 QColor c; c.setNamedColor(value);
executed (the execution status of this line is deduced): QColor c; c.setNamedColor(value);
-
1626 if (!c.isValid())
partially evaluated: !c.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1627 qWarning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
never executed: QMessageLogger("text/qtexthtmlparser.cpp", 1627, __PRETTY_FUNCTION__).warning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
0
1628 node->charFormat.setBackground(c);
executed (the execution status of this line is deduced): node->charFormat.setBackground(c);
-
1629 } else if (key == QLatin1String("background")) {
executed: }
Execution Count:2
partially evaluated: key == QLatin1String("background")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
1630 node->applyBackgroundImage(value, resourceProvider);
never executed (the execution status of this line is deduced): node->applyBackgroundImage(value, resourceProvider);
-
1631 } else if (key == QLatin1String("cellspacing")) {
never executed: }
evaluated: key == QLatin1String("cellspacing")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:19
0-19
1632 setFloatAttribute(&node->tableCellSpacing, value);
executed (the execution status of this line is deduced): setFloatAttribute(&node->tableCellSpacing, value);
-
1633 } else if (key == QLatin1String("cellpadding")) {
executed: }
Execution Count:1
evaluated: key == QLatin1String("cellpadding")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18
1-18
1634 setFloatAttribute(&node->tableCellPadding, value);
executed (the execution status of this line is deduced): setFloatAttribute(&node->tableCellPadding, value);
-
1635 } else if (key == QLatin1String("width")) {
executed: }
Execution Count:1
evaluated: key == QLatin1String("width")
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:15
1-15
1636 setWidthAttribute(&node->width, value);
executed (the execution status of this line is deduced): setWidthAttribute(&node->width, value);
-
1637 } else if (key == QLatin1String("height")) {
executed: }
Execution Count:3
evaluated: key == QLatin1String("height")
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:13
2-13
1638 setWidthAttribute(&node->height, value);
executed (the execution status of this line is deduced): setWidthAttribute(&node->height, value);
-
1639 }
executed: }
Execution Count:2
2
1640 break;
executed: break;
Execution Count:40
40
1641 case Html_meta: -
1642 if (key == QLatin1String("name")
evaluated: key == QLatin1String("name")
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:14
14
1643 && value == QLatin1String("qrichtext")) {
partially evaluated: value == QLatin1String("qrichtext")
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
1644 seenQt3Richtext = true;
executed (the execution status of this line is deduced): seenQt3Richtext = true;
-
1645 }
executed: }
Execution Count:14
14
1646 -
1647 if (key == QLatin1String("content")
evaluated: key == QLatin1String("content")
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:14
14
1648 && value == QLatin1String("1")
partially evaluated: value == QLatin1String("1")
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
1649 && seenQt3Richtext) {
partially evaluated: seenQt3Richtext
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
1650 -
1651 textEditMode = true;
executed (the execution status of this line is deduced): textEditMode = true;
-
1652 }
executed: }
Execution Count:14
14
1653 break;
executed: break;
Execution Count:28
28
1654 case Html_hr: -
1655 if (key == QLatin1String("width"))
partially evaluated: key == QLatin1String("width")
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1656 setWidthAttribute(&node->width, value);
executed: setWidthAttribute(&node->width, value);
Execution Count:1
1
1657 break;
executed: break;
Execution Count:1
1
1658 case Html_link: -
1659 if (key == QLatin1String("href"))
evaluated: key == QLatin1String("href")
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
1660 linkHref = value;
executed: linkHref = value;
Execution Count:3
3
1661 else if (key == QLatin1String("type"))
partially evaluated: key == QLatin1String("type")
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1662 linkType = value;
executed: linkType = value;
Execution Count:3
3
1663 break;
executed: break;
Execution Count:6
6
1664 default: -
1665 break;
executed: break;
Execution Count:164
164
1666 } -
1667 -
1668 if (key == QLatin1String("style")) {
evaluated: key == QLatin1String("style")
TRUEFALSE
yes
Evaluation Count:173
yes
Evaluation Count:277
173-277
1669#ifndef QT_NO_CSSPARSER -
1670 node->parseStyleAttribute(value, resourceProvider);
executed (the execution status of this line is deduced): node->parseStyleAttribute(value, resourceProvider);
-
1671#endif -
1672 } else if (key == QLatin1String("align")) {
executed: }
Execution Count:173
evaluated: key == QLatin1String("align")
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:263
14-263
1673 value = value.toLower();
executed (the execution status of this line is deduced): value = value.toLower();
-
1674 bool alignmentSet = true;
executed (the execution status of this line is deduced): bool alignmentSet = true;
-
1675 -
1676 if (value == QLatin1String("left"))
evaluated: value == QLatin1String("left")
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:12
2-12
1677 node->blockFormat.setAlignment(Qt::AlignLeft|Qt::AlignAbsolute);
executed: node->blockFormat.setAlignment(Qt::AlignLeft|Qt::AlignAbsolute);
Execution Count:2
2
1678 else if (value == QLatin1String("right"))
evaluated: value == QLatin1String("right")
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6
1679 node->blockFormat.setAlignment(Qt::AlignRight|Qt::AlignAbsolute);
executed: node->blockFormat.setAlignment(Qt::AlignRight|Qt::AlignAbsolute);
Execution Count:6
6
1680 else if (value == QLatin1String("center"))
evaluated: value == QLatin1String("center")
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
1681 node->blockFormat.setAlignment(Qt::AlignHCenter);
executed: node->blockFormat.setAlignment(Qt::AlignHCenter);
Execution Count:3
3
1682 else if (value == QLatin1String("justify"))
partially evaluated: value == QLatin1String("justify")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1683 node->blockFormat.setAlignment(Qt::AlignJustify);
never executed: node->blockFormat.setAlignment(Qt::AlignJustify);
0
1684 else -
1685 alignmentSet = false;
executed: alignmentSet = false;
Execution Count:3
3
1686 -
1687 if (node->id == Html_img) {
evaluated: node->id == Html_img
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:8
6-8
1688 // HTML4 compat -
1689 if (alignmentSet) {
evaluated: alignmentSet
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
1690 if (node->blockFormat.alignment() & Qt::AlignLeft)
evaluated: node->blockFormat.alignment() & Qt::AlignLeft
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
1691 node->cssFloat = QTextFrameFormat::FloatLeft;
executed: node->cssFloat = QTextFrameFormat::FloatLeft;
Execution Count:1
1
1692 else if (node->blockFormat.alignment() & Qt::AlignRight)
partially evaluated: node->blockFormat.alignment() & Qt::AlignRight
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1693 node->cssFloat = QTextFrameFormat::FloatRight;
executed: node->cssFloat = QTextFrameFormat::FloatRight;
Execution Count:2
2
1694 } else if (value == QLatin1String("middle")) {
evaluated: value == QLatin1String("middle")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
1695 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
executed (the execution status of this line is deduced): node->charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
-
1696 } else if (value == QLatin1String("top")) {
executed: }
Execution Count:1
evaluated: value == QLatin1String("top")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1697 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignTop);
executed (the execution status of this line is deduced): node->charFormat.setVerticalAlignment(QTextCharFormat::AlignTop);
-
1698 }
executed: }
Execution Count:1
1
1699 } -
1700 } else if (key == QLatin1String("valign")) {
executed: }
Execution Count:14
evaluated: key == QLatin1String("valign")
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:257
6-257
1701 value = value.toLower();
executed (the execution status of this line is deduced): value = value.toLower();
-
1702 if (value == QLatin1String("top"))
evaluated: value == QLatin1String("top")
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
2-4
1703 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignTop);
executed: node->charFormat.setVerticalAlignment(QTextCharFormat::AlignTop);
Execution Count:2
2
1704 else if (value == QLatin1String("middle"))
evaluated: value == QLatin1String("middle")
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
1705 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
executed: node->charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
Execution Count:2
2
1706 else if (value == QLatin1String("bottom"))
partially evaluated: value == QLatin1String("bottom")
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1707 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignBottom);
executed: node->charFormat.setVerticalAlignment(QTextCharFormat::AlignBottom);
Execution Count:2
2
1708 } else if (key == QLatin1String("dir")) {
evaluated: key == QLatin1String("dir")
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:252
5-252
1709 value = value.toLower();
executed (the execution status of this line is deduced): value = value.toLower();
-
1710 if (value == QLatin1String("ltr"))
evaluated: value == QLatin1String("ltr")
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
2-3
1711 node->blockFormat.setLayoutDirection(Qt::LeftToRight);
executed: node->blockFormat.setLayoutDirection(Qt::LeftToRight);
Execution Count:2
2
1712 else if (value == QLatin1String("rtl"))
partially evaluated: value == QLatin1String("rtl")
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1713 node->blockFormat.setLayoutDirection(Qt::RightToLeft);
executed: node->blockFormat.setLayoutDirection(Qt::RightToLeft);
Execution Count:3
3
1714 } else if (key == QLatin1String("title")) {
evaluated: key == QLatin1String("title")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:251
1-251
1715 node->charFormat.setToolTip(value);
executed (the execution status of this line is deduced): node->charFormat.setToolTip(value);
-
1716 } else if (key == QLatin1String("id")) {
executed: }
Execution Count:1
evaluated: key == QLatin1String("id")
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:244
1-244
1717 node->charFormat.setAnchor(true);
executed (the execution status of this line is deduced): node->charFormat.setAnchor(true);
-
1718 node->charFormat.setAnchorName(value);
executed (the execution status of this line is deduced): node->charFormat.setAnchorName(value);
-
1719 }
executed: }
Execution Count:7
7
1720 } -
1721 -
1722#ifndef QT_NO_CSSPARSER -
1723 if (resourceProvider && !linkHref.isEmpty() && linkType == QLatin1String("text/css"))
partially evaluated: resourceProvider
TRUEFALSE
yes
Evaluation Count:1593
no
Evaluation Count:0
evaluated: !linkHref.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1590
partially evaluated: linkType == QLatin1String("text/css")
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-1593
1724 importStyleSheet(linkHref);
executed: importStyleSheet(linkHref);
Execution Count:3
3
1725#endif -
1726}
executed: }
Execution Count:1593
1593
1727 -
1728#ifndef QT_NO_CSSPARSER -
1729class QTextHtmlStyleSelector : public QCss::StyleSelector -
1730{ -
1731public: -
1732 inline QTextHtmlStyleSelector(const QTextHtmlParser *parser) -
1733 : parser(parser) { nameCaseSensitivity = Qt::CaseInsensitive; }
executed: }
Execution Count:1593
1593
1734 -
1735 virtual QStringList nodeNames(NodePtr node) const; -
1736 virtual QString attribute(NodePtr node, const QString &name) const; -
1737 virtual bool hasAttributes(NodePtr node) const; -
1738 virtual bool isNullNode(NodePtr node) const; -
1739 virtual NodePtr parentNode(NodePtr node) const; -
1740 virtual NodePtr previousSiblingNode(NodePtr node) const; -
1741 virtual NodePtr duplicateNode(NodePtr node) const; -
1742 virtual void freeNode(NodePtr node) const; -
1743 -
1744private: -
1745 const QTextHtmlParser *parser; -
1746}; -
1747 -
1748QStringList QTextHtmlStyleSelector::nodeNames(NodePtr node) const -
1749{ -
1750 return QStringList(parser->at(node.id).tag.toLower());
executed: return QStringList(parser->at(node.id).tag.toLower());
Execution Count:190
190
1751} -
1752 -
1753#endif // QT_NO_CSSPARSER -
1754 -
1755static inline int findAttribute(const QStringList &attributes, const QString &name) -
1756{ -
1757 int idx = -1;
executed (the execution status of this line is deduced): int idx = -1;
-
1758 do { -
1759 idx = attributes.indexOf(name, idx + 1);
executed (the execution status of this line is deduced): idx = attributes.indexOf(name, idx + 1);
-
1760 } while (idx != -1 && (idx % 2 == 1));
executed: }
Execution Count:17
evaluated: idx != -1
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:1
evaluated: (idx % 2 == 1)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:15
1-17
1761 return idx;
executed: return idx;
Execution Count:16
16
1762} -
1763 -
1764#ifndef QT_NO_CSSPARSER -
1765 -
1766QString QTextHtmlStyleSelector::attribute(NodePtr node, const QString &name) const -
1767{ -
1768 const QStringList &attributes = parser->at(node.id).attributes;
executed (the execution status of this line is deduced): const QStringList &attributes = parser->at(node.id).attributes;
-
1769 const int idx = findAttribute(attributes, name);
executed (the execution status of this line is deduced): const int idx = findAttribute(attributes, name);
-
1770 if (idx == -1)
evaluated: idx == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:15
1-15
1771 return QString();
executed: return QString();
Execution Count:1
1
1772 return attributes.at(idx + 1);
executed: return attributes.at(idx + 1);
Execution Count:15
15
1773} -
1774 -
1775bool QTextHtmlStyleSelector::hasAttributes(NodePtr node) const -
1776{ -
1777 const QStringList &attributes = parser->at(node.id).attributes;
executed (the execution status of this line is deduced): const QStringList &attributes = parser->at(node.id).attributes;
-
1778 return !attributes.isEmpty();
executed: return !attributes.isEmpty();
Execution Count:16
16
1779} -
1780 -
1781bool QTextHtmlStyleSelector::isNullNode(NodePtr node) const -
1782{ -
1783 return node.id == 0;
never executed: return node.id == 0;
0
1784} -
1785 -
1786QCss::StyleSelector::NodePtr QTextHtmlStyleSelector::parentNode(NodePtr node) const -
1787{ -
1788 NodePtr parent;
never executed (the execution status of this line is deduced): NodePtr parent;
-
1789 parent.id = 0;
never executed (the execution status of this line is deduced): parent.id = 0;
-
1790 if (node.id) {
never evaluated: node.id
0
1791 parent.id = parser->at(node.id).parent;
never executed (the execution status of this line is deduced): parent.id = parser->at(node.id).parent;
-
1792 }
never executed: }
0
1793 return parent;
never executed: return parent;
0
1794} -
1795 -
1796QCss::StyleSelector::NodePtr QTextHtmlStyleSelector::duplicateNode(NodePtr node) const -
1797{ -
1798 return node;
never executed: return node;
0
1799} -
1800 -
1801QCss::StyleSelector::NodePtr QTextHtmlStyleSelector::previousSiblingNode(NodePtr node) const -
1802{ -
1803 NodePtr sibling;
never executed (the execution status of this line is deduced): NodePtr sibling;
-
1804 sibling.id = 0;
never executed (the execution status of this line is deduced): sibling.id = 0;
-
1805 if (!node.id)
never evaluated: !node.id
0
1806 return sibling;
never executed: return sibling;
0
1807 int parent = parser->at(node.id).parent;
never executed (the execution status of this line is deduced): int parent = parser->at(node.id).parent;
-
1808 if (!parent)
never evaluated: !parent
0
1809 return sibling;
never executed: return sibling;
0
1810 const int childIdx = parser->at(parent).children.indexOf(node.id);
never executed (the execution status of this line is deduced): const int childIdx = parser->at(parent).children.indexOf(node.id);
-
1811 if (childIdx <= 0)
never evaluated: childIdx <= 0
0
1812 return sibling;
never executed: return sibling;
0
1813 sibling.id = parser->at(parent).children.at(childIdx - 1);
never executed (the execution status of this line is deduced): sibling.id = parser->at(parent).children.at(childIdx - 1);
-
1814 return sibling;
never executed: return sibling;
0
1815} -
1816 -
1817void QTextHtmlStyleSelector::freeNode(NodePtr) const -
1818{ -
1819} -
1820 -
1821void QTextHtmlParser::resolveStyleSheetImports(const QCss::StyleSheet &sheet) -
1822{ -
1823 for (int i = 0; i < sheet.importRules.count(); ++i) {
evaluated: i < sheet.importRules.count()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:45
5-45
1824 const QCss::ImportRule &rule = sheet.importRules.at(i);
executed (the execution status of this line is deduced): const QCss::ImportRule &rule = sheet.importRules.at(i);
-
1825 if (rule.media.isEmpty()
evaluated: rule.media.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
1826 || rule.media.contains(QLatin1String("screen"), Qt::CaseInsensitive))
partially evaluated: rule.media.contains(QLatin1String("screen"), Qt::CaseInsensitive)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1827 importStyleSheet(rule.href);
executed: importStyleSheet(rule.href);
Execution Count:5
5
1828 }
executed: }
Execution Count:5
5
1829}
executed: }
Execution Count:45
45
1830 -
1831void QTextHtmlParser::importStyleSheet(const QString &href) -
1832{ -
1833 if (!resourceProvider)
partially evaluated: !resourceProvider
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1834 return;
never executed: return;
0
1835 for (int i = 0; i < externalStyleSheets.count(); ++i)
evaluated: i < externalStyleSheets.count()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:8
6-8
1836 if (externalStyleSheets.at(i).url == href)
partially evaluated: externalStyleSheets.at(i).url == href
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1837 return;
never executed: return;
0
1838 -
1839 QVariant res = resourceProvider->resource(QTextDocument::StyleSheetResource, href);
never executed (the execution status of this line is deduced): QVariant res = resourceProvider->resource(QTextDocument::StyleSheetResource, href);
-
1840 QString css;
never executed (the execution status of this line is deduced): QString css;
-
1841 if (res.type() == QVariant::String) {
partially evaluated: res.type() == QVariant::String
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
1842 css = res.toString();
executed (the execution status of this line is deduced): css = res.toString();
-
1843 } else if (res.type() == QVariant::ByteArray) {
executed: }
Execution Count:8
never evaluated: res.type() == QVariant::ByteArray
0-8
1844 // #### detect @charset -
1845 css = QString::fromUtf8(res.toByteArray());
never executed (the execution status of this line is deduced): css = QString::fromUtf8(res.toByteArray());
-
1846 }
never executed: }
0
1847 if (!css.isEmpty()) {
partially evaluated: !css.isEmpty()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
1848 QCss::Parser parser(css);
executed (the execution status of this line is deduced): QCss::Parser parser(css);
-
1849 QCss::StyleSheet sheet;
executed (the execution status of this line is deduced): QCss::StyleSheet sheet;
-
1850 parser.parse(&sheet, Qt::CaseInsensitive);
executed (the execution status of this line is deduced): parser.parse(&sheet, Qt::CaseInsensitive);
-
1851 externalStyleSheets.append(ExternalStyleSheet(href, sheet));
executed (the execution status of this line is deduced): externalStyleSheets.append(ExternalStyleSheet(href, sheet));
-
1852 resolveStyleSheetImports(sheet);
executed (the execution status of this line is deduced): resolveStyleSheetImports(sheet);
-
1853 }
executed: }
Execution Count:8
8
1854}
executed: }
Execution Count:8
8
1855 -
1856QVector<QCss::Declaration> QTextHtmlParser::declarationsForNode(int node) const -
1857{ -
1858 QVector<QCss::Declaration> decls;
executed (the execution status of this line is deduced): QVector<QCss::Declaration> decls;
-
1859 -
1860 QTextHtmlStyleSelector selector(this);
executed (the execution status of this line is deduced): QTextHtmlStyleSelector selector(this);
-
1861 -
1862 int idx = 0;
executed (the execution status of this line is deduced): int idx = 0;
-
1863 selector.styleSheets.resize((resourceProvider ? 1 : 0)
executed (the execution status of this line is deduced): selector.styleSheets.resize((resourceProvider ? 1 : 0)
-
1864 + externalStyleSheets.count()
executed (the execution status of this line is deduced): + externalStyleSheets.count()
-
1865 + inlineStyleSheets.count());
executed (the execution status of this line is deduced): + inlineStyleSheets.count());
-
1866 if (resourceProvider)
partially evaluated: resourceProvider
TRUEFALSE
yes
Evaluation Count:1593
no
Evaluation Count:0
0-1593
1867 selector.styleSheets[idx++] = resourceProvider->docHandle()->parsedDefaultStyleSheet;
executed: selector.styleSheets[idx++] = resourceProvider->docHandle()->parsedDefaultStyleSheet;
Execution Count:1593
1593
1868 -
1869 for (int i = 0; i < externalStyleSheets.count(); ++i, ++idx)
evaluated: i < externalStyleSheets.count()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1593
8-1593
1870 selector.styleSheets[idx] = externalStyleSheets.at(i).sheet;
executed: selector.styleSheets[idx] = externalStyleSheets.at(i).sheet;
Execution Count:8
8
1871 -
1872 for (int i = 0; i < inlineStyleSheets.count(); ++i, ++idx)
evaluated: i < inlineStyleSheets.count()
TRUEFALSE
yes
Evaluation Count:117
yes
Evaluation Count:1593
117-1593
1873 selector.styleSheets[idx] = inlineStyleSheets.at(i);
executed: selector.styleSheets[idx] = inlineStyleSheets.at(i);
Execution Count:117
117
1874 -
1875 selector.medium = QLatin1String("screen");
executed (the execution status of this line is deduced): selector.medium = QLatin1String("screen");
-
1876 -
1877 QCss::StyleSelector::NodePtr n;
executed (the execution status of this line is deduced): QCss::StyleSelector::NodePtr n;
-
1878 n.id = node;
executed (the execution status of this line is deduced): n.id = node;
-
1879 -
1880 const char *extraPseudo = 0;
executed (the execution status of this line is deduced): const char *extraPseudo = 0;
-
1881 if (nodes.at(node).id == Html_a && nodes.at(node).hasHref)
evaluated: nodes.at(node).id == Html_a
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:1526
evaluated: nodes.at(node).hasHref
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:21
21-1526
1882 extraPseudo = "link";
executed: extraPseudo = "link";
Execution Count:46
46
1883 decls = selector.declarationsForNode(n, extraPseudo);
executed (the execution status of this line is deduced): decls = selector.declarationsForNode(n, extraPseudo);
-
1884 -
1885 return decls;
executed: return decls;
Execution Count:1593
1593
1886} -
1887 -
1888bool QTextHtmlParser::nodeIsChildOf(int i, QTextHTMLElements id) const -
1889{ -
1890 while (i) {
never evaluated: i
0
1891 if (at(i).id == id)
never evaluated: at(i).id == id
0
1892 return true;
never executed: return true;
0
1893 i = at(i).parent;
never executed (the execution status of this line is deduced): i = at(i).parent;
-
1894 }
never executed: }
0
1895 return false;
never executed: return false;
0
1896} -
1897 -
1898QT_END_NAMESPACE -
1899#endif // QT_NO_CSSPARSER -
1900 -
1901#endif // QT_NO_TEXTHTMLPARSER -
1902 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial