1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/base/nsCSSColorUtils.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* functions that manipulate colors */ 1.10 + 1.11 +#ifndef __nsCSSColorUtils_h 1.12 +#define __nsCSSColorUtils_h 1.13 + 1.14 +#include "nsColor.h" 1.15 + 1.16 +// "Sufficient contrast" is determined by 1.17 +// "Techniques For Accessibility Evalution And Repair Tools". 1.18 +// See http://www.w3.org/TR/AERT#color-contrast 1.19 +#define NS_SUFFICIENT_LUMINOSITY_DIFFERENCE 125000 1.20 +#define NS_LUMINOSITY_DIFFERENCE(a, b) \ 1.21 + int32_t(mozilla::Abs(NS_GetLuminosity(a) - NS_GetLuminosity(b))) 1.22 + 1.23 +// To determine colors based on the background brightness and border color 1.24 +void NS_GetSpecial3DColors(nscolor aResult[2], 1.25 + nscolor aBackgroundColor, 1.26 + nscolor aBorderColor); 1.27 + 1.28 +// Determins brightness for a specific color 1.29 +int NS_GetBrightness(uint8_t aRed, uint8_t aGreen, uint8_t aBlue); 1.30 + 1.31 +// Get Luminosity of a specific color. That is same as Y of YIQ color space. 1.32 +// The range of return value is 0 to 255000. 1.33 +int32_t NS_GetLuminosity(nscolor aColor); 1.34 + 1.35 +// function to convert from RGBA color space to HSVA color space 1.36 +void NS_RGB2HSV(nscolor aColor, uint16_t &aHue, uint16_t &aSat, 1.37 + uint16_t &aValue, uint8_t &aAlpha); 1.38 + 1.39 +// function to convert from HSVA color space to RGBA color space 1.40 +void NS_HSV2RGB(nscolor &aColor, uint16_t aHue, uint16_t aSat, uint16_t aValue, 1.41 + uint8_t aAlpha); 1.42 + 1.43 +#endif