Re: [css3-fonts][cssom] proposal for revised definition of CSSFontFaceRule

> In the context of @font-face rules, there's some crossover between the
> set of descriptors defined for @font-face rules and for style rules
> (e.g. "font-family", "font-weight", "font-style", etc.) but several of
> descriptors are unique to @font-face rules (e.g. "unicode-range",
> "src").  This makes use the CSSStyleDeclaration interface for
> @font-face rules very odd.  There are also some subtle differences,
> the "font-family" descriptor for @font-face rules only takes a
> *single* name, not the list of multiple names allowed for the
> "font-family" property in style rules.
For the sake of differentiating the @font-face descriptors from the
style rule properties are not the same and to avoid unnecessary typing
I suggest to remove "font" from the descriptor names.
So instead of "font-family", "font-style", "font-weight",
"font-stretch", "font-variant" and "font-feature-settings" we'll just
have "family", "style", "weight", "stretch", "variant" and
"feature-settings" inside @font-face.

> I think it might make sense to define a new, simpler interface for accessing
> descriptors in @-rules and simply define CSSFontFactRule as an interface
> containing descriptors that implements that interface.
I totally agree.

>   [NoInterfaceObject] interface DescriptorAccess {
>     DOMString GetDescriptorValue(DOMString descName);
>     void SetDescriptorValue(DOMString descName, DOMString value);
>
>     readonly attribute unsigned long length;
>     DOMString item(unsigned long index);
>   };
Small initials! I.e. it should be getDescriptorValue() and setDescriptorValue().

>
>   interface CSSFontFaceRule : CSSRule {
>
>     // descriptors
>     attribute DOMString fontFamily;
>     attribute DOMString src;
>     attribute DOMString fontWeight;
>     attribute DOMString fontStyle;
>     attribute DOMString fontStretch;
>     attribute DOMString fontVariant;
>     attribute DOMString fontFeatureSettings;
>     attribute DOMString unicodeRange;
>
>     // load state - whether the font is loaded or not
>     readonly attribute boolean loaded;
>
>   };
According to the suggestion above the OM attributes would of course
also be renamed to "family", "weight", "style", "stretch", "variant"
and "featureSettings".

Also where's the "style" attribute? From the examples below all
descriptor attributes should be put in there. This raises the question
if we really need a "style" attribute (of type CSSFontFaceDeclaration
in accordance to CSSStyleRule -> CSSStyleDeclaration) or if all
descriptors should be put directly into the CSSFontFaceRule as shown
above.


> Example 1: If 'rule' is a CSSFontFaceRule object, what should
>            the code below do?
>
>     rule.style.font = "bold italic 12px test57";
>
>   Both Webkit and IE9 parse this as a shorthand and set the relevant
>   descriptors (e.g. "font-weight", "font-style") but also set
>   "line-height" and "font-size" and it makes a mess of
>   rule.style.cssText.  Opera is smarter, the line above has no effect
>   on the descriptor values.  Firefox throws an error on all attempts
>   to access rule.style.xxx in @font-face rules (I think Boris
>   mentioned that the CSS2Properties isn't used with these, I haven't
>   dug into the code just yet).
Because "font" in a CSSFontFaceRule != "font" in a CSSStyleRule, the
correct behavior is to ignore it.

> Example 2: What should the code below do?
>
>     rule.style.fontFamily = "test1, test2";
Same reason as above, so ignore it. Will be even clearer that it's not
the same as a CSSStyleRule "fontFamily" when it's renamed to "family".

> Example 3: What should the call below return?
>
>     var src = rule.style.getPropertyValue("src");
CSSFontFaceRule.style != CSSStyleRule.style, so getPropertyValue()
should not be defined. getDescriptorValue() is used instead.

> Example 4: What should the value of the two variables below be?
>
>     var ur1 = rule.style.src;
>     var ur2 = rule.style.getPropertyValue("src");
Both should return the value of the "src" descriptor.

> Example 5: Should the three values below be equal or not?
>
>     var ur = el.style.unicodeRange;
>     var unk = el.style.unknownProperty;
Same here. "unicodeRange" and "unknownProperty" are just something
related to @font-face rules, so they should not be available in
CSS2Properties / CSSStyleDeclaration.

Sebastian

Received on Thursday, 13 September 2012 22:11:23 UTC