Exemple #1
0
        private static CSSRule ParseMediaRule(AtRule rule, CSSStyleSheet parentSheet, ref string OriginalCss)
        {
            CSSMediaRule mediarule = new CSSMediaRule();

            mediarule.parentStyleSheet = parentSheet;

            string media = string.Empty;
            string wholeconditiontext = string.Empty;

            int startindex       = -1;
            int endindex         = -1;
            int endindexselector = -1;

            startindex = rule.prelude[0].startindex;

            // the first componentvalue is a preservedtoken and it media.
            rule.prelude.RemoveAt(0);

            wholeconditiontext = ComponentValueExtension.getString(rule.prelude, ref startindex, ref endindexselector, ref OriginalCss);

            foreach (var item in wholeconditiontext.Split(','))
            {
                mediarule.media.appendMedium(item);
            }

            CSSRuleList blockrulelist = ParseMediaRuleList(rule.block, ref endindex, mediarule, ref OriginalCss);

            if (blockrulelist != null)
            {
                mediarule.cssRules = blockrulelist;
            }

            mediarule.conditionText = wholeconditiontext;

            //SelectorText is assigned in a different way now.
            // mediarule.selectorText = wholeconditiontext; /// NON-W3C.

            mediarule.StartIndex = rule.startindex;

            if (rule.endindex > endindex)
            {
                endindex = rule.endindex;
            }

            mediarule.EndIndex         = endindex;
            mediarule.EndSelectorIndex = endindexselector - mediarule.StartIndex + 1;

            return(mediarule);
        }
Exemple #2
0
        /// <summary>
        /// From W3C, in most case, th preclude matchs to Selector and block value contains declaration.
        /// </summary>
        /// <param name="rule"></param>
        /// <returns></returns>
        private static CSSRule ParseQualifiedRule(QualifiedRule rule, ref string OriginalCss)
        {
            CSSStyleRule cssrule      = new CSSStyleRule();
            string       selectorText = string.Empty;

            int startindex = -1;
            int endindex   = -1;

            int endindexselector = -1;

            selectorText = ComponentValueExtension.getString(rule.prelude, ref startindex, ref endindexselector, ref OriginalCss);

            cssrule.selectorText = selectorText;

            cssrule.style = ParseDeclarations(rule.block, ref endindex, ref OriginalCss);


            cssrule.StartIndex       = rule.startindex;
            cssrule.EndIndex         = rule.endindex;
            cssrule.EndSelectorIndex = endindexselector - cssrule.StartIndex + 1;

            return(cssrule);
        }