internal void Apply(VisualElementStyles other, StylePropertyApplyMode mode) { this.m_CustomProperties = other.m_CustomProperties; this.width.Apply(other.width, mode); this.height.Apply(other.height, mode); this.maxWidth.Apply(other.maxWidth, mode); this.maxHeight.Apply(other.maxHeight, mode); this.minWidth.Apply(other.minWidth, mode); this.minHeight.Apply(other.minHeight, mode); this.flex.Apply(other.flex, mode); this.overflow.Apply(other.overflow, mode); this.positionLeft.Apply(other.positionLeft, mode); this.positionTop.Apply(other.positionTop, mode); this.positionRight.Apply(other.positionRight, mode); this.positionBottom.Apply(other.positionBottom, mode); this.marginLeft.Apply(other.marginLeft, mode); this.marginTop.Apply(other.marginTop, mode); this.marginRight.Apply(other.marginRight, mode); this.marginBottom.Apply(other.marginBottom, mode); this.borderLeft.Apply(other.borderLeft, mode); this.borderTop.Apply(other.borderTop, mode); this.borderRight.Apply(other.borderRight, mode); this.borderBottom.Apply(other.borderBottom, mode); this.paddingLeft.Apply(other.paddingLeft, mode); this.paddingTop.Apply(other.paddingTop, mode); this.paddingRight.Apply(other.paddingRight, mode); this.paddingBottom.Apply(other.paddingBottom, mode); this.positionType.Apply(other.positionType, mode); this.alignSelf.Apply(other.alignSelf, mode); this.textAlignment.Apply(other.textAlignment, mode); this.fontStyle.Apply(other.fontStyle, mode); this.textClipping.Apply(other.textClipping, mode); this.fontSize.Apply(other.fontSize, mode); this.font.Apply(other.font, mode); this.wordWrap.Apply(other.wordWrap, mode); this.textColor.Apply(other.textColor, mode); this.flexDirection.Apply(other.flexDirection, mode); this.backgroundColor.Apply(other.backgroundColor, mode); this.borderColor.Apply(other.borderColor, mode); this.backgroundImage.Apply(other.backgroundImage, mode); this.backgroundSize.Apply(other.backgroundSize, mode); this.alignItems.Apply(other.alignItems, mode); this.alignContent.Apply(other.alignContent, mode); this.justifyContent.Apply(other.justifyContent, mode); this.flexWrap.Apply(other.flexWrap, mode); this.borderWidth.Apply(other.borderWidth, mode); this.borderRadius.Apply(other.borderRadius, mode); this.sliceLeft.Apply(other.sliceLeft, mode); this.sliceTop.Apply(other.sliceTop, mode); this.sliceRight.Apply(other.sliceRight, mode); this.sliceBottom.Apply(other.sliceBottom, mode); this.opacity.Apply(other.opacity, mode); }
public VisualElementStyles(VisualElementStyles other, bool isShared) : this(isShared) { this.Apply(other, StylePropertyApplyMode.Copy); }
private void UpdateStyles(VisualElement element, int depth) { if (element.IsDirty(ChangeType.Styles) || element.IsDirty(ChangeType.StylesPath)) { VisualContainer visualContainer = element as VisualContainer; int count = this.m_Matchers.Count; if (visualContainer != null && visualContainer.styleSheets != null) { this.AddMatchersFromSheet(visualContainer.styleSheets); } string fullTypeName = element.fullTypeName; long num = (long)fullTypeName.GetHashCode(); num = (num * 397L ^ (long)this.currentPixelsPerPoint.GetHashCode()); this.m_MatchedRules.Clear(); int count2 = this.m_Matchers.Count; for (int i = 0; i < count2; i++) { RuleMatcher ruleMatcher = this.m_Matchers[i]; if (ruleMatcher.depth >= depth && StyleContext.Match(element, ref ruleMatcher)) { StyleSelector[] selectors = ruleMatcher.complexSelector.selectors; int num2 = ruleMatcher.simpleSelectorIndex + 1; int num3 = selectors.Length; if (num2 < num3) { RuleMatcher item = new RuleMatcher { complexSelector = ruleMatcher.complexSelector, depth = ((selectors[num2].previousRelationship != StyleSelectorRelationship.Child) ? 2147483647 : (depth + 1)), simpleSelectorIndex = num2, sheet = ruleMatcher.sheet }; this.m_Matchers.Add(item); } else { StyleRule rule = ruleMatcher.complexSelector.rule; int specificity = ruleMatcher.complexSelector.specificity; num = (num * 397L ^ (long)rule.GetHashCode()); num = (num * 397L ^ (long)specificity); this.m_MatchedRules.Add(new StyleContext.RuleRef { selector = ruleMatcher.complexSelector, sheet = ruleMatcher.sheet }); } } } VisualElementStyles visualElementStyles; if (StyleContext.s_StyleCache.TryGetValue(num, out visualElementStyles)) { element.SetSharedStyles(visualElementStyles); } else { visualElementStyles = new VisualElementStyles(true); int j = 0; int count3 = this.m_MatchedRules.Count; while (j < count3) { StyleContext.RuleRef ruleRef = this.m_MatchedRules[j]; StylePropertyID[] propertyIDs = StyleSheetCache.GetPropertyIDs(ruleRef.sheet, ruleRef.selector.ruleIndex); visualElementStyles.ApplyRule(ruleRef.sheet, ruleRef.selector.specificity, ruleRef.selector.rule, propertyIDs, this.m_VisualTree.elementPanel.loadResourceFunc); j++; } StyleContext.s_StyleCache[num] = visualElementStyles; element.SetSharedStyles(visualElementStyles); } if (visualContainer != null) { for (int k = 0; k < visualContainer.childrenCount; k++) { VisualElement childAt = visualContainer.GetChildAt(k); this.UpdateStyles(childAt, depth + 1); } } if (this.m_Matchers.Count > count) { this.m_Matchers.RemoveRange(count, this.m_Matchers.Count - count); } } }