Beispiel #1
0
        private bool CheckSimpleSelector(string selector, out StyleSelectorPart[] parts)
        {
            bool result;

            if (!CSSSpec.ParseSelector(selector, out parts))
            {
                this.m_Errors.AddSemanticError(StyleSheetImportErrorCode.UnsupportedSelectorFormat, selector);
                result = false;
            }
            else if (parts.Any((StyleSelectorPart p) => p.type == StyleSelectorType.Unknown))
            {
                this.m_Errors.AddSemanticError(StyleSheetImportErrorCode.UnsupportedSelectorFormat, selector);
                result = false;
            }
            else if (parts.Any((StyleSelectorPart p) => p.type == StyleSelectorType.RecursivePseudoClass))
            {
                this.m_Errors.AddSemanticError(StyleSheetImportErrorCode.RecursiveSelectorDetected, selector);
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
Beispiel #2
0
        public static int GetSelectorSpecificity(string selector)
        {
            int result = 0;

            StyleSelectorPart[] parts;
            if (CSSSpec.ParseSelector(selector, out parts))
            {
                result = CSSSpec.GetSelectorSpecificity(parts);
            }
            return(result);
        }
Beispiel #3
0
        public static StyleComplexSelector CreateSimpleSelector(string styleName)
        {
            var cs = new StyleComplexSelector();

            StyleSelectorPart[] parts;
            CSSSpec.ParseSelector(styleName, out parts);
            var selector = new StyleSelector();

            selector.parts = parts;
            cs.selectors   = new[] { selector };
            return(cs);
        }
 bool CheckSimpleSelector(string selector, out StyleSelectorPart[] parts)
 {
     if (!CSSSpec.ParseSelector(selector, out parts))
     {
         m_Errors.AddSemanticError(StyleSheetImportErrorCode.UnsupportedSelectorFormat, selector);
         return(false);
     }
     if (parts.Any(p => p.type == StyleSelectorType.Unknown))
     {
         m_Errors.AddSemanticError(StyleSheetImportErrorCode.UnsupportedSelectorFormat, selector);
         return(false);
     }
     if (parts.Any(p => p.type == StyleSelectorType.RecursivePseudoClass))
     {
         m_Errors.AddSemanticError(StyleSheetImportErrorCode.RecursiveSelectorDetected, selector);
         return(false);
     }
     return(true);
 }