10#include <qguiapplication.h>
20#ifndef QT_NO_TEXTHTMLPARSER
24using namespace Qt::StringLiterals;
47 {
"Epsilon", 0x0395 },
68 {
"Omicron", 0x039f },
86 {
"Upsilon", 0x03a5 },
97 {
"alefsym", 0x2135 },
105 {
"atilde", 0x00e3 },
109 {
"brvbar", 0x00a6 },
112 {
"ccedil", 0x00e7 },
122 {
"curren", 0x00a4 },
124 {
"dagger", 0x2020 },
129 {
"divide", 0x00f7 },
130 {
"eacute", 0x00e9 },
132 {
"egrave", 0x00e8 },
136 {
"epsilon", 0x03b5 },
144 {
"forall", 0x2200 },
145 {
"frac12", 0x00bd },
146 {
"frac14", 0x00bc },
147 {
"frac34", 0x00be },
154 {
"hearts", 0x2665 },
155 {
"hellip", 0x2026 },
156 {
"iacute", 0x00ed },
159 {
"igrave", 0x00ec },
164 {
"iquest", 0x00bf },
169 {
"lambda", 0x03bb },
176 {
"lfloor", 0x230a },
177 {
"lowast", 0x2217 },
180 {
"lsaquo", 0x2039 },
186 {
"middot", 0x00b7 },
197 {
"ntilde", 0x00f1 },
199 {
"oacute", 0x00f3 },
202 {
"ograve", 0x00f2 },
205 {
"omicron", 0x03bf },
210 {
"oslash", 0x00f8 },
211 {
"otilde", 0x00f5 },
212 {
"otimes", 0x2297 },
216 {
"percnt", 0x0025 },
217 {
"permil", 0x2030 },
222 {
"plusmn", 0x00b1 },
238 {
"rfloor", 0x230b },
241 {
"rsaquo", 0x203a },
244 {
"scaron", 0x0161 },
249 {
"sigmaf", 0x03c2 },
251 {
"spades", 0x2660 },
262 {
"there4", 0x2234 },
264 {
"thetasym", 0x03d1 },
265 {
"thinsp", 0x2009 },
271 {
"uacute", 0x00fa },
274 {
"ugrave", 0x00f9 },
277 {
"upsilon", 0x03c5 },
279 {
"weierp", 0x2118 },
281 {
"yacute", 0x00fd },
288static_assert(
MAX_ENTITY ==
sizeof entities /
sizeof *entities);
290#if defined(Q_CC_MSVC_ONLY) && _MSC_VER < 1600
291bool operator<(
const QTextHtmlEntity &entity1,
const QTextHtmlEntity &entity2)
293 return QLatin1StringView(entity1.name) < QLatin1StringView(entity2.name);
299 return entityStr < QLatin1StringView(entity
.name);
304 return QLatin1StringView(entity
.name) < entityStr;
312 if (e == end || (entity < *e))
418 return str < QLatin1StringView(e
.name);
423 return QLatin1StringView(e
.name) < str;
431 if ((e == end) || (element < *e))
448 n.replace(u'\n',
"\\n"_L1);
468 for (
int i = 0; i < 4; ++i) {
469 tableCellBorderStyle[i] = QTextFrameFormat::BorderStyle_None;
470 tableCellBorder[i] = 0;
471 tableCellBorderBrush[i] = Qt::NoBrush;
477 for (
int i = 0; i <
count(); ++i) {
478 qDebug().nospace() << qPrintable(QString(depth(i) * 4, u' '))
479 << qPrintable(at(i).tag) <<
':'
480 << quoteNewline(at(i).text);
489 bool reuseLastNode =
true;
491 if (nodes.size() == 1) {
492 reuseLastNode =
false;
493 }
else if (lastNode->tag.isEmpty()) {
495 if (lastNode->text.isEmpty()) {
496 reuseLastNode =
true;
499 if (lastNode->text.size() == 1 && lastNode->text.at(0).isSpace()) {
509 reuseLastNode =
false;
511 reuseLastNode =
true;
515 reuseLastNode =
false;
522 reuseLastNode =
false;
527 newNode->tag.clear();
528 newNode->text.clear();
531 nodes.append(
new QTextHtmlParserNode);
532 newNode = nodes.last();
539void QTextHtmlParser::parse(
const QString &text,
const QTextDocument *_resourceProvider)
543 nodes.append(
new QTextHtmlParserNode);
548 resourceProvider = _resourceProvider;
597 while (pos < len && txt.at(pos).isSpace() && txt.at(pos) != QChar::ParagraphSeparator)
604 QChar c = txt.at(pos++);
607 }
else if (c == u'&') {
608 nodes.last()->text += parseEntity();
610 nodes.last()->text += c;
621 if (hasPrefix(u'!')) {
623 if (nodes.last()->wsm != QTextHtmlParserNode::WhiteSpacePre
624 && nodes.last()->wsm != QTextHtmlParserNode::WhiteSpacePreWrap
631 if (hasPrefix(u'/')) {
632 if (nodes.last()->id == Html_style) {
633#ifndef QT_NO_CSSPARSER
634 QCss::Parser parser(nodes.constLast()->text);
635 QCss::StyleSheet sheet;
636 sheet.origin = QCss::StyleSheetOrigin_Author;
637 parser.parse(&sheet, Qt::CaseInsensitive);
638 inlineStyleSheets.append(sheet);
639 resolveStyleSheetImports(sheet);
647 while (p &&
at(p
).tag.size() == 0)
653 node->tag = parseWord().toLower();
658 node->displayMode = elem->displayMode;
663 node->attributes.clear();
665 if (pos < len && txt.at(pos).isSpace())
666 node->attributes = parseAttributes();
674#ifndef QT_NO_CSSPARSER
675 const int nodeIndex = nodes.size() - 1;
676 node->applyCssDeclarations(declarationsForNode(nodeIndex), resourceProvider);
678 applyAttributes(node->attributes);
681 bool tagClosed =
false;
682 while (pos < len && txt.at(pos) != u'>') {
683 if (txt.at(pos) == u'/')
696 if (pos < len - 1 && txt.at(pos) == u'\n')
710 QString tag = parseWord().toLower().trimmed();
712 QChar c = txt.at(pos++);
720 &&
at(p - 1
).tag == tag
724 while (p &&
at(p
).tag != tag)
741 if (at(last()).text.endsWith(u'\n'))
742 nodes[last()]->text.chop(1);
753 if (hasPrefix(u'-') && hasPrefix(u'-', 1)) {
756 int end = txt.indexOf(
"-->"_L1, pos);
757 pos = (end >= 0 ? end + 3 :
len);
761 QChar c = txt.at(pos++);
770 QChar resolved = resolveEntity(entity);
771 if (!resolved.isNull())
772 return QString(resolved);
774 if (entity.size() > 1 && entity.at(0) == u'#') {
775 entity = entity.mid(1);
780 if (entity.at(0).toLower() == u'x') {
781 entity = entity.mid(1);
785 uint uc = entity.toUInt(&ok, base);
789 return QStringView{QChar::fromUcs4(uc)}.toString();
798 const int recover =
pos;
801 QChar c = txt.at(pos++);
802 if (c.isSpace() ||
pos - recover > 9) {
810 const QStringView entity = QStringView(txt).mid(recover, entityLen);
811 QString parsedEntity = parseEntity(entity);
812 if (!parsedEntity.isNull()) {
825 if (hasPrefix(u'\"')) {
828 QChar c = txt.at(pos++);
832 word += parseEntity();
836 }
else if (hasPrefix(u'\'')) {
839 QChar c = txt.at(pos++);
841 if (c == u'\'' && (txt.size() > 1 && txt.at(pos - 2) != u'\\'))
848 QChar c = txt.at(pos++);
849 if (c == u'>' || (c == u'/' && hasPrefix(u'>'))
850 || c == u'<' || c == u'=' || c.isSpace()) {
855 word += parseEntity();
879 nodes.insert(nodes.size() - 1,
new QTextHtmlParserNode);
880 nodes.insert(nodes.size() - 1,
new QTextHtmlParserNode);
885 table->tag =
"table"_L1;
886 table->children.append(nodes.size() - 2);
889 row->parent = nodes.size() - 3;
893 p = nodes.size() - 2;
904 nodes.insert(nodes.size() - 1,
new QTextHtmlParserNode);
908 table->tag =
"table"_L1;
909 p = nodes.size() - 2;
957 nodes[p]->children.append(nodes.size() - 1);
986 charFormat = parent->charFormat;
989 blockFormat.setLayoutDirection(Qt::LeftToRight);
990 else if (parent->blockFormat.hasProperty(QTextFormat::LayoutDirection))
991 blockFormat.setLayoutDirection(parent->blockFormat.layoutDirection());
993 if (parent->displayMode == QTextHtmlElement::DisplayNone)
994 displayMode = QTextHtmlElement::DisplayNone;
997 if (parent->blockFormat.hasProperty(QTextFormat::BlockAlignment))
998 blockFormat.setAlignment(parent->blockFormat.alignment());
1000 blockFormat.clearProperty(QTextFormat::BlockAlignment);
1006 if ((parent->id != Html_tr || !isTableCell())
1007 && (displayMode != QTextHtmlElement::DisplayInline || parent->displayMode != QTextHtmlElement::DisplayInline)
1008 && (parent->id == Html_body || displayMode != QTextHtmlElement::DisplayBlock || parent->displayMode != QTextHtmlElement::DisplayBlock)
1010 charFormat.clearProperty(QTextFormat::BackgroundBrush);
1013 listStyle = parent->listStyle;
1016 charFormat.clearProperty(QTextFormat::AnchorName);
1024 cssFloat = QTextFrameFormat::InFlow;
1026 for (
int i = 0; i < 4; ++i)
1032 for (
int i = 0; i < attributes.size(); i += 2) {
1033 const QString key = attributes.at(i);
1034 if (key.compare(
"href"_L1, Qt::CaseInsensitive) == 0
1035 && !attributes.at(i + 1).isEmpty()) {
1039 charFormat.setAnchor(
true);
1042 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(1));
1045 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(-1));
1048 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(3));
1053 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(2));
1058 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(1));
1063 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(0));
1068 charFormat.setProperty(QTextFormat::FontSizeAdjustment,
int(-1));
1093 text = QChar(QChar::LineSeparator);
1104 blockFormat.setProperty(QTextFormat::BlockQuoteLevel, 1);
1117#ifndef QT_NO_CSSPARSER
1120 for (
int i = 0; i < cssValues.size(); ++i) {
1121 if (cssValues.at(i).type == QCss::Value::KnownIdentifier) {
1122 switch (
static_cast<QCss::KnownValue>(cssValues.at(i).variant.toInt())) {
1123 case QCss::Value_None: hasOwnListStyle =
true; listStyle = QTextListFormat::ListStyleUndefined;
break;
1124 case QCss::Value_Disc: hasOwnListStyle =
true; listStyle = QTextListFormat::ListDisc;
break;
1125 case QCss::Value_Square: hasOwnListStyle =
true; listStyle = QTextListFormat::ListSquare;
break;
1126 case QCss::Value_Circle: hasOwnListStyle =
true; listStyle = QTextListFormat::ListCircle;
break;
1127 case QCss::Value_Decimal: hasOwnListStyle =
true; listStyle = QTextListFormat::ListDecimal;
break;
1128 case QCss::Value_LowerAlpha: hasOwnListStyle =
true; listStyle = QTextListFormat::ListLowerAlpha;
break;
1129 case QCss::Value_UpperAlpha: hasOwnListStyle =
true; listStyle = QTextListFormat::ListUpperAlpha;
break;
1130 case QCss::Value_LowerRoman: hasOwnListStyle =
true; listStyle = QTextListFormat::ListLowerRoman;
break;
1131 case QCss::Value_UpperRoman: hasOwnListStyle =
true; listStyle = QTextListFormat::ListUpperRoman;
break;
1137 if (id == Html_li && hasOwnListStyle)
1138 blockFormat.setProperty(QTextFormat::ListStyle, listStyle);
1144 case QCss::BorderStyle::BorderStyle_Dotted:
1145 return QTextFrameFormat::BorderStyle::BorderStyle_Dotted;
1146 case QCss::BorderStyle::BorderStyle_Dashed:
1147 return QTextFrameFormat::BorderStyle::BorderStyle_Dashed;
1148 case QCss::BorderStyle::BorderStyle_Solid:
1149 return QTextFrameFormat::BorderStyle::BorderStyle_Solid;
1150 case QCss::BorderStyle::BorderStyle_Double:
1151 return QTextFrameFormat::BorderStyle::BorderStyle_Double;
1152 case QCss::BorderStyle::BorderStyle_DotDash:
1153 return QTextFrameFormat::BorderStyle::BorderStyle_DotDash;
1154 case QCss::BorderStyle::BorderStyle_DotDotDash:
1155 return QTextFrameFormat::BorderStyle::BorderStyle_DotDotDash;
1156 case QCss::BorderStyle::BorderStyle_Groove:
1157 return QTextFrameFormat::BorderStyle::BorderStyle_Groove;
1158 case QCss::BorderStyle::BorderStyle_Ridge:
1159 return QTextFrameFormat::BorderStyle::BorderStyle_Ridge;
1160 case QCss::BorderStyle::BorderStyle_Inset:
1161 return QTextFrameFormat::BorderStyle::BorderStyle_Inset;
1162 case QCss::BorderStyle::BorderStyle_Outset:
1163 return QTextFrameFormat::BorderStyle::BorderStyle_Outset;
1164 case QCss::BorderStyle::BorderStyle_Unknown:
1165 case QCss::BorderStyle::BorderStyle_None:
1166 case QCss::BorderStyle::BorderStyle_Native:
1167 return QTextFrameFormat::BorderStyle::BorderStyle_None;
1168 case QCss::BorderStyle::NumKnownBorderStyles:
1176 return static_cast<QTextFrameFormat::BorderStyle>(-1);
1179void QTextHtmlParserNode::applyCssDeclarations(
const QList<QCss::Declaration> &declarations,
const QTextDocument *resourceProvider)
1181 QCss::ValueExtractor extractor(declarations);
1182 extractor.extractBox(margin, padding);
1184 auto getBorderValues = [&extractor](qreal *borderWidth, QBrush *borderBrush, QTextFrameFormat::BorderStyle *borderStyles) {
1185 QCss::BorderStyle cssStyles[4];
1188 for (
int i = 0; i < 4; ++i) {
1189 cssStyles[i] = QCss::BorderStyle_None;
1196 bool hit = extractor.extractBorder(cssBorder, borderBrush, cssStyles, cssRadii);
1197 for (
int i = 0; i < 4; ++i) {
1198 borderStyles[i] = toQTextFrameFormat(cssStyles[i]);
1199 borderWidth[i] =
static_cast<qreal>(cssBorder[i]);
1204 if (id == Html_td || id == Html_th)
1205 getBorderValues(tableCellBorder, tableCellBorderBrush, tableCellBorderStyle);
1207 for (
int i = 0; i < declarations.size(); ++i) {
1208 const QCss::Declaration &decl = declarations.at(i);
1209 if (decl.d->values.isEmpty())
continue;
1211 QCss::KnownValue identifier = QCss::UnknownValue;
1212 if (decl.d->values.constFirst().type == QCss::Value::KnownIdentifier)
1213 identifier =
static_cast<QCss::KnownValue>(decl.d->values.constFirst().variant.toInt());
1215 switch (decl.d->propertyId) {
1216 case QCss::BorderColor: {
1217 QBrush bordersBrush[4];
1218 decl.brushValues(bordersBrush);
1219 if (bordersBrush[0].color().isValid())
1220 borderBrush = bordersBrush[0];
1223 case QCss::BorderStyles:
1224 if (decl.styleValue() != QCss::BorderStyle_Unknown && decl.styleValue() != QCss::BorderStyle_Native)
1225 borderStyle =
static_cast<QTextFrameFormat::BorderStyle>(decl.styleValue() - 1);
1227 case QCss::BorderWidth: {
1229 extractor.lengthValues(decl, borders);
1230 tableBorder = borders[0];
1233 case QCss::Border: {
1235 QBrush tblBorderBrush[4];
1236 QTextFrameFormat::BorderStyle tblBorderStyle[4];
1237 if (getBorderValues(tblBorder, tblBorderBrush, tblBorderStyle)) {
1238 tableBorder = tblBorder[0];
1239 if (tblBorderBrush[0].color().isValid())
1240 borderBrush = tblBorderBrush[0];
1241 if (tblBorderStyle[0] !=
static_cast<QTextFrameFormat::BorderStyle>(-1))
1242 borderStyle = tblBorderStyle[0];
1246 case QCss::BorderCollapse:
1249 case QCss::Color: charFormat.setForeground(decl.colorValue());
break;
1251 cssFloat = QTextFrameFormat::InFlow;
1252 switch (identifier) {
1253 case QCss::Value_Left: cssFloat = QTextFrameFormat::FloatLeft;
break;
1254 case QCss::Value_Right: cssFloat = QTextFrameFormat::FloatRight;
break;
1258 case QCss::QtBlockIndent:
1259 blockFormat.setIndent(decl.d->values.constFirst().variant.toInt());
1261 case QCss::QtLineHeightType: {
1262 QString lineHeightTypeName = decl.d->values.constFirst().variant.toString();
1263 QTextBlockFormat::LineHeightTypes lineHeightType;
1264 if (lineHeightTypeName.compare(
"proportional"_L1, Qt::CaseInsensitive) == 0)
1265 lineHeightType = QTextBlockFormat::ProportionalHeight;
1266 else if (lineHeightTypeName.compare(
"fixed"_L1, Qt::CaseInsensitive) == 0)
1267 lineHeightType = QTextBlockFormat::FixedHeight;
1268 else if (lineHeightTypeName.compare(
"minimum"_L1, Qt::CaseInsensitive) == 0)
1269 lineHeightType = QTextBlockFormat::MinimumHeight;
1270 else if (lineHeightTypeName.compare(
"line-distance"_L1, Qt::CaseInsensitive) == 0)
1271 lineHeightType = QTextBlockFormat::LineDistanceHeight;
1273 lineHeightType = QTextBlockFormat::SingleHeight;
1275 if (hasLineHeightMultiplier) {
1276 qreal lineHeight = blockFormat.lineHeight() / 100.0;
1277 blockFormat.setProperty(QTextBlockFormat::LineHeight, lineHeight);
1280 blockFormat.setProperty(QTextBlockFormat::LineHeightType, lineHeightType);
1281 hasOwnLineHeightType =
true;
1284 case QCss::LineHeight: {
1286 QTextBlockFormat::LineHeightTypes lineHeightType;
1287 if (decl.realValue(&lineHeight,
"px")) {
1288 lineHeightType = QTextBlockFormat::MinimumHeight;
1291 QCss::Value cssValue = decl.d->values.constFirst();
1292 QString value = cssValue.toString();
1293 lineHeight = value.toDouble(&ok);
1295 if (!hasOwnLineHeightType && cssValue.type == QCss::Value::Number) {
1296 lineHeight *= 100.0;
1297 hasLineHeightMultiplier =
true;
1299 lineHeightType = QTextBlockFormat::ProportionalHeight;
1302 lineHeightType = QTextBlockFormat::SingleHeight;
1307 if (hasOwnLineHeightType)
1308 lineHeightType = QTextBlockFormat::LineHeightTypes(blockFormat.lineHeightType());
1310 blockFormat.setLineHeight(lineHeight, lineHeightType);
1313 case QCss::TextIndent: {
1315 if (decl.realValue(&indent,
"px"))
1316 blockFormat.setTextIndent(indent);
1318 case QCss::QtListIndent:
1319 if (decl.intValue(&cssListIndent))
1320 hasCssListIndent =
true;
1322 case QCss::QtParagraphType:
1323 if (decl.d->values.constFirst().variant.toString().compare(
"empty"_L1, Qt::CaseInsensitive) == 0)
1324 isEmptyParagraph =
true;
1326 case QCss::QtTableType:
1327 if (decl.d->values.constFirst().variant.toString().compare(
"frame"_L1, Qt::CaseInsensitive) == 0)
1329 else if (decl.d->values.constFirst().variant.toString().compare(
"root"_L1, Qt::CaseInsensitive) == 0) {
1334 case QCss::QtUserState:
1335 userState = decl.d->values.constFirst().variant.toInt();
1337 case QCss::Whitespace:
1338 switch (identifier) {
1347 case QCss::VerticalAlignment:
1348 switch (identifier) {
1349 case QCss::Value_Sub: charFormat.setVerticalAlignment(QTextCharFormat::AlignSubScript);
break;
1350 case QCss::Value_Super: charFormat.setVerticalAlignment(QTextCharFormat::AlignSuperScript);
break;
1351 case QCss::Value_Middle: charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
break;
1352 case QCss::Value_Top: charFormat.setVerticalAlignment(QTextCharFormat::AlignTop);
break;
1353 case QCss::Value_Bottom: charFormat.setVerticalAlignment(QTextCharFormat::AlignBottom);
break;
1354 default: charFormat.setVerticalAlignment(QTextCharFormat::AlignNormal);
break;
1357 case QCss::PageBreakBefore:
1358 switch (identifier) {
1359 case QCss::Value_Always: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() | QTextFormat::PageBreak_AlwaysBefore);
break;
1360 case QCss::Value_Auto: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() & ~QTextFormat::PageBreak_AlwaysBefore);
break;
1364 case QCss::PageBreakAfter:
1365 switch (identifier) {
1366 case QCss::Value_Always: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() | QTextFormat::PageBreak_AlwaysAfter);
break;
1367 case QCss::Value_Auto: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() & ~QTextFormat::PageBreak_AlwaysAfter);
break;
1371 case QCss::TextUnderlineStyle:
1372 switch (identifier) {
1373 case QCss::Value_None: charFormat.setUnderlineStyle(QTextCharFormat::NoUnderline);
break;
1374 case QCss::Value_Solid: charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
break;
1375 case QCss::Value_Dashed: charFormat.setUnderlineStyle(QTextCharFormat::DashUnderline);
break;
1376 case QCss::Value_Dotted: charFormat.setUnderlineStyle(QTextCharFormat::DotLine);
break;
1377 case QCss::Value_DotDash: charFormat.setUnderlineStyle(QTextCharFormat::DashDotLine);
break;
1378 case QCss::Value_DotDotDash: charFormat.setUnderlineStyle(QTextCharFormat::DashDotDotLine);
break;
1379 case QCss::Value_Wave: charFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline);
break;
1383 case QCss::TextDecorationColor: charFormat.setUnderlineColor(decl.colorValue());
break;
1384 case QCss::ListStyleType:
1385 case QCss::ListStyle:
1386 setListStyle(decl.d->values);
1388 case QCss::QtListNumberPrefix:
1389 textListNumberPrefix = decl.d->values.constFirst().variant.toString();
1391 case QCss::QtListNumberSuffix:
1392 textListNumberSuffix = decl.d->values.constFirst().variant.toString();
1394 case QCss::TextAlignment:
1395 switch (identifier) {
1396 case QCss::Value_Left: blockFormat.setAlignment(Qt::AlignLeft);
break;
1397 case QCss::Value_Center: blockFormat.setAlignment(Qt::AlignCenter);
break;
1398 case QCss::Value_Right: blockFormat.setAlignment(Qt::AlignRight);
break;
1403 case QCss::QtForegroundTextureCacheKey:
1405 if (resourceProvider !=
nullptr && QTextDocumentPrivate::get(resourceProvider) !=
nullptr) {
1407 qint64 searchKey = decl.d->values.constFirst().variant.toLongLong(&ok);
1409 applyForegroundImage(searchKey, resourceProvider);
1413 case QCss::QtStrokeColor:
1415 QPen pen = charFormat.textOutline();
1416 pen.setStyle(Qt::SolidLine);
1417 pen.setColor(decl.colorValue());
1418 charFormat.setTextOutline(pen);
1421 case QCss::QtStrokeWidth:
1424 if (decl.realValue(&width,
"px")) {
1425 QPen pen = charFormat.textOutline();
1426 pen.setWidthF(width);
1427 charFormat.setTextOutline(pen);
1431 case QCss::QtStrokeLineCap:
1433 QPen pen = charFormat.textOutline();
1434 switch (identifier) {
1435 case QCss::Value_SquareCap: pen.setCapStyle(Qt::SquareCap);
break;
1436 case QCss::Value_FlatCap: pen.setCapStyle(Qt::FlatCap);
break;
1437 case QCss::Value_RoundCap: pen.setCapStyle(Qt::RoundCap);
break;
1440 charFormat.setTextOutline(pen);
1443 case QCss::QtStrokeLineJoin:
1445 QPen pen = charFormat.textOutline();
1446 switch (identifier) {
1447 case QCss::Value_MiterJoin: pen.setJoinStyle(Qt::MiterJoin);
break;
1448 case QCss::Value_BevelJoin: pen.setJoinStyle(Qt::BevelJoin);
break;
1449 case QCss::Value_RoundJoin: pen.setJoinStyle(Qt::RoundJoin);
break;
1450 case QCss::Value_SvgMiterJoin: pen.setJoinStyle(Qt::SvgMiterJoin);
break;
1453 charFormat.setTextOutline(pen);
1456 case QCss::QtStrokeMiterLimit:
1459 if (decl.realValue(&miterLimit)) {
1460 QPen pen = charFormat.textOutline();
1461 pen.setMiterLimit(miterLimit);
1462 charFormat.setTextOutline(pen);
1466 case QCss::QtStrokeDashArray:
1468 QList<qreal> dashes = decl.dashArray();
1469 if (!dashes.empty()) {
1470 QPen pen = charFormat.textOutline();
1471 pen.setDashPattern(dashes);
1472 charFormat.setTextOutline(pen);
1476 case QCss::QtStrokeDashOffset:
1479 if (decl.realValue(&dashOffset)) {
1480 QPen pen = charFormat.textOutline();
1481 pen.setDashOffset(dashOffset);
1482 charFormat.setTextOutline(pen);
1486 case QCss::QtForeground:
1488 QBrush brush = decl.brushValue();
1489 charFormat.setForeground(brush);
1492 case QCss::MaximumWidth:
1494 auto imageFormat = charFormat.toImageFormat();
1495 imageFormat.setMaximumWidth(extractor.textLength(decl));
1496 charFormat = imageFormat;
1504 int adjustment = -255;
1505 extractor.extractFont(&f, &adjustment);
1506 if (f.pixelSize() > INT32_MAX / 2)
1507 f.setPixelSize(INT32_MAX / 2);
1508 charFormat.setFont(f, QTextCharFormat::FontPropertiesSpecifiedOnly);
1510 if (adjustment >= -1)
1511 charFormat.setProperty(QTextFormat::FontSizeAdjustment, adjustment);
1514 Qt::Alignment ignoredAlignment;
1515 QCss::Repeat ignoredRepeat;
1518 QCss::Origin ignoredOrigin, ignoredClip;
1519 QCss::Attachment ignoredAttachment;
1520 extractor.extractBackground(&bgBrush, &bgImage, &ignoredRepeat, &ignoredAlignment,
1521 &ignoredOrigin, &ignoredAttachment, &ignoredClip);
1523 if (!bgImage.isEmpty() && resourceProvider) {
1524 applyBackgroundImage(bgImage, resourceProvider);
1525 }
else if (bgBrush.style() != Qt::NoBrush) {
1526 charFormat.setBackground(bgBrush);
1528 blockFormat.setProperty(QTextFormat::BackgroundBrush, bgBrush);
1537 const QTextDocumentPrivate *priv = QTextDocumentPrivate::get(resourceProvider);
1538 for (
int i = 0; i < priv->formats.numFormats(); ++i) {
1539 QTextCharFormat format = priv->formats.charFormat(i);
1540 if (format.isValid()) {
1541 QBrush brush = format.foreground();
1542 if (brush.style() == Qt::TexturePattern) {
1543 const bool isPixmap = qHasPixmapTexture(brush);
1545 if (isPixmap && QCoreApplication::instance()->thread() != QThread::currentThread()) {
1546 qWarning(
"Can't apply QPixmap outside of GUI thread");
1550 const qint64 cacheKey = isPixmap ? brush.texture().cacheKey() : brush.textureImage().cacheKey();
1551 if (cacheKey == searchKey) {
1554 b.setTexture(brush.texture());
1556 b.setTextureImage(brush.textureImage());
1557 b.setStyle(Qt::TexturePattern);
1558 charFormat.setForeground(b);
1568 if (!url.isEmpty() && resourceProvider) {
1569 QVariant val = resourceProvider->resource(QTextDocument::ImageResource, url);
1571 if (QCoreApplication::instance()->thread() != QThread::currentThread()) {
1573 if (val.userType() == QMetaType::QImage) {
1574 QImage image = qvariant_cast<QImage>(val);
1575 charFormat.setBackground(image);
1576 }
else if (val.userType() == QMetaType::QByteArray) {
1578 if (image.loadFromData(val.toByteArray())) {
1579 charFormat.setBackground(image);
1583 if (val.userType() == QMetaType::QImage || val.userType() == QMetaType::QPixmap) {
1584 charFormat.setBackground(qvariant_cast<QPixmap>(val));
1585 }
else if (val.userType() == QMetaType::QByteArray) {
1587 if (pm.loadFromData(val.toByteArray())) {
1588 charFormat.setBackground(pm);
1594 charFormat.setProperty(QTextFormat::BackgroundImageUrl, url);
1599 for (
int i = 0; i < text.size(); ++i)
1600 if (!text.at(i).isSpace() || text.at(i) == QChar::LineSeparator)
1608 int val = value.toInt(&ok);
1618 qreal val = value.toDouble(&ok);
1628 qreal realVal = valueStr.toDouble(&ok);
1630 *width = QTextLength(QTextLength::FixedLength, realVal);
1632 auto value = QStringView(valueStr).trimmed();
1633 if (!value.isEmpty() && value.endsWith(u'%')) {
1634 value.truncate(value.size() - 1);
1635 realVal = value.toDouble(&ok);
1637 *width = QTextLength(QTextLength::PercentageLength, realVal);
1642#ifndef QT_NO_CSSPARSER
1645 const QString css =
"* {"_L1 + value + u'}';
1646 QCss::Parser parser(css);
1647 QCss::StyleSheet sheet;
1648 parser.parse(&sheet, Qt::CaseInsensitive);
1649 if (sheet.styleRules.size() != 1)
return;
1650 applyCssDeclarations(sheet.styleRules.at(0).declarations, resourceProvider);
1660 if (hasPrefix(u'>') || hasPrefix(u'/'))
1662 QString key = parseWord().toLower();
1663 QString value =
"1"_L1;
1664 if (key.size() == 0)
1667 if (hasPrefix(u'=')){
1670 value = parseWord();
1672 if (value.size() == 0)
1674 attrs << key << value;
1683 bool seenQt3Richtext =
false;
1687 if (attributes.size() % 2 == 1)
1692 for (
int i = 0; i < attributes.size(); i += 2) {
1693 QString key = attributes.at(i);
1694 QString value = attributes.at(i + 1);
1699 if (key ==
"size"_L1 && value.size()) {
1700 int n = value.toInt();
1701 if (value.at(0) != u'+' && value.at(0) != u'-')
1703 node->charFormat.setProperty(QTextFormat::FontSizeAdjustment, n);
1704 }
else if (key ==
"face"_L1) {
1705 if (value.contains(u',')) {
1706 QStringList families;
1707 for (
auto family : value.tokenize(u','))
1708 families << family.trimmed().toString();
1709 node->charFormat.setFontFamilies(families);
1711 node->charFormat.setFontFamilies(QStringList(value));
1713 }
else if (key ==
"color"_L1) {
1714 QColor c = QColor::fromString(value);
1716 qWarning(
"QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1717 node->charFormat.setForeground(c);
1722 if (key ==
"type"_L1) {
1723 node->hasOwnListStyle =
true;
1724 if (value ==
"1"_L1) {
1725 node->listStyle = QTextListFormat::ListDecimal;
1726 }
else if (value ==
"a"_L1) {
1727 node->listStyle = QTextListFormat::ListLowerAlpha;
1728 }
else if (value ==
"A"_L1) {
1729 node->listStyle = QTextListFormat::ListUpperAlpha;
1730 }
else if (value ==
"i"_L1) {
1731 node->listStyle = QTextListFormat::ListLowerRoman;
1732 }
else if (value ==
"I"_L1) {
1733 node->listStyle = QTextListFormat::ListUpperRoman;
1735 value =
std::move(value).toLower();
1736 if (value ==
"square"_L1)
1737 node->listStyle = QTextListFormat::ListSquare;
1738 else if (value ==
"disc"_L1)
1739 node->listStyle = QTextListFormat::ListDisc;
1740 else if (value ==
"circle"_L1)
1741 node->listStyle = QTextListFormat::ListCircle;
1742 else if (value ==
"none"_L1)
1743 node->listStyle = QTextListFormat::ListStyleUndefined;
1745 }
else if (key ==
"start"_L1) {
1750 if (key ==
"class"_L1) {
1751 if (value ==
"unchecked"_L1)
1752 node->blockFormat.setMarker(QTextBlockFormat::MarkerType::Unchecked);
1753 else if (value ==
"checked"_L1)
1754 node->blockFormat.setMarker(QTextBlockFormat::MarkerType::Checked);
1758 if (key ==
"href"_L1)
1759 node->charFormat.setAnchorHref(value);
1760 else if (key ==
"name"_L1)
1761 node->charFormat.setAnchorNames({value});
1764 if (key ==
"src"_L1 || key ==
"source"_L1) {
1765 node->imageName = value;
1766 }
else if (key ==
"width"_L1) {
1767 node->imageWidth = -2;
1768 setFloatAttribute(&node->imageWidth, value);
1769 }
else if (key ==
"height"_L1) {
1770 node->imageHeight = -2;
1771 setFloatAttribute(&node->imageHeight, value);
1772 }
else if (key ==
"alt"_L1) {
1773 node->imageAlt = value;
1774 }
else if (key ==
"title"_L1) {
1780 if (key ==
"bgcolor"_L1) {
1781 QColor c = QColor::fromString(value);
1783 qWarning(
"QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1784 node->charFormat.setBackground(c);
1785 }
else if (key ==
"background"_L1) {
1786 node->applyBackgroundImage(value, resourceProvider);
1791 if (key ==
"width"_L1) {
1792 setWidthAttribute(&node->width, value);
1793 }
else if (key ==
"bgcolor"_L1) {
1794 QColor c = QColor::fromString(value);
1796 qWarning(
"QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1797 node->charFormat.setBackground(c);
1798 }
else if (key ==
"background"_L1) {
1799 node->applyBackgroundImage(value, resourceProvider);
1800 }
else if (key ==
"rowspan"_L1) {
1803 }
else if (key ==
"colspan"_L1) {
1810 if (key ==
"border"_L1 && !node->tableBorder) {
1811 setFloatAttribute(&node->tableBorder, value);
1812 }
else if (key ==
"bgcolor"_L1) {
1813 QColor c = QColor::fromString(value);
1815 qWarning(
"QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1816 node->charFormat.setBackground(c);
1817 }
else if (key ==
"bordercolor"_L1) {
1818 QColor c = QColor::fromString(value);
1820 qWarning(
"QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1821 node->borderBrush = c;
1822 }
else if (key ==
"background"_L1) {
1823 node->applyBackgroundImage(value, resourceProvider);
1824 }
else if (key ==
"cellspacing"_L1) {
1825 setFloatAttribute(&node->tableCellSpacing, value);
1826 }
else if (key ==
"cellpadding"_L1) {
1827 setFloatAttribute(&node->tableCellPadding, value);
1828 }
else if (key ==
"width"_L1) {
1829 setWidthAttribute(&node->width, value);
1830 }
else if (key ==
"height"_L1) {
1831 setWidthAttribute(&node->height, value);
1835 if (key ==
"name"_L1 && value ==
"qrichtext"_L1)
1836 seenQt3Richtext =
true;
1838 if (key ==
"content"_L1 && value ==
"1"_L1 && seenQt3Richtext)
1842 if (key ==
"width"_L1)
1843 setWidthAttribute(&node->width, value);
1846 if (key ==
"href"_L1)
1848 else if (key ==
"type"_L1)
1852 if (key ==
"class"_L1 && value.startsWith(
"language-"_L1))
1853 node->blockFormat.setProperty(QTextFormat::BlockCodeLanguage, value.mid(9));
1859 if (key ==
"style"_L1) {
1860#ifndef QT_NO_CSSPARSER
1861 node->parseStyleAttribute(value, resourceProvider);
1863 }
else if (key ==
"align"_L1) {
1864 value =
std::move(value).toLower();
1865 bool alignmentSet =
true;
1867 if (value ==
"left"_L1)
1868 node->blockFormat.setAlignment(Qt::AlignLeft|Qt::AlignAbsolute);
1869 else if (value ==
"right"_L1)
1870 node->blockFormat.setAlignment(Qt::AlignRight|Qt::AlignAbsolute);
1871 else if (value ==
"center"_L1)
1872 node->blockFormat.setAlignment(Qt::AlignHCenter);
1873 else if (value ==
"justify"_L1)
1874 node->blockFormat.setAlignment(Qt::AlignJustify);
1876 alignmentSet =
false;
1881 if (node->blockFormat.alignment() & Qt::AlignLeft)
1882 node->cssFloat = QTextFrameFormat::FloatLeft;
1883 else if (node->blockFormat.alignment() & Qt::AlignRight)
1884 node->cssFloat = QTextFrameFormat::FloatRight;
1885 }
else if (value ==
"middle"_L1) {
1886 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
1887 }
else if (value ==
"top"_L1) {
1888 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignTop);
1891 }
else if (key ==
"valign"_L1) {
1892 value =
std::move(value).toLower();
1893 if (value ==
"top"_L1)
1894 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignTop);
1895 else if (value ==
"middle"_L1)
1896 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignMiddle);
1897 else if (value ==
"bottom"_L1)
1898 node->charFormat.setVerticalAlignment(QTextCharFormat::AlignBottom);
1899 }
else if (key ==
"dir"_L1) {
1900 value =
std::move(value).toLower();
1901 if (value ==
"ltr"_L1)
1902 node->blockFormat.setLayoutDirection(Qt::LeftToRight);
1903 else if (value ==
"rtl"_L1)
1904 node->blockFormat.setLayoutDirection(Qt::RightToLeft);
1905 }
else if (key ==
"title"_L1) {
1906 node->charFormat.setToolTip(value);
1907 }
else if (key ==
"id"_L1) {
1908 node->charFormat.setAnchor(
true);
1909 node->charFormat.setAnchorNames({value});
1913#ifndef QT_NO_CSSPARSER
1914 if (resourceProvider && !linkHref.isEmpty() && linkType ==
"text/css"_L1)
1915 importStyleSheet(linkHref);
1919#ifndef QT_NO_CSSPARSER
1924 : parser(parser) { nameCaseSensitivity = Qt::CaseInsensitive; }
1927 QString
attributeValue(NodePtr node,
const QCss::AttributeSelector &aSelector)
const override;
1941 return QStringList(parser
->at(node.id
).tag.toLower());
1946#ifndef QT_NO_CSSPARSER
1948static inline int findAttribute(
const QStringList &attributes,
const QString &name)
1952 idx = attributes.indexOf(name, idx + 1);
1953 }
while (idx != -1 && (idx % 2 == 1));
1959 const QStringList &attributes = parser->at(node.id).attributes;
1960 const int idx = findAttribute(attributes, aSelector.name);
1963 return attributes.at(idx + 1);
1968 const QStringList &attributes = parser->at(node.id).attributes;
1969 return !attributes.isEmpty();
1974 return node.id == 0;
1982 parent.id = parser
->at(node.id
).parent;
1998 int parent = parser
->at(node.id
).parent;
2001 const int childIdx = parser
->at(parent
).children.indexOf(node.id);
2004 sibling.id = parser
->at(parent
).children.at(childIdx - 1);
2012void QTextHtmlParser::resolveStyleSheetImports(
const QCss::StyleSheet &sheet)
2014 for (
int i = 0; i < sheet.importRules.size(); ++i) {
2015 const QCss::ImportRule &rule = sheet.importRules.at(i);
2016 if (rule.media.isEmpty() || rule.media.contains(
"screen"_L1, Qt::CaseInsensitive))
2017 importStyleSheet(rule.href);
2023 if (!resourceProvider)
2025 for (
int i = 0; i < externalStyleSheets.size(); ++i)
2026 if (externalStyleSheets.at(i).url == href)
2029 QVariant res = resourceProvider->resource(QTextDocument::StyleSheetResource, href);
2031 if (res.userType() == QMetaType::QString) {
2032 css = res.toString();
2033 }
else if (res.userType() == QMetaType::QByteArray) {
2035 css = QString::fromUtf8(res.toByteArray());
2037 if (!css.isEmpty()) {
2038 QCss::Parser parser(css);
2039 QCss::StyleSheet sheet;
2040 parser.parse(&sheet, Qt::CaseInsensitive);
2041 externalStyleSheets.append(ExternalStyleSheet(href, sheet));
2042 resolveStyleSheetImports(sheet);
2048 QList<QCss::Declaration> decls;
2049 QCss::Declaration decl;
2054 bool needsUnderline = (node
.id ==
Html_u) ?
true :
false;
2056 for (
int i = 0; i < node.attributes.size(); i += 2) {
2057 const QString key = node.attributes.at(i);
2058 if (key.compare(
"href"_L1, Qt::CaseInsensitive) == 0
2059 && !node.attributes.at(i + 1).isEmpty()) {
2060 needsUnderline =
true;
2061 decl.d->property =
"color"_L1;
2062 decl.d->propertyId = QCss::Color;
2063 val.type = QCss::Value::Function;
2064 val.variant = QStringList() <<
"palette"_L1 <<
"link"_L1;
2065 decl.d->values = QList<QCss::Value> { val };
2066 decl.d->inheritable =
true;
2072 if (needsUnderline) {
2073 decl = QCss::Declaration();
2074 decl.d->property =
"text-decoration"_L1;
2075 decl.d->propertyId = QCss::TextDecoration;
2076 val.type = QCss::Value::KnownIdentifier;
2077 val.variant = QVariant(QCss::Value_Underline);
2078 decl.d->values = QList<QCss::Value> { val };
2079 decl.d->inheritable =
true;
2092 decl = QCss::Declaration();
2093 decl.d->property =
"font-weight"_L1;
2094 decl.d->propertyId = QCss::FontWeight;
2095 val.type = QCss::Value::KnownIdentifier;
2096 val.variant = QVariant(QCss::Value_Bold);
2097 decl.d->values = QList<QCss::Value> { val };
2098 decl.d->inheritable =
true;
2106 decl = QCss::Declaration();
2107 decl.d->property =
"font-size"_L1;
2108 decl.d->propertyId = QCss::FontSize;
2109 decl.d->inheritable =
false;
2110 val.type = QCss::Value::KnownIdentifier;
2112 case Html_h1: val.variant = QVariant(QCss::Value_XXLarge);
break;
2113 case Html_h2: val.variant = QVariant(QCss::Value_XLarge);
break;
2114 case Html_h3:
case Html_big: val.variant = QVariant(QCss::Value_Large);
break;
2115 case Html_h4: val.variant = QVariant(QCss::Value_Medium);
break;
2116 case Html_h5:
case Html_small: val.variant = QVariant(QCss::Value_Small);
break;
2119 decl.d->values = QList<QCss::Value> { val };
2126 decl = QCss::Declaration();
2127 decl.d->property =
"text-align"_L1;
2128 decl.d->propertyId = QCss::TextAlignment;
2129 val.type = QCss::Value::KnownIdentifier;
2130 val.variant = (node.id == Html_td) ? QVariant(QCss::Value_Left) : QVariant(QCss::Value_Center);
2131 decl.d->values = QList<QCss::Value> { val };
2132 decl.d->inheritable =
true;
2136 decl = QCss::Declaration();
2137 decl.d->property =
"text-decoration"_L1;
2138 decl.d->propertyId = QCss::TextDecoration;
2139 val.type = QCss::Value::KnownIdentifier;
2140 val.variant = QVariant(QCss::Value_LineThrough);
2141 decl.d->values = QList<QCss::Value> { val };
2142 decl.d->inheritable =
true;
2151 decl = QCss::Declaration();
2152 decl.d->property =
"font-style"_L1;
2153 decl.d->propertyId = QCss::FontStyle;
2154 val.type = QCss::Value::KnownIdentifier;
2155 val.variant = QVariant(QCss::Value_Italic);
2156 decl.d->values = QList<QCss::Value> { val };
2157 decl.d->inheritable =
true;
2162 decl = QCss::Declaration();
2163 decl.d->property =
"vertical-align"_L1;
2164 decl.d->propertyId = QCss::VerticalAlignment;
2165 val.type = QCss::Value::KnownIdentifier;
2166 val.variant = (node.id == Html_sub) ? QVariant(QCss::Value_Sub) : QVariant(QCss::Value_Super);
2167 decl.d->values = QList<QCss::Value> { val };
2168 decl.d->inheritable =
true;
2173 decl = QCss::Declaration();
2174 decl.d->property =
"list-style"_L1;
2175 decl.d->propertyId = QCss::ListStyle;
2176 val.type = QCss::Value::KnownIdentifier;
2177 val.variant = (node.id == Html_ul) ? QVariant(QCss::Value_Disc) : QVariant(QCss::Value_Decimal);
2178 decl.d->values = QList<QCss::Value> { val };
2179 decl.d->inheritable =
true;
2187 decl = QCss::Declaration();
2188 decl.d->property =
"font-family"_L1;
2189 decl.d->propertyId = QCss::FontFamily;
2190 QList<QCss::Value> values;
2191 val.type = QCss::Value::String;
2192 val.variant = QFontDatabase::systemFont(QFontDatabase::FixedFont).families().constFirst();
2194 decl.d->values = values;
2195 decl.d->inheritable =
true;
2203 decl = QCss::Declaration();
2204 decl.d->property =
"whitespace"_L1;
2205 decl.d->propertyId = QCss::Whitespace;
2206 val.type = QCss::Value::KnownIdentifier;
2208 case Html_br: val.variant = QVariant(QCss::Value_PreWrap);
break;
2209 case Html_nobr: val.variant = QVariant(QCss::Value_NoWrap);
break;
2210 case Html_pre: val.variant = QVariant(QCss::Value_Pre);
break;
2213 decl.d->values = QList<QCss::Value> { val };
2214 decl.d->inheritable =
true;
2223QList<QCss::Declaration>
QTextHtmlParser::declarationsForNode(
int node)
const
2225 QList<QCss::Declaration> decls;
2230 selector.styleSheets.resize((resourceProvider ? 1 : 0)
2231 + externalStyleSheets.size()
2232 + inlineStyleSheets.size());
2233 if (resourceProvider)
2234 selector.styleSheets[idx++] = QTextDocumentPrivate::get(resourceProvider)->parsedDefaultStyleSheet;
2236 for (
int i = 0; i < externalStyleSheets.size(); ++i, ++idx)
2237 selector.styleSheets[idx] = externalStyleSheets.at(i).sheet;
2239 for (
int i = 0; i < inlineStyleSheets.size(); ++i, ++idx)
2240 selector.styleSheets[idx] = inlineStyleSheets.at(i);
2242 selector.medium = resourceProvider ? resourceProvider->metaInformation(QTextDocument::CssMedia) :
"screen"_L1;
2244 QCss::StyleSelector::NodePtr n;
2247 const char *extraPseudo =
nullptr;
2248 if (nodes.at(node)->id == Html_a && nodes.at(node)->hasHref)
2249 extraPseudo =
"link";
2251 decls = standardDeclarationForNode(*nodes.at(node));
2252 decls += selector.declarationsForNode(n, extraPseudo);
2253 n = selector.parentNode(n);
2254 while (!selector.isNullNode(n)) {
2255 QList<QCss::Declaration> inheritedDecls;
2256 inheritedDecls = selector.declarationsForNode(n, extraPseudo);
2257 for (
int i = 0; i < inheritedDecls.size(); ++i) {
2258 const QCss::Declaration &decl = inheritedDecls.at(i);
2259 if (decl.d->inheritable)
2260 decls.prepend(decl);
2262 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