| Being one of the ones who hated it, let me give you the main reason why we must apply css style rules to subclasses: doing otherwise totally breaks our expectations about OO encapsulation. Let's say you have an LZX app with six instances of 'testview', and a bunch of CSS rules applying to instances of 'testview' in various ways. Then you decide you need a minor change to the behavior -- but not the appearance -- of two of those instances, so you write a subclass, 'testviewsub', and modify the tag declaration of those two to be <testviewsub/> instead of <testview/>. What would the OO (never mind the CSS) developer expect to happen? They'd expect instances of 'testviewsub' to look like instances of 'testview'. Having 'testviewsub' instances suddenly lose all of the styling applied to 'testview' instances is (a) unexpected, (b) annoying, and (c) leads to very wasteful duplication of CSS rules, which in turn leads to (e) lots of bugs and maintenance headaches. So I believe we need to integrate our class system with CSS such that the rules applying to a class also apply to the subclass. My expectation of this was that subclass specificity would follow similar rules to DOM hierarchy specificity. (And note that I say "DOM hierarchy specificity" because "lexical specificity" doesn't have any meaning in this context since we are using @immediateparent instead of @parent in order to adhere to CSS' DOM hierarchy inheritance.) And, as Tucker points out, the CSS specification is clear about DOM hierarchy specificity. To further narrow down what our subclass specificity rules should be, let me walk into the CSS2.1 spec a bit, starting with the description of how to compute the specified value (http://www.w3.org/TR/CSS21/cascade.html#specified-value):
Note that by "inherited", the spec means "inherited from the DOM parent", not "inherited from some putative superclass". As for the cascade, the first rule in the cascade description says:
The "matches" link leads us to a description of the various types of selectors, including this one:
Our CSS Proposal on the wiki suggests that LZX classes be considered "document element language types" in the sense used in the W3C CSS spec. I think this is the right approach. So if you follow this whole chain through, the p-inherits-from-div model in HTML maps directly over to our button-inherits-from-view class hierarchy. Unfortunately, in the end what is not made sufficiently clear in the CSS2.1 spec is how sub-typing relations (both the p/div one in HTML and our button/view on in LZX) affect specificity in the cascade. I can't find any commentary on this in either the CSS2.1 spec or the two relevant CSS3 specs (CSS Selectors, www.w3.org/TR/css3-selectors/, and CSS Cascading the Inheritance, http://www.w3.org/TR/css3-cascade/). However, as Tucker has pointed out we have plenty of de facto evidence that the specificity of all rules applying directly to a class should be higher than the specificity of any rules applying to its immediate superclass, and so on. And if that's not the precise model, I strongly feel that we should test the behavior of the major browsers in this area and follow their lead. jim On Sep 9, 2006, at 11:40 AM, Adam Wolff wrote:
|
_______________________________________________ Laszlo-dev mailing list [email protected] http://www.openlaszlo.org/mailman/listinfo/laszlo-dev
