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 --- tests/auto/gui/text/qcssparser/tst_qcssparser.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index 5bd4091832..df9e8dab71 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -840,10 +840,13 @@ void tst_QCssParser::colorValue_data() QTest::newRow("rgbaf") << "color: rgba(10, 20, 30, 0.5)" << QColor(10, 20, 30, 127); QTest::newRow("hsv") << "color: hsv(10, 20, 30)" << QColor::fromHsv(10, 20, 30); QTest::newRow("hsva") << "color: hsva(10, 20, 30, 40)" << QColor::fromHsv(10, 20, 30, 40); - QTest::newRow("hsvaf") << "color: hsva(10, 20, 30, 0.5)" << QColor::fromHsv(10, 20, 30, 127); + // the percent and float values are well chosen to not get in trouble due to rounding errors + QTest::newRow("hsva-percent") << "color: hsva(100%, 20%, 40%, 60%)" << QColor::fromHsv(359, 51, 102, 153); + QTest::newRow("hsva-float") << "color: hsva(180, 20%, 40%, 0.6)" << QColor::fromHsvF(0.5, 0.2, 0.4, 0.6); QTest::newRow("hsl") << "color: hsl(60, 100%, 50%)" << QColor::fromHsl(60., 255, 127); QTest::newRow("hsla") << "color: hsla(240, 255, 127, 192)" << QColor::fromHsl(240, 255, 127, 192); - QTest::newRow("hslaf") << "color: hsla(240, 255, 127, 0.25)" << QColor::fromHsl(240, 255, 127, 63); + QTest::newRow("hsla-percent") << "color: hsla(100%, 80%, 40%, 0%)" << QColor::fromHsl(359, 204, 102, 0); + QTest::newRow("hsla-float") << "color: hsla(252, 40%, 60%, 0.2)" << QColor::fromHslF(0.7, 0.4, 0.6, 0.2); QTest::newRow("invalid1") << "color: rgb(why, does, it, always, rain, on, me)" << QColor(); QTest::newRow("invalid2") << "color: rgba(i, meant, norway)" << QColor(); QTest::newRow("invalid3") << "color: rgb(21)" << QColor(); -- cgit v1.2.3