From aaae0274353544bba9f6eb50ded6c9ffd040dc18 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 3 Oct 2018 14:11:08 +0200 Subject: Qt Style Sheets: fix range of hue in hsl/hsv functions The hue parameter in hsl/hsv was treated the same way as a the other parameters although it's range is from 0-359 and not from 0-255. Fix it by extending the maximum range for the first parameter when parsing a color value given in hsv or hsl. [ChangeLog][QtGui][CSS] Fix the range of the hue parameter when parsing a color given in hsl or hsv Fixes: QTBUG-70897 Change-Id: I9ffa65a89c0abcca62bae35777ca1cbde3375180 Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qcssparser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index b65e89f69d..1c454b0fca 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -754,7 +754,8 @@ static ColorData parseColorValue(QCss::Value v) for (int i = 0; i < qMin(tokenCount, 7); i += 2) { if (colorDigits.at(i).type == Value::Percentage) { - colorDigits[i].variant = colorDigits.at(i).variant.toReal() * (255. / 100.); + const qreal maxRange = (rgb || i != 0) ? 255. : 359.; + colorDigits[i].variant = colorDigits.at(i).variant.toReal() * (maxRange / 100.); colorDigits[i].type = Value::Number; } else if (colorDigits.at(i).type != Value::Number) { return ColorData(); -- cgit v1.2.3