qtexthtmlparser.cpp

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

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