Beispiel #1
0
        /// <summary>
        /// The parsing algo from W3C does not parse CSS into right CSS object model, this is to convert to right CSSOM.
        /// </summary>
        /// <param name="rawstylesheet"></param>
        /// <returns></returns>
        private static CSSStyleSheet ParseCSSStyleSheet(stylesheet rawstylesheet, string baseurl, bool downloadImportRule, ref string OriginalCss)
        {
            CSSStyleSheet CssStyleSheet = new CSSStyleSheet();

            foreach (var item in rawstylesheet.items)
            {
                if (item.Type == enumRuleType.QualifiedRule)
                {
                    CSSRule rule = ParseQualifiedRule(item as QualifiedRule, ref OriginalCss);
                    if (rule != null)
                    {
                        rule.parentStyleSheet = CssStyleSheet;
                        CssStyleSheet.cssRules.appendRule(rule);
                    }
                }
                else if (item.Type == enumRuleType.AtRule)
                {
                    CSSRule rule = ParseAtRule(item as AtRule, CssStyleSheet, baseurl, downloadImportRule, ref OriginalCss);

                    if (rule != null)
                    {
                        rule.parentStyleSheet = CssStyleSheet;
                        CssStyleSheet.cssRules.appendRule(rule);
                    }
                }
            }

            return(CssStyleSheet);
        }
Beispiel #2
0
        /// <summary>
        /// 5.3.1. Parse a stylesheet. To parse a stylesheet from a stream of tokens:
        /// </summary>
        /// <returns></returns>
        public stylesheet ParseStyleSheet()
        {
            //Create a new stylesheet.
            stylesheet stylesheet = new stylesheet();

            //Consume a list of rules from the stream of tokens, with the top-level flag set.
            //Assign the returned value to the stylesheet’s value.
            stylesheet.items = ConsumeListOfRules(true);
            //Return the stylesheet.
            return(stylesheet);
        }
Beispiel #3
0
        /// <summary>
        /// parse a style sheet.
        /// </summary>
        /// <param name="cssText"></param>
        /// <param name="baseurl"></param>
        /// <returns></returns>
        public static CSSStyleSheet ParseCSSStyleSheet(string cssText, string baseurl, bool downloadImportRule)
        {
            //this.baseurl = baseurl;
            //this.downloadimportrule = downloadImportRule;

            TokenParser   parser        = new TokenParser();
            stylesheet    rawstylesheet = parser.ParseStyleSheet(cssText);
            CSSStyleSheet stylesheet    = ParseCSSStyleSheet(rawstylesheet, baseurl, downloadImportRule, ref cssText);

            stylesheet.cssText = cssText;
            return(stylesheet);
        }
Beispiel #4
0
 Load(new XPathDocument(stylesheet, XmlSpace.Preserve), resolver);
 CompileXsltToQil(stylesheet, settings, stylesheetResolver);