1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set expandtab shiftwidth=2 tabstop=2: */
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/. */
9 #include "nsStyleConsts.h"
11 using namespace mozilla
;
12 using namespace mozilla::a11y
;
14 void StyleInfo::FormatColor(const nscolor
& aValue
, nsAString
& aFormattedValue
) {
15 // Combine the string like rgb(R, G, B) from nscolor.
16 // FIXME: What about the alpha channel?
17 aFormattedValue
.AppendLiteral("rgb(");
18 aFormattedValue
.AppendInt(NS_GET_R(aValue
));
19 aFormattedValue
.AppendLiteral(", ");
20 aFormattedValue
.AppendInt(NS_GET_G(aValue
));
21 aFormattedValue
.AppendLiteral(", ");
22 aFormattedValue
.AppendInt(NS_GET_B(aValue
));
23 aFormattedValue
.Append(')');
26 already_AddRefed
<nsAtom
> StyleInfo::TextDecorationStyleToAtom(
27 StyleTextDecorationStyle aValue
) {
28 // TODO: When these are enum classes that rust also understands we should just
29 // make an FFI call here.
30 // TODO: These should probably be static atoms.
32 case StyleTextDecorationStyle::None
:
33 return NS_Atomize("-moz-none");
34 case StyleTextDecorationStyle::Solid
:
35 return NS_Atomize("solid");
36 case StyleTextDecorationStyle::Double
:
37 return NS_Atomize("double");
38 case StyleTextDecorationStyle::Dotted
:
39 return NS_Atomize("dotted");
40 case StyleTextDecorationStyle::Dashed
:
41 return NS_Atomize("dashed");
42 case StyleTextDecorationStyle::Wavy
:
43 return NS_Atomize("wavy");
45 MOZ_ASSERT_UNREACHABLE("Unknown decoration style");