[cssom] Idiom for representing at-rules containing properties?

When representing an at-rule that contains a set of specialized
properties, what's the right idiom for the IDL?

CSSPageRule currently exposes a .style attribute which holds all the
properties.  CSSFontFaceRule just exposes the properties directly as
attributes on the at-rule object (as does CSSCounterStyleRule, but
that's because I just copied @font-face).

I think that using .style makes sense when the set of properties is
large and ever-growing, like it is for normal CSS properties.  The
CSSStyleDeclaration interface makes it at least somewhat more
convenient to determine what properties are actually set, at least
over the alternative of querying every possible attribute to see if
it's null or not.

On the other hand, when the set of properties is small and
rarely-growing, like in @page or @font-face, I think it makes the most
sense to just expose them directly.  You'll much more rarely want to
interact with the properties "generically", and even if you do, it's
not hard to quickly iterate through them all.  The extra indirection
of a .style object seems unnecessary, as does exposing all the
additional machinery for iterating/adding/removing rules by index.

So, I think it's best to settle on the CSSFontFaceRule idiom, and
change CSSPageRule accordingly.  (@page's OM is already broken; Simon
has a bug on it
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=22500>.)

~TJ

Received on Thursday, 27 June 2013 21:55:06 UTC