Skip to content

Commit

Permalink
Backed out changeset 7585591a9bad (bug 1773558) for causing failures …
Browse files Browse the repository at this point in the history
…in system-fonts.html
  • Loading branch information
nerli1 committed Jun 12, 2022
1 parent 333532f commit cffbcc8
Show file tree
Hide file tree
Showing 56 changed files with 1,126 additions and 808 deletions.
18 changes: 10 additions & 8 deletions accessible/base/TextAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,14 @@ void TextAttrsMgr::FontStyleTextAttr::ExposeValue(
RefPtr<nsAtom> atom = NS_Atomize("italic");
aAttributes->SetAttribute(nsGkAtoms::font_style, atom);
} else {
nsAutoCString s;
aValue.ToString(s);
nsString wide;
CopyUTF8toUTF16(s, wide);
aAttributes->SetAttribute(nsGkAtoms::font_style, std::move(wide));
auto angle = aValue.ObliqueAngle();
nsString string(u"oblique"_ns);
if (angle != FontSlantStyle::kDefaultAngle) {
string.AppendLiteral(" ");
nsStyleUtil::AppendCSSNumber(angle, string);
string.AppendLiteral("deg");
}
aAttributes->SetAttribute(nsGkAtoms::font_style, std::move(string));
}
}

Expand Down Expand Up @@ -540,8 +543,7 @@ bool TextAttrsMgr::FontWeightTextAttr::GetValueFor(LocalAccessible* aAccessible,

void TextAttrsMgr::FontWeightTextAttr::ExposeValue(AccAttributes* aAttributes,
const FontWeight& aValue) {
int value = aValue.ToIntRounded();
aAttributes->SetAttribute(nsGkAtoms::fontWeight, value);
aAttributes->SetAttribute(nsGkAtoms::fontWeight, aValue.ToIntRounded());
}

FontWeight TextAttrsMgr::FontWeightTextAttr::GetFontWeight(nsIFrame* aFrame) {
Expand All @@ -558,7 +560,7 @@ FontWeight TextAttrsMgr::FontWeightTextAttr::GetFontWeight(nsIFrame* aFrame) {
// 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()) {
return FontWeight::BOLD;
return FontWeight::Bold();
}

// On Windows, font->GetStyle()->weight will give the same weight as
Expand Down
2 changes: 1 addition & 1 deletion build/moz.configure/bindgen.configure
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ option(env="CBINDGEN", nargs=1, when=cbindgen_is_needed, help="Path to cbindgen"
def check_cbindgen_version(cbindgen, fatal=False):
log.debug("trying cbindgen: %s" % cbindgen)

cbindgen_min_version = Version("0.24.3")
cbindgen_min_version = Version("0.24.2")

# cbindgen x.y.z
version = Version(check_cmd_output(cbindgen, "--version").strip().split(" ")[1])
Expand Down
59 changes: 47 additions & 12 deletions dom/canvas/OffscreenCanvasRenderingContext2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,15 @@ static void SerializeFontForCanvas(const StyleFontFamilyList& aList,
// Re-serialize the font shorthand as required by the canvas spec.
aUsedFont.Truncate();

if (!aStyle.style.IsNormal()) {
aStyle.style.ToString(aUsedFont);
aUsedFont.Append(" ");
if (aStyle.style.IsItalic()) {
aUsedFont.Append("italic ");
} else if (aStyle.style.IsOblique()) {
aUsedFont.Append("oblique ");
// Include the angle if it is not the default font-style:oblique value.
if (aStyle.style != FontSlantStyle::Oblique()) {
aUsedFont.AppendFloat(aStyle.style.ObliqueAngle());
aUsedFont.Append("deg ");
}
}

// font-weight is serialized as a number
Expand All @@ -112,9 +118,24 @@ static void SerializeFontForCanvas(const StyleFontFamilyList& aList,
}

// font-stretch is serialized using CSS Fonts 3 keywords, not percentages.
if (!aStyle.stretch.IsNormal() &&
Servo_FontStretch_SerializeKeyword(&aStyle.stretch, &aUsedFont)) {
aUsedFont.Append(" ");
if (!aStyle.stretch.IsNormal()) {
if (aStyle.stretch == FontStretch::UltraCondensed()) {
aUsedFont.Append("ultra-condensed ");
} else if (aStyle.stretch == FontStretch::ExtraCondensed()) {
aUsedFont.Append("extra-condensed ");
} else if (aStyle.stretch == FontStretch::Condensed()) {
aUsedFont.Append("condensed ");
} else if (aStyle.stretch == FontStretch::SemiCondensed()) {
aUsedFont.Append("semi-condensed ");
} else if (aStyle.stretch == FontStretch::SemiExpanded()) {
aUsedFont.Append("semi-expanded ");
} else if (aStyle.stretch == FontStretch::Expanded()) {
aUsedFont.Append("expanded ");
} else if (aStyle.stretch == FontStretch::ExtraExpanded()) {
aUsedFont.Append("extra-expanded ");
} else if (aStyle.stretch == FontStretch::UltraExpanded()) {
aUsedFont.Append("ultra-expanded ");
}
}

// Serialize the computed (not specified) size, and the family name(s).
Expand All @@ -128,18 +149,31 @@ bool OffscreenCanvasRenderingContext2D::SetFontInternal(const nsACString& aFont,
// In the OffscreenCanvas case we don't have the context necessary to call
// GetFontStyleForServo(), as we do in the main-thread canvas context, so
// instead we borrow ParseFontShorthandForMatching to parse the attribute.
float stretch = FontStretch::Normal().Percentage(),
weight = FontWeight::Normal().ToFloat(), size = 10.0;
StyleComputedFontStyleDescriptor style(
StyleComputedFontStyleDescriptor::Normal());
StyleFontFamilyList list;
gfxFontStyle fontStyle;
float size = 0.0f;
if (!ServoCSSParser::ParseFontShorthandForMatching(
aFont, nullptr, list, fontStyle.style, fontStyle.stretch,
fontStyle.weight, &size)) {
aFont, nullptr, list, style, stretch, weight, &size)) {
return false;
}

gfxFontStyle fontStyle;
fontStyle.size = size;
fontStyle.weight = FontWeight(weight);
fontStyle.stretch = FontStretch::FromStyle(stretch);
switch (style.tag) {
case StyleComputedFontStyleDescriptor::Tag::Normal:
fontStyle.style = FontSlantStyle::Normal();
break;
case StyleComputedFontStyleDescriptor::Tag::Italic:
fontStyle.style = FontSlantStyle::Italic();
break;
case StyleComputedFontStyleDescriptor::Tag::Oblique:
fontStyle.style = FontSlantStyle::Oblique(style.AsOblique()._0);
break;
}

// TODO: Get a userFontSet from the Worker and pass to the fontGroup
// TODO: Should we be passing a language? Where from?
Expand All @@ -155,8 +189,9 @@ bool OffscreenCanvasRenderingContext2D::SetFontInternal(const nsACString& aFont,
1.0); // aDevToCssSize
CurrentState().fontGroup = fontGroup;
SerializeFontForCanvas(list, fontStyle, CurrentState().font);
CurrentState().fontFont = nsFont(StyleFontFamily{list, false, false},
StyleCSSPixelLength::FromPixels(size));
CurrentState().fontFont =
nsFont(StyleFontFamily{list, false, false},
StyleCSSPixelLength::FromPixels(float(fontStyle.size)));
CurrentState().fontLanguage = nullptr;
CurrentState().fontExplicitLanguage = false;
return true;
Expand Down
4 changes: 2 additions & 2 deletions dom/mathml/MathMLElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,10 @@ void MathMLElement::MapMathMLAttributesInto(
str.CompressWhitespace();
if (str.EqualsASCII("normal")) {
aDecls.SetKeywordValue(eCSSProperty_font_weight,
FontWeight::NORMAL.ToFloat());
FontWeight::Normal().ToFloat());
} else if (str.EqualsASCII("bold")) {
aDecls.SetKeywordValue(eCSSProperty_font_weight,
FontWeight::BOLD.ToFloat());
FontWeight::Bold().ToFloat());
}
}
}
Expand Down
35 changes: 33 additions & 2 deletions gfx/2d/ScaledFontDWrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "ScaledFontDWrite.h"
#include "gfxDWriteCommon.h"
#include "UnscaledFontDWrite.h"
#include "PathD2D.h"
#include "gfxFont.h"
Expand Down Expand Up @@ -87,6 +86,38 @@ static bool DoGrayscale(IDWriteFontFace* aDWFace, Float ppem) {
return true;
}

static inline DWRITE_FONT_STRETCH DWriteFontStretchFromStretch(
FontStretch aStretch) {
if (aStretch == FontStretch::UltraCondensed()) {
return DWRITE_FONT_STRETCH_ULTRA_CONDENSED;
}
if (aStretch == FontStretch::ExtraCondensed()) {
return DWRITE_FONT_STRETCH_EXTRA_CONDENSED;
}
if (aStretch == FontStretch::Condensed()) {
return DWRITE_FONT_STRETCH_CONDENSED;
}
if (aStretch == FontStretch::SemiCondensed()) {
return DWRITE_FONT_STRETCH_SEMI_CONDENSED;
}
if (aStretch == FontStretch::Normal()) {
return DWRITE_FONT_STRETCH_NORMAL;
}
if (aStretch == FontStretch::SemiExpanded()) {
return DWRITE_FONT_STRETCH_SEMI_EXPANDED;
}
if (aStretch == FontStretch::Expanded()) {
return DWRITE_FONT_STRETCH_EXPANDED;
}
if (aStretch == FontStretch::ExtraExpanded()) {
return DWRITE_FONT_STRETCH_EXTRA_EXPANDED;
}
if (aStretch == FontStretch::UltraExpanded()) {
return DWRITE_FONT_STRETCH_ULTRA_EXPANDED;
}
return DWRITE_FONT_STRETCH_UNDEFINED;
}

ScaledFontDWrite::ScaledFontDWrite(IDWriteFontFace* aFontFace,
const RefPtr<UnscaledFont>& aUnscaledFont,
Float aSize, bool aUseEmbeddedBitmap,
Expand All @@ -101,7 +132,7 @@ ScaledFontDWrite::ScaledFontDWrite(IDWriteFontFace* aFontFace,
mStyle = SkFontStyle(aStyle->weight.ToIntRounded(),
DWriteFontStretchFromStretch(aStyle->stretch),
// FIXME(jwatt): also use kOblique_Slant
aStyle->style == FontSlantStyle::NORMAL
aStyle->style == FontSlantStyle::Normal()
? SkFontStyle::kUpright_Slant
: SkFontStyle::kItalic_Slant);
}
Expand Down
Loading

0 comments on commit cffbcc8

Please sign in to comment.