summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtexthtmlparser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qtexthtmlparser.cpp')
-rw-r--r--src/gui/text/qtexthtmlparser.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 103a208c26..7bca50325c 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1418,16 +1418,16 @@ static bool setFloatAttribute(qreal *destination, const QString &value)
return ok;
}
-static void setWidthAttribute(QTextLength *width, QString value)
+static void setWidthAttribute(QTextLength *width, const QString &valueStr)
{
bool ok = false;
- qreal realVal = value.toDouble(&ok);
+ qreal realVal = valueStr.toDouble(&ok);
if (ok) {
*width = QTextLength(QTextLength::FixedLength, realVal);
} else {
- value = value.trimmed();
+ QStringRef value = QStringRef(&valueStr).trimmed();
if (!value.isEmpty() && value.endsWith(QLatin1Char('%'))) {
- value.chop(1);
+ value.truncate(value.size() - 1);
realVal = value.toDouble(&ok);
if (ok)
*width = QTextLength(QTextLength::PercentageLength, realVal);
@@ -1438,9 +1438,7 @@ static void setWidthAttribute(QTextLength *width, QString value)
#ifndef QT_NO_CSSPARSER
void QTextHtmlParserNode::parseStyleAttribute(const QString &value, const QTextDocument *resourceProvider)
{
- QString css = value;
- css.prepend(QLatin1String("* {"));
- css.append(QLatin1Char('}'));
+ const QString css = QLatin1String("* {") + value + QLatin1Char('}');
QCss::Parser parser(css);
QCss::StyleSheet sheet;
parser.parse(&sheet, Qt::CaseInsensitive);