Resolve property inheritance ahead of rendering
With the code I pushed for #223 (closed), I disabled the pservers-grad-18-b.svg
test because it fails. This is because the stop-color
and stop-opacity
properties are not supposed to inherit by default, but all of our machinery assumes that all properties inherit automatically. I'd like to do the following:
- Have the parsing code create a
SpecifiedValue
enum for each property, with variants something likeUnspecified
,Inherit
,Specified(ExistingPropertyType)
. - Before rendering, add a new traversal of the tree to actually do the cascading. Here we turn each
SpecifiedValue
into aComputedValue
or something: theInherit
ones always copy their value from their parent;Unspecified
ones only copy the value if the property hasinherits_automatically
(already in themake_property!
macro), andSpecified
ones get used as they are. We may add a methodNodeTrait::here_are_your_cascaded_values()
or something, so that nodes can store those values as they need. - Maybe remove the
State
fromdraw()
and assume nodes already copied the values they needed?
This should let us handle properties that don't inherit automatically (stop-color
, stop-opacity
), plus special ones like in feSpecularLighting
and feDiffuseLighting
that right now need to call reconstruct()
in their set_atts()
because they need to fetch style properties, not presentation attributes.
Also, the extra tree traversal should let us handle things like markers and NodeUse
, which need to reference a subtree that is not a descendant of the current node. Right now those are a bit convoluted; these changes should help make them more uniform.
Finally, this should help pave the way for doing CSS styling with rust-selectors instead of libcroco, as this model is closer to what Servo does already.