11#include <qguiapplication.h>
21#ifndef QT_NO_TEXTHTMLPARSER
25using namespace Qt::StringLiterals;
48 {
"Epsilon", 0x0395 },
69 {
"Omicron", 0x039f },
87 {
"Upsilon", 0x03a5 },
98 {
"alefsym", 0x2135 },
106 {
"atilde", 0x00e3 },
110 {
"brvbar", 0x00a6 },
113 {
"ccedil", 0x00e7 },
123 {
"curren", 0x00a4 },
125 {
"dagger", 0x2020 },
130 {
"divide", 0x00f7 },
131 {
"eacute", 0x00e9 },
133 {
"egrave", 0x00e8 },
137 {
"epsilon", 0x03b5 },
145 {
"forall", 0x2200 },
146 {
"frac12", 0x00bd },
147 {
"frac14", 0x00bc },
148 {
"frac34", 0x00be },
155 {
"hearts", 0x2665 },
156 {
"hellip", 0x2026 },
157 {
"iacute", 0x00ed },
160 {
"igrave", 0x00ec },
165 {
"iquest", 0x00bf },
170 {
"lambda", 0x03bb },
177 {
"lfloor", 0x230a },
178 {
"lowast", 0x2217 },
181 {
"lsaquo", 0x2039 },
187 {
"middot", 0x00b7 },
198 {
"ntilde", 0x00f1 },
200 {
"oacute", 0x00f3 },
203 {
"ograve", 0x00f2 },
206 {
"omicron", 0x03bf },
211 {
"oslash", 0x00f8 },
212 {
"otilde", 0x00f5 },
213 {
"otimes", 0x2297 },
217 {
"percnt", 0x0025 },
218 {
"permil", 0x2030 },
223 {
"plusmn", 0x00b1 },
239 {
"rfloor", 0x230b },
242 {
"rsaquo", 0x203a },
245 {
"scaron", 0x0161 },
250 {
"sigmaf", 0x03c2 },
252 {
"spades", 0x2660 },
263 {
"there4", 0x2234 },
265 {
"thetasym", 0x03d1 },
266 {
"thinsp", 0x2009 },
272 {
"uacute", 0x00fa },
275 {
"ugrave", 0x00f9 },
278 {
"upsilon", 0x03c5 },
280 {
"weierp", 0x2118 },
282 {
"yacute", 0x00fd },
289static_assert(
MAX_ENTITY ==
sizeof entities /
sizeof *entities);
291#if defined(Q_CC_MSVC_ONLY) && _MSC_VER < 1600
292bool operator<(
const QTextHtmlEntity &entity1,
const QTextHtmlEntity &entity2)
294 return QLatin1StringView(entity1.name) < QLatin1StringView(entity2.name);
300 return entityStr < QLatin1StringView(entity
.name);
305 return QLatin1StringView(entity
.name) < entityStr;
313 if (e == end || (entity < *e))
420 return str < QLatin1StringView(e
.name);
425 return QLatin1StringView(e
.name) < str;
433 if ((e == end) || (element < *e))
450 n.replace(u'\n',
"\\n"_L1);
470 for (
int i = 0; i < 4; ++i) {
471 tableCellBorderStyle[i] = QTextFrameFormat::BorderStyle_None;
472 tableCellBorder[i] = 0;
473 tableCellBorderBrush[i] = Qt::NoBrush;
479 for (
int i = 0; i <
count(); ++i) {
480 qDebug().nospace() << qPrintable(QString(depth(i) * 4, u' '))
481 << qPrintable(at(i).tag) <<
':'
482 << quoteNewline(at(i).text);
491 bool reuseLastNode =
true;
493 if (nodes.size() == 1) {
494 reuseLastNode =
false;
495 }
else if (lastNode->tag.isEmpty()) {
497 if (lastNode->text.isEmpty()) {
498 reuseLastNode =
true;
501 if (lastNode->text.size() == 1 && lastNode->text.at(0).isSpace()) {
511 reuseLastNode =
false;
513 reuseLastNode =
true;
517 reuseLastNode =
false;
524 reuseLastNode =
false;
529 newNode->tag.clear();
530 newNode->text.clear();
533 nodes.append(
new QTextHtmlParserNode);
534 newNode = nodes.last();
541void QTextHtmlParser::parse(
const QString &text,
const QTextDocument *_resourceProvider)
545 nodes.append(
new QTextHtmlParserNode);
550 resourceProvider = _resourceProvider;
599 while (pos < len && txt.at(pos).isSpace() && txt.at(pos) != QChar::ParagraphSeparator)
606 QChar c = txt.at(pos++);
609 }
else if (c == u'&') {
610 nodes.last()->text += parseEntity();
612 nodes.last()->text += c;
623 if (hasPrefix(u'!')) {
625 if (nodes.last()->wsm != QTextHtmlParserNode::WhiteSpacePre
626 && nodes.last()->wsm != QTextHtmlParserNode::WhiteSpacePreWrap
633 if (hasPrefix(u'/')) {
634 if (nodes.last()->id == Html_style) {
635#ifndef QT_NO_CSSPARSER
636 QCss::Parser parser(nodes.constLast()->text);
637 QCss::StyleSheet sheet;
638 sheet.origin = QCss::StyleSheetOrigin_Author;
639 parser.parse(&sheet, Qt::CaseInsensitive);
640 inlineStyleSheets.append(sheet);
641 resolveStyleSheetImports(sheet);
649 while (p &&
at(p
).tag.size() == 0)
655 node->tag = parseWord().toLower();
660 node->displayMode = elem->displayMode;
665 node->attributes.clear();
667 if (pos < len && txt.at(pos).isSpace())
668 node->attributes = parseAttributes();
676#ifndef QT_NO_CSSPARSER
677 const int nodeIndex = nodes.size() - 1;
678 node->applyCssDeclarations(declarationsForNode(nodeIndex), resourceProvider);
680 applyAttributes(node->attributes);
683 bool tagClosed =
false;
684 while (pos < len && txt.at(pos) != u'>') {
685 if (txt.at(pos) == u'/')
698 if (pos < len - 1 && txt.at(pos) == u'\n')
712 QString tag = parseWord().toLower().trimmed();
714 QChar c = txt.at(pos++);
722 &&
at(p - 1
).tag == tag
726 while (p &&
at(p
).tag != tag)
743 if (at(last()).text.endsWith(u'\n'))
744 nodes[last()]->text.chop(1);
755 if (hasPrefix(u'-') && hasPrefix(u'-', 1)) {
758 int end = txt.indexOf(
"-->"_L1, pos);
759 pos = (end >= 0 ? end + 3 :
len);
763 QChar c = txt.at(pos++);
772 QChar resolved = resolveEntity(entity);
773 if (!resolved.isNull())
774 return QString(resolved);
776 if (entity.size() > 1 && entity.at(0) == u'#') {
777 entity = entity.mid(1);
782 if (entity.at(0).toLower() == u'x') {
783 entity = entity.mid(1);
787 uint uc = entity.toUInt(&ok, base);
791 return QStringView{QChar::fromUcs4(uc)}.toString();
800 const int recover =
pos;
803 QChar c = txt.at(pos++);
804 if (c.isSpace() ||
pos - recover > 9) {
812 const QStringView entity = QStringView(txt).mid(recover, entityLen);
813 QString parsedEntity = parseEntity(entity);
814 if (!parsedEntity.isNull()) {
827 if (hasPrefix(u'\"')) {
830 QChar c = txt.at(pos++);
834 word += parseEntity();
838 }
else if (hasPrefix(u'\'')) {
841 QChar c = txt.at(pos++);
843 if (c == u'\'' && (txt.size() > 1 && txt.at(pos - 2) != u'\\'))
850 QChar c = txt.at(pos++);
851 if (c == u'>' || (c == u'/' && hasPrefix(u'>'))
852 || c == u'<' || c == u'=' || c.isSpace()) {
857 word += parseEntity();
881 nodes.insert(nodes.size() - 1,
new QTextHtmlParserNode);
882 nodes.insert(nodes.size() - 1,
new QTextHtmlParserNode);
887 table->tag =
"table"_L1;
888 table->children.append(nodes.size() - 2);
891 row->parent = nodes.size() - 3;
895 p = nodes.size() - 2;
906 nodes.insert(nodes.size() - 1,
new QTextHtmlParserNode);
910 table->tag =
"table"_L1;
911 p = nodes.size() - 2;
959 nodes[p]->children.append(nodes.size() - 1);
988 charFormat = parent->charFormat;
991 blockFormat.setLayoutDirection(Qt::LeftToRight);
992 else if (parent->blockFormat.hasProperty(QTextFormat::LayoutDirection))
993 blockFormat.setLayoutDirection(parent->blockFormat.layoutDirection());
995 if (parent->displayMode == QTextHtmlElement::DisplayNone)
996 displayMode = QTextHtmlElement::DisplayNone;
999 if (parent->blockFormat.hasProperty(QTextFormat::BlockAlignment))
1000 blockFormat.setAlignment(parent->blockFormat.alignment());
1002 blockFormat.clearProperty(QTextFormat::BlockAlignment);
1008 if ((parent->id != Html_tr || !isTableCell())
1009 && (displayMode != QTextHtmlElement::DisplayInline || parent->displayMode != QTextHtmlElement::DisplayInline)
1010 && (parent->id == Html_body || displayMode != QTextHtmlElement::DisplayBlock || parent->displayMode != QTextHtmlElement::DisplayBlock)
1012 charFormat.clearProperty(QTextFormat::BackgroundBrush);
1015 listStyle = parent->listStyle;
1018 charFormat.clearProperty(QTextFormat::AnchorName);
1026 cssFloat = QTextFrameFormat::InFlow;
1028 for (
int i = 0; i < 4; ++i)
1034 for (
int i = 0; i < attributes.size(); i += 2) {
1035 const QString key = attributes.at(i);
1036 if (key.compare(
"href"_L1, Qt::CaseInsensitive) == 0
1037 && !attributes.at(i + 1).isEmpty()) {
1041 charFormat.setAnchor(
true);
1044 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(1));
1047 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(-1));
1050 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(3));
1055 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(2));
1060 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(1));
1065 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(0));
1070 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(-1));
1095 text = QChar(QChar::LineSeparator);
1106 blockFormat.setProperty(QTextFormat::BlockQuoteLevel, 1);
1119#ifndef QT_NO_CSSPARSER
1122 for (
int i = 0; i < cssValues.size(); ++i) {
1123 if (cssValues.at(i).type == QCss::Value::KnownIdentifier) {
1124 switch (
static_cast<QCss::KnownValue>(cssValues.at(i).variant.toInt())) {
1125 case QCss::Value_None: hasOwnListStyle =
true; listStyle = QTextListFormat::ListStyleUndefined;
break;
1126 case QCss::Value_Disc: hasOwnListStyle =
true; listStyle = QTextListFormat::ListDisc;
break;
1127 case QCss::Value_Square: hasOwnListStyle =
true; listStyle = QTextListFormat::ListSquare;
break;
1128 case QCss::Value_Circle: hasOwnListStyle =
true; listStyle = QTextListFormat::ListCircle;
break;
1129 case QCss::Value_Decimal: hasOwnListStyle =
true; listStyle = QTextListFormat::ListDecimal;
break;
1130 case QCss::Value_LowerAlpha: hasOwnListStyle =
true; listStyle = QTextListFormat::ListLowerAlpha;
break;
1131 case QCss::Value_UpperAlpha: hasOwnListStyle =
true; listStyle = QTextListFormat::ListUpperAlpha;
break;
1132 case QCss::Value_LowerRoman: hasOwnListStyle =
true; listStyle = QTextListFormat::ListLowerRoman;
break;
1133 case QCss::Value_UpperRoman: hasOwnListStyle =
true; listStyle = QTextListFormat::ListUpperRoman;
break;
1139 if (id == Html_li && hasOwnListStyle)
1140 blockFormat.setProperty(QTextFormat::ListStyle, listStyle);
1146 case QCss::BorderStyle::BorderStyle_Dotted:
1147 return QTextFrameFormat::BorderStyle::BorderStyle_Dotted;
1148 case QCss::BorderStyle::BorderStyle_Dashed:
1149 return QTextFrameFormat::BorderStyle::BorderStyle_Dashed;
1150 case QCss::BorderStyle::BorderStyle_Solid:
1151 return QTextFrameFormat::BorderStyle::BorderStyle_Solid;
1152 case QCss::BorderStyle::BorderStyle_Double:
1153 return QTextFrameFormat::BorderStyle::BorderStyle_Double;
1154 case QCss::BorderStyle::BorderStyle_DotDash:
1155 return QTextFrameFormat::BorderStyle::BorderStyle_DotDash;
1156 case QCss::BorderStyle::BorderStyle_DotDotDash:
1157 return QTextFrameFormat::BorderStyle::BorderStyle_DotDotDash;
1158 case QCss::BorderStyle::BorderStyle_Groove:
1159 return QTextFrameFormat::BorderStyle::BorderStyle_Groove;
1160 case QCss::BorderStyle::BorderStyle_Ridge:
1161 return QTextFrameFormat::BorderStyle::BorderStyle_Ridge;
1162 case QCss::BorderStyle::BorderStyle_Inset:
1163 return QTextFrameFormat::BorderStyle::BorderStyle_Inset;
1164 case QCss::BorderStyle::BorderStyle_Outset:
1165 return QTextFrameFormat::BorderStyle::BorderStyle_Outset;
1166 case QCss::BorderStyle::BorderStyle_Unknown:
1167 case QCss::BorderStyle::BorderStyle_None:
1168 case QCss::BorderStyle::BorderStyle_Native:
1169 return QTextFrameFormat::BorderStyle::BorderStyle_None;
1170 case QCss::BorderStyle::NumKnownBorderStyles:
1178 return static_cast<QTextFrameFormat::BorderStyle>(-1);
1181void QTextHtmlParserNode::applyCssDeclarations(
const QList<QCss::Declaration> &declarations,
const QTextDocument *resourceProvider)
1183 QCss::ValueExtractor extractor(declarations);
1184 extractor.extractBox(margin, padding);
1186 auto getBorderValues = [&extractor](qreal *borderWidth, QBrush *borderBrush, QTextFrameFormat::BorderStyle *borderStyles) {
1187 QCss::BorderStyle cssStyles[4];
1190 for (
int i = 0; i < 4; ++i) {
1191 cssStyles[i] = QCss::BorderStyle_None;
1198 bool hit = extractor.extractBorder(cssBorder, borderBrush, cssStyles, cssRadii);
1199 for (
int i = 0; i < 4; ++i) {
1200 borderStyles[i] = toQTextFrameFormat(cssStyles[i]);
1201 borderWidth[i] =
static_cast<qreal>(cssBorder[i]);
1207 getBorderValues(tableCellBorder, tableCellBorderBrush, tableCellBorderStyle);
1209 for (
int i = 0; i < declarations.size(); ++i) {
1210 const QCss::Declaration &decl = declarations.at(i);
1211 if (decl.d->values.isEmpty())
continue;
1213 QCss::KnownValue identifier = QCss::UnknownValue;
1214 if (decl.d->values.constFirst().type == QCss::Value::KnownIdentifier)
1215 identifier =
static_cast<QCss::KnownValue>(decl.d->values.constFirst().variant.toInt());
1217 switch (decl.d->propertyId) {
1218 case QCss::BorderColor: {
1219 QBrush bordersBrush[4];
1220 decl.brushValues(bordersBrush);
1221 if (bordersBrush[0].color().isValid())
1222 borderBrush = bordersBrush[0];
1225 case QCss::BorderStyles:
1226 if (decl.styleValue() != QCss::BorderStyle_Unknown && decl.styleValue() != QCss::BorderStyle_Native)
1227 borderStyle =
static_cast<QTextFrameFormat::BorderStyle>(decl.styleValue() - 1);
1229 case QCss::BorderWidth: {
1231 extractor.lengthValues(decl, borders);
1232 tableBorder = borders[0];
1235 case QCss::Border: {
1237 QBrush tblBorderBrush[4];
1238 QTextFrameFormat::BorderStyle tblBorderStyle[4];
1239 if (getBorderValues(tblBorder, tblBorderBrush, tblBorderStyle)) {
1240 tableBorder = tblBorder[0];
1241 if (tblBorderBrush[0].color().isValid())
1242 borderBrush = tblBorderBrush[0];
1243 if (tblBorderStyle[0] !=
static_cast<QTextFrameFormat::BorderStyle>(-1))
1244 borderStyle = tblBorderStyle[0];
1248 case QCss::BorderCollapse:
1251 case QCss::Color: charFormat.setForeground(decl.colorValue());
break;
1253 cssFloat = QTextFrameFormat::InFlow;
1254 switch (identifier) {
1255 case QCss::Value_Left: cssFloat = QTextFrameFormat::FloatLeft;
break;
1256 case QCss::Value_Right: cssFloat = QTextFrameFormat::FloatRight;
break;
1260 case QCss::QtBlockIndent:
1261 blockFormat.setIndent(decl.d->values.constFirst().variant.toInt());
1263 case QCss::QtLineHeightType: {
1264 QString lineHeightTypeName = decl.d->values.constFirst().variant.toString();
1265 QTextBlockFormat::LineHeightTypes lineHeightType;
1266 if (lineHeightTypeName.compare(
"proportional"_L1, Qt::CaseInsensitive) == 0)
1267 lineHeightType = QTextBlockFormat::ProportionalHeight;
1268 else if (lineHeightTypeName.compare(
"fixed"_L1, Qt::CaseInsensitive) == 0)
1269 lineHeightType = QTextBlockFormat::FixedHeight;
1270 else if (lineHeightTypeName.compare(
"minimum"_L1, Qt::CaseInsensitive) == 0)
1271 lineHeightType = QTextBlockFormat::MinimumHeight;
1272 else if (lineHeightTypeName.compare(
"line-distance"_L1, Qt::CaseInsensitive) == 0)
1273 lineHeightType = QTextBlockFormat::LineDistanceHeight;
1275 lineHeightType = QTextBlockFormat::SingleHeight;
1277 if (hasLineHeightMultiplier) {
1278 qreal lineHeight = blockFormat.lineHeight() / 100.0;
1279 blockFormat.setProperty(QTextBlockFormat::LineHeight, lineHeight);
1282 blockFormat.setProperty(QTextBlockFormat::LineHeightType, lineHeightType);
1283 hasOwnLineHeightType =
true;
1286 case QCss::LineHeight: {
1288 QTextBlockFormat::LineHeightTypes lineHeightType;
1289 if (decl.realValue(&lineHeight,
"px")) {
1290 lineHeightType = QTextBlockFormat::MinimumHeight;
1293 QCss::Value cssValue = decl.d->values.constFirst();
1294 QString value = cssValue.toString();
1295 lineHeight = value.toDouble(&ok);
1297 if (!hasOwnLineHeightType && cssValue.type == QCss::Value::Number) {
1298 lineHeight *= 100.0;
1299 hasLineHeightMultiplier =
true;
1301 lineHeightType = QTextBlockFormat::ProportionalHeight;
1304 lineHeightType = QTextBlockFormat::SingleHeight;
1309 if (hasOwnLineHeightType)
1310 lineHeightType = QTextBlockFormat::LineHeightTypes(blockFormat.lineHeightType());
1312 blockFormat.setLineHeight(lineHeight, lineHeightType);
1315 case QCss::TextIndent: {
1317 if (decl.realValue(&indent,
"px"))
1318 blockFormat.setTextIndent(indent);
1320 case QCss::QtListIndent:
1321 if (decl.intValue(&cssListIndent))
1322 hasCssListIndent =
true;
1324 case QCss::QtParagraphType:
1325 if (decl.d->values.constFirst().variant.toString().compare(
"empty"_L1, Qt::CaseInsensitive) == 0)
1326 isEmptyParagraph =
true;
1328 case QCss::QtTableType:
1329 if (decl.d->values.constFirst().variant.toString().compare(
"frame"_L1, Qt::CaseInsensitive) == 0)
1331 else if (decl.d->values.constFirst().variant.toString().compare(
"root"_L1, Qt::CaseInsensitive) == 0) {
1336 case QCss::QtUserState:
1337 userState = decl.d->values.constFirst().variant.toInt();
1339 case QCss::Whitespace:
1340 switch (identifier) {
1349 case QCss::VerticalAlignment:
1350 switch (identifier) {
1351 case QCss::Value_Sub: charFormat.setVerticalAlignment(QTextCharFormat::AlignSubScript);
break;
1352 case QCss::Value_Super: charFormat.setVerticalAlignment(QTextCharFormat::AlignSuperScript);
break;
1353 case QCss::Value_Middle: charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
break;
1354 case QCss::Value_Top: charFormat.setVerticalAlignment(QTextCharFormat::AlignTop);
break;
1355 case QCss::Value_Bottom: charFormat.setVerticalAlignment(QTextCharFormat::AlignBottom);
break;
1356 default: charFormat.setVerticalAlignment(QTextCharFormat::AlignNormal);
break;
1359 case QCss::PageBreakBefore:
1360 switch (identifier) {
1361 case QCss::Value_Always: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() | QTextFormat::PageBreak_AlwaysBefore);
break;
1362 case QCss::Value_Auto: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() & ~QTextFormat::PageBreak_AlwaysBefore);
break;
1366 case QCss::PageBreakAfter:
1367 switch (identifier) {
1368 case QCss::Value_Always: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() | QTextFormat::PageBreak_AlwaysAfter);
break;
1369 case QCss::Value_Auto: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() & ~QTextFormat::PageBreak_AlwaysAfter);
break;
1373 case QCss::TextUnderlineStyle:
1374 switch (identifier) {
1375 case QCss::Value_None: charFormat.setUnderlineStyle(QTextCharFormat::NoUnderline);
break;
1376 case QCss::Value_Solid: charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
break;
1377 case QCss::Value_Dashed: charFormat.setUnderlineStyle(QTextCharFormat::DashUnderline);
break;
1378 case QCss::Value_Dotted: charFormat.setUnderlineStyle(QTextCharFormat::DotLine);
break;
1379 case QCss::Value_DotDash: charFormat.setUnderlineStyle(QTextCharFormat::DashDotLine);
break;
1380 case QCss::Value_DotDotDash: charFormat.setUnderlineStyle(QTextCharFormat::DashDotDotLine);
break;
1381 case QCss::Value_Wave: charFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline);
break;
1385 case QCss::TextDecorationColor: charFormat.setUnderlineColor(decl.colorValue());
break;
1386 case QCss::ListStyleType:
1387 case QCss::ListStyle:
1388 setListStyle(decl.d->values);
1390 case QCss::QtListNumberPrefix:
1391 textListNumberPrefix = decl.d->values.constFirst().variant.toString();
1393 case QCss::QtListNumberSuffix:
1394 textListNumberSuffix = decl.d->values.constFirst().variant.toString();
1396 case QCss::TextAlignment:
1397 switch (identifier) {
1398 case QCss::Value_Left: blockFormat.setAlignment(Qt::AlignLeft);
break;
1399 case QCss::Value_Center: blockFormat.setAlignment(Qt::AlignCenter);
break;
1400 case QCss::Value_Right: blockFormat.setAlignment(Qt::AlignRight);
break;
1405 case QCss::QtForegroundTextureCacheKey:
1407 if (resourceProvider !=
nullptr && QTextDocumentPrivate::get(resourceProvider) !=
nullptr) {
1409 qint64 searchKey = decl.d->values.constFirst().variant.toLongLong(&ok);
1411 applyForegroundImage(searchKey, resourceProvider);
1415 case QCss::QtStrokeColor:
1417 QPen pen = charFormat.textOutline();
1418 pen.setStyle(Qt::SolidLine);
1419 pen.setColor(decl.colorValue());
1420 charFormat.setTextOutline(pen);
1423 case QCss::QtStrokeWidth:
1426 if (decl.realValue(&width,
"px")) {
1427 QPen pen = charFormat.textOutline();
1428 pen.setWidthF(width);
1429 charFormat.setTextOutline(pen);
1433 case QCss::QtStrokeLineCap:
1435 QPen pen = charFormat.textOutline();
1436 switch (identifier) {
1437 case QCss::Value_SquareCap: pen.setCapStyle(Qt::SquareCap);
break;
1438 case QCss::Value_FlatCap: pen.setCapStyle(Qt::FlatCap);
break;
1439 case QCss::Value_RoundCap: pen.setCapStyle(Qt::RoundCap);
break;
1442 charFormat.setTextOutline(pen);
1445 case QCss::QtStrokeLineJoin:
1447 QPen pen = charFormat.textOutline();
1448 switch (identifier) {
1449 case QCss::Value_MiterJoin: pen.setJoinStyle(Qt::MiterJoin);
break;
1450 case QCss::Value_BevelJoin: pen.setJoinStyle(Qt::BevelJoin);
break;
1451 case QCss::Value_RoundJoin: pen.setJoinStyle(Qt::RoundJoin);
break;
1452 case QCss::Value_SvgMiterJoin: pen.setJoinStyle(Qt::SvgMiterJoin);
break;
1455 charFormat.setTextOutline(pen);
1458 case QCss::QtStrokeMiterLimit:
1461 if (decl.realValue(&miterLimit)) {
1462 QPen pen = charFormat.textOutline();
1463 pen.setMiterLimit(miterLimit);
1464 charFormat.setTextOutline(pen);
1468 case QCss::QtStrokeDashArray:
1470 QList<qreal> dashes = decl.dashArray();
1471 if (!dashes.empty()) {
1472 QPen pen = charFormat.textOutline();
1473 pen.setDashPattern(dashes);
1474 charFormat.setTextOutline(pen);
1478 case QCss::QtStrokeDashOffset:
1481 if (decl.realValue(&dashOffset)) {
1482 QPen pen = charFormat.textOutline();
1483 pen.setDashOffset(dashOffset);
1484 charFormat.setTextOutline(pen);
1488 case QCss::QtForeground:
1490 QBrush brush = decl.brushValue();
1491 charFormat.setForeground(brush);
1494 case QCss::MaximumWidth:
1496 auto imageFormat = charFormat.toImageFormat();
1497 imageFormat.setMaximumWidth(extractor.textLength(decl));
1498 charFormat = imageFormat;
1506 int adjustment = -255;
1507 extractor.extractFont(&f, &adjustment);
1508 if (f.pixelSize() > INT32_MAX / 2)
1509 f.setPixelSize(INT32_MAX / 2);
1510 charFormat.setFont(f, QTextCharFormat::FontPropertiesSpecifiedOnly);
1512 if (adjustment >= -1)
1513 charFormat.setProperty(QTextFormat::FontSizeAdjustment, adjustment);
1516 Qt::Alignment ignoredAlignment;
1517 QCss::Repeat ignoredRepeat;
1520 QCss::Origin ignoredOrigin, ignoredClip;
1521 QCss::Attachment ignoredAttachment;
1522 extractor.extractBackground(&bgBrush, &bgImage, &ignoredRepeat, &ignoredAlignment,
1523 &ignoredOrigin, &ignoredAttachment, &ignoredClip);
1525 if (!bgImage.isEmpty() && resourceProvider) {
1526 applyBackgroundImage(bgImage, resourceProvider);
1527 }
else if (bgBrush.style() != Qt::NoBrush) {
1528 charFormat.setBackground(bgBrush);
1530 blockFormat.setProperty(QTextFormat::BackgroundBrush, bgBrush);
1539 const QTextDocumentPrivate *priv = QTextDocumentPrivate::get(resourceProvider);
1540 for (
int i = 0; i < priv->formats.numFormats(); ++i) {
1541 QTextCharFormat format = priv->formats.charFormat(i);
1542 if (format.isValid()) {
1543 QBrush brush = format.foreground();
1544 if (brush.style() == Qt::TexturePattern) {
1545 const bool isPixmap = qHasPixmapTexture(brush);
1547 if (isPixmap && QCoreApplication::instance()->thread() != QThread::currentThread()) {
1548 qWarning(
"Can't apply QPixmap outside of GUI thread");
1552 const qint64 cacheKey = isPixmap ? brush.texture().cacheKey() : brush.textureImage().cacheKey();
1553 if (cacheKey == searchKey) {
1556 b.setTexture(brush.texture());
1558 b.setTextureImage(brush.textureImage());
1559 b.setStyle(Qt::TexturePattern);
1560 charFormat.setForeground(b);
1570 if (!url.isEmpty() && resourceProvider) {
1571 QVariant val = resourceProvider->resource(QTextDocument::ImageResource, QUrl{url});
1573 if (QCoreApplication::instance()->thread() != QThread::currentThread()) {
1575 if (val.userType() == QMetaType::QImage) {
1576 QImage image = qvariant_cast<QImage>(val);
1577 charFormat.setBackground(image);
1578 }
else if (val.userType() == QMetaType::QByteArray) {
1580 if (image.loadFromData(val.toByteArray())) {
1581 charFormat.setBackground(image);
1585 if (val.userType() == QMetaType::QImage || val.userType() == QMetaType::QPixmap) {
1586 charFormat.setBackground(qvariant_cast<QPixmap>(val));
1587 }
else if (val.userType() == QMetaType::QByteArray) {
1589 if (pm.loadFromData(val.toByteArray())) {
1590 charFormat.setBackground(pm);
1596 charFormat.setProperty(QTextFormat::BackgroundImageUrl, url);
1601 for (
int i = 0; i < text.size(); ++i)
1602 if (!text.at(i).isSpace() || text.at(i) == QChar::LineSeparator)
1610 int val = value.toInt(&ok);
1620 qreal val = value.toDouble(&ok);
1630 qreal realVal = valueStr.toDouble(&ok);
1632 *width = QTextLength(QTextLength::FixedLength, realVal);
1634 auto value = QStringView(valueStr).trimmed();
1635 if (!value.isEmpty() && value.endsWith(u'%')) {
1636 value.truncate(value.size() - 1);
1637 realVal = value.toDouble(&ok);
1639 *width = QTextLength(QTextLength::PercentageLength, realVal);
1644#ifndef QT_NO_CSSPARSER
1647 const QString css =
"* {"_L1 + value + u'}';
1648 QCss::Parser parser(css);
1649 QCss::StyleSheet sheet;
1650 parser.parse(&sheet, Qt::CaseInsensitive);
1651 if (sheet.styleRules.size() != 1)
return;
1652 applyCssDeclarations(sheet.styleRules.at(0).declarations, resourceProvider);
1662 if (hasPrefix(u'>') || hasPrefix(u'/'))
1664 QString key = parseWord().toLower();
1665 QString value =
"1"_L1;
1666 if (key.size() == 0)
1669 if (hasPrefix(u'=')){
1672 value = parseWord();
1674 if (value.size() == 0)
1676 attrs << key << value;
1685 bool seenQt3Richtext =
false;
1689 if (attributes.size() % 2 == 1)
1694 for (
int i = 0; i < attributes.size(); i += 2) {
1695 QString key = attributes.at(i);
1696 QString value = attributes.at(i + 1);
1701 if (key ==
"size"_L1 && value.size()) {
1702 int n = value.toInt();
1703 if (value.at(0) != u'+' && value.at(0) != u'-')
1705 node->charFormat.setProperty(QTextFormat::FontSizeAdjustment, n);
1706 }
else if (key ==
"face"_L1) {
1707 if (value.contains(u',')) {
1708 QStringList families;
1709 for (
auto family : value.tokenize(u','))
1710 families << family.trimmed().toString();
1711 node->charFormat.setFontFamilies(families);
1713 node->charFormat.setFontFamilies(QStringList(value));
1715 }
else if (key ==
"color"_L1) {
1716 QColor c = QColor::fromString(value);
1718 qWarning(
"QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1719 node->charFormat.setForeground(c);
1724 if (key ==
"type"_L1) {
1725 node->hasOwnListStyle =
true;
1726 if (value ==
"1"_L1) {
1727 node->listStyle = QTextListFormat::ListDecimal;
1728 }
else if (value ==
"a"_L1) {
1729 node->listStyle = QTextListFormat::ListLowerAlpha;
1730 }
else if (value ==
"A"_L1) {
1731 node->listStyle = QTextListFormat::ListUpperAlpha;
1732 }
else if (value ==
"i"_L1) {
1733 node->listStyle = QTextListFormat::ListLowerRoman;
1734 }
else if (value ==
"I"_L1) {
1735 node->listStyle = QTextListFormat::ListUpperRoman;
1737 value =
std::move(value).toLower();
1738 if (value ==
"square"_L1)
1739 node->listStyle = QTextListFormat::ListSquare;
1740 else if (value ==
"disc"_L1)
1741 node->listStyle = QTextListFormat::ListDisc;
1742 else if (value ==
"circle"_L1)
1743 node->listStyle = QTextListFormat::ListCircle;
1744 else if (value ==
"none"_L1)
1745 node->listStyle = QTextListFormat::ListStyleUndefined;
1747 }
else if (key ==
"start"_L1) {
1752 if (key ==
"class"_L1) {
1753 if (value ==
"unchecked"_L1)
1754 node->blockFormat.setMarker(QTextBlockFormat::MarkerType::Unchecked);
1755 else if (value ==
"checked"_L1)
1756 node->blockFormat.setMarker(QTextBlockFormat::MarkerType::Checked);
1760 if (key ==
"href"_L1)
1761 node->charFormat.setAnchorHref(value);
1762 else if (key ==
"name"_L1)
1763 node->charFormat.setAnchorNames({value});
1766 if (key ==
"src"_L1 || key ==
"source"_L1) {
1767 node->imageName = value;
1768 }
else if (key ==
"width"_L1) {
1769 node->imageWidth = -2;
1770 setFloatAttribute(&node->imageWidth, value);
1771 }
else if (key ==
"height"_L1) {
1772 node->imageHeight = -2;
1773 setFloatAttribute(&node->imageHeight, value);
1774 }
else if (key ==
"alt"_L1) {
1775 node->imageAlt = value;
1776 }
else if (key ==
"title"_L1) {
1782 if (key ==
"bgcolor"_L1) {
1783 QColor c = QColor::fromString(value);
1785 qWarning(
"QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1786 node->charFormat.setBackground(c);
1787 }
else if (key ==
"background"_L1) {
1788 node->applyBackgroundImage(value, resourceProvider);
1793 if (key ==
"width"_L1) {
1794 setWidthAttribute(&node->width, value);
1795 }
else if (key ==
"bgcolor"_L1) {
1796 QColor c = QColor::fromString(value);
1798 qWarning(
"QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1799 node->charFormat.setBackground(c);
1800 }
else if (key ==
"background"_L1) {
1801 node->applyBackgroundImage(value, resourceProvider);
1802 }
else if (key ==
"rowspan"_L1) {
1805 }
else if (key ==
"colspan"_L1) {
1812 if (key ==
"border"_L1 && !node->tableBorder) {
1813 setFloatAttribute(&node->tableBorder, value);
1814 }
else if (key ==
"bgcolor"_L1) {
1815 QColor c = QColor::fromString(value);
1817 qWarning(
"QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1818 node->charFormat.setBackground(c);
1819 }
else if (key ==
"bordercolor"_L1) {
1820 QColor c = QColor::fromString(value);
1822 qWarning(
"QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1823 node->borderBrush = c;
1824 }
else if (key ==
"background"_L1) {
1825 node->applyBackgroundImage(value, resourceProvider);
1826 }
else if (key ==
"cellspacing"_L1) {
1827 setFloatAttribute(&node->tableCellSpacing, value);
1828 }
else if (key ==
"cellpadding"_L1) {
1829 setFloatAttribute(&node->tableCellPadding, value);
1830 }
else if (key ==
"width"_L1) {
1831 setWidthAttribute(&node->width, value);
1832 }
else if (key ==
"height"_L1) {
1833 setWidthAttribute(&node->height, value);
1837 if (key ==
"name"_L1 && value ==
"qrichtext"_L1)
1838 seenQt3Richtext =
true;
1840 if (key ==
"content"_L1 && value ==
"1"_L1 && seenQt3Richtext)
1844 if (key ==
"width"_L1)
1845 setWidthAttribute(&node->width, value);
1848 if (key ==
"href"_L1)
1850 else if (key ==
"type"_L1)
1854 if (key ==
"class"_L1 && value.startsWith(
"language-"_L1))
1855 node->blockFormat.setProperty(QTextFormat::BlockCodeLanguage, value.mid(9));
1861 if (key ==
"style"_L1) {
1862#ifndef QT_NO_CSSPARSER
1863 node->parseStyleAttribute(value, resourceProvider);
1865 }
else if (key ==
"align"_L1) {
1866 value =
std::move(value).toLower();
1867 bool alignmentSet =
true;
1869 if (value ==
"left"_L1)
1870 node->blockFormat.setAlignment(Qt::AlignLeft|Qt::AlignAbsolute);
1871 else if (value ==
"right"_L1)
1872 node->blockFormat.setAlignment(Qt::AlignRight|Qt::AlignAbsolute);
1873 else if (value ==
"center"_L1)
1874 node->blockFormat.setAlignment(Qt::AlignHCenter);
1875 else if (value ==
"justify"_L1)
1876 node->blockFormat.setAlignment(Qt::AlignJustify);
1878 alignmentSet =
false;
1883 if (node->blockFormat.alignment() & Qt::AlignLeft)
1884 node->cssFloat = QTextFrameFormat::FloatLeft;
1885 else if (node->blockFormat.alignment() & Qt::AlignRight)
1886 node->cssFloat = QTextFrameFormat::FloatRight;
1887 }
else if (value ==
"middle"_L1) {
1888 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
1889 }
else if (value ==
"top"_L1) {
1890 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignTop);
1893 }
else if (key ==
"valign"_L1) {
1894 value =
std::move(value).toLower();
1895 if (value ==
"top"_L1)
1896 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignTop);
1897 else if (value ==
"middle"_L1)
1898 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
1899 else if (value ==
"bottom"_L1)
1900 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignBottom);
1901 }
else if (key ==
"dir"_L1) {
1902 value =
std::move(value).toLower();
1903 if (value ==
"ltr"_L1)
1904 node->blockFormat.setLayoutDirection(Qt::LeftToRight);
1905 else if (value ==
"rtl"_L1)
1906 node->blockFormat.setLayoutDirection(Qt::RightToLeft);
1907 }
else if (key ==
"title"_L1) {
1908 node->charFormat.setToolTip(value);
1909 }
else if (key ==
"id"_L1) {
1910 node->charFormat.setAnchor(
true);
1911 node->charFormat.setAnchorNames({value});
1915#ifndef QT_NO_CSSPARSER
1916 if (resourceProvider && !linkHref.isEmpty() && linkType ==
"text/css"_L1)
1917 importStyleSheet(linkHref);
1921#ifndef QT_NO_CSSPARSER
1926 : parser(parser) { nameCaseSensitivity = Qt::CaseInsensitive; }
1929 QString
attributeValue(NodePtr node,
const QCss::AttributeSelector &aSelector)
const override;
1943 return QStringList(parser
->at(node.id
).tag.toLower());
1948#ifndef QT_NO_CSSPARSER
1950static inline int findAttribute(
const QStringList &attributes,
const QString &name)
1954 idx = attributes.indexOf(name, idx + 1);
1955 }
while (idx != -1 && (idx % 2 == 1));
1961 const QStringList &attributes = parser
->at(node.id
).attributes;
1962 const int idx = findAttribute(attributes, aSelector.name);
1965 return attributes.at(idx + 1);
1970 const QStringList &attributes = parser
->at(node.id
).attributes;
1971 return !attributes.isEmpty();
1976 return node.id == 0;
1984 parent.id = parser
->at(node.id
).parent;
2000 int parent = parser
->at(node.id
).parent;
2003 const int childIdx = parser
->at(parent
).children.indexOf(node.id);
2006 sibling.id = parser
->at(parent
).children.at(childIdx - 1);
2014void QTextHtmlParser::resolveStyleSheetImports(
const QCss::StyleSheet &sheet)
2016 for (
int i = 0; i < sheet.importRules.size(); ++i) {
2017 const QCss::ImportRule &rule = sheet.importRules.at(i);
2018 if (rule.media.isEmpty() || rule.media.contains(
"screen"_L1, Qt::CaseInsensitive))
2019 importStyleSheet(rule.href);
2025 if (!resourceProvider)
2027 for (
int i = 0; i < externalStyleSheets.size(); ++i)
2028 if (externalStyleSheets.at(i).url == href)
2031 QVariant res = resourceProvider->resource(QTextDocument::StyleSheetResource, QUrl{href});
2033 if (res.userType() == QMetaType::QString) {
2034 css = res.toString();
2035 }
else if (res.userType() == QMetaType::QByteArray) {
2037 css = QString::fromUtf8(res.toByteArray());
2039 if (!css.isEmpty()) {
2040 QCss::Parser parser(css);
2041 QCss::StyleSheet sheet;
2042 parser.parse(&sheet, Qt::CaseInsensitive);
2043 externalStyleSheets.append(ExternalStyleSheet(href, sheet));
2044 resolveStyleSheetImports(sheet);
2050 QList<QCss::Declaration> decls;
2051 QCss::Declaration decl;
2056 bool needsUnderline = (node
.id ==
Html_u) ?
true :
false;
2058 for (
int i = 0; i < node.attributes.size(); i += 2) {
2059 const QString key = node.attributes.at(i);
2060 if (key.compare(
"href"_L1, Qt::CaseInsensitive) == 0
2061 && !node.attributes.at(i + 1).isEmpty()) {
2062 needsUnderline =
true;
2063 decl.d->property =
"color"_L1;
2064 decl.d->propertyId = QCss::Color;
2065 val.type = QCss::Value::Function;
2066 val.variant = QStringList() <<
"palette"_L1 <<
"link"_L1;
2067 decl.d->values = QList<QCss::Value> { val };
2068 decl.d->inheritable =
true;
2074 if (needsUnderline) {
2075 decl = QCss::Declaration();
2076 decl.d->property =
"text-decoration"_L1;
2077 decl.d->propertyId = QCss::TextDecoration;
2078 val.type = QCss::Value::KnownIdentifier;
2079 val.variant = QVariant(QCss::Value_Underline);
2080 decl.d->values = QList<QCss::Value> { val };
2081 decl.d->inheritable =
true;
2094 decl = QCss::Declaration();
2095 decl.d->property =
"font-weight"_L1;
2096 decl.d->propertyId = QCss::FontWeight;
2097 val.type = QCss::Value::KnownIdentifier;
2098 val.variant = QVariant(QCss::Value_Bold);
2099 decl.d->values = QList<QCss::Value> { val };
2100 decl.d->inheritable =
true;
2108 decl = QCss::Declaration();
2109 decl.d->property =
"font-size"_L1;
2110 decl.d->propertyId = QCss::FontSize;
2111 decl.d->inheritable =
false;
2112 val.type = QCss::Value::KnownIdentifier;
2114 case Html_h1: val.variant = QVariant(QCss::Value_XXLarge);
break;
2115 case Html_h2: val.variant = QVariant(QCss::Value_XLarge);
break;
2116 case Html_h3:
case Html_big: val.variant = QVariant(QCss::Value_Large);
break;
2117 case Html_h4: val.variant = QVariant(QCss::Value_Medium);
break;
2118 case Html_h5:
case Html_small: val.variant = QVariant(QCss::Value_Small);
break;
2121 decl.d->values = QList<QCss::Value> { val };
2128 decl = QCss::Declaration();
2129 decl.d->property =
"text-align"_L1;
2130 decl.d->propertyId = QCss::TextAlignment;
2131 val.type = QCss::Value::KnownIdentifier;
2132 val.variant = (node.id == Html_td) ? QVariant(QCss::Value_Left) : QVariant(QCss::Value_Center);
2133 decl.d->values = QList<QCss::Value> { val };
2134 decl.d->inheritable =
true;
2139 decl = QCss::Declaration();
2140 decl.d->property =
"text-decoration"_L1;
2141 decl.d->propertyId = QCss::TextDecoration;
2142 val.type = QCss::Value::KnownIdentifier;
2143 val.variant = QVariant(QCss::Value_LineThrough);
2144 decl.d->values = QList<QCss::Value> { val };
2145 decl.d->inheritable =
true;
2154 decl = QCss::Declaration();
2155 decl.d->property =
"font-style"_L1;
2156 decl.d->propertyId = QCss::FontStyle;
2157 val.type = QCss::Value::KnownIdentifier;
2158 val.variant = QVariant(QCss::Value_Italic);
2159 decl.d->values = QList<QCss::Value> { val };
2160 decl.d->inheritable =
true;
2165 decl = QCss::Declaration();
2166 decl.d->property =
"vertical-align"_L1;
2167 decl.d->propertyId = QCss::VerticalAlignment;
2168 val.type = QCss::Value::KnownIdentifier;
2169 val.variant = (node.id == Html_sub) ? QVariant(QCss::Value_Sub) : QVariant(QCss::Value_Super);
2170 decl.d->values = QList<QCss::Value> { val };
2171 decl.d->inheritable =
true;
2176 decl = QCss::Declaration();
2177 decl.d->property =
"list-style"_L1;
2178 decl.d->propertyId = QCss::ListStyle;
2179 val.type = QCss::Value::KnownIdentifier;
2180 val.variant = (node.id == Html_ul) ? QVariant(QCss::Value_Disc) : QVariant(QCss::Value_Decimal);
2181 decl.d->values = QList<QCss::Value> { val };
2182 decl.d->inheritable =
true;
2190 decl = QCss::Declaration();
2191 decl.d->property =
"font-family"_L1;
2192 decl.d->propertyId = QCss::FontFamily;
2193 QList<QCss::Value> values;
2194 val.type = QCss::Value::String;
2195 val.variant = QFontDatabase::systemFont(QFontDatabase::FixedFont).families().constFirst();
2197 decl.d->values = values;
2198 decl.d->inheritable =
true;
2206 decl = QCss::Declaration();
2207 decl.d->property =
"whitespace"_L1;
2208 decl.d->propertyId = QCss::Whitespace;
2209 val.type = QCss::Value::KnownIdentifier;
2211 case Html_br: val.variant = QVariant(QCss::Value_PreWrap);
break;
2212 case Html_nobr: val.variant = QVariant(QCss::Value_NoWrap);
break;
2213 case Html_pre: val.variant = QVariant(QCss::Value_Pre);
break;
2216 decl.d->values = QList<QCss::Value> { val };
2217 decl.d->inheritable =
true;
2226QList<QCss::Declaration>
QTextHtmlParser::declarationsForNode(
int node)
const
2228 QList<QCss::Declaration> decls;
2233 selector.styleSheets.resize((resourceProvider ? 1 : 0)
2234 + externalStyleSheets.size()
2235 + inlineStyleSheets.size());
2236 if (resourceProvider)
2237 selector.styleSheets[idx++] = QTextDocumentPrivate::get(resourceProvider)->parsedDefaultStyleSheet;
2239 for (
int i = 0; i < externalStyleSheets.size(); ++i, ++idx)
2240 selector.styleSheets[idx] = externalStyleSheets.at(i).sheet;
2242 for (
int i = 0; i < inlineStyleSheets.size(); ++i, ++idx)
2243 selector.styleSheets[idx] = inlineStyleSheets.at(i);
2245 selector.medium = resourceProvider ? resourceProvider->metaInformation(QTextDocument::CssMedia) :
"screen"_L1;
2247 QCss::StyleSelector::NodePtr n;
2250 const char *extraPseudo =
nullptr;
2251 if (nodes.at(node)->id == Html_a && nodes.at(node)->hasHref)
2252 extraPseudo =
"link";
2254 decls = standardDeclarationForNode(*nodes.at(node));
2255 decls += selector.declarationsForNode(n, extraPseudo);
2256 n = selector.parentNode(n);
2257 while (!selector.isNullNode(n)) {
2258 QList<QCss::Declaration> inheritedDecls;
2259 inheritedDecls = selector.declarationsForNode(n, extraPseudo);
2260 for (
int i = 0; i < inheritedDecls.size(); ++i) {
2261 const QCss::Declaration &decl = inheritedDecls.at(i);
2262 if (decl.d->inheritable)
2263 decls.prepend(decl);
2265 n = selector.parentNode(n);
void parseExclamationTag()
bool nodeIsChildOf(int i, QTextHTMLElements id) const
QTextHtmlParserNode * resolveParent()
void applyAttributes(const QStringList &attributes)
int margin(int i, int mar) const
int topMargin(int i) const
const QTextHtmlParserNode & at(int i) const
QStringList parseAttributes()
int bottomMargin(int i) const
QTextHtmlParserNode * newNode(int parent)
NodePtr previousSiblingNode(NodePtr node) const override
bool isNullNode(NodePtr node) const override
QString attributeValue(NodePtr node, const QCss::AttributeSelector &aSelector) const override
bool hasAttributes(NodePtr node) const override
NodePtr duplicateNode(NodePtr node) const override
QTextHtmlStyleSelector(const QTextHtmlParser *parser)
void freeNode(NodePtr node) const override
NodePtr parentNode(NodePtr node) const override
QStringList nodeNames(NodePtr node) const override
static int findAttribute(const QStringList &attributes, const QString &name)
static bool operator<(QStringView entityStr, const QTextHtmlEntity &entity)
static bool operator<(const QTextHtmlEntity &entity, QStringView entityStr)
QList< QCss::Declaration > standardDeclarationForNode(const QTextHtmlParserNode &node)
static const QTextHtmlElement elements[Html_NumElements]
static bool operator<(QStringView str, const QTextHtmlElement &e)
static bool setFloatAttribute(qreal *destination, const QString &value)
static const QTextHtmlElement * lookupElementHelper(QStringView element)
static QTextFrameFormat::BorderStyle toQTextFrameFormat(QCss::BorderStyle cssStyle)
static void setWidthAttribute(QTextLength *width, const QString &valueStr)
static const ushort windowsLatin1ExtendedCharacters[0xA0 - 0x80]
static bool operator<(const QTextHtmlElement &e, QStringView str)
static bool setIntAttribute(int *destination, const QString &value)
static QChar resolveEntity(QStringView entity)
static QString quoteNewline(const QString &s)
bool isNotSelfNesting() const
void initializeProperties(const QTextHtmlParserNode *parent, const QTextHtmlParser *parser)
bool hasOnlyWhitespace() const
bool isNestedList(const QTextHtmlParser *parser) const
bool allowedInContext(int parentId) const
@ WhiteSpaceModeUndefined
void applyForegroundImage(qint64 cacheKey, const QTextDocument *resourceProvider)
bool mayNotHaveChildren() const