private void AppendStyles(HtmlNode node, HtmlNode parent) { CSSPropertyParser propertyParser = new CSSPropertyParser(); foreach (HtmlStyle parentStyle in parent.HtmlStyles) { if (!propertyParser.CanInherit(parentStyle.Name)) { continue; } bool found = false; if (propertyParser.InheritStyle(parentStyle, node)) { continue; } foreach (HtmlStyle childStyle in node.HtmlStyles) { if (propertyParser.StyleContains(parentStyle, childStyle)) { found = true; break; } } if (!found) { node.UpdateInheritedStyles(parentStyle); } } foreach (HtmlStyle parentStyle in parent.InheritedHtmlStyles) { if (!propertyParser.CanInherit(parentStyle.Name)) { continue; } if(parent.HasStyle(parentStyle.Name)) { continue; } propertyParser.InheritStyle(parentStyle, node); } }
private void UpdateCurrentNodeInheritedStyles(HtmlNode node) { CSSPropertyParser propertyParser = new CSSPropertyParser(); foreach(HtmlStyle style in node.HtmlStyles) { if (!propertyParser.CanInherit(style.Name)) { continue; } node.UpdateInheritedStyles(style); } }