summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-02-27 18:40:59 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-02-27 18:40:59 +0100
commit848f0de244cff8565f323dfc3ffdf479ad2b0f2e (patch)
tree21fc9a5870c3fed1c15bed132e5b86ecbbfac9b0
parent1f5a2f92d5c08a2ddaf5bf1aec2c33316483d54c (diff)
parentd4addd30de02c1afd5f93cbc2319bd3bdaed9588 (diff)
downloadqtsvg-848f0de244cff8565f323dfc3ffdf479ad2b0f2e.tar.gz
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: Ic2b1b60b29f756fc5c82517ac108c5583d8bdf0b
-rw-r--r--dist/changes-5.10.126
-rw-r--r--src/svg/qsvghandler.cpp187
-rw-r--r--src/svg/svg.pro2
-rw-r--r--tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp6
4 files changed, 134 insertions, 87 deletions
diff --git a/dist/changes-5.10.1 b/dist/changes-5.10.1
new file mode 100644
index 0000000..695c4e3
--- /dev/null
+++ b/dist/changes-5.10.1
@@ -0,0 +1,26 @@
+Qt 5.10.1 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.10.0.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+http://doc.qt.io/qt-5/index.html
+
+The Qt version 5.10 series is binary compatible with the 5.9.x series.
+Applications compiled for 5.9 will continue to run with 5.10.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+This release contains all fixes included in the Qt 5.9.4 release.
+
+****************************************************************************
+* Qt 5.10.1 Changes *
+****************************************************************************
+
+ - This release contains only minor code improvements.
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index 6c0e742..6d2e279 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -896,10 +896,11 @@ static bool constructColor(const QStringRef &colorStr, const QStringRef &opacity
return true;
}
-static qreal parseLength(const QString &str, QSvgHandler::LengthType &type,
+template <class String> // QString/QStringRef
+static qreal parseLength(const String &str, QSvgHandler::LengthType &type,
QSvgHandler *handler, bool *ok = NULL)
{
- QString numStr = str.trimmed();
+ String numStr = str.trimmed();
if (numStr.endsWith(QLatin1Char('%'))) {
numStr.chop(1);
@@ -931,7 +932,7 @@ static qreal parseLength(const QString &str, QSvgHandler::LengthType &type,
return len;
}
-static inline qreal convertToNumber(const QString &str, QSvgHandler *handler, bool *ok = NULL)
+static inline qreal convertToNumber(const QStringRef &str, QSvgHandler *handler, bool *ok = NULL)
{
QSvgHandler::LengthType type;
qreal num = parseLength(str, type, handler, ok);
@@ -1226,7 +1227,7 @@ static void parsePen(QSvgNode *node,
//stroke-width handling
if (!attributes.strokeWidth.isEmpty() && attributes.strokeWidth != QT_INHERIT) {
QSvgHandler::LengthType lt;
- prop->setWidth(parseLength(attributes.strokeWidth.toString(), lt, handler));
+ prop->setWidth(parseLength(attributes.strokeWidth, lt, handler));
}
//stroke-dasharray
@@ -1288,6 +1289,49 @@ static void parsePen(QSvgNode *node,
}
}
+enum FontSizeSpec { XXSmall, XSmall, Small, Medium, Large, XLarge, XXLarge,
+ FontSizeNone, FontSizeValue };
+
+static const qreal sizeTable[] =
+{ qreal(6.9), qreal(8.3), qreal(10.0), qreal(12.0), qreal(14.4), qreal(17.3), qreal(20.7) };
+
+Q_STATIC_ASSERT(sizeof(sizeTable)/sizeof(sizeTable[0]) == FontSizeNone);
+
+static FontSizeSpec fontSizeSpec(const QStringRef &spec)
+{
+ switch (spec.at(0).unicode()) {
+ case 'x':
+ if (spec == QLatin1String("xx-small"))
+ return XXSmall;
+ if (spec == QLatin1String("x-small"))
+ return XSmall;
+ if (spec == QLatin1String("x-large"))
+ return XLarge;
+ if (spec == QLatin1String("xx-large"))
+ return XXLarge;
+ break;
+ case 's':
+ if (spec == QLatin1String("small"))
+ return Small;
+ break;
+ case 'm':
+ if (spec == QLatin1String("medium"))
+ return Medium;
+ break;
+ case 'l':
+ if (spec == QLatin1String("large"))
+ return Large;
+ break;
+ case 'n':
+ if (spec == QLatin1String("none"))
+ return FontSizeNone;
+ break;
+ default:
+ break;
+ }
+ return FontSizeValue;
+}
+
static void parseFont(QSvgNode *node,
const QSvgAttributes &attributes,
QSvgHandler *handler)
@@ -1311,38 +1355,19 @@ static void parseFont(QSvgNode *node,
if (!attributes.fontSize.isEmpty() && attributes.fontSize != QT_INHERIT) {
// TODO: Support relative sizes 'larger' and 'smaller'.
- QSvgHandler::LengthType dummy; // should always be pixel size
- qreal size = 0;
- static const qreal sizeTable[] = { qreal(6.9), qreal(8.3), qreal(10.0), qreal(12.0), qreal(14.4), qreal(17.3), qreal(20.7) };
- enum AbsFontSize { XXSmall, XSmall, Small, Medium, Large, XLarge, XXLarge };
- switch (attributes.fontSize.at(0).unicode()) {
- case 'x':
- if (attributes.fontSize == QLatin1String("xx-small"))
- size = sizeTable[XXSmall];
- else if (attributes.fontSize == QLatin1String("x-small"))
- size = sizeTable[XSmall];
- else if (attributes.fontSize == QLatin1String("x-large"))
- size = sizeTable[XLarge];
- else if (attributes.fontSize == QLatin1String("xx-large"))
- size = sizeTable[XXLarge];
+ const FontSizeSpec spec = fontSizeSpec(attributes.fontSize);
+ switch (spec) {
+ case FontSizeNone:
break;
- case 's':
- if (attributes.fontSize == QLatin1String("small"))
- size = sizeTable[Small];
- break;
- case 'm':
- if (attributes.fontSize == QLatin1String("medium"))
- size = sizeTable[Medium];
- break;
- case 'l':
- if (attributes.fontSize == QLatin1String("large"))
- size = sizeTable[Large];
+ case FontSizeValue: {
+ QSvgHandler::LengthType dummy; // should always be pixel size
+ fontStyle->setSize(parseLength(attributes.fontSize, dummy, handler));
+ }
break;
default:
- size = parseLength(attributes.fontSize.toString(), dummy, handler);
+ fontStyle->setSize(sizeTable[spec]);
break;
}
- fontStyle->setSize(size);
}
if (!attributes.fontStyle.isEmpty() && attributes.fontStyle != QT_INHERIT) {
@@ -1357,7 +1382,7 @@ static void parseFont(QSvgNode *node,
if (!attributes.fontWeight.isEmpty() && attributes.fontWeight != QT_INHERIT) {
bool ok = false;
- int weightNum = attributes.fontWeight.toString().toInt(&ok);
+ const int weightNum = attributes.fontWeight.toInt(&ok);
if (ok) {
fontStyle->setWeight(weightNum);
} else {
@@ -2100,7 +2125,7 @@ static void parseOpacity(QSvgNode *node,
if (attributes.opacity.isEmpty())
return;
- const QString value = attributes.opacity.toString().trimmed();
+ const QStringRef value = attributes.opacity.trimmed();
bool ok = false;
qreal op = value.toDouble(&ok);
@@ -2510,9 +2535,9 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
const QXmlStreamAttributes &attributes,
QSvgHandler *)
{
- QString cx = attributes.value(QLatin1String("cx")).toString();
- QString cy = attributes.value(QLatin1String("cy")).toString();
- QString r = attributes.value(QLatin1String("r")).toString();
+ const QStringRef cx = attributes.value(QLatin1String("cx"));
+ const QStringRef cy = attributes.value(QLatin1String("cy"));
+ const QStringRef r = attributes.value(QLatin1String("r"));
qreal ncx = toDouble(cx);
qreal ncy = toDouble(cy);
qreal nr = toDouble(r);
@@ -2551,10 +2576,10 @@ static QSvgNode *createEllipseNode(QSvgNode *parent,
const QXmlStreamAttributes &attributes,
QSvgHandler *)
{
- QString cx = attributes.value(QLatin1String("cx")).toString();
- QString cy = attributes.value(QLatin1String("cy")).toString();
- QString rx = attributes.value(QLatin1String("rx")).toString();
- QString ry = attributes.value(QLatin1String("ry")).toString();
+ const QStringRef cx = attributes.value(QLatin1String("cx"));
+ const QStringRef cy = attributes.value(QLatin1String("cy"));
+ const QStringRef rx = attributes.value(QLatin1String("rx"));
+ const QStringRef ry = attributes.value(QLatin1String("ry"));
qreal ncx = toDouble(cx);
qreal ncy = toDouble(cy);
qreal nrx = toDouble(rx);
@@ -2569,7 +2594,7 @@ static QSvgStyleProperty *createFontNode(QSvgNode *parent,
const QXmlStreamAttributes &attributes,
QSvgHandler *)
{
- QString hax = attributes.value(QLatin1String("horiz-adv-x")).toString();
+ const QStringRef hax = attributes.value(QLatin1String("horiz-adv-x"));
QString myId = someId(attributes);
qreal horizAdvX = toDouble(hax);
@@ -2602,7 +2627,7 @@ static bool parseFontFaceNode(QSvgStyleProperty *parent,
QSvgFontStyle *style = static_cast<QSvgFontStyle*>(parent);
QSvgFont *font = style->svgFont();
QString name = attributes.value(QLatin1String("font-family")).toString();
- QString unitsPerEmStr = attributes.value(QLatin1String("units-per-em")).toString();
+ const QStringRef unitsPerEmStr = attributes.value(QLatin1String("units-per-em"));
qreal unitsPerEm = toDouble(unitsPerEmStr);
if (!unitsPerEm)
@@ -2708,11 +2733,11 @@ static QSvgNode *createImageNode(QSvgNode *parent,
const QXmlStreamAttributes &attributes,
QSvgHandler *handler)
{
- QString x = attributes.value(QLatin1String("x")).toString();
- QString y = attributes.value(QLatin1String("y")).toString();
- QString width = attributes.value(QLatin1String("width")).toString();
- QString height = attributes.value(QLatin1String("height")).toString();
- QString filename = attributes.value(QLatin1String("xlink:href")).toString();
+ const QStringRef x = attributes.value(QLatin1String("x"));
+ const QStringRef y = attributes.value(QLatin1String("y"));
+ const QStringRef width = attributes.value(QLatin1String("width"));
+ const QStringRef height = attributes.value(QLatin1String("height"));
+ QStringRef filename = attributes.value(QLatin1String("xlink:href"));
qreal nx = toDouble(x);
qreal ny = toDouble(y);
QSvgHandler::LengthType type;
@@ -2737,14 +2762,14 @@ static QSvgNode *createImageNode(QSvgNode *parent,
int idx = filename.lastIndexOf(QLatin1String("base64,"));
if (idx != -1) {
idx += 7;
- QString dataStr = filename.mid(idx);
+ QStringRef dataStr = filename.mid(idx);
QByteArray data = QByteArray::fromBase64(dataStr.toLatin1());
image = QImage::fromData(data);
} else {
qCDebug(lcSvgHandler) << "QSvgHandler::createImageNode: Unrecognized inline image format!";
}
} else
- image = QImage(filename);
+ image = QImage(filename.toString());
if (image.isNull()) {
qDebug()<<"couldn't create image from "<<filename;
@@ -2767,10 +2792,10 @@ static QSvgNode *createLineNode(QSvgNode *parent,
const QXmlStreamAttributes &attributes,
QSvgHandler *)
{
- QString x1 = attributes.value(QLatin1String("x1")).toString();
- QString y1 = attributes.value(QLatin1String("y1")).toString();
- QString x2 = attributes.value(QLatin1String("x2")).toString();
- QString y2 = attributes.value(QLatin1String("y2")).toString();
+ const QStringRef x1 = attributes.value(QLatin1String("x1"));
+ const QStringRef y1 = attributes.value(QLatin1String("y1"));
+ const QStringRef x2 = attributes.value(QLatin1String("x2"));
+ const QStringRef y2 = attributes.value(QLatin1String("y2"));
qreal nx1 = toDouble(x1);
qreal ny1 = toDouble(y1);
qreal nx2 = toDouble(x2);
@@ -2847,10 +2872,10 @@ static QSvgStyleProperty *createLinearGradientNode(QSvgNode *node,
const QXmlStreamAttributes &attributes,
QSvgHandler *handler)
{
- QString x1 = attributes.value(QLatin1String("x1")).toString();
- QString y1 = attributes.value(QLatin1String("y1")).toString();
- QString x2 = attributes.value(QLatin1String("x2")).toString();
- QString y2 = attributes.value(QLatin1String("y2")).toString();
+ const QStringRef x1 = attributes.value(QLatin1String("x1"));
+ const QStringRef y1 = attributes.value(QLatin1String("y1"));
+ const QStringRef x2 = attributes.value(QLatin1String("x2"));
+ const QStringRef y2 = attributes.value(QLatin1String("y2"));
qreal nx1 = 0.0;
qreal ny1 = 0.0;
@@ -2969,11 +2994,11 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
const QXmlStreamAttributes &attributes,
QSvgHandler *handler)
{
- QString cx = attributes.value(QLatin1String("cx")).toString();
- QString cy = attributes.value(QLatin1String("cy")).toString();
- QString r = attributes.value(QLatin1String("r")).toString();
- QString fx = attributes.value(QLatin1String("fx")).toString();
- QString fy = attributes.value(QLatin1String("fy")).toString();
+ const QStringRef cx = attributes.value(QLatin1String("cx"));
+ const QStringRef cy = attributes.value(QLatin1String("cy"));
+ const QStringRef r = attributes.value(QLatin1String("r"));
+ const QStringRef fx = attributes.value(QLatin1String("fx"));
+ const QStringRef fy = attributes.value(QLatin1String("fy"));
qreal ncx = 0.5;
qreal ncy = 0.5;
@@ -3005,12 +3030,12 @@ static QSvgNode *createRectNode(QSvgNode *parent,
const QXmlStreamAttributes &attributes,
QSvgHandler *handler)
{
- QString x = attributes.value(QLatin1String("x")).toString();
- QString y = attributes.value(QLatin1String("y")).toString();
- QString width = attributes.value(QLatin1String("width")).toString();
- QString height = attributes.value(QLatin1String("height")).toString();
- QString rx = attributes.value(QLatin1String("rx")).toString();
- QString ry = attributes.value(QLatin1String("ry")).toString();
+ const QStringRef x = attributes.value(QLatin1String("x"));
+ const QStringRef y = attributes.value(QLatin1String("y"));
+ const QStringRef width = attributes.value(QLatin1String("width"));
+ const QStringRef height = attributes.value(QLatin1String("height"));
+ const QStringRef rx = attributes.value(QLatin1String("rx"));
+ const QStringRef ry = attributes.value(QLatin1String("ry"));
QSvgHandler::LengthType type;
qreal nwidth = parseLength(width, type, handler);
@@ -3129,12 +3154,11 @@ static bool parseStopNode(QSvgStyleProperty *parent,
QSvgGradientStyle *style =
static_cast<QSvgGradientStyle*>(parent);
- QString offsetStr = attrs.offset.toString();
QStringRef colorStr = attrs.stopColor;
QColor color;
bool ok = true;
- qreal offset = convertToNumber(offsetStr, handler, &ok);
+ qreal offset = convertToNumber(attrs.offset, handler, &ok);
if (!ok)
offset = 0.0;
QString black = QString::fromLatin1("#000000");
@@ -3178,12 +3202,9 @@ static bool parseStyleNode(QSvgNode *parent,
Q_UNUSED(attributes)
Q_UNUSED(handler)
#else
- QString type = attributes.value(QLatin1String("type")).toString();
- type = type.toLower();
-
- if (type == QLatin1String("text/css")) {
+ const QStringRef type = attributes.value(QLatin1String("type"));
+ if (type.compare(QLatin1String("text/css"), Qt::CaseInsensitive) == 0)
handler->setInStyle(true);
- }
#endif
return true;
@@ -3196,8 +3217,8 @@ static QSvgNode *createSvgNode(QSvgNode *parent,
Q_UNUSED(parent); Q_UNUSED(attributes);
QSvgTinyDocument *node = new QSvgTinyDocument();
- QString widthStr = attributes.value(QLatin1String("width")).toString();
- QString heightStr = attributes.value(QLatin1String("height")).toString();
+ const QStringRef widthStr = attributes.value(QLatin1String("width"));
+ const QStringRef heightStr = attributes.value(QLatin1String("height"));
QString viewBoxStr = attributes.value(QLatin1String("viewBox")).toString();
QSvgHandler::LengthType type = QSvgHandler::LT_PX; // FIXME: is the default correct?
@@ -3273,8 +3294,8 @@ static QSvgNode *createTextNode(QSvgNode *parent,
const QXmlStreamAttributes &attributes,
QSvgHandler *handler)
{
- QString x = attributes.value(QLatin1String("x")).toString();
- QString y = attributes.value(QLatin1String("y")).toString();
+ const QStringRef x = attributes.value(QLatin1String("x"));
+ const QStringRef y = attributes.value(QLatin1String("y"));
//### editable and rotate not handled
QSvgHandler::LengthType type;
qreal nx = parseLength(x, type, handler);
@@ -3291,8 +3312,8 @@ static QSvgNode *createTextAreaNode(QSvgNode *parent,
QSvgText *node = static_cast<QSvgText *>(createTextNode(parent, attributes, handler));
if (node) {
QSvgHandler::LengthType type;
- qreal width = parseLength(attributes.value(QLatin1String("width")).toString(), type, handler);
- qreal height = parseLength(attributes.value(QLatin1String("height")).toString(), type, handler);
+ qreal width = parseLength(attributes.value(QLatin1String("width")), type, handler);
+ qreal height = parseLength(attributes.value(QLatin1String("height")), type, handler);
node->setTextArea(QSizeF(width, height));
}
return node;
@@ -3318,8 +3339,8 @@ static QSvgNode *createUseNode(QSvgNode *parent,
QSvgHandler *handler)
{
QString linkId = attributes.value(QLatin1String("xlink:href")).toString().remove(0, 1);
- QString xStr = attributes.value(QLatin1String("x")).toString();
- QString yStr = attributes.value(QLatin1String("y")).toString();
+ const QStringRef xStr = attributes.value(QLatin1String("x"));
+ const QStringRef yStr = attributes.value(QLatin1String("y"));
QSvgStructureNode *group = 0;
if (linkId.isEmpty())
diff --git a/src/svg/svg.pro b/src/svg/svg.pro
index f9e43b0..b6f17a7 100644
--- a/src/svg/svg.pro
+++ b/src/svg/svg.pro
@@ -3,7 +3,7 @@ QT = core-private gui-private
qtHaveModule(widgets): QT += widgets-private
DEFINES += QT_NO_USING_NAMESPACE
-win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000
+msvc:equals(QT_ARCH, i386): QMAKE_LFLAGS += /BASE:0x66000000
solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_DOCS = $$PWD/doc/qtsvg.qdocconf
diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
index fd1b350..87d24c7 100644
--- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
@@ -1235,7 +1235,7 @@ void tst_QSvgRenderer::testStopOffsetOpacity()
void tst_QSvgRenderer::testUseElement()
{
static const char *svgs[] = {
- //Use refering to non group node (1)
+ //Use referring to non group node (1)
"<svg viewBox = \"0 0 200 200\">"
" <polygon points=\"20,20 50,120 100,10 40,80 50,80\"/>"
" <polygon points=\"20,80 50,180 100,70 40,140 50,140\" fill= \"red\" stroke = \"blue\" fill-opacity = \"0.7\" fill-rule = \"evenodd\" stroke-width = \"3\"/>"
@@ -1256,7 +1256,7 @@ void tst_QSvgRenderer::testUseElement()
" <use y = \"60\" xlink:href = \"#usedPolyline\" fill = \" red\" stroke = \"blue\" fill-opacity = \"0.7\" fill-rule = \"evenodd\"/>"
" </g>"
"</svg>",
- //Use refering to non group node (2)
+ //Use referring to non group node (2)
"<svg viewBox = \"0 0 200 200\">"
" <polygon points=\"20,20 50,120 100,10 40,80 50,80\" fill = \"green\" fill-rule = \"nonzero\" stroke = \"purple\" stroke-width = \"4\" stroke-dasharray = \"1,1,3,1\" stroke-offset = \"3\" stroke-miterlimit = \"6\" stroke-linecap = \"butt\" stroke-linejoin = \"round\"/>"
" <polygon points=\"20,80 50,180 100,70 40,140 50,140\" fill= \"red\" stroke = \"blue\" fill-opacity = \"0.7\" fill-rule = \"evenodd\" stroke-width = \"3\" stroke-dasharray = \"1,1,1,1\" stroke-offset = \"5\" stroke-miterlimit = \"3\" stroke-linecap = \"butt\" stroke-linejoin = \"square\"/>"
@@ -1277,7 +1277,7 @@ void tst_QSvgRenderer::testUseElement()
" <use y = \"60\" xlink:href = \"#usedPolyline\" fill= \"red\" stroke = \"blue\" fill-opacity = \"0.7\" fill-rule = \"evenodd\" />"
" </g>"
"</svg>",
- //Use refering to group node
+ //Use referring to group node
"<svg viewBox = \"0 0 200 200\">"
" <g>"
" <circle cx=\"0\" cy=\"0\" r=\"100\" fill = \"red\" fill-opacity = \"0.6\"/>"