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);
            }
        }
        internal void OverWrite(HtmlStyle htmlStyle)
        {
            CSSPropertyParser propertyParser = new CSSPropertyParser();

            //if (string.Compare(name, htmlStyle.Name, StringComparison.InvariantCultureIgnoreCase) == 0)
            if (propertyParser.StyleContains(this, htmlStyle))
            {
                if (!important && htmlStyle.Important)
                {
                    name = htmlStyle.Name;
                    value = htmlStyle.Value;
                    important = htmlStyle.Important;
                    specificity = htmlStyle.Specificity;
                }
                else if (htmlStyle.Specificity >= specificity && (!important || (important && htmlStyle.Important)))
                {
                    name = htmlStyle.Name;
                    value = htmlStyle.Value;
                }
            }
        }
		public override void ParseStyles()
		{
			if (current != null)
			{
				CSSTracker cssTracker = new CSSTracker();

                cssTracker.UriSchema = uriSchema;
                cssTracker.BaseURL = baseUrl;

				StyleSheet styleSheet = cssTracker.TrackCSS(current);
                styleSheet.ApplyStyles(current);
                
                CSSPropertyParser propertyParser = new CSSPropertyParser();
                propertyParser.ParseStyle(current);
                
                CSSInheritance cssInheritance = new CSSInheritance();
                cssInheritance.Apply(current);
			}
		}
        private void UpdateCurrentNodeInheritedStyles(HtmlNode node)
        {
            CSSPropertyParser propertyParser = new CSSPropertyParser();

            foreach(HtmlStyle style in node.HtmlStyles)
            {
                if (!propertyParser.CanInherit(style.Name))
                {
                    continue;
                }

                node.UpdateInheritedStyles(style);
            }
        }
示例#5
0
        internal void UpdateInheritedStyles(HtmlStyle style)
        {
            CSSPropertyParser propertyParser = new CSSPropertyParser();

            foreach (HtmlStyle inheritedStyle in inheritedHtmlStyles)
            {
                if (propertyParser.StyleContains(style, inheritedStyle))
                {
                    inheritedStyle.ModifyStyle(style.Value);
                    return;
                }
            }

            //If style found in the inheritedStyles, control will return without hit this statment.
            inheritedHtmlStyles.Add(style.Clone());
        }
示例#6
0
        internal void CopyHtmlStyles(List<HtmlStyle> newStyles, Specificity specificity)
        {
            CSSPropertyParser propertyParser = new CSSPropertyParser();

            foreach (HtmlStyle newStyle in newStyles)
            {
                bool found = false;

                newStyle.Specificity = specificity;

                foreach (HtmlStyle style in htmlStyles)
                {
                    if (propertyParser.StyleContains(newStyle, style))
                    {
                        found = true;
                        style.OverWrite(newStyle);
                    }
                }

                if (!found)
                {
                    htmlStyles.Add(newStyle.Clone());
                }
            }
        }