Bug 1826564 [wpt PR 39394] - Update mypy, a=testonly
[gecko.git] / layout / style / StyleColorInlines.h
blob72b4dbae8adb70b36e23822c1a49f53c74becd66
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* Inline functions for StyleColor (aka values::computed::Color) */
9 #ifndef mozilla_StyleColorInlines_h_
10 #define mozilla_StyleColorInlines_h_
12 #include "nsColor.h"
13 #include "mozilla/ServoStyleConsts.h"
14 #include "nsStyleUtil.h"
16 namespace mozilla {
18 inline StyleAbsoluteColor StyleAbsoluteColor::FromColor(nscolor aColor) {
19 return StyleAbsoluteColor::Srgb(
20 NS_GET_R(aColor) / 255.0f, NS_GET_G(aColor) / 255.0f,
21 NS_GET_B(aColor) / 255.0f, NS_GET_A(aColor) / 255.0f);
24 // static
25 inline StyleAbsoluteColor StyleAbsoluteColor::Srgb(float red, float green,
26 float blue, float alpha) {
27 return StyleAbsoluteColor{StyleColorComponents{red, green, blue}, alpha,
28 StyleColorSpace::Srgb, StyleColorFlags{0}};
31 inline StyleAbsoluteColor StyleAbsoluteColor::Transparent() {
32 return StyleAbsoluteColor::Srgb(0.0f, 0.0f, 0.0f, 0.0f);
35 inline StyleAbsoluteColor StyleAbsoluteColor::Black() {
36 return StyleAbsoluteColor::Srgb(0.0f, 0.0f, 0.0f, 1.0f);
39 inline StyleAbsoluteColor StyleAbsoluteColor::White() {
40 return StyleAbsoluteColor::Srgb(1.0f, 1.0f, 1.0f, 1.0f);
43 template <>
44 inline StyleColor StyleColor::FromColor(nscolor aColor) {
45 return StyleColor::Absolute(StyleAbsoluteColor::FromColor(aColor));
48 template <>
49 inline StyleColor StyleColor::Black() {
50 return FromColor(NS_RGB(0, 0, 0));
53 template <>
54 inline StyleColor StyleColor::White() {
55 return FromColor(NS_RGB(255, 255, 255));
58 template <>
59 inline StyleColor StyleColor::Transparent() {
60 return FromColor(NS_RGBA(0, 0, 0, 0));
63 template <>
64 StyleAbsoluteColor StyleColor::ResolveColor(const StyleAbsoluteColor&) const;
66 template <>
67 nscolor StyleColor::CalcColor(const StyleAbsoluteColor&) const;
69 template <>
70 nscolor StyleColor::CalcColor(nscolor) const;
72 template <>
73 nscolor StyleColor::CalcColor(const ComputedStyle&) const;
75 template <>
76 nscolor StyleColor::CalcColor(const nsIFrame*) const;
78 } // namespace mozilla
80 #endif // mozilla_StyleColor_h_