2012-02-20 15:45:29 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-06-29 10:42:59 +00:00
|
|
|
/* vim: set expandtab shiftwidth=2 tabstop=2: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-02-20 15:45:29 +00:00
|
|
|
|
|
|
|
#include "StyleInfo.h"
|
|
|
|
|
2023-05-12 23:33:12 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2012-02-20 15:45:29 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2021-06-10 23:07:06 +00:00
|
|
|
void StyleInfo::FormatColor(const nscolor& aValue, nsAString& aFormattedValue) {
|
2012-02-27 14:43:39 +00:00
|
|
|
// Combine the string like rgb(R, G, B) from nscolor.
|
2023-04-12 08:43:15 +00:00
|
|
|
// FIXME: What about the alpha channel?
|
2012-02-27 14:43:39 +00:00
|
|
|
aFormattedValue.AppendLiteral("rgb(");
|
|
|
|
aFormattedValue.AppendInt(NS_GET_R(aValue));
|
|
|
|
aFormattedValue.AppendLiteral(", ");
|
|
|
|
aFormattedValue.AppendInt(NS_GET_G(aValue));
|
|
|
|
aFormattedValue.AppendLiteral(", ");
|
|
|
|
aFormattedValue.AppendInt(NS_GET_B(aValue));
|
|
|
|
aFormattedValue.Append(')');
|
|
|
|
}
|
2012-02-29 07:35:51 +00:00
|
|
|
|
2022-12-19 22:47:24 +00:00
|
|
|
already_AddRefed<nsAtom> StyleInfo::TextDecorationStyleToAtom(
|
|
|
|
StyleTextDecorationStyle aValue) {
|
2020-02-24 13:30:46 +00:00
|
|
|
// TODO: When these are enum classes that rust also understands we should just
|
|
|
|
// make an FFI call here.
|
2023-04-12 08:43:15 +00:00
|
|
|
// TODO: These should probably be static atoms.
|
2020-02-24 13:30:46 +00:00
|
|
|
switch (aValue) {
|
2022-12-19 22:47:24 +00:00
|
|
|
case StyleTextDecorationStyle::None:
|
2021-06-10 23:07:06 +00:00
|
|
|
return NS_Atomize("-moz-none");
|
2022-12-19 22:47:24 +00:00
|
|
|
case StyleTextDecorationStyle::Solid:
|
2021-06-10 23:07:06 +00:00
|
|
|
return NS_Atomize("solid");
|
2022-12-19 22:47:24 +00:00
|
|
|
case StyleTextDecorationStyle::Double:
|
2021-06-10 23:07:06 +00:00
|
|
|
return NS_Atomize("double");
|
2022-12-19 22:47:24 +00:00
|
|
|
case StyleTextDecorationStyle::Dotted:
|
2021-06-10 23:07:06 +00:00
|
|
|
return NS_Atomize("dotted");
|
2022-12-19 22:47:24 +00:00
|
|
|
case StyleTextDecorationStyle::Dashed:
|
2021-06-10 23:07:06 +00:00
|
|
|
return NS_Atomize("dashed");
|
2022-12-19 22:47:24 +00:00
|
|
|
case StyleTextDecorationStyle::Wavy:
|
2021-06-10 23:07:06 +00:00
|
|
|
return NS_Atomize("wavy");
|
2020-02-24 13:30:46 +00:00
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Unknown decoration style");
|
|
|
|
break;
|
|
|
|
}
|
2021-06-10 23:07:06 +00:00
|
|
|
|
|
|
|
return nullptr;
|
2012-03-10 15:35:02 +00:00
|
|
|
}
|