LzCSSStyle#281 and following, is where the dependency is noted. #294 applies that constraint, and any constraints that were noted when computing the rule applicability. #298 and following is where we only send an event if the inherited properties or values are actually different after the update.
I will add the following overview comment on the property caching: The first time we look up a CSS property on a node, we compute and cache all the rules applicable to that node, and compute and cache all the CSS properties that those rules specify. These property values are kept in a node-local cache so that subsequent property lookups can be done with no function call overhead by simply looking in the cache. CSS rules can depend on attribute values (the [attr=value] selector). As we are gathering the rules that could apply to the node, we gather then nodes and attributes that these selectors could match on. Once the gathering and caching is complete, we create a delegate that will update the cache (and re-apply the values) if any of these dependencies change. Some CSS properties can be inherited (from ancestor nodes), so we also compute a second cache which is all the inheritable CSS property values. We compute and cache the inheritable properties by requesting our parent node's local cache (which will request it's parent's, etc.) The inheritable properties are also cached so that in computing the local cache we can quickly find and merge in any inheritable property values that are not specified by locally applicable rules, or properties that are specified to be inherited by the local rules. The inherited property values can change if the parent node's inherited cache changes (and it depends on it's parent), so we always install an additional dependency for the update delegate to listen to the parent inherited cache changing. To minimize unnecessary updates, we carefully compare the old and new inheritance cache and only send a change event if the properties or values in the cache have actually changed on update. On 2010-11-03, at 12:09, Henry Minsky wrote: > I just realized I didn't understand something, where does the listener get > set up to get triggered by changes to the parent properties which can be > inherited? > > > On Tue, Nov 2, 2010 at 6:15 PM, P T Withington <[email protected]> wrote: > >> Change ptw-20101031-MxX by [email protected] on 2010-10-31 18:20:08 EDT >> in /Users/ptw/OpenLaszlo/trunk-3 >> for http://svn.openlaszlo.org/openlaszlo/trunk >> >> Summary: Revise CSS inherit behavior to match standard >> >> Bugs Fixed: >> LPP-9493 box-model incorrectly inherits style from parent node >> LPP-9495 Need a way to say if a custom CSS property inherits or not >> LPP-9496 Implement CSS 'inherit' keyword >> >> Technical Reviewer: [email protected] (pending) >> QA Reviewer: [email protected] (pending) >> Doc Reviewer: [email protected] (pending) >> >> Release Notes: >> >> Summary >> >> CSS properties no longer inherit (from parent) by default. Only >> the standard properties that are defined to inherit do so. Custom >> properties must explicitly state that they inherit using the new >> `style` and `inherit` properties of <attribute>. >> >> Details >> >> a) Standard properties will only inherit if they are defined to do >> so by the W3 standard: http://www.w3.org/TR/CSS21/propidx.html >> >> b) Custom CSS properties default to not inheriting. >> >> c) The CSS `inherit` keyword can be used in a stylesheet to make >> any CSS property have the inheriting behavior (where the CSS rule >> is applicable). >> >> d) There is a new property of <attribute>, when you specify >> `style="property"`, you can also specify `inherit="true"`, to make >> that CSS property inherit (or false to disable standard >> inheritance). >> >> e) For backwards compatibility, when there is no local applicable >> CSS style property, but there is an inheritable property, the >> inheritable property will be used. In debug mode, you will get a >> warning, in case this is not the intended behavior. The warning >> will give instructions on how to change your code to silence the >> warning (i.e., to make the inherit behavior explicit). >> >> Details: >> >> classes, neighborhoodclasses, subclassing, constraint-test, >> simplerdescendent-test: Add `inherit="true"` to styled attributes >> expecting to inherit to silence warnings. >> >> speedtest: Specify `inherit` in CSS for subsubclass to silence >> warnings. >> >> designerview: Give a default value to miscdata, to silence >> warnings. >> >> LzSprite.js: Actually set the padding on the sprite div. >> >> LzCSSStyle: Add table of standard attributes that inherit. >> Completely rewrite property cache computation to compute both a >> local and inherited cache, to inherit (according to rules >> described in release notes), to listen for changes in inherited >> properties, and to send an event only when the inherited >> properties change. >> >> LzDebug: Improve explainStyleBindings to omit redundant >> information. >> >> LzNode, NodeModel: accumulate properties that are specified to >> inherit and install them early on. Add back-compatibility to find >> inheritable properties if they exist and print a helpful warning >> explaining "the new way". >> >> CSSHandler, ViewSchema: Handle the `inherit` keyword. >> >> Tests: >> >> {smokecheck, metasuite, test from bug} x {swf8, swf10, dhtml} >> >> Files: >> M test/style/classes/classes.lzx >> M test/style/neighborhood/neighborhoodclasses.lzx >> M test/style/constraints/subclassing.lzx >> M test/style/constraints/speedtest.lzx >> M test/style/constraints/constraint-test.lzx >> M test/style/designerview.lzx >> M test/style/descendantselector/simplerdescendant-test.lzx >> M WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js >> M WEB-INF/lps/lfc/services/LzCSSStyle.lzs >> M WEB-INF/lps/lfc/debugger/LzDebug.lzs >> M WEB-INF/lps/lfc/core/LzNode.lzs >> M WEB-INF/lps/server/src/org/openlaszlo/css/CSSHandler.java >> M WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java >> M WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java >> >> Changeset: >> http://svn.openlaszlo.org/openlaszlo/patches/ptw-20101031-MxX.tar >> > > > > -- > Henry Minsky > Software Architect > [email protected]
