Bug 1349417 - Part 2: stylo: Add basic system font support, use for font-size and font-family; r=xidorn

MozReview-Commit-ID: 4ZMR83GkAZN
This commit is contained in:
Manish Goregaokar 2017-03-21 20:38:12 -07:00
Родитель ff8c1a3788
Коммит 7e8d2f0775
3 изменённых файлов: 43 добавлений и 3 удалений

Просмотреть файл

@ -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<LookAndFeel::FontID>(aFontId);
nsRuleNode::ComputeSystemFont(system, fontID, aPresContext);
}
void
Gecko_nsFont_Destroy(nsFont* aDest)
{
aDest->~nsFont();
}
void
Gecko_SetImageOrientation(nsStyleVisibility* aVisibility,
double aRadians, bool aFlip)

Просмотреть файл

@ -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,

Просмотреть файл

@ -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);
};
/**