What is the motivation of why style propagation is implemented
differently in Royale vs. Flex?

In Flex, UIComponent.getStyle() can look at materialized versions of the
inherited and non-inherited style values.  It's quick.  Propagation is
done through notifyStyleChangeInChildren().  (And that can be a
bottleneck in some cases;  I've had to override
ViewStack.notifyStyleChangeInChildren() in Flex for performance, for
example.)

In Royale, UIComponent.getStyle() calls
ValuesManager.valuesImpl.getValue().  For
SimpleCSSValuesImpl.getValue(), that results in looping up the class
hierarchy (A extends B extends C etc.) and then recursive calls to
getValue() up the parent chain (A contains B contains C etc.),
potentially many levels.  SimpleCSSValuesImpl.getValue() takes a
non-trivial amount time.  And all this happens for each call to
UIComponent.getStyle().

In other words:

In Flex,
- getStyle() is usually cheap [O(1)],
- but style changes are expensive [O(size of tree)];

In Royale,
- getStyle() is probably expensive (at least in SimpleCSSValuesImpl up
many levels) [O(class hierarchy depth + longest paths in tree)],
- but style changes are cheap (presumably) [O(1) + event dispatches].

So this becomes a bottleneck in some parts of MX / Spark.  For example,
during AdvancedDataGrid scrolling (after some other bigger bottlenecks
are eliminated), where some of the renderers (especially header
renderers) call getStyle() over and over and over again.

Before I go about trying to optimize some side of this, I just wanted to
understand why it's like this.

Reply via email to