forked from qt-creator/qt-creator
AutoTest: Re-use established code
Instead of "parsing", modifying and highlighting the text after it has been added use existing code to get formatted code beforehand. Change-Id: I33be2950f9b9a6910ad80b10b132089f4e5f0b1c Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -573,7 +573,7 @@ QList<int> StyleHelper::availableImageResolutions(const QString &fileName)
|
||||
return result;
|
||||
}
|
||||
|
||||
static double luminance(const QColor &color)
|
||||
double StyleHelper::luminance(const QColor &color)
|
||||
{
|
||||
// calculate the luminance based on
|
||||
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
||||
@@ -595,7 +595,7 @@ static double contrastRatio(const QColor &color1, const QColor &color2)
|
||||
{
|
||||
// calculate the contrast ratio based on
|
||||
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
|
||||
auto contrast = (luminance(color1) + 0.05) / (luminance(color2) + 0.05);
|
||||
auto contrast = (StyleHelper::luminance(color1) + .05) / (StyleHelper::luminance(color2) + .05);
|
||||
if (contrast < 1)
|
||||
return 1 / contrast;
|
||||
return contrast;
|
||||
|
||||
Reference in New Issue
Block a user