示例#1
0
 private void SetupReferences()
 {
     if (this.complexSelectors != null && this.rules != null)
     {
         for (int i = 0; i < this.complexSelectors.Length; i++)
         {
             StyleComplexSelector styleComplexSelector = this.complexSelectors[i];
             if (styleComplexSelector.ruleIndex < this.rules.Length)
             {
                 styleComplexSelector.rule = this.rules[styleComplexSelector.ruleIndex];
             }
         }
     }
 }
示例#2
0
        void SetupReferences()
        {
            if (complexSelectors == null || rules == null)
            {
                return;
            }

            for (int i = 0; i < complexSelectors.Length; i++)
            {
                // Here we set-up runtime-only pointers
                StyleComplexSelector complexSel = complexSelectors[i];

                if (complexSel.ruleIndex < rules.Length)
                {
                    complexSel.rule = rules[complexSel.ruleIndex];
                }
            }
        }
        void SetupReferences()
        {
            if (complexSelectors == null || rules == null)
            {
                return;
            }

            orderedClassSelectors = new TableType(StringComparer.Ordinal);
            orderedNameSelectors  = new TableType(StringComparer.Ordinal);
            orderedTypeSelectors  = new TableType(StringComparer.Ordinal);

            for (int i = 0; i < complexSelectors.Length; i++)
            {
                // Here we set-up runtime-only pointers
                StyleComplexSelector complexSel = complexSelectors[i];

                if (complexSel.ruleIndex < rules.Length)
                {
                    complexSel.rule = rules[complexSel.ruleIndex];
                }

                complexSel.orderInStyleSheet = i;

                StyleSelector     lastSelector = complexSel.selectors[complexSel.selectors.Length - 1];
                StyleSelectorPart part         = lastSelector.parts[0];

                string key = part.value;

                TableType tableToUse = null;

                switch (part.type)
                {
                case StyleSelectorType.Class:
                    tableToUse = orderedClassSelectors;
                    break;

                case StyleSelectorType.ID:
                    tableToUse = orderedNameSelectors;
                    break;

                case StyleSelectorType.Type:
                case StyleSelectorType.Wildcard:
                    key        = part.value ?? "*";
                    tableToUse = orderedTypeSelectors;
                    break;

                // in this case we assume a wildcard selector
                // since a selector such as ":selected" applies to all elements
                case StyleSelectorType.PseudoClass:
                    key        = "*";
                    tableToUse = orderedTypeSelectors;
                    break;

                default:
                    Debug.LogError($"Invalid first part type {part.type}");
                    break;
                }

                if (tableToUse != null)
                {
                    StyleComplexSelector previous;
                    if (tableToUse.TryGetValue(key, out previous))
                    {
                        complexSel.nextInTable = previous;
                    }
                    tableToUse[key] = complexSel;
                }
            }
        }