summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2489e4e)
raw | patch | inline | side by side (parent: 2489e4e)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Tue, 27 Mar 2007 07:05:49 +0000 (07:05 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Tue, 27 Mar 2007 07:05:49 +0000 (07:05 +0000) |
src/xml/repr-css.cpp | patch | blob | history |
diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp
index e2954ddf3e25b0d778a3ece586641b3ec00d2343..d3c39e5a201717bc13afe990681f16774c75b3b9 100644 (file)
--- a/src/xml/repr-css.cpp
+++ b/src/xml/repr-css.cpp
return css;
}
+static void
+sp_repr_css_attr_inherited_recursive(SPCSSAttr *css, Node *repr, gchar const *attr)
+{
+ Node *parent = sp_repr_parent(repr);
+
+ // read the ancestors from root down, using head recursion, so that children override parents
+ if (parent) {
+ sp_repr_css_attr_inherited_recursive(css, parent, attr);
+ }
+
+ sp_repr_css_add_components(css, repr, attr);
+}
+
+
SPCSSAttr *sp_repr_css_attr_inherited(Node *repr, gchar const *attr)
{
g_assert(repr != NULL);
SPCSSAttr *css = sp_repr_css_attr_new();
- sp_repr_css_add_components(css, repr, attr);
- Node *current = sp_repr_parent(repr);
-
- while (current) {
- sp_repr_css_add_components(css, current, attr);
- current = sp_repr_parent(current);
- }
+ sp_repr_css_attr_inherited_recursive(css, repr, attr);
return css;
}
static void
sp_repr_css_merge_from_decl_list(SPCSSAttr *css, CRDeclaration const *const decl_list)
{
+ // read the decls from start to end, using tail recursion, so that latter declarations override
+ // (Ref: http://www.w3.org/TR/REC-CSS2/cascade.html#cascading-order point 4.)
+ // because sp_repr_css_merge_from_decl sets properties unconditionally
+ sp_repr_css_merge_from_decl(css, decl_list);
if (decl_list->next) {
sp_repr_css_merge_from_decl_list(css, decl_list->next);
}
- sp_repr_css_merge_from_decl(css, decl_list);
}
void