public override void TraverseRecursive(VisualElement element, int depth)
            {
                int count  = this.m_Matchers.Count;
                int count2 = this.m_Matchers.Count;

                for (int i = 0; i < count2; i++)
                {
                    RuleMatcher          ruleMatcher = this.m_Matchers[i];
                    StyleComplexSelector arg_51_1    = ruleMatcher.complexSelector;
                    Action <VisualElement, MatchResultInfo> arg_51_2;
                    if ((arg_51_2 = UQuery.UQueryMatcher.< > c.< > 9__5_0) == null)
                    {
                        arg_51_2 = (UQuery.UQueryMatcher.< > c.< > 9__5_0 = new Action <VisualElement, MatchResultInfo>(UQuery.UQueryMatcher.< > c.< > 9. < TraverseRecursive > b__5_0));
                    }
                    bool flag = StyleSelectorHelper.MatchRightToLeft(element, arg_51_1, arg_51_2);
                    if (flag)
                    {
                        bool flag2 = this.OnRuleMatchedElement(ruleMatcher, element);
                        if (flag2)
                        {
                            return;
                        }
                    }
                }
                base.Recurse(element, depth);
                bool flag3 = this.m_Matchers.Count > count;

                if (flag3)
                {
                    this.m_Matchers.RemoveRange(count, this.m_Matchers.Count - count);
                    return;
                }
            }
Exemple #2
0
 private void FinishSelector()
 {
     FinishCurrentSelector();
     if (styleSelectors.Count > 0)
     {
         var selector = new StyleComplexSelector();
         selector.selectors = styleSelectors.ToArray();
         styleSelectors.Clear();
         m_Matchers.Add(new RuleMatcher {
             complexSelector = selector
         });
     }
 }
Exemple #3
0
        unsafe public bool IsCandidate(StyleComplexSelector complexSel)
        {
            // We traverse the hash values for the complex selector parts to detect if any part isn't found
            // in the Bloom filter, in which case the selector is not a candidate for the exhaustive search.
            // Also, if a value of 0 is found during the search, then all parts have been visited without a
            // Bloom filter rejection, in which case we must proceed with the exhaustive search.
            for (int i = 0; i < Hashes.kSize; i++)
            {
                // A default part hash value means that all parts have been visited without a Bloom filter rejection.
                if (complexSel.ancestorHashes.hashes[i] == 0)
                {
                    return(true);
                }

                // A negative search in the Bloom filter means that the exhaustive search can be skipped for this selector.
                if (!m_CountingBloomFilter.ContainsHash((uint)complexSel.ancestorHashes.hashes[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #4
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;
                }
            }
        }
        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;
                }
            }
        }
Exemple #6
0
 public RuleMatcher(StyleSheet sheet, StyleComplexSelector complexSelector, int styleSheetIndexInStack)
 {
     this.sheet           = sheet;
     this.complexSelector = complexSelector;
 }