mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
9d38cfb2a9
This simplifies a tiny bit our bindings in some places, and complicates it in others, but over all I think it's better. It requires a bit more manual code in the rust side to drop and cast the relevant pointers (which was done implicitly before), but it's a lot less magic than it used to be, and that's all autogenerated so consumers don't need to care about it. The set up is still not ideal. I don't like that we rely on destructors running in both sides of the FFI boundary, but that's for another day. This is the last usage of RawOffsetArc, so remove that. We now support proper Arc<> in structs (GridTemplateAreas uses it), so I don't think we'll need it any time soon. Differential Revision: https://phabricator.services.mozilla.com/D177905
51 lines
1.7 KiB
C++
51 lines
1.7 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set expandtab shiftwidth=2 tabstop=2: */
|
|
/* 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/. */
|
|
|
|
#include "StyleInfo.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::a11y;
|
|
|
|
void StyleInfo::FormatColor(const nscolor& aValue, nsAString& aFormattedValue) {
|
|
// Combine the string like rgb(R, G, B) from nscolor.
|
|
// FIXME: What about the alpha channel?
|
|
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(')');
|
|
}
|
|
|
|
already_AddRefed<nsAtom> StyleInfo::TextDecorationStyleToAtom(
|
|
StyleTextDecorationStyle aValue) {
|
|
// TODO: When these are enum classes that rust also understands we should just
|
|
// make an FFI call here.
|
|
// TODO: These should probably be static atoms.
|
|
switch (aValue) {
|
|
case StyleTextDecorationStyle::None:
|
|
return NS_Atomize("-moz-none");
|
|
case StyleTextDecorationStyle::Solid:
|
|
return NS_Atomize("solid");
|
|
case StyleTextDecorationStyle::Double:
|
|
return NS_Atomize("double");
|
|
case StyleTextDecorationStyle::Dotted:
|
|
return NS_Atomize("dotted");
|
|
case StyleTextDecorationStyle::Dashed:
|
|
return NS_Atomize("dashed");
|
|
case StyleTextDecorationStyle::Wavy:
|
|
return NS_Atomize("wavy");
|
|
default:
|
|
MOZ_ASSERT_UNREACHABLE("Unknown decoration style");
|
|
break;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|