Bug 1278647 [stylo] Add font family bindings for Servo r?heycam
MozReview-Commit-ID: IlEB0f1xrKF
--- a/gfx/thebes/gfxFontFamilyList.h
+++ b/gfx/thebes/gfxFontFamilyList.h
@@ -16,17 +16,17 @@
namespace mozilla {
/**
* type of font family name, either a name (e.g. Helvetica) or a
* generic (e.g. serif, sans-serif), with the ability to distinguish
* between unquoted and quoted names for serializaiton
*/
-enum FontFamilyType {
+enum FontFamilyType : uint32_t {
eFamily_none = 0, // used when finding generics
// explicitly named font family (e.g. Helvetica)
eFamily_named,
eFamily_named_quoted,
// generics
eFamily_serif, // pref font code relies on this ordering!!!
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1,16 +1,17 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "mozilla/ServoBindings.h"
+#include "gfxFontFamilyList.h"
#include "nsAttrValueInlines.h"
#include "nsCSSRuleProcessor.h"
#include "nsContentUtils.h"
#include "nsDOMTokenList.h"
#include "nsIDOMNode.h"
#include "nsIDocument.h"
#include "nsINode.h"
#include "nsIPrincipal.h"
@@ -282,16 +283,43 @@ Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom*
// find the right thing to call.
nsAutoString atomStr;
aAtom->ToString(atomStr);
NS_ConvertUTF8toUTF16 inStr(nsDependentCSubstring(aString, aLength));
return nsContentUtils::EqualsIgnoreASCIICase(atomStr, inStr);
}
void
+Gecko_FontFamilyList_Clear(FontFamilyList* aList) {
+ aList->Clear();
+}
+
+void
+Gecko_FontFamilyList_AppendNamed(FontFamilyList* aList, nsIAtom* aName)
+{
+ // Servo doesn't record whether the name was quoted or unquoted, so just
+ // assume unquoted for now.
+ FontFamilyName family;
+ aName->ToString(family.mName);
+ aList->Append(family);
+}
+
+void
+Gecko_FontFamilyList_AppendGeneric(FontFamilyList* aList, FontFamilyType aType)
+{
+ aList->Append(FontFamilyName(aType));
+}
+
+void
+Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src)
+{
+ dst->fontlist = src->fontlist;
+}
+
+void
Gecko_SetListStyleType(nsStyleList* style_struct, uint32_t type)
{
// Builtin counter styles are static and use no-op refcounting, and thus are
// safe to use off-main-thread.
style_struct->SetCounterStyle(CounterStyleManager::GetBuiltinStyle(type));
}
void
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -20,17 +20,24 @@
* Functions beginning with Servo_ are implemented in Servo and invoked from Gecko.
*/
class nsIAtom;
class nsINode;
typedef nsINode RawGeckoNode;
class nsIPrincipal;
class nsIURI;
-namespace mozilla { namespace dom { class Element; } }
+struct nsFont;
+namespace mozilla {
+ class FontFamilyList;
+ enum FontFamilyType : uint32_t;
+ namespace dom { class Element; }
+}
+using mozilla::FontFamilyList;
+using mozilla::FontFamilyType;
using mozilla::dom::Element;
typedef mozilla::dom::Element RawGeckoElement;
class nsIDocument;
typedef nsIDocument RawGeckoDocument;
struct ServoNodeData;
struct ServoComputedValues;
struct RawServoStyleSheet;
struct RawServoStyleSet;
@@ -116,16 +123,22 @@ void Servo_DropNodeData(ServoNodeData* d
nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
void Gecko_AddRefAtom(nsIAtom* aAtom);
void Gecko_ReleaseAtom(nsIAtom* aAtom);
uint32_t Gecko_HashAtom(nsIAtom* aAtom);
const uint16_t* Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength);
bool Gecko_AtomEqualsUTF8(nsIAtom* aAtom, const char* aString, uint32_t aLength);
bool Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* aAtom, const char* aString, uint32_t aLength);
+// Font style
+void Gecko_FontFamilyList_Clear(FontFamilyList* aList);
+void Gecko_FontFamilyList_AppendNamed(FontFamilyList* aList, nsIAtom* aName);
+void Gecko_FontFamilyList_AppendGeneric(FontFamilyList* list, FontFamilyType familyType);
+void Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src);
+
// Counter style.
void Gecko_SetListStyleType(nsStyleList* style_struct, uint32_t type);
void Gecko_CopyListStyleTypeFrom(nsStyleList* dst, const nsStyleList* src);
// background-image style.
// TODO: support url() values (and maybe element() too?).
void Gecko_SetNullImageValue(nsStyleImage* image);
void Gecko_SetGradientImageValue(nsStyleImage* image, nsStyleGradient* gradient);