Set CSS styles until loading is finished
Per the discussion on !185 (merged):
As the code loads an SVG, it accumlates <style>
element contents into a CssStyles
as soon as they are found. However, it applies the current state of the CssStyles
to a Node
whenever another element is found.
The spec says, "Style sheets defined anywhere within the SVG document (in style elements or style attributes, or in external style sheets linked with the style sheet processing instruction) apply across the entire SVG document". It looks like we may have to aggregate all the CSS styles together, and only apply them at the end... in yet another pass? Or within the cascade?
In any case, XmlState::create_node()
has this:
// The "svg" node is special; it will parse its style attributes
// until the end, in standard_element_end().
if new_node.get_type() != NodeType::Svg {
new_node.set_style(self.css_styles.as_ref().unwrap(), pbag);
}
So,
- That call to
new_node.set_style()
has a call tonode.set_css_styles(&css_styles)
. We may have to move this to the cascade step... - ... and that may allow us to remove the special case where the SVG node sets its styles at the end of the loading stage.