Commit 31fb7739 authored by Darren Shen's avatar Darren Shen Committed by Commit Bot

[css-typed-om] Add support for font properties.

Had to modify the test harness to allow numbers in keywords. This
coincidentally fixed an error in one of the tests (transform-style).

Bug: 820299
Change-Id: Ia7e2854f38a5b960e6537d2c4ba309cb71c1e963
Reviewed-on: https://chromium-review.googlesource.com/999225Reviewed-by: default avatarnainar <nainar@chromium.org>
Commit-Queue: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549473}
parent 64729272
<!doctype html>
<meta charset="utf-8">
<title>'font-feature-settings' property</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-get">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-set">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#property-stle-value-normalization">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/testhelper.js"></script>
<script src="resources/testsuite.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
runPropertyTests('font-feature-settings', [
{ syntax: 'normal' }
]);
runUnsupportedPropertyTests('font-feature-settings', [
'"dlig" 1',
'"smcp" on',
]);
</script>
<!doctype html>
<meta charset="utf-8">
<title>'font-kerning' property</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-get">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-set">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#property-stle-value-normalization">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/testhelper.js"></script>
<script src="resources/testsuite.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
runPropertyTests('font-kerning', [
{ syntax: 'auto' },
{ syntax: 'normal' },
{ syntax: 'none' },
]);
</script>
<!doctype html>
<meta charset="utf-8">
<title>'font-variant-caps' property</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-get">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-set">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#property-stle-value-normalization">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/testhelper.js"></script>
<script src="resources/testsuite.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
runPropertyTests('font-variant-caps', [
{ syntax: 'normal' },
{ syntax: 'small-caps' },
{ syntax: 'all-small-caps' },
{ syntax: 'petite-caps' },
{ syntax: 'all-petite-caps' },
{ syntax: 'unicase' },
{ syntax: 'titling-caps' },
]);
</script>
<!doctype html>
<meta charset="utf-8">
<title>'font-variant-east-asian' property</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-get">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-set">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#property-stle-value-normalization">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/testhelper.js"></script>
<script src="resources/testsuite.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
runPropertyTests('font-variant-east-asian', [
{ syntax: 'normal' },
{ syntax: 'jis78' },
{ syntax: 'jis83' },
{ syntax: 'jis90' },
{ syntax: 'jis04' },
{ syntax: 'simplified' },
{ syntax: 'traditional' },
{ syntax: 'full-width' },
{ syntax: 'proportional-width' },
{ syntax: 'ruby' },
]);
runUnsupportedPropertyTests('font-variant-east-asian', [
'jis78 full-width',
'traditional proportional-width ruby',
]);
</script>
<!doctype html>
<meta charset="utf-8">
<title>'font-variant-ligatures' property</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-get">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-set">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#property-stle-value-normalization">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/testhelper.js"></script>
<script src="resources/testsuite.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
runPropertyTests('font-variant-ligatures', [
{ syntax: 'normal' },
{ syntax: 'none' },
{ syntax: 'common-ligatures' },
{ syntax: 'no-common-ligatures' },
{ syntax: 'discretionary-ligatures' },
{ syntax: 'no-discretionary-ligatures' },
{ syntax: 'historical-ligatures' },
{ syntax: 'no-historical-ligatures' },
{ syntax: 'contextual' },
{ syntax: 'no-contextual' },
]);
runUnsupportedPropertyTests('font-variant-ligatures', [
'common-ligatures contextual',
'no-common-ligatures discretionary-ligatures no-historical-ligatures no-contextual',
]);
</script>
<meta charset="utf-8">
<title>'font-variant-numeric' property</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-get">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-set">
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#property-stle-value-normalization">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../resources/testhelper.js"></script>
<script src="resources/testsuite.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
runPropertyTests('font-variant-numeric', [
{ syntax: 'normal' },
{ syntax: 'lining-nums' },
{ syntax: 'oldstyle-nums' },
{ syntax: 'proportional-nums' },
{ syntax: 'tabular-nums' },
{ syntax: 'diagonal-fractions' },
{ syntax: 'stacked-fractions' },
{ syntax: 'ordinal' },
{ syntax: 'slashed-zero' },
]);
runUnsupportedPropertyTests('font-variant-numeric', [
'lining-nums ordinal',
'oldstyle-nums tabular-nums stacked-fractions ordinal slashed-zero',
]);
</script>
......@@ -389,7 +389,7 @@ function runPropertyTests(propertyName, testCases) {
// Retrieve test examples for this test case's syntax. If the syntax
// looks like a keyword, then create an example on the fly.
const syntaxExamples = testCase.syntax.toLowerCase().match(/^[a-z\-]+$/) ?
const syntaxExamples = testCase.syntax.toLowerCase().match(/^[a-z0-9\-]+$/) ?
createKeywordExample(testCase.syntax) :
gTestSyntaxExamples[testCase.syntax];
......
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: 'preserve-3d' is not a valid CSS component
PASS Can set 'transform-style' to CSS-wide keywords
PASS Can set 'transform-style' to var() references
FAIL Can set 'transform-style' to the 'auto' keyword Failed to execute 'set' on 'StylePropertyMap': Invalid type for property
PASS Can set 'transform-style' to the 'flat' keyword
PASS Can set 'transform-style' to the 'preserve-3d' keyword
PASS Setting 'transform-style' to a length throws TypeError
PASS Setting 'transform-style' to a percent throws TypeError
PASS Setting 'transform-style' to a time throws TypeError
PASS Setting 'transform-style' to a flexible length throws TypeError
PASS Setting 'transform-style' to a number throws TypeError
PASS Setting 'transform-style' to a position throws TypeError
PASS Setting 'transform-style' to a URL throws TypeError
PASS Setting 'transform-style' to a transform throws TypeError
Harness: the test ran to completion.
......@@ -505,6 +505,8 @@
name_for_methods: "Kerning",
type_name: "FontDescription::Kerning",
priority: "High",
keywords: ["auto", "normal", "none"],
typedom_types: ["Keyword"],
},
{
name: "font-size",
......@@ -568,6 +570,13 @@
type_name: "VariantLigatures",
converter: "ConvertFontVariantLigatures",
priority: "High",
keywords: [
"normal", "none", "common-ligatures", "no-common-ligatures",
"discretionary-ligatures", "no-discretionary-ligatures",
"historical-ligatures", "no-historical-ligatures", "contextual",
"no-contextual"
],
typedom_types: ["Keyword"],
},
{
name: "font-variant-caps",
......@@ -577,6 +586,11 @@
name_for_methods: "VariantCaps",
converter: "ConvertFontVariantCaps",
priority: "High",
keywords: [
"normal", "small-caps", "all-small-caps", "petite-caps",
"all-petite-caps", "unicase", "titling-caps"
],
typedom_types: ["Keyword"],
},
{
name: "font-variant-east-asian",
......@@ -586,6 +600,11 @@
name_for_methods: "VariantEastAsian",
converter: "ConvertFontVariantEastAsian",
priority: "High",
keywords: [
"normal", "jis78", "jis83", "jis90", "jis04", "simplified",
"traditional", "full-width", "proportional-width", "ruby"
],
typedom_types: ["Keyword"],
},
{
name: "font-variant-numeric",
......@@ -595,6 +614,12 @@
name_for_methods: "VariantNumeric",
converter: "ConvertFontVariantNumeric",
priority: "High",
keywords: [
"normal", "lining-nums", "oldstyle-nums", "proportional-nums",
"tabular-nums", "diagonal-fractions", "stacked-fractions", "ordinal",
"slashed-zero"
],
typedom_types: ["Keyword"],
},
{
name: "font-weight",
......@@ -618,6 +643,8 @@
name_for_methods: "FeatureSettings",
converter: "ConvertFontFeatureSettings",
priority: "High",
keywords: ["normal"],
typedom_types: ["Keyword"],
},
{
name: "font-variation-settings",
......
......@@ -67,6 +67,25 @@ const CSSValue* StyleValueToCSSValue(
}
break;
}
case CSSPropertyFontVariantEastAsian:
case CSSPropertyFontVariantLigatures:
case CSSPropertyFontVariantNumeric: {
// level 1 only accept single keywords, but font-variant-* store
// them as a list
if (const auto* value =
ToCSSIdentifierValueOrNull(style_value.ToCSSValue())) {
// 'none' and 'normal' are stored as a single value
if (value->GetValueID() == CSSValueNone ||
value->GetValueID() == CSSValueNormal) {
break;
}
CSSValueList* list = CSSValueList::CreateSpaceSeparated();
list->Append(*style_value.ToCSSValue());
return list;
}
break;
}
case CSSPropertyGridAutoFlow: {
// level 1 only accepts single keywords
const auto* value = style_value.ToCSSValue();
......
......@@ -82,6 +82,17 @@ CSSStyleValue* CreateStyleValueWithPropertyInternal(CSSPropertyID property_id,
return CSSKeywordValue::Create("currentcolor");
}
return CSSUnsupportedStyleValue::Create(property_id, value);
case CSSPropertyFontVariantEastAsian:
case CSSPropertyFontVariantLigatures:
case CSSPropertyFontVariantNumeric: {
// Only single keywords are supported in level 1.
if (const auto* value_list = ToCSSValueListOrNull(value)) {
if (value_list->length() != 1U)
return nullptr;
return CreateStyleValue(value_list->Item(0));
}
return CreateStyleValue(value);
}
case CSSPropertyGridAutoFlow: {
const auto& value_list = ToCSSValueList(value);
// Only single keywords are supported in level 1.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment