Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add font reification #731

Merged
merged 2 commits into from
Mar 23, 2018
Merged

Add font reification #731

merged 2 commits into from
Mar 23, 2018

Conversation

darrnshn
Copy link
Collaborator

@darrnshn darrnshn commented Mar 9, 2018

Hi @tabatkins , PTAL. I got some questions too.

@darrnshn darrnshn requested a review from tabatkins March 9, 2018 03:04
::
:: For both specified and computed values:

1. If the value is <css>none</css>, <css>weight</css>, <css>style</css> or <css>small-caps</css>,
Copy link
Collaborator Author

@darrnshn darrnshn Mar 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax is none | [ weight || style || small-caps ]. Is this correct? I wonder what will happen when we support values like weight style. Might be some ergonomic issues (sorry, I said backwards compat issue before, but realised it's backwards compatible).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, I mean if we reify weight style as a list, then I have to write code like:

// Want to know if 'small-caps' is synthesized.
const result = styleMap.get('font-synthesis');
if (result is keyword with value 'small-caps' or result is a list containing value 'small-caps')

instead of just

if (result is a list containing value 'small-caps')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, "weight style" should definitely be a CSSStyleValue; it's a single value with two keywords in it, not a list-valued property.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about weight by itself? Basically, should weight and weight style reify to two different data structures (e.g. CSSKeywordValue and CSSPairValue), or the same data structure (e.g. CSSValueSet)? I think it might be more convenient if they reified to the same data structure (e.g. if you want to detect whether a font-synthesis contains small-caps, you don't need separate cases for single vs multiple keyword). WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an ideal world where we're designing all of the data structures that CSS will ever need all at once, yeah, we'd give the whole property a specialized data structure that works the same whether you specify one keyword or several.

Unfortunately, we're in the world where CSS is always evolving. Properties that once took single keywords might becomes multi-keyword in the future; we can't backwards-compatibly upgrade them to a new type of object.

That said, I wonder if we should make this sort of upgrade possible. I just raised #735 for this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes that makes sense. We can just rely on the upgrade mechanism here.

::
:: For both specified and computed values,
reify as a {{CSSStyleValue}}
and return the result.

: <a>font-variant-alternates</a>
::
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as font-synthesis.


: <a>font-variation-settings</a>
::
:: For both specified and computed values:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax is none | <something>#, so it's neither list-valued nor single-valued. I think reification-wise it's fine, but the wording for styleMap.append etc. might be hard (can append <something> if it's not none, can never append none). Alternatively, we can always represent the list values as a separate type (like transform which suffers the same problem), but it means we can never append to it directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I figured we probably had an example of this somewhere; the 'animation' handling of "none" seemed sufficiently weird that I was pretty sure somewhere wouldn't have gone for it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(It's "normal", not "none".)

Let's leave this off for the moment - we can just reify to a CSSStyleValue until we figure it out. I suspect this'll be something we want to run by the group and get opinions on.

@darrnshn
Copy link
Collaborator Author

Hi @tabatkins , can you PTAL?

@tabatkins
Copy link
Member

Other than font-variation-settings, looks good.

@darrnshn
Copy link
Collaborator Author

Fixed font-variation-settings and added font-variant-alternates. PTAL thanks!

@tabatkins tabatkins merged commit 82f017f into w3c:master Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants