summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtexthtmlparser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix namespace build when cssparser is disabledJuha Vuolle2025-04-231-1/+2
| | | | | | | | | | | | | | The QT_BEGIN_NAMESPACE was inside "#if TEXTHTMLPARSER" code block, whereas the QT_END_NAMESPACE was inside a nested "#if CSSPARSER" block. Therefore if cssparser was disabled, the file will effectively have just QT_BEGIN_NAMESPACE, and the build will fail (if it's an actual namespace build). Pick-to: 6.9 6.8 Change-Id: Ibd750a71c154cb9596a7227327b7d5b3ab307001 Reviewed-by: Ivan Solovev <[email protected]>
* Mark HTML, CSS and Markdown parsers as security-criticalShawn Rutledge2025-03-121-0/+1
| | | | | | | Pick-to: 6.8 6.9 Task-number: QTBUG-134508 Change-Id: Ib973b9344a19fa2f8c79e2a2ceddf530d9ab62cd Reviewed-by: Alexandru Croitor <[email protected]>
* QTextHtmlParser: parse border color correctlyHatem ElKharashy2024-06-201-1/+7
| | | | | | | | | | | Use QCss::Declaration::brushValues to parse the values into a list. This will not only lead to correctly parsing the values, but also prevent an an assertion from firing when ValueExtractor::extractBorder is called. Fixes: QTBUG-126381 Pick-to: 6.8 6.7 6.5 6.2 Change-Id: Ic6f3d722ffe0d72dcb5faa9916a23c804211ce49 Reviewed-by: Santhosh Kumar <[email protected]>
* Support SVG specific stroke styling propertiesHatem ElKharashy2024-05-141-0/+55
| | | | | | | | | | | SVG has special properties for stroke styling. Those are usually supported by different browsers, because SVG documents can be used inside HTML files. This kind of styling is already supported by QPen and all need to be done is some plumbing to save and retrieve those values in QTextDocument when it is stored as HTML. Change-Id: I291efab5483ac5e852d117e762e203257c64b47f Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
* QTextDocument: Add support for responsive imagesCarl Schwan2024-05-071-0/+7
| | | | | | | | | | | | | | | | Add support for the max-width css attribute in image. This allows images to be responsive: it adapts their size to the size of the QTextDocument so that they never grow bigger than the QTextDocument pageSize. This is implemented for the image handler used in QTextEdit and other QtWidget text related classes. [ChangeLog][QtGui][CSS] The max-width style can now be applied to <img/> to set the maximum width in pixels or percentage. Task-number: QTBUG-12283 Change-Id: Ic94e16279a1240ab4a509823de59dc0bfc920bb9 Reviewed-by: Shawn Rutledge <[email protected]>
* Support rendering CSS 'border' property for html tableSanthosh Kumar2024-04-181-6/+24
| | | | | | | | | | | | We supported CSS 'border-width', 'border-style' and 'border-color' for HTML tables since 8a9bec35fb0c60a0e5990c1a12ffe6f39fdbf2d. Now we also support the 'border' property, which is shorthand to set all four borders' width, style and color. Fixes: QTBUG-123167 Pick-to: 6.7 6.6 Change-Id: I5f29b94ab9facf412a9c230d554efb5c69368b6b Reviewed-by: Shawn Rutledge <[email protected]>
* Support foreground gradient in CSS parser and HTML generatorEskil Abrahamsen Blomfeldt2024-03-181-0/+6
| | | | | | | | | | | | | | | Qt supports some complex foreground brushes which we cannot express using normal CSS, so we introduce a Qt-specific property for this. We already had some support for background gradients in widget style sheets, but this expands support to foreground brushes of text when converting a QTextDocument from and to HTML. It also adds an optional "coordinatemode" attribute to the gradient functions so that this can be faithfully restored from HTML. Task-number: QTBUG-123357 Change-Id: I3d6dd828f68272995c8525bec5a7b421fdbed670 Reviewed-by: Eirik Aavitsland <[email protected]>
* Implement support for stroke color and width in CSS parserEskil Abrahamsen Blomfeldt2024-03-181-0/+18
| | | | | | | | | | | | | | | CSS does not have text outline properties, instead different browsers have custom properties for this. That currently means that you can have a QTextDocument where you applied a stroke to text and textEdit.setHtml(textEdit.toHtml()) will remove it. Since a primary goal of the HTML support in QTextDocument is that it can be used to save and faithfully restore its contents, we implement qt specific properties for stroke. Task-number: QTBUG-123357 Change-Id: Id9cf63abfabe2109ffb6fd74f9cb013304763ccb Reviewed-by: Eirik Aavitsland <[email protected]>
* qtexthtmlparser: use tokenize instead of splitAnton Kudryavtsev2023-09-251-3/+2
| | | | | | | | to avoid needless tmp list Change-Id: I5f6bc9c3edd17c04e5293feb0aad86cd5ed49695 Reviewed-by: Mårten Nordheim <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
* QTextHtmlParser::lookupElement: port to QSVAnton Kudryavtsev2023-09-101-4/+4
| | | | | Change-Id: I7d45d1a8985b57457eaa8226332929b6a1817108 Reviewed-by: Edward Welbourne <[email protected]>
* gui/text: use const methods moreAnton Kudryavtsev2023-09-091-13/+13
| | | | | | | to avoid implicit detach Change-Id: I2c6edfcf8b9dc6e9bb0801b7bd58f34a8033a955 Reviewed-by: Volker Hilsheimer <[email protected]>
* Add QTextListFormat::start: html and markdown ordered list index offsetNicolas Werner2023-03-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | This is useful for a lot of applications that render text coming from sources which already support arbitrarily numbered lists (like chat applications for example). Application-side workarounds usually have significant overhead; and this feature has been requested multiple times. It should be possible to both read and write HTML with the <ol start="x"> attribute, and read and write Markdown with arbitrary numbers for the first item in a list. [ChangeLog][QtGui] QTextList now supports specifying a start index using the new QTextList::{setStart, start} functions. The HTML start attribute on ordered lists in rich text documents is now parsed and used when rendering a text list. Non-negative indices in markdown lists are now also parsed and written properly. This allows starting a list with a different number than 1. Fixes: QTBUG-30407 Fixes: QTBUG-65384 Task-number: QTBUG-107562 Change-Id: Ib35b9378d9134ffedaa2d92f728b0984793aa7c1 Reviewed-by: Shawn Rutledge <[email protected]>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-26/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* Use CSS classes on html list items for checkbox supportShawn Rutledge2022-06-111-0/+8
| | | | | | | | | | | | | | If we replace the bullet character with a UC checkbox character, it looks ok in a browser, and the HTML parser can recover the BlockMarker attribute from the css class. [ChangeLog][QtGui][Text] Checkbox list items can now be read and written in both HTML and Markdown, including conversions. Task-number: QTBUG-103714 Change-Id: Ic6b74512075cd4ac16d6f80fdf55b221447491a9 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Allan Sandfeld Jensen <[email protected]>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Lars Knoll <[email protected]> Reviewed-by: Jörg Bornemann <[email protected]>
* Use Q_CC_{GNU,MSVC}_ONLY when comparing to particular versionsMarc Mutz2022-05-061-1/+1
| | | | | | | | | | | | | | | | | This prevents false-negatives and false-positives, as e.g. Clang 10.0.0 masks as GCC 4.2, so Q_CC_GNU is 402 on that compiler. Depending on the test (Q_CC_GNU > NNN or Q_CC_GNU < NNN), the result of the test is almost random. Q_CC_<comp>_ONLY makes sure we match only GCC or MSVC, not bycatch such as Clang or ICC. Pick-to: 6.3 6.2 5.15 Change-Id: I4c550a11ecf85fc9a2216b330b69bd03d45b47e0 Reviewed-by: Giuseppe D'Angelo <[email protected]> Reviewed-by: Edward Welbourne <[email protected]> Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* QtGui: replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-04-281-5/+5
| | | | | | Task-number: QTBUG-98434 Change-Id: I98c27030c783f968cbf38dc966ce486dc366b302 Reviewed-by: Edward Welbourne <[email protected]>
* QtGui: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-281-97/+92
| | | | | | Task-number: QTBUG-98434 Change-Id: Idcb71c1d27125333a53b6bdd3e1af0d4c66617fa Reviewed-by: Edward Welbourne <[email protected]>
* QtGui: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-131-35/+31
| | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. Change-Id: I308d86cefcbfd126929b68f9a853d420840c965f Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Marc Mutz <[email protected]>
* Fix deprecated use of QColor::setNamedColorMårten Nordheim2022-03-171-5/+5
| | | | | | | 'Use fromString() instead.' Change-Id: I4efef147a8b0486f2664fd7fe6c35a9c82479b90 Reviewed-by: Marc Mutz <[email protected]>
* Fix deprecated use of QBA/Q*String::countMårten Nordheim2022-03-151-1/+1
| | | | | | | 'Use size() or length() instead' Change-Id: I284fce29727c4c1ec9ea38a4e8ea13a9e0af5390 Reviewed-by: Sona Kurazyan <[email protected]>
* QCSS: Support Qt 5-style integer property selectorsVolker Hilsheimer2022-01-151-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Qt 5 style sheets, objects could be selected by an enum-type property using the integer value of the enum value, e.g QToolButton[popupMode="1"] { ... } In Qt 6, the the new meta type system and QVariant implementation enabled QVariant::toString to return the string representation of the enum value instead for a property containing an enum. Since QStyleSheetStyle's attribute matching is string based, this breaks the Qt 5 style selector, and QCSS code instead needs to use e.g. QToolButton[popupMode=MenuButtonPopup] { ... } While the new syntax is arguably preferable, this is an unintentional change that silently breaks style sheet code (no error or warning at compile- or run-time). To support Qt 5-style selectors, we have to change the StyleSelector interface of the QCssParser API so that we can pass through what type of value the attribute extractor should return; if an integer string "1" is provided, then we need to compare the enum integer value; if the string provided does not represent a number, then we need to compare the name of the enum value. Since the pure virtual attribute() method that needs to be implemented to extract the attribute value of the node is implemented in modules outside qtbase, add a second virtual method that takes the entire QCss::AttributeSelector, which includes the value to match. Extractor implementations can use it to evaluate which type of data to return for an exact match. The default implementation calls the old attribute() method so that existing StyleSelector implementations continue to work. Make the respective change in the QStyleSheetStyleSelector, and simplify the surrounding code. Adjust other StyleSelector implemnentations in qtbase. As a drive-by, remove the superfluous virtual declaration from those overrides. Once submodules are adjusted to override this virtual function instead of the (now no longer pure) virtual attribute() method, that method can be removed. Pick-to: 6.3 6.2 Fixes: QTBUG-99642 Change-Id: I9a2b3498f77bf7cab5e90980b7dab2f621d3d859 Reviewed-by: Oliver Eftevaag <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* QTextHtmlParser: fix prefix lookahead and html commentsOliver Eftevaag2021-12-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | The hasPrefix() function would only use the second 'lookahead' parameter to check if there was more unparsed text after the current character. When it's obvious from the codebase that it should actually look ahead of the current character being processed, and compare againt that future character. Html comments were also not handled quite right. Partially because of the broken hasPrefix() function, but also because it would advance the current index tracker by 3 instead of 2. Remember that the beginning of an html comment is <!-- meaning that there are only supposed to be 2 dashes required, not 3. The result would be that something like this <!----> would not automatically close, because the current index tracker would jump over the first 3 dashes when it begins a comment, and the remaining unprocessed string would be -> Also, because of the broken lookahead in hasPrefix(), a comment could actually be started with just <!- not requiring a second dash at all. Pick-to: 6.3 6.2 5.15 Fixes: QTBUG-99147 Change-Id: I8f4d4a1107eaf2dae16d16b7b860525d45a1c474 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* Add css media rule support for QTextDocument::setHtml()Ralf Habacker2021-12-151-1/+1
| | | | | | | | | | | | | | | | | CSS styles can contain '@media <rule> {...}' blocks, which were previously ignored for all values except "screen". To use a media rule other than the default "screen" rule, specify it before calling setHtml() with setMetaInformation() and the new info value 'CssMedia'. [ChangeLog][Gui][QTextDocument] Add css media rule support for QTextDocument::setHtml() Pick-to: 6.3 Fixes: QTBUG-98408 Change-Id: Ie05f815a6dedbd970210f467e26b116f6ee3b9ca Reviewed-by: Shawn Rutledge <[email protected]>
* Support background-color CSS styling on <hr/>Shawn Rutledge2021-10-141-0/+2
| | | | | | | | | [ChangeLog][QtGui][CSS] The background-color style can now be applied to <hr/> to set the rule color. Task-number: QTBUG-74342 Change-Id: Ib960ce4d38caa225f258b6d228fb794cef43e1b7 Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
* QTextHtmlParser::parseEntity: Remove const that prevents automatic moveAlbert Astals Cid2021-06-041-1/+1
| | | | | | | Reported in https://testresults.qt.io/codechecker/daily_diffs/qtbase/dev/qtbase-dev-20210604-57bb7cac64 Change-Id: I3365879d18ceb0977c5fc24e2c11c9339afaafd6 Reviewed-by: Fabian Kosmale <[email protected]>
* Extract the entity parsing code to a static functionAlbert Astals Cid2021-06-031-23/+31
| | | | | | | This way we can use it from qtdeclarative to parse styled text Change-Id: Ic888a75a9700558e97b3e743d6d42fda121ddcba Reviewed-by: Allan Sandfeld Jensen <[email protected]>
* QTextHtmlParserNode: Avoid invalid enum valuesRobert Löhning2021-05-211-1/+39
| | | | | | | | | | Fixes oss-fuzz issue 31027 Fixes: QTBUG-93072 Change-Id: I8c7fa31bae79221fbeaf84db7c839fc61c93d48e Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Nils Jeisecke <[email protected]> Reviewed-by: Shawn Rutledge <[email protected]>
* Allow background inheritance between non-body block elementsAllan Sandfeld Jensen2021-05-081-1/+4
| | | | | | | | | | | Most nested block elements are merged together, so while we shouldn't do real inheritance we need to do it when block elements are combined. Pick-to: 6.1 Fixes: QTBUG-91236 Change-Id: I9e37b15f705db92c79a620d0d772f25d0ee72b8d Reviewed-by: Mårten Nordheim <[email protected]> Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
* Support CSS text-decoration-color in underlines, overlines, strikethroughShawn Rutledge2021-05-071-0/+1
| | | | | | | | | | | | Also add a feature to the textedit example to set this value. [ChangeLog][QtGui][CSS] The CSS text-decoration-color attribute is now supported in rich text spans with underlines, overlines and strikethrough. Fixes: QTBUG-82114 Task-number: QTBUG-39617 Change-Id: I0065cb5431833da55b0f503ce7ff2b83b74b718a Reviewed-by: Allan Sandfeld Jensen <[email protected]>
* QTextHtmlParserNode: Limit colspan to avoid segfaultRobert Löhning2021-04-071-1/+1
| | | | | | | | | | | | | This fixes oss-fuzz issue 29758. [ChangeLog][QtGui][Text] QTextDocument::setHtml: column spans are limited to 20480, an arbitrarily high but reasonable value. Fixes: QTBUG-92463 Pick-to: 5.15 6.0 6.1 Change-Id: Ib759e3e3ac0b0d0d483f8e8ce11002e079db3ace Reviewed-by: Thiago Macieira <[email protected]>
* QFont: Prefer setFamilies() over setFamily()Andy Shaw2020-11-201-3/+2
| | | | | | | | | | | | | | | | By depending on setFamilies() then we can be sure that font names with spaces, commas, quotes and so on are correctly handled without being misinterpreted. For now it will split on the comma when a string containing one is passed to setFamily. But from Qt 6.2 this will be removed to preserve the family string as a convenience function. [ChangeLog][QtGui][QFont] Indicated that setFamilies/families is preferred over setFamily/family to ensure that font family names are preserved when spaces, commas and so on are used in the name. Change-Id: Id3c1a4e827756a4c928fed461a4aafa5a0f06633 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
* Don't store QTextHtmlParserNode by value in a QListLars Knoll2020-10-051-26/+27
| | | | | | | | | This is a performance bottleneck as the parse nodes are huge and we don't want to reallocate them all the time. Fixes: QTBUG-86354 Change-Id: Ia437acbb5b2c8af1723932d2cd96ba2ae48a871b Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
* QTextHtmlParserNode: Fix warnings flood about setting negative pixel sizeFriedemann Kleint2020-09-021-1/+2
| | | | | | | | | | | Exclude the default value (-1) from the check. Amends 0bd770fb875d5391dd78df95542c25bd15051938. Pick-to: 5.12 5.15 5.15.1 Change-Id: Ib98ae166fd5fdab546c5d4212ce78345b5c9b583 Reviewed-by: Shawn Rutledge <[email protected]> Reviewed-by: Tor Arne Vestbø <[email protected]>
* QTextHtmlParserNode: Avoid extreme values for font's pixelsizeRobert Loehning2020-08-281-0/+1
| | | | | | | | | | They currently cause an integer-overflow in variantHash(). Fixes: oss-fuzz-24702 Pick-to: 5.12 5.15 Change-Id: Ibee4413ca766c8ade9aeff2f2052b82cb9f7d213 Reviewed-by: Volker Hilsheimer <[email protected]> Reviewed-by: Thiago Macieira <[email protected]>
* Don't flatten link color in QTextHtmlParser::declarationsForNodeTor Arne Vestbø2020-07-141-2/+2
| | | | | | | | | | | It's still flattened in the next step, when the parser calls QTextHtmlParserNode::applyCssDeclarations, but this at least makes it clear where the problem is. Task-number: QTBUG-85567 Change-Id: I1ecc7d808c58297f40f6cf8de86dfa7035e167c9 Reviewed-by: Volker Hilsheimer <[email protected]> Reviewed-by: Andy Shaw <[email protected]>
* Use QList instead of QVector in gui implementationJarek Kobus2020-07-071-18/+18
| | | | | | | Task-number: QTBUG-84469 Change-Id: I366e845249203d80d640355a7780ac2f91a762f1 Reviewed-by: Tor Arne Vestbø <[email protected]> Reviewed-by: Friedemann Kleint <[email protected]>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-191-1/+1
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <[email protected]>
* Port QtGui from QStringRef to QStringViewLars Knoll2020-06-111-6/+6
| | | | | | Task-number: QTBUG-84319 Change-Id: I1761096fbcc9421a013cf73f831a2a2ba0c18006 Reviewed-by: Alex Blasche <[email protected]>
* QtGui: fix deprecated QChar conversionsMarc Mutz2020-05-111-8/+1
| | | | | | | | | Conversions from non-char-types to QChar are going to be deprecated. Use QChar::fromUcs2(), fromUcs4(), QLatin1Char(), or convert the constructor argument to char16_t. Change-Id: Ib45ebd5560aa3a2bc460037ab09773607485c6e2 Reviewed-by: Volker Hilsheimer <[email protected]>
* QtGui: fix a few more char/int/uint -> QChar conversionsMarc Mutz2020-04-301-1/+1
| | | | | | | | They were masked by all QChar ctors being made explicit, except the char16_t one, which was left as the only viable choice. Change-Id: I343269b61d555c259b5780011e99f85f5375ef78 Reviewed-by: Mårten Nordheim <[email protected]>
* Remove references to QTextDocumentPrivate from public APIEskil Abrahamsen Blomfeldt2020-03-041-3/+3
| | | | | | | | | | | | | | | The private object of QTextDocument has been exposed through public APIs marked internal, which we should avoid as much as possible, since it clutters the headers. For accessing private data without adding friends, we have a nice pattern of adding a static get() function to the private class itself. Fixes: QTBUG-55059 Change-Id: I03e949a677e03487e95f24e3608a06aa0a3511ab Reviewed-by: Konstantin Ritt <[email protected]> Reviewed-by: Simon Hausmann <[email protected]>
* Replace most use of QVariant::type and occurrences of QVariant::TypeOlivier Goffart2020-01-231-6/+6
| | | | | | | | | | | | | | | | | | | | | I made a clazy automated check that replaced the use of QVariant::Type by the equivalent in QMetaType. This has been deprecated since Qt 5.0, but many uses were not yet removed. In addition, there was some manual changes to fix the compilation errors. Adapted the Private API of QDateTimeParser and QMimeDataPrivate and adjust QDateTimeEdit and QSpinBox. QVariant(QVariant::Invalid) in qstylesheet made no sense. But note that in QVariant::save, we actually wanted to use the non-user type. In the SQL module, many changes were actually reverted because the API still expects QVarient::Type. Change-Id: I98c368490e4ee465ed3a3b63bda8b8eaa50ea67e Reviewed-by: Lars Knoll <[email protected]>
* Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-3/+3
| | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <[email protected]> Reviewed-by: Lars Knoll <[email protected]>
* Fix assert in QTextDocument CSS parser on "border-width: 1pt"David Faure2019-12-031-2/+5
| | | | | | | | | | | | | | | | | The code was assuming that if the parsing of the value worked, then it must be a list of 4 variants. But in this case it's just a single length. This came from <td> using 4 values for border-width while other elements use a single value. But the storage is shared. So the fix is to use 4 values everywhere. When reading 4 and there's only one, it gets duplicated, so the caller can just use the first one in that case. Task-number: QTBUG-80496 Change-Id: I682244b6e3781c4d673a62d5e6511dac263c58e8 Reviewed-by: Nils Jeisecke <[email protected]> Reviewed-by: Shawn Rutledge <[email protected]>
* QTextDocument: add css-styling of table cell borders to HTML import/exportNils Jeisecke2019-08-191-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Supported style attributes: <table> style: supports "border-collapse: collapse" and "border-color". border: width of the outer border bordercolor: basic color for all borders <tr> style: not supported <td>/</th> style: supports the "border", "border-[top|left|bottom|right]]" shorthand styles and the "border-width", "border-color" and "border-style" (and the top/left/bottom/right variants) attributes <table border=1 style="border-collapse: collapse"> will render a simple 1px table grid. Notes: The QTextDocument table model is much simpler than the HTML table model. It basically only has <table> and <td> support. So the HTML parser is forced to map markup and styling to the QTextDocument model which is not without loss. In other words: While QTextDocument -> HTML -> QTextDocument should preserve the QTextDocument structure, HTML -> QTextDocument -> HTML does not preserve the HTML DOM at all. So for now the HTML importer and writer only support border styles on the <td> and <th> nodes. In future updates, the HTML parser might be enhanced to map <tr> and <table> CSS styles to the cells. Change-Id: If9e7312fa6cbf270cf8f7b3c72ba1fa094107517 Reviewed-by: Shawn Rutledge <[email protected]>
* Support missing white-space:pre-line CSSAllan Sandfeld Jensen2019-08-121-3/+6
| | | | | | | A mode that only preserves new lines. Change-Id: I612347b181c6e6c41dfae0cf60b22a662cba1b7e Reviewed-by: Lars Knoll <[email protected]>
* Merge remote-tracking branch 'origin/5.13' into devLiang Qi2019-07-051-1/+10
|\ | | | | | | | | | | | | | | Conflicts: .qmake.conf qmake/generators/makefile.cpp Change-Id: Ifb2633a69d0bf8cdf12d799c6259beefc279c49e
| * Handle multiple font-families in <font> face attributeAllan Sandfeld Jensen2019-07-031-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This seems to be a common use case, and to be expected from pastes of MSWord documents. Change-Id: I5849d7f51408e76f15a0b03c2118649f118af1d6 Fixes: QTBUG-66794 Reviewed-by: Friedemann Kleint <[email protected]> Reviewed-by: Lars Knoll <[email protected]>