예제 #1
0
        internal void CachePseudoStateMasks()
        {
            // If we have already cached data on this selector, skip it
            if (selectors[0].pseudoStateMask != -1)
            {
                return;
            }

            // lazily build a cache of pseudo state names
            if (s_PseudoStates == null)
            {
                s_PseudoStates             = new Dictionary <string, PseudoStateData>();
                s_PseudoStates["active"]   = new PseudoStateData(PseudoStates.Active, false);
                s_PseudoStates["hover"]    = new PseudoStateData(PseudoStates.Hover, false);
                s_PseudoStates["checked"]  = new PseudoStateData(PseudoStates.Checked, false);
                s_PseudoStates["selected"] = new PseudoStateData(PseudoStates.Checked, false); //for backward-compatibility
                s_PseudoStates["disabled"] = new PseudoStateData(PseudoStates.Disabled, false);
                s_PseudoStates["focus"]    = new PseudoStateData(PseudoStates.Focus, false);
                s_PseudoStates["root"]     = new PseudoStateData(PseudoStates.Root, false);

                // A few substates can be negated, meaning them match if the flag is not set
                s_PseudoStates["inactive"] = new PseudoStateData(PseudoStates.Active, true);
                s_PseudoStates["enabled"]  = new PseudoStateData(PseudoStates.Disabled, true);
            }

            for (int j = 0, subCount = selectors.Length; j < subCount; j++)
            {
                StyleSelector       selector               = selectors[j];
                StyleSelectorPart[] parts                  = selector.parts;
                PseudoStates        pseudoClassMask        = 0;
                PseudoStates        negatedPseudoClassMask = 0;
                for (int i = 0; i < selector.parts.Length; i++)
                {
                    if (selector.parts[i].type == StyleSelectorType.PseudoClass)
                    {
                        PseudoStateData data;
                        if (s_PseudoStates.TryGetValue(parts[i].value, out data))
                        {
                            if (!data.negate)
                            {
                                pseudoClassMask |= data.state;
                            }
                            else
                            {
                                negatedPseudoClassMask |= data.state;
                            }
                        }
                        else
                        {
                            Debug.LogWarningFormat("Unknown pseudo class \"{0}\"", parts[i].value);
                        }
                    }
                }
                selector.pseudoStateMask        = (int)pseudoClassMask;
                selector.negatedPseudoStateMask = (int)negatedPseudoClassMask;
            }
        }
예제 #2
0
        private void FinishCurrentSelector()
        {
            if (!CurrentSelectorEmpty())
            {
                StyleSelector sel = new StyleSelector();
                sel.previousRelationship = m_Relationship;

                AddPseudoStatesRuleIfNecessasy();

                sel.parts                  = m_Parts.ToArray();
                sel.pseudoStateMask        = pseudoStatesMask;
                sel.negatedPseudoStateMask = negatedPseudoStatesMask;
                styleSelectors.Add(sel);
                m_Parts.Clear();
                pseudoStatesMask = negatedPseudoStatesMask = 0;
            }
        }
예제 #3
0
        private void SetupReferences()
        {
            bool flag = this.complexSelectors == null || this.rules == null;

            if (!flag)
            {
                StyleRule[] rules = this.rules;
                for (int i = 0; i < rules.Length; i++)
                {
                    StyleRule       styleRule  = rules[i];
                    StyleProperty[] properties = styleRule.properties;
                    for (int j = 0; j < properties.Length; j++)
                    {
                        StyleProperty styleProperty = properties[j];
                        bool          flag2         = StyleSheet.CustomStartsWith(styleProperty.name, StyleSheet.kCustomPropertyMarker);
                        if (flag2)
                        {
                            styleRule.customPropertiesCount++;
                            styleProperty.isCustomProperty = true;
                        }
                        StyleValueHandle[] values = styleProperty.values;
                        for (int k = 0; k < values.Length; k++)
                        {
                            StyleValueHandle handle = values[k];
                            bool             flag3  = handle.IsVarFunction();
                            if (flag3)
                            {
                                styleProperty.requireVariableResolve = true;
                                break;
                            }
                        }
                    }
                }
                int l   = 0;
                int num = this.complexSelectors.Length;
                while (l < num)
                {
                    this.complexSelectors[l].CachePseudoStateMasks();
                    l++;
                }
                this.orderedClassSelectors = new Dictionary <string, StyleComplexSelector>(StringComparer.Ordinal);
                this.orderedNameSelectors  = new Dictionary <string, StyleComplexSelector>(StringComparer.Ordinal);
                this.orderedTypeSelectors  = new Dictionary <string, StyleComplexSelector>(StringComparer.Ordinal);
                int m = 0;
                while (m < this.complexSelectors.Length)
                {
                    StyleComplexSelector styleComplexSelector = this.complexSelectors[m];
                    bool flag4 = styleComplexSelector.ruleIndex < this.rules.Length;
                    if (flag4)
                    {
                        styleComplexSelector.rule = this.rules[styleComplexSelector.ruleIndex];
                    }
                    styleComplexSelector.orderInStyleSheet = m;
                    StyleSelector     styleSelector     = styleComplexSelector.selectors[styleComplexSelector.selectors.Length - 1];
                    StyleSelectorPart styleSelectorPart = styleSelector.parts[0];
                    string            key = styleSelectorPart.value;
                    Dictionary <string, StyleComplexSelector> dictionary = null;
                    switch (styleSelectorPart.type)
                    {
                    case StyleSelectorType.Wildcard:
                    case StyleSelectorType.Type:
                        key        = (styleSelectorPart.value ?? "*");
                        dictionary = this.orderedTypeSelectors;
                        break;

                    case StyleSelectorType.Class:
                        dictionary = this.orderedClassSelectors;
                        break;

                    case StyleSelectorType.PseudoClass:
                        key        = "*";
                        dictionary = this.orderedTypeSelectors;
                        break;

                    case StyleSelectorType.RecursivePseudoClass:
                        goto IL_22B;

                    case StyleSelectorType.ID:
                        dictionary = this.orderedNameSelectors;
                        break;

                    default:
                        goto IL_22B;
                    }
IL_249:
                    bool flag5 = dictionary != null;
                    if (flag5)
                    {
                        StyleComplexSelector nextInTable;
                        bool flag6 = dictionary.TryGetValue(key, out nextInTable);
                        if (flag6)
                        {
                            styleComplexSelector.nextInTable = nextInTable;
                        }
                        dictionary[key] = styleComplexSelector;
                    }
                    m++;
                    continue;
IL_22B:
                    Debug.LogError(string.Format("Invalid first part type {0}", styleSelectorPart.type));
                    goto IL_249;
                }
            }
        }
예제 #4
0
        void SetupReferences()
        {
            if (complexSelectors == null || rules == null)
            {
                return;
            }

            // Setup rules and properties for var
            foreach (var rule in rules)
            {
                foreach (var property in rule.properties)
                {
                    if (property.name.StartsWith("--"))
                    {
                        ++rule.customPropertiesCount;
                        property.isCustomProperty = true;
                    }
                }
            }

            for (int i = 0, count = complexSelectors.Length; i < count; i++)
            {
                complexSelectors[i].CachePseudoStateMasks();
            }

            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;
                }
            }
        }
 internal string <ToString> b__20_0(StyleSelector x)
 {
     return(x.ToString());
 }