mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1157064 - font-display descriptor parsing. r=dbaron
This commit is contained in:
parent
3c47961d0e
commit
bb31e75a7b
@ -41,6 +41,12 @@
|
||||
#define NS_FONT_SYNTHESIS_WEIGHT 0x1
|
||||
#define NS_FONT_SYNTHESIS_STYLE 0x2
|
||||
|
||||
#define NS_FONT_DISPLAY_AUTO 0
|
||||
#define NS_FONT_DISPLAY_BLOCK 1
|
||||
#define NS_FONT_DISPLAY_SWAP 2
|
||||
#define NS_FONT_DISPLAY_FALLBACK 3
|
||||
#define NS_FONT_DISPLAY_OPTIONAL 4
|
||||
|
||||
enum {
|
||||
eFeatureAlternates_historical,
|
||||
eFeatureAlternates_stylistic,
|
||||
|
@ -11,3 +11,4 @@ CSS_FONT_DESC(src, Src)
|
||||
CSS_FONT_DESC(unicode-range, UnicodeRange)
|
||||
CSS_FONT_DESC(font-feature-settings, FontFeatureSettings)
|
||||
CSS_FONT_DESC(font-language-override, FontLanguageOverride)
|
||||
CSS_FONT_DESC(font-display, Display)
|
||||
|
@ -261,6 +261,7 @@ CSS_KEY(extends, extends)
|
||||
CSS_KEY(extra-condensed, extra_condensed)
|
||||
CSS_KEY(extra-expanded, extra_expanded)
|
||||
CSS_KEY(ew-resize, ew_resize)
|
||||
CSS_KEY(fallback, fallback)
|
||||
CSS_KEY(fantasy, fantasy)
|
||||
CSS_KEY(farthest-side, farthest_side)
|
||||
CSS_KEY(farthest-corner, farthest_corner)
|
||||
@ -409,6 +410,7 @@ CSS_KEY(oldstyle-nums, oldstyle_nums)
|
||||
CSS_KEY(opacity, opacity)
|
||||
CSS_KEY(open, open)
|
||||
CSS_KEY(open-quote, open_quote)
|
||||
CSS_KEY(optional, optional)
|
||||
CSS_KEY(ordinal, ordinal)
|
||||
CSS_KEY(ornaments, ornaments)
|
||||
CSS_KEY(outset, outset)
|
||||
@ -548,6 +550,7 @@ CSS_KEY(subgrid, subgrid)
|
||||
CSS_KEY(super, super)
|
||||
CSS_KEY(sw-resize, sw_resize)
|
||||
CSS_KEY(swash, swash)
|
||||
CSS_KEY(swap, swap)
|
||||
CSS_KEY(table, table)
|
||||
CSS_KEY(table-caption, table_caption)
|
||||
CSS_KEY(table-cell, table_cell)
|
||||
|
@ -3948,7 +3948,9 @@ CSSParserImpl::ParseFontDescriptor(nsCSSFontFaceRule* aRule)
|
||||
nsCSSFontDesc descID = nsCSSProps::LookupFontDesc(descName);
|
||||
nsCSSValue value;
|
||||
|
||||
if (descID == eCSSFontDesc_UNKNOWN) {
|
||||
if (descID == eCSSFontDesc_UNKNOWN ||
|
||||
(descID == eCSSFontDesc_Display &&
|
||||
!Preferences::GetBool("layout.css.font-display.enabled"))) {
|
||||
if (NonMozillaVendorIdentifier(descName)) {
|
||||
// silently skip other vendors' extensions
|
||||
SkipDeclaration(true);
|
||||
@ -11603,6 +11605,10 @@ CSSParserImpl::ParseFontDescriptorValue(nsCSSFontDesc aDescID,
|
||||
return ParseSingleTokenVariant(aValue, VARIANT_KEYWORD | VARIANT_NORMAL,
|
||||
nsCSSProps::kFontStyleKTable);
|
||||
|
||||
case eCSSFontDesc_Display:
|
||||
return ParseSingleTokenVariant(aValue, VARIANT_KEYWORD,
|
||||
nsCSSProps::kFontDisplayKTable);
|
||||
|
||||
case eCSSFontDesc_Weight:
|
||||
return (ParseFontWeight(aValue) &&
|
||||
aValue.GetUnit() != eCSSUnit_Inherit &&
|
||||
|
@ -613,7 +613,19 @@ nsCSSFontDesc
|
||||
nsCSSProps::LookupFontDesc(const nsACString& aFontDesc)
|
||||
{
|
||||
MOZ_ASSERT(gFontDescTable, "no lookup table, needs addref");
|
||||
return nsCSSFontDesc(gFontDescTable->Lookup(aFontDesc));
|
||||
nsCSSFontDesc which = nsCSSFontDesc(gFontDescTable->Lookup(aFontDesc));
|
||||
|
||||
if (which == eCSSFontDesc_Display &&
|
||||
!Preferences::GetBool("layout.css.font-display.enabled")) {
|
||||
which = eCSSFontDesc_UNKNOWN;
|
||||
} else if (which == eCSSFontDesc_UNKNOWN) {
|
||||
// check for unprefixed font-feature-settings/font-language-override
|
||||
nsAutoCString prefixedProp;
|
||||
prefixedProp.AppendLiteral("-moz-");
|
||||
prefixedProp.Append(aFontDesc);
|
||||
which = nsCSSFontDesc(gFontDescTable->Lookup(prefixedProp));
|
||||
}
|
||||
return which;
|
||||
}
|
||||
|
||||
nsCSSFontDesc
|
||||
@ -622,8 +634,11 @@ nsCSSProps::LookupFontDesc(const nsAString& aFontDesc)
|
||||
MOZ_ASSERT(gFontDescTable, "no lookup table, needs addref");
|
||||
nsCSSFontDesc which = nsCSSFontDesc(gFontDescTable->Lookup(aFontDesc));
|
||||
|
||||
// check for unprefixed font-feature-settings/font-language-override
|
||||
if (which == eCSSFontDesc_UNKNOWN) {
|
||||
if (which == eCSSFontDesc_Display &&
|
||||
!Preferences::GetBool("layout.css.font-display.enabled")) {
|
||||
which = eCSSFontDesc_UNKNOWN;
|
||||
} else if (which == eCSSFontDesc_UNKNOWN) {
|
||||
// check for unprefixed font-feature-settings/font-language-override
|
||||
nsAutoString prefixedProp;
|
||||
prefixedProp.AppendLiteral("-moz-");
|
||||
prefixedProp.Append(aFontDesc);
|
||||
@ -1381,6 +1396,15 @@ const KTableEntry nsCSSProps::kFloatEdgeKTable[] = {
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
const KTableEntry nsCSSProps::kFontDisplayKTable[] = {
|
||||
{ eCSSKeyword_auto, NS_FONT_DISPLAY_AUTO },
|
||||
{ eCSSKeyword_block, NS_FONT_DISPLAY_BLOCK },
|
||||
{ eCSSKeyword_swap, NS_FONT_DISPLAY_SWAP },
|
||||
{ eCSSKeyword_fallback, NS_FONT_DISPLAY_FALLBACK },
|
||||
{ eCSSKeyword_optional, NS_FONT_DISPLAY_OPTIONAL },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
const KTableEntry nsCSSProps::kFontKTable[] = {
|
||||
// CSS2.
|
||||
{ eCSSKeyword_caption, NS_STYLE_FONT_CAPTION },
|
||||
|
@ -741,6 +741,7 @@ public:
|
||||
// "layout.css.float-logical-values.enabled" changes:
|
||||
static KTableEntry kFloatKTable[];
|
||||
static const KTableEntry kFloatEdgeKTable[];
|
||||
static const KTableEntry kFontDisplayKTable[];
|
||||
static const KTableEntry kFontKTable[];
|
||||
static const KTableEntry kFontKerningKTable[];
|
||||
static const KTableEntry kFontSizeKTable[];
|
||||
|
@ -1302,6 +1302,13 @@ nsCSSFontFaceStyleDecl::GetPropertyValue(nsCSSFontDesc aFontDescID,
|
||||
nsCSSValue::eNormalized);
|
||||
return NS_OK;
|
||||
|
||||
case eCSSFontDesc_Display:
|
||||
NS_ASSERTION(val.GetUnit() == eCSSUnit_Enumerated,
|
||||
"unknown unit for font-display descriptor");
|
||||
AppendASCIItoUTF16(nsCSSProps::ValueToKeyword(val.GetIntValue(),
|
||||
nsCSSProps::kFontDisplayKTable), aResult);
|
||||
return NS_OK;
|
||||
|
||||
case eCSSFontDesc_Src:
|
||||
nsStyleUtil::AppendSerializedFontSrc(val, aResult);
|
||||
return NS_OK;
|
||||
|
@ -14,6 +14,7 @@
|
||||
<pre id="display"></pre>
|
||||
<style type="text/css" id="testbox"></style>
|
||||
<script class="testbody" type="text/javascript">
|
||||
function runTest() {
|
||||
function _(b) { return "@font-face { " + b + " }"; };
|
||||
var testset = [
|
||||
// Complete nonsense - shouldn't make a font-face rule at all.
|
||||
@ -287,6 +288,24 @@
|
||||
{ rule: _("font-language-override: #999;"), d: {} },
|
||||
{ rule: _("font-language-override: 'TRK' 'SRB'"), d: {} },
|
||||
{ rule: _("font-language-override: 'TRK', 'SRB'"), d: {} },
|
||||
|
||||
// font-display:
|
||||
{ rule: _("font-display: auto;"),
|
||||
d: { "font-display" : "auto" } },
|
||||
{ rule: _("font-display: block;"),
|
||||
d: { "font-display" : "block" } },
|
||||
{ rule: _("font-display: swap;"),
|
||||
d: { "font-display" : "swap" } },
|
||||
{ rule: _("font-display: fallback;"),
|
||||
d: { "font-display" : "fallback" } },
|
||||
{ rule: _("font-display: optional;"),
|
||||
d: { "font-display" : "optional" } },
|
||||
|
||||
// incorrect font-display
|
||||
{ rule: _("font-display: hidden"), d: {} },
|
||||
{ rule: _("font-display: swap 3"), d: {} },
|
||||
{ rule: _("font-display: block 2 swap 0"), d: {} },
|
||||
{ rule: _("font-display: all"), d: {} },
|
||||
];
|
||||
|
||||
var display = document.getElementById("display");
|
||||
@ -352,6 +371,12 @@
|
||||
ok(false, testset[curTest].rule, "During test: " + e);
|
||||
}
|
||||
}
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({ set: [["layout.css.font-display.enabled", true]] },
|
||||
runTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -2297,6 +2297,9 @@ pref("layout.css.float-logical-values.enabled", false);
|
||||
// Is support for the CSS4 image-orientation property enabled?
|
||||
pref("layout.css.image-orientation.enabled", true);
|
||||
|
||||
// Is support for the font-display @font-face descriptor enabled?
|
||||
pref("layout.css.font-display.enabled", false);
|
||||
|
||||
// Are sets of prefixed properties supported?
|
||||
pref("layout.css.prefixes.border-image", true);
|
||||
pref("layout.css.prefixes.transforms", true);
|
||||
|
Loading…
Reference in New Issue
Block a user