void ProcessMatchedRules(VisualElement element, List <SelectorMatchRecord> matchingSelectors)
        {
            matchingSelectors.Sort(SelectorMatchRecord.Compare);

            Int64 matchingRulesHash = element.fullTypeName.GetHashCode();

            // Let current DPI contribute to the hash so cache is invalidated when this changes
            matchingRulesHash = (matchingRulesHash * 397) ^ currentPixelsPerPoint.GetHashCode();

            foreach (var record in matchingSelectors)
            {
                StyleRule rule        = record.complexSelector.rule;
                int       specificity = record.complexSelector.specificity;
                matchingRulesHash = (matchingRulesHash * 397) ^ rule.GetHashCode();
                matchingRulesHash = (matchingRulesHash * 397) ^ specificity;
            }

            VisualElementStylesData resolvedStyles;

            if (StyleCache.TryGetValue(matchingRulesHash, out resolvedStyles))
            {
                element.SetSharedStyles(resolvedStyles);
            }
            else
            {
                resolvedStyles = new VisualElementStylesData(isShared: true);

                foreach (var record in matchingSelectors)
                {
                    StylePropertyID[] propertyIDs = StyleSheetCache.GetPropertyIDs(record.sheet, record.complexSelector.ruleIndex);
                    resolvedStyles.ApplyRule(record.sheet, record.complexSelector.specificity, record.complexSelector.rule, propertyIDs);
                }

                resolvedStyles.ApplyLayoutValues();


                StyleCache.SetValue(matchingRulesHash, resolvedStyles);

                element.SetSharedStyles(resolvedStyles);
            }
        }