text/qtexthtmlparser.cpp

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

Generated by Squish Coco Non-Commercial