public override void ProcessMatchedRules(VisualElement element) { VisualElementStylesData resolvedStyles; if (s_StyleCache.TryGetValue(m_MatchingRulesHash, out resolvedStyles)) { // we should not new it in StyleTree element.SetSharedStyles(resolvedStyles); } else { resolvedStyles = new VisualElementStylesData(isShared: true); for (int i = 0, ruleCount = m_MatchedRules.Count; i < ruleCount; i++) { RuleRef ruleRef = m_MatchedRules[i]; StylePropertyID[] propertyIDs = StyleSheetCache.GetPropertyIDs(ruleRef.sheet, ruleRef.selector.ruleIndex); resolvedStyles.ApplyRule(ruleRef.sheet, ruleRef.selector.specificity, ruleRef.selector.rule, propertyIDs); } s_StyleCache[m_MatchingRulesHash] = resolvedStyles; element.SetSharedStyles(resolvedStyles); } }
public override void ProcessMatchedRules(VisualElement element) { VisualElementStylesData visualElementStylesData; if (StyleContext.s_StyleCache.TryGetValue(this.m_MatchingRulesHash, out visualElementStylesData)) { element.SetSharedStyles(visualElementStylesData); } else { visualElementStylesData = new VisualElementStylesData(true); int i = 0; int count = this.m_MatchedRules.Count; while (i < count) { StyleContext.RuleRef ruleRef = this.m_MatchedRules[i]; StylePropertyID[] propertyIDs = StyleSheetCache.GetPropertyIDs(ruleRef.sheet, ruleRef.selector.ruleIndex); visualElementStylesData.ApplyRule(ruleRef.sheet, ruleRef.selector.specificity, ruleRef.selector.rule, propertyIDs); i++; } StyleContext.s_StyleCache[this.m_MatchingRulesHash] = visualElementStylesData; element.SetSharedStyles(visualElementStylesData); } }