diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp index ab38a166bc1d..3ce77eee9849 100644 --- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -904,6 +904,12 @@ Gecko_Atomize(const char* aString, uint32_t aLength) return NS_Atomize(nsDependentCSubstring(aString, aLength)).take(); } +nsIAtom* +Gecko_Atomize16(const nsAString* aString) +{ + return NS_Atomize(*aString).take(); +} + void Gecko_AddRefAtom(nsIAtom* aAtom) { @@ -977,6 +983,33 @@ Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src) dst->fontlist = src->fontlist; } +void +Gecko_nsFont_InitSystem(nsFont* aDest, int32_t aFontId, + const nsStyleFont* aFont, RawGeckoPresContextBorrowed aPresContext) +{ + + const nsFont* defaultVariableFont = + aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID, + aFont->mLanguage); + + // We have passed uninitialized memory to this function, + // initialize it. We can't simply return an nsFont because then + // we need to know its size beforehand. Servo cannot initialize nsFont + // itself, so this will do. + nsFont* system = new (aDest) nsFont(*defaultVariableFont); + + *system = *defaultVariableFont; + LookAndFeel::FontID fontID = static_cast(aFontId); + nsRuleNode::ComputeSystemFont(system, fontID, aPresContext); +} + +void +Gecko_nsFont_Destroy(nsFont* aDest) +{ + aDest->~nsFont(); +} + + void Gecko_SetImageOrientation(nsStyleVisibility* aVisibility, double aRadians, bool aFlip) diff --git a/layout/style/ServoBindings.h b/layout/style/ServoBindings.h index 44247a8f616d..0d8883da67f8 100644 --- a/layout/style/ServoBindings.h +++ b/layout/style/ServoBindings.h @@ -232,6 +232,7 @@ RawServoAnimationValueBorrowedOrNull Gecko_AnimationGetBaseStyle( // Atoms. nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength); +nsIAtom* Gecko_Atomize16(const nsAString* aString); void Gecko_AddRefAtom(nsIAtom* aAtom); void Gecko_ReleaseAtom(nsIAtom* aAtom); const uint16_t* Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength); @@ -243,6 +244,11 @@ void Gecko_FontFamilyList_Clear(FontFamilyList* aList); void Gecko_FontFamilyList_AppendNamed(FontFamilyList* aList, nsIAtom* aName, bool aQuoted); void Gecko_FontFamilyList_AppendGeneric(FontFamilyList* list, FontFamilyType familyType); void Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src); +// will not run destructors on dst, give it uninitialized memory +// font_id is LookAndFeel::FontID +void Gecko_nsFont_InitSystem(nsFont* dst, int32_t font_id, + const nsStyleFont* font, RawGeckoPresContextBorrowed pres_context); +void Gecko_nsFont_Destroy(nsFont* dst); // Visibility style void Gecko_SetImageOrientation(nsStyleVisibility* aVisibility, diff --git a/layout/style/nsRuleNode.h b/layout/style/nsRuleNode.h index 6502b35575fd..3548b2f74a35 100644 --- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -1087,6 +1087,10 @@ public: static void FillAllMaskLists(nsStyleImageLayers& aLayers, uint32_t aMaxItemCount); + static void ComputeSystemFont(nsFont* aSystemFont, + mozilla::LookAndFeel::FontID aFontID, + const nsPresContext* aPresContext); + private: #ifdef DEBUG // non-inline helper function to allow assertions without incomplete @@ -1099,9 +1103,6 @@ private: static void StoreStyleOnContext(nsStyleContext* aContext, nsStyleStructID aSID, void* aStruct); - static void ComputeSystemFont(nsFont* aSystemFont, - mozilla::LookAndFeel::FontID aFontID, - const nsPresContext* aPresContext); }; /**