public static bool MatchRightToLeft(VisualElement element, StyleComplexSelector complexSelector, Action <VisualElement, MatchResultInfo> processResult)
        {
            VisualElement visualElement  = element;
            int           i              = complexSelector.selectors.Length - 1;
            VisualElement visualElement2 = null;
            int           num            = -1;
            bool          result;

            while (i >= 0)
            {
                bool flag = visualElement == null;
                if (flag)
                {
                    break;
                }
                MatchResultInfo matchResultInfo = StyleSelectorHelper.MatchesSelector(visualElement, complexSelector.selectors[i]);
                processResult(visualElement, matchResultInfo);
                bool flag2 = !matchResultInfo.success;
                if (flag2)
                {
                    bool flag3 = i < complexSelector.selectors.Length - 1 && complexSelector.selectors[i + 1].previousRelationship == StyleSelectorRelationship.Descendent;
                    if (flag3)
                    {
                        visualElement = visualElement.parent;
                    }
                    else
                    {
                        bool flag4 = visualElement2 != null;
                        if (!flag4)
                        {
                            break;
                        }
                        visualElement = visualElement2;
                        i             = num;
                    }
                }
                else
                {
                    bool flag5 = i < complexSelector.selectors.Length - 1 && complexSelector.selectors[i + 1].previousRelationship == StyleSelectorRelationship.Descendent;
                    if (flag5)
                    {
                        visualElement2 = visualElement.parent;
                        num            = i;
                    }
                    bool flag6 = --i < 0;
                    if (flag6)
                    {
                        result = true;
                        return(result);
                    }
                    visualElement = visualElement.parent;
                }
            }
            result = false;
            return(result);
        }
        private static void FastLookup(IDictionary <string, StyleComplexSelector> table, List <SelectorMatchRecord> matchedSelectors, StyleMatchingContext context, string input, ref SelectorMatchRecord record)
        {
            StyleComplexSelector nextInTable;
            bool flag = table.TryGetValue(input, out nextInTable);

            if (flag)
            {
                while (nextInTable != null)
                {
                    bool flag2 = StyleSelectorHelper.MatchRightToLeft(context.currentElement, nextInTable, context.processResult);
                    if (flag2)
                    {
                        record.complexSelector = nextInTable;
                        matchedSelectors.Add(record);
                    }
                    nextInTable = nextInTable.nextInTable;
                }
            }
        }
        public static void FindMatches(StyleMatchingContext context, List <SelectorMatchRecord> matchedSelectors)
        {
            Debug.Assert(matchedSelectors.Count == 0);
            Debug.Assert(context.currentElement != null, "context.currentElement != null");
            VisualElement currentElement = context.currentElement;

            for (int i = 0; i < context.styleSheetStack.Count; i++)
            {
                StyleSheet          styleSheet          = context.styleSheetStack[i];
                SelectorMatchRecord selectorMatchRecord = new SelectorMatchRecord(styleSheet, i);
                StyleSelectorHelper.FastLookup(styleSheet.orderedTypeSelectors, matchedSelectors, context, currentElement.typeName, ref selectorMatchRecord);
                StyleSelectorHelper.FastLookup(styleSheet.orderedTypeSelectors, matchedSelectors, context, "*", ref selectorMatchRecord);
                bool flag = !string.IsNullOrEmpty(currentElement.name);
                if (flag)
                {
                    StyleSelectorHelper.FastLookup(styleSheet.orderedNameSelectors, matchedSelectors, context, currentElement.name, ref selectorMatchRecord);
                }
                foreach (string current in currentElement.GetClassesForIteration())
                {
                    StyleSelectorHelper.FastLookup(styleSheet.orderedClassSelectors, matchedSelectors, context, current, ref selectorMatchRecord);
                }
            }
        }