Currently we do not have any RuleHash optimization for pure attribute selectors, which means we need to explicitly test those rules against every single element, which could be slow. There are several rules in html.css related to dir attribute only has attribute selector, which may hurt the performance. We may want to use attribute mapping instead for stylesheet rules.
We used to do this. We stopped in bug 261361 (which is very clear from the blame on these rules in html.css). The basic problem that bug was trying to solve is that this bidi stuff needs to be a rule on the UA level, not a rule on the document level, which is what attr mapped stuff is.
Hmmm, I think we probably should make the stylesheet for attribute mapping to be on the UA level.
There are two kinds of things that one could implement via attribute mapping: 1) What the spec calls "presentation hints". These are defined per spec to be on the document level, just below author rules. This is things like <font face="Comic Sans" size="7" color="hotpink">, and turning off author styles _should_ turn these off. 2) What the spec defines as UA rules but we choose to implement via attribute mapping. The thing with @dir, and perhaps some things like @center or whatnot. These need to go on the UA level.
Thanks for the explanation. Then it seems we have a lot of things which do not match the spec, examles like: * [hidden] is a UA rule, but we handle it in attribute mapping which means it is currently handled as a presentational hint * table[align] rules and most rules for table[rules] are presentational hints, but we handle them in html.css We probably should open a bug for cleaning all those things up, then.
Bug 252530 covers half of it; I don't see a bug on applying some of the nsHTMLStyleSheet rules at the UA level.