Example #1
0
 private CssRuleSetGroup(CssRuleSetGroup parent, string name, WebDom.CssSimpleElementSelector simpleSelector)
 {
     //if (dbugId == 170)
     //{
     //}
     this.Name              = name;
     this._parent           = parent;
     this._originalSelector = simpleSelector;
 }
Example #2
0
        static CssRuleSetGroup GetGroupOrCreateIfNotExists(Dictionary <string, CssRuleSetGroup> dic,
                                                           WebDom.CssSimpleElementSelector simpleSelector)
        {
            CssRuleSetGroup ruleSetGroup;

            if (!dic.TryGetValue(simpleSelector.Name, out ruleSetGroup))
            {
                ruleSetGroup = new CssRuleSetGroup(simpleSelector.Name);
                dic.Add(simpleSelector.Name, ruleSetGroup);
            }
            //-------------
            if (simpleSelector.Parent != null)
            {
                //get or create subgroup
                return(ruleSetGroup.GetOrCreateSubgroup(simpleSelector));
            }
            //-------------
            return(ruleSetGroup);
        }
Example #3
0
        public CssRuleSetGroup GetOrCreateSubgroup(WebDom.CssSimpleElementSelector simpleSelector)
        {
            if (_subGroups == null)
            {
                _subGroups = new List <CssRuleSetGroup>();
            }
            int j = _subGroups.Count;

            for (int i = 0; i < j; ++i)
            {
                //find sub group for specific selector
                WebDom.CssSimpleElementSelector selector = _subGroups[i]._originalSelector;
                if (WebDom.CssSimpleElementSelector.IsCompatible(selector, simpleSelector))
                {
                    //found
                    return(_subGroups[i]);
                }
            }
            //if not found then create new one
            CssRuleSetGroup newSubgroup = new CssRuleSetGroup(this, this.Name, simpleSelector);

            this._subGroups.Add(newSubgroup);
            return(newSubgroup);
        }
Example #4
0
        private CssRuleSetGroup(CssRuleSetGroup parent, string name, WebDom.CssSimpleElementSelector simpleSelector)
        {
            this.Name = name;
            this._parent = parent;
            this._originalSelector = simpleSelector;

        }
Example #5
0
        void ExpandSelector(List <CssRuleSetGroup> relatedRuleSets, WebDom.CssElementSelector selector)
        {
            //recursive
            //create active element set
            if (selector.IsSimpleSelector)
            {
                WebDom.CssSimpleElementSelector simpleSelector = (WebDom.CssSimpleElementSelector)selector;
                switch (simpleSelector.selectorType)
                {
                default:
                {
                    throw new NotSupportedException();
                }

                case WebDom.SimpleElementSelectorKind.ClassName:
                {
                    //any element with specific class name
                    relatedRuleSets.Add(
                        GetGroupOrCreateIfNotExists(
                            rulesForClassName,
                            simpleSelector));
                }
                break;

                case WebDom.SimpleElementSelectorKind.Extend:
                {
                }
                break;

                case WebDom.SimpleElementSelectorKind.Id:
                {
                    //element with id
                    relatedRuleSets.Add(
                        GetGroupOrCreateIfNotExists(
                            rulesForElementId,
                            simpleSelector));
                }
                break;

                case WebDom.SimpleElementSelectorKind.PseudoClass:
                {
                    relatedRuleSets.Add(
                        GetGroupOrCreateIfNotExists(
                            rulesForPsedoClass,
                            simpleSelector));
                }
                break;

                case WebDom.SimpleElementSelectorKind.TagName:
                {
                    relatedRuleSets.Add(
                        GetGroupOrCreateIfNotExists(
                            rulesForTagName,
                            simpleSelector));
                }
                break;

                case WebDom.SimpleElementSelectorKind.All:
                {
                    relatedRuleSets.Add(
                        GetGroupOrCreateIfNotExists(
                            rulesForAll,
                            simpleSelector));
                }
                break;
                }
            }
            else
            {
                WebDom.CssCompundElementSelector combiSelector = (WebDom.CssCompundElementSelector)selector;
                switch (combiSelector.OperatorName)
                {
                case WebDom.CssCombinatorOperator.List:
                {
                    ExpandSelector(relatedRuleSets, combiSelector.LeftSelector);
                    ExpandSelector(relatedRuleSets, combiSelector.RightSelector);
                }
                break;

                case WebDom.CssCombinatorOperator.Descendant:
                {
                    //focus on right side?
                    ExpandSelector(relatedRuleSets, combiSelector.RightSelector);
                }
                break;

                default:
                {
                    throw new NotSupportedException();
                }
                }
            }
            //-----------------------------------------------------------------------------
        }