Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* functions that manipulate colors */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef __nsCSSColorUtils_h |
michael@0 | 9 | #define __nsCSSColorUtils_h |
michael@0 | 10 | |
michael@0 | 11 | #include "nsColor.h" |
michael@0 | 12 | |
michael@0 | 13 | // "Sufficient contrast" is determined by |
michael@0 | 14 | // "Techniques For Accessibility Evalution And Repair Tools". |
michael@0 | 15 | // See http://www.w3.org/TR/AERT#color-contrast |
michael@0 | 16 | #define NS_SUFFICIENT_LUMINOSITY_DIFFERENCE 125000 |
michael@0 | 17 | #define NS_LUMINOSITY_DIFFERENCE(a, b) \ |
michael@0 | 18 | int32_t(mozilla::Abs(NS_GetLuminosity(a) - NS_GetLuminosity(b))) |
michael@0 | 19 | |
michael@0 | 20 | // To determine colors based on the background brightness and border color |
michael@0 | 21 | void NS_GetSpecial3DColors(nscolor aResult[2], |
michael@0 | 22 | nscolor aBackgroundColor, |
michael@0 | 23 | nscolor aBorderColor); |
michael@0 | 24 | |
michael@0 | 25 | // Determins brightness for a specific color |
michael@0 | 26 | int NS_GetBrightness(uint8_t aRed, uint8_t aGreen, uint8_t aBlue); |
michael@0 | 27 | |
michael@0 | 28 | // Get Luminosity of a specific color. That is same as Y of YIQ color space. |
michael@0 | 29 | // The range of return value is 0 to 255000. |
michael@0 | 30 | int32_t NS_GetLuminosity(nscolor aColor); |
michael@0 | 31 | |
michael@0 | 32 | // function to convert from RGBA color space to HSVA color space |
michael@0 | 33 | void NS_RGB2HSV(nscolor aColor, uint16_t &aHue, uint16_t &aSat, |
michael@0 | 34 | uint16_t &aValue, uint8_t &aAlpha); |
michael@0 | 35 | |
michael@0 | 36 | // function to convert from HSVA color space to RGBA color space |
michael@0 | 37 | void NS_HSV2RGB(nscolor &aColor, uint16_t aHue, uint16_t aSat, uint16_t aValue, |
michael@0 | 38 | uint8_t aAlpha); |
michael@0 | 39 | |
michael@0 | 40 | #endif |