Merge mozilla-central to autoland. CLOSED TREE

This commit is contained in:
Butkovits Atila 2022-02-09 12:07:17 +02:00
Родитель ed3f0bc491 c12a59323e
Коммит 7a0ca71a26
15 изменённых файлов: 57 добавлений и 137 удалений

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

@ -556,9 +556,10 @@ FontWeight TextAttrsMgr::FontWeightTextAttr::GetFontWeight(nsIFrame* aFrame) {
// When there doesn't exist a bold font in the family and so the rendering of
// a non-bold font face is changed so that the user sees what looks like a
// bold font, i.e. synthetic bolding is used. (Simply returns false on any
// platforms that don't use the multi-strike synthetic bolding.)
if (font->ApplySyntheticBold()) {
// bold font, i.e. synthetic bolding is used. IsSyntheticBold method is only
// needed on Mac, but it is "safe" to use on all platforms. (For non-Mac
// platforms it always return false.)
if (font->IsSyntheticBold()) {
return FontWeight::Bold();
}

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

@ -483,7 +483,7 @@
"win64-aarch64-devedition",
"win64-devedition"
],
"revision": "4bb4c259d94a258fa77ca5fa36d25c924ec58fb3"
"revision": "4d418676e19ccff5f18352472598d5ee14c3abf6"
},
"es-CL": {
"pin": false,
@ -555,7 +555,7 @@
"win64-aarch64-devedition",
"win64-devedition"
],
"revision": "cd11e1d52aeb09fb25c4f1bb49df356703bfbf03"
"revision": "fc4872771ddc4961039f10b1125ceff451af7093"
},
"eu": {
"pin": false,
@ -825,7 +825,7 @@
"win64-aarch64-devedition",
"win64-devedition"
],
"revision": "22063ca8f2b1d7bf99320af6acfdbfd75a9b3b17"
"revision": "d45a54f989a51c504a8cca37dc5a1cd506764644"
},
"hu": {
"pin": false,
@ -897,7 +897,7 @@
"win64-aarch64-devedition",
"win64-devedition"
],
"revision": "913b68b3333d48ddb3ba3a12fa27631d73510a76"
"revision": "19d4df4896eee57482c3a6d01d52dc4a03a7b152"
},
"id": {
"pin": false,
@ -1083,7 +1083,7 @@
"win64-aarch64-devedition",
"win64-devedition"
],
"revision": "dfb6871b39830d3764a161ad185af8ee7d2c7247"
"revision": "17fe8344f59d13cf19d1126f21e4c02dcf3921f2"
},
"lij": {
"pin": false,
@ -1677,7 +1677,7 @@
"win64-aarch64-devedition",
"win64-devedition"
],
"revision": "0f752a278aba23248d5af6e5c74c1e5fa23f2740"
"revision": "a4fe5b2d85d36420e7e83efed62183a2cd7f9ffd"
},
"szl": {
"pin": false,
@ -1749,7 +1749,7 @@
"win64-aarch64-devedition",
"win64-devedition"
],
"revision": "78188c1885d7da1fa7f35577e2fa9fa0dad999ff"
"revision": "9553e8993f8c9fb4b0e7912eed2f4f99385cb64d"
},
"th": {
"pin": false,
@ -1767,7 +1767,7 @@
"win64-aarch64-devedition",
"win64-devedition"
],
"revision": "0e90ff7bb6277799be92363a3bf35d27ec9b99a1"
"revision": "9c09c46a50141cfb213f77a97a78df9a2c37cce7"
},
"tl": {
"pin": false,

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

@ -2045,7 +2045,7 @@ class GFX2D_API Factory {
static already_AddRefed<ScaledFont> CreateScaledFontForDWriteFont(
IDWriteFontFace* aFontFace, const gfxFontStyle* aStyle,
const RefPtr<UnscaledFont>& aUnscaledFont, Float aSize,
bool aUseEmbeddedBitmap, bool aUseMultistrikeBold, bool aGDIForced);
bool aUseEmbeddedBitmap, bool aGDIForced);
static already_AddRefed<ScaledFont> CreateScaledFontForGDIFont(
const void* aLogFont, const RefPtr<UnscaledFont>& aUnscaledFont,

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

@ -929,10 +929,9 @@ void Factory::D2DCleanup() {
already_AddRefed<ScaledFont> Factory::CreateScaledFontForDWriteFont(
IDWriteFontFace* aFontFace, const gfxFontStyle* aStyle,
const RefPtr<UnscaledFont>& aUnscaledFont, float aSize,
bool aUseEmbeddedBitmap, bool aUseMultistrikeBold, bool aGDIForced) {
bool aUseEmbeddedBitmap, bool aGDIForced) {
return MakeAndAddRef<ScaledFontDWrite>(
aFontFace, aUnscaledFont, aSize, aUseEmbeddedBitmap, aUseMultistrikeBold,
aGDIForced, aStyle);
aFontFace, aUnscaledFont, aSize, aUseEmbeddedBitmap, aGDIForced, aStyle);
}
already_AddRefed<ScaledFont> Factory::CreateScaledFontForGDIFont(

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

@ -121,12 +121,10 @@ static inline DWRITE_FONT_STRETCH DWriteFontStretchFromStretch(
ScaledFontDWrite::ScaledFontDWrite(IDWriteFontFace* aFontFace,
const RefPtr<UnscaledFont>& aUnscaledFont,
Float aSize, bool aUseEmbeddedBitmap,
bool aUseMultistrikeBold, bool aGDIForced,
const gfxFontStyle* aStyle)
bool aGDIForced, const gfxFontStyle* aStyle)
: ScaledFontBase(aUnscaledFont, aSize),
mFontFace(aFontFace),
mUseEmbeddedBitmap(aUseEmbeddedBitmap),
mUseMultistrikeBold(aUseMultistrikeBold),
mGDIForced(aGDIForced) {
if (aStyle) {
mStyle = SkFontStyle(aStyle->weight.ToIntRounded(),
@ -393,16 +391,14 @@ bool UnscaledFontDWrite::GetFontDescriptor(FontDescriptorOutput aCb,
ScaledFontDWrite::InstanceData::InstanceData(
const wr::FontInstanceOptions* aOptions,
const wr::FontInstancePlatformOptions* aPlatformOptions) {
const wr::FontInstancePlatformOptions* aPlatformOptions)
: mUseEmbeddedBitmap(false), mApplySyntheticBold(false) {
if (aOptions) {
if (aOptions->flags & wr::FontInstanceFlags::EMBEDDED_BITMAPS) {
mUseEmbeddedBitmap = true;
}
if (aOptions->flags & wr::FontInstanceFlags::SYNTHETIC_BOLD) {
mUseBoldSimulation = true;
}
if (aOptions->flags & wr::FontInstanceFlags::MULTISTRIKE_BOLD) {
mUseMultistrikeBold = true;
mApplySyntheticBold = true;
}
if (aOptions->flags & wr::FontInstanceFlags::FORCE_GDI) {
mGDIForced = true;
@ -470,12 +466,9 @@ bool ScaledFontDWrite::GetWRFontInstanceOptions(
wr::FontInstanceOptions options;
options.render_mode = wr::ToFontRenderMode(GetDefaultAAMode());
options.flags = wr::FontInstanceFlags{0};
if (HasBoldSimulation()) {
if (HasSyntheticBold()) {
options.flags |= wr::FontInstanceFlags::SYNTHETIC_BOLD;
}
if (UseMultistrikeBold()) {
options.flags |= wr::FontInstanceFlags::MULTISTRIKE_BOLD;
}
if (UseEmbeddedBitmaps()) {
options.flags |= wr::FontInstanceFlags::EMBEDDED_BITMAPS;
}
@ -621,7 +614,7 @@ already_AddRefed<ScaledFont> UnscaledFontDWrite::CreateScaledFont(
*reinterpret_cast<const ScaledFontDWrite::InstanceData*>(aInstanceData);
IDWriteFontFace* face = mFontFace;
if (instanceData.mUseBoldSimulation) {
if (instanceData.mApplySyntheticBold) {
if (!InitBold()) {
gfxWarning() << "Failed creating bold IDWriteFontFace.";
return nullptr;
@ -643,9 +636,9 @@ already_AddRefed<ScaledFont> UnscaledFontDWrite::CreateScaledFont(
}
}
return MakeAndAddRef<ScaledFontDWrite>(
face, this, aGlyphSize, instanceData.mUseEmbeddedBitmap,
instanceData.mUseMultistrikeBold, instanceData.mGDIForced, nullptr);
return MakeAndAddRef<ScaledFontDWrite>(face, this, aGlyphSize,
instanceData.mUseEmbeddedBitmap,
instanceData.mGDIForced);
}
already_AddRefed<ScaledFont> UnscaledFontDWrite::CreateScaledFontFromWRFont(

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

@ -25,8 +25,8 @@ class ScaledFontDWrite final : public ScaledFontBase {
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontDWrite, override)
ScaledFontDWrite(IDWriteFontFace* aFontFace,
const RefPtr<UnscaledFont>& aUnscaledFont, Float aSize,
bool aUseEmbeddedBitmap, bool aUseMultistrikeBold,
bool aGDIForced, const gfxFontStyle* aStyle);
bool aUseEmbeddedBitmap, bool aGDIForced,
const gfxFontStyle* aStyle = nullptr);
FontType GetType() const override { return FontType::DWRITE; }
@ -52,10 +52,9 @@ class ScaledFontDWrite final : public ScaledFontBase {
AntialiasMode GetDefaultAAMode() override;
bool UseEmbeddedBitmaps() const { return mUseEmbeddedBitmap; }
bool UseMultistrikeBold() const { return mUseMultistrikeBold; }
bool ForceGDIMode() const { return mGDIForced; }
bool HasBoldSimulation() const {
bool HasSyntheticBold() const {
return (mFontFace->GetSimulations() & DWRITE_FONT_SIMULATIONS_BOLD) != 0;
}
@ -65,7 +64,6 @@ class ScaledFontDWrite final : public ScaledFontBase {
RefPtr<IDWriteFontFace> mFontFace;
bool mUseEmbeddedBitmap;
bool mUseMultistrikeBold = false;
bool mGDIForced = false;
cairo_font_face_t* CreateCairoFontFace(
@ -79,16 +77,14 @@ class ScaledFontDWrite final : public ScaledFontBase {
struct InstanceData {
explicit InstanceData(ScaledFontDWrite* aScaledFont)
: mUseEmbeddedBitmap(aScaledFont->mUseEmbeddedBitmap),
mUseBoldSimulation(aScaledFont->HasBoldSimulation()),
mUseMultistrikeBold(aScaledFont->UseMultistrikeBold()),
mApplySyntheticBold(aScaledFont->HasSyntheticBold()),
mGDIForced(aScaledFont->mGDIForced) {}
InstanceData(const wr::FontInstanceOptions* aOptions,
const wr::FontInstancePlatformOptions* aPlatformOptions);
bool mUseEmbeddedBitmap = false;
bool mUseBoldSimulation = false;
bool mUseMultistrikeBold = false;
bool mUseEmbeddedBitmap;
bool mApplySyntheticBold;
bool mGDIForced = false;
};
};

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

@ -651,25 +651,11 @@ void gfxDWriteFontEntry::GetVariationInstances(
gfxFont* gfxDWriteFontEntry::CreateFontInstance(
const gfxFontStyle* aFontStyle) {
// We use the DirectWrite bold simulation for installed fonts, but NOT for
// webfonts; those will use multi-strike synthetic bold instead.
bool useBoldSim = false;
if (aFontStyle->NeedsSyntheticBold(this)) {
switch (StaticPrefs::gfx_font_rendering_directwrite_bold_simulation()) {
case 0: // never use the DWrite simulation
break;
case 1: // use DWrite simulation for installed fonts but not webfonts
useBoldSim = !mIsDataUserFont;
break;
default: // always use DWrite bold simulation
useBoldSim = true;
break;
}
}
bool needsBold = aFontStyle->NeedsSyntheticBold(this);
DWRITE_FONT_SIMULATIONS sims =
useBoldSim ? DWRITE_FONT_SIMULATIONS_BOLD : DWRITE_FONT_SIMULATIONS_NONE;
needsBold ? DWRITE_FONT_SIMULATIONS_BOLD : DWRITE_FONT_SIMULATIONS_NONE;
ThreadSafeWeakPtr<UnscaledFontDWrite>& unscaledFontPtr =
useBoldSim ? mUnscaledFontBold : mUnscaledFont;
needsBold ? mUnscaledFontBold : mUnscaledFont;
RefPtr<UnscaledFontDWrite> unscaledFont(unscaledFontPtr);
if (!unscaledFont) {
RefPtr<IDWriteFontFace> fontFace;

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

@ -89,21 +89,7 @@ gfxDWriteFont::gfxDWriteFont(const RefPtr<UnscaledFontDWrite>& aUnscaledFont,
// faster glyph width retrieval.
mFontFace->QueryInterface(__uuidof(IDWriteFontFace1),
(void**)getter_AddRefs(mFontFace1));
// If a fake-bold effect is needed, determine whether we're using DWrite's
// "simulation" or applying our multi-strike "synthetic bold".
if (aFontStyle->NeedsSyntheticBold(aFontEntry)) {
switch (StaticPrefs::gfx_font_rendering_directwrite_bold_simulation()) {
case 0: // never use the DWrite simulation
mApplySyntheticBold = true;
break;
case 1: // use DWrite simulation for installed fonts but not webfonts
mApplySyntheticBold = aFontEntry->mIsDataUserFont;
break;
default: // always use DWrite bold simulation
// the flag is initialized to false in gfxFont
break;
}
}
ComputeMetrics(anAAOption);
}
@ -464,19 +450,6 @@ void gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption) {
SanitizeMetrics(mMetrics, GetFontEntry()->mIsBadUnderlineFont);
if (ApplySyntheticBold()) {
auto delta = GetSyntheticBoldOffset();
mMetrics->spaceWidth += delta;
mMetrics->aveCharWidth += delta;
mMetrics->maxAdvance += delta;
if (mMetrics->zeroWidth > 0) {
mMetrics->zeroWidth += delta;
}
if (mMetrics->ideographicWidth > 0) {
mMetrics->ideographicWidth += delta;
}
}
#if 0
printf("Font: %p (%s) size: %f\n", this,
NS_ConvertUTF16toUTF8(GetName()).get(), mStyle.size);
@ -797,7 +770,7 @@ already_AddRefed<ScaledFont> gfxDWriteFont::GetScaledFont(
const gfxFontStyle* fontStyle = GetStyle();
azureScaledFont = Factory::CreateScaledFontForDWriteFont(
mFontFace, fontStyle, GetUnscaledFont(), GetAdjustedSize(),
useEmbeddedBitmap, ApplySyntheticBold(), forceGDI);
useEmbeddedBitmap, forceGDI);
if (!azureScaledFont) {
return nullptr;
}

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

@ -2259,12 +2259,11 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd,
fontParams.contextPaint = contextPaint.get();
}
// Synthetic-bold strikes are each offset one device pixel in run direction
// (these values are only needed if ApplySyntheticBold() is true).
// If drawing via webrender, it will do multistrike internally so we don't
// need to handle it here.
bool doMultistrikeBold = ApplySyntheticBold() && !textDrawer;
if (doMultistrikeBold) {
// Synthetic-bold strikes are each offset one device pixel in run direction.
// (these values are only needed if IsSyntheticBold() is true)
// WebRender handles synthetic bold independently via FontInstanceFlags,
// so just ignore requests in that case.
if (IsSyntheticBold() && !textDrawer) {
gfx::Float xscale = CalcXScale(aRunParams.context->GetDrawTarget());
fontParams.synBoldOnePixelOffset = aRunParams.direction * xscale;
if (xscale != 0.0) {
@ -2947,7 +2946,7 @@ bool gfxFont::ShapeText(DrawTarget* aDrawTarget, const char16_t* aText,
void gfxFont::PostShapingFixup(DrawTarget* aDrawTarget, const char16_t* aText,
uint32_t aOffset, uint32_t aLength,
bool aVertical, gfxShapedText* aShapedText) {
if (ApplySyntheticBold()) {
if (IsSyntheticBold()) {
const Metrics& metrics = GetMetrics(aVertical ? nsFontMetrics::eVertical
: nsFontMetrics::eHorizontal);
if (metrics.maxAdvance > metrics.aveCharWidth) {

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

@ -1783,7 +1783,7 @@ class gfxFont {
virtual bool AllowSubpixelAA() { return true; }
bool ApplySyntheticBold() const { return mApplySyntheticBold; }
bool IsSyntheticBold() const { return mApplySyntheticBold; }
float AngleForSyntheticOblique() const;
float SkewForSyntheticOblique() const;

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

@ -366,17 +366,9 @@ void gfxGDIFont::Initialize() {
mFUnitsConvFactor = 0.0; // zero-sized font: all values scale to zero
}
if (ApplySyntheticBold()) {
auto delta = GetSyntheticBoldOffset();
mMetrics->spaceWidth += delta;
mMetrics->aveCharWidth += delta;
mMetrics->maxAdvance += delta;
if (mMetrics->zeroWidth > 0) {
mMetrics->zeroWidth += delta;
}
if (mMetrics->ideographicWidth > 0) {
mMetrics->ideographicWidth += delta;
}
if (IsSyntheticBold()) {
mMetrics->aveCharWidth += GetSyntheticBoldOffset();
mMetrics->maxAdvance += GetSyntheticBoldOffset();
}
#if 0

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

@ -382,23 +382,19 @@ void gfxMacFont::InitMetrics() {
mMetrics.ideographicWidth = -1.0;
}
if (IsSyntheticBold()) {
mMetrics.spaceWidth += GetSyntheticBoldOffset();
mMetrics.aveCharWidth += GetSyntheticBoldOffset();
mMetrics.maxAdvance += GetSyntheticBoldOffset();
if (mMetrics.zeroWidth > 0) {
mMetrics.zeroWidth += GetSyntheticBoldOffset();
}
}
CalculateDerivedMetrics(mMetrics);
SanitizeMetrics(&mMetrics, mFontEntry->mIsBadUnderlineFont);
if (ApplySyntheticBold()) {
auto delta = GetSyntheticBoldOffset();
mMetrics.spaceWidth += delta;
mMetrics.aveCharWidth += delta;
mMetrics.maxAdvance += delta;
if (mMetrics.zeroWidth > 0) {
mMetrics.zeroWidth += delta;
}
if (mMetrics.ideographicWidth > 0) {
mMetrics.ideographicWidth += delta;
}
}
#if 0
fprintf (stderr, "Font: %p (%s) size: %f\n", this,
NS_ConvertUTF16toUTF8(GetName()).get(), mStyle.size);
@ -587,7 +583,7 @@ already_AddRefed<ScaledFont> gfxMacFont::GetScaledFont(
mAzureScaledFont = Factory::CreateScaledFontForMacFont(
GetCGFontRef(), GetUnscaledFont(), GetAdjustedSize(),
ToDeviceColor(mFontSmoothingBackgroundColor),
!mStyle.useGrayscaleAntialiasing, ApplySyntheticBold(), hasColorGlyphs);
!mStyle.useGrayscaleAntialiasing, IsSyntheticBold(), hasColorGlyphs);
if (!mAzureScaledFont) {
return nullptr;
}

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

@ -517,7 +517,7 @@ void gfxTextRun::DrawPartialLigature(gfxFont* aFont, Range aRange,
// check whether the text run needs to be explicitly composited in order to
// support opacity.
static bool HasSyntheticBoldOrColor(gfxFont* aFont) {
if (aFont->ApplySyntheticBold()) {
if (aFont->IsSyntheticBold()) {
return true;
}
gfxFontEntry* fe = aFont->GetFontEntry();

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

@ -587,7 +587,7 @@ impl FontContext {
let (bold_pixels, bold_width) = apply_multistrike_bold(
&bgra_pixels,
(width + padding * 2) as usize,
(height + padding * 2) as usize,
height as usize,
is_subpixel,
extra_strikes,
pixel_step,

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

@ -5398,21 +5398,6 @@
value: true
mirror: always
#if defined(XP_WIN)
# Whether the DirectWrite bold simulation should be used when a bold font-weight
# is requested but no bold face available in the family. This renders poorly with
# some third-party fonts, so by default we disable it for webfonts and allow it
# only with locally-installed fonts.
# Values:
# 0 - never use DWrite bold simulation; always multi-strike instead
# 1 - use DWrite bold for installed fonts, multi-strike for webfont resources
# 2 - use DWrite bold for all fonts
- name: gfx.font_rendering.directwrite.bold_simulation
type: uint32_t
value: 1
mirror: always
#endif
# The level of logging:
# - 0: no logging;
# - 1: adds errors;