On Mon, 19 Jul 2010, Greg Brown wrote:
I just took a look at a small part of your implementation and I see
that our approaches are fundamentally different. You parse the
stylesheet, set static properties on the Component class or some
subclass thereof, and then use that information somewhere along the
line to perform the styling.
That's correct. Based on what I have read, I believe styling in Flex
works similarly.
Flex's styling support is painfully limited. Probably the biggest
annoyance is its lack of support for Element.class selectors. This has
caused me a lot of duplication of effort.
I parse the stylesheet into a "stylesheet document" and apply it to a
component hierarchy, presumably after it's been constructed by a
serializer.
This certainly works, but it requires traversing the component tree
twice (once to build it and again to style it). This may have
performance implications, especially for large applications. The current
approach applies styling as the tree is constructed, which requires only
one traversal.
True, but that traversal does not involve any parsing. It's done with
objects already loaded into memory. I think some actual benchmarking is
in order before we can discuss performance considerations. I mean, I
could write a test application that builds some kind of ginormous
Component hierarchy and applies a ginormous stylesheet and see how long
that takes to run.
As far as implementation goes, I prefer avoiding the use of static
variables. It seems to me your stylesheet styles are locked-in to all
instances of XYZ component and all components using a certain style class
name. In my implementation you can apply any stylesheet to any component
hierarchy at any time. No static state is kept in the UI.
Cheers.