summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-09-10 08:39:42 (GMT)
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-09-10 08:46:42 (GMT)
commit53b4b458982fd9520ac710843fd5b68780adf159 (patch)
treea646e0fafa0e39bc808bff1721336af880e8ee4c
parent0adc0bc91d0745177a30ce5899583f5e127d01b9 (diff)
downloadQt-53b4b458982fd9520ac710843fd5b68780adf159.zip
Qt-53b4b458982fd9520ac710843fd5b68780adf159.tar.gz
Qt-53b4b458982fd9520ac710843fd5b68780adf159.tar.bz2
Fixed handling of stop-color="currentColor" in the SVG module.
The 'color' attribute is now explicitly parsed for gradient nodes. Task-number: 260921 Reviewed-by: Trond
-rw-r--r--src/svg/qsvghandler.cpp43
-rw-r--r--src/svg/qsvghandler_p.h2
2 files changed, 31 insertions, 14 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index 06a49d8..98fa26f 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -968,6 +968,7 @@ static void parseColor(QSvgNode *,
{
QColor color;
if (constructColor(attributes.color, attributes.colorOpacity, color, handler)) {
+ handler->popColor();
handler->pushColor(color);
}
}
@@ -2728,6 +2729,14 @@ static void parseBaseGradient(QSvgNode *node,
QStringRef trans = attributes.value(QLatin1String("gradientTransform"));
QString spread = attributes.value(QLatin1String("spreadMethod")).toString();
QString units = attributes.value(QLatin1String("gradientUnits")).toString();
+ QStringRef colorStr = attributes.value(QLatin1String("color"));
+ QStringRef colorOpacityStr = attributes.value(QLatin1String("color-opacity"));
+
+ QColor color;
+ if (constructColor(colorStr, colorOpacityStr, color, handler)) {
+ handler->popColor();
+ handler->pushColor(color);
+ }
QMatrix matrix;
QGradient *grad = gradProp->qgradient();
@@ -3558,11 +3567,7 @@ bool QSvgHandler::startElement(const QString &localName,
{
QSvgNode *node = 0;
- if (m_colorTagCount.count()) {
- int top = m_colorTagCount.pop();
- ++top;
- m_colorTagCount.push(top);
- }
+ pushColorCopy();
/* The xml:space attribute may appear on any element. We do
* a lookup by the qualified name here, but this is namespace aware, since
@@ -3696,15 +3701,7 @@ bool QSvgHandler::endElement(const QStringRef &localName)
m_skipNodes.pop();
m_whitespaceMode.pop();
- if (m_colorTagCount.count()) {
- int top = m_colorTagCount.pop();
- --top;
- if (!top) {
- m_colorStack.pop();
- } else {
- m_colorTagCount.push(top);
- }
- }
+ popColor();
if (node == Unknown) {
return true;
@@ -3801,6 +3798,24 @@ void QSvgHandler::pushColor(const QColor &color)
m_colorTagCount.push(1);
}
+void QSvgHandler::pushColorCopy()
+{
+ if (m_colorTagCount.count())
+ ++m_colorTagCount.top();
+ else
+ pushColor(Qt::black);
+}
+
+void QSvgHandler::popColor()
+{
+ if (m_colorTagCount.count()) {
+ if (!--m_colorTagCount.top()) {
+ m_colorStack.pop();
+ m_colorTagCount.pop();
+ }
+ }
+}
+
QColor QSvgHandler::currentColor() const
{
if (!m_colorStack.isEmpty())
diff --git a/src/svg/qsvghandler_p.h b/src/svg/qsvghandler_p.h
index 1b31677..aff6f1d 100644
--- a/src/svg/qsvghandler_p.h
+++ b/src/svg/qsvghandler_p.h
@@ -111,6 +111,8 @@ public:
LengthType defaultCoordinateSystem() const;
void pushColor(const QColor &color);
+ void pushColorCopy();
+ void popColor();
QColor currentColor() const;
void setInStyle(bool b);