public static void FindSpecifiedStyles(ComputedStyle computedStyle, IEnumerable <SelectorMatchRecord> matchRecords, Dictionary <StylePropertyId, int> result) { result.Clear(); if (computedStyle == null) { return; } // Find matched styles foreach (var record in matchRecords) { int specificity = record.complexSelector.specificity; if (record.sheet.isUnityStyleSheet) { specificity = UnitySpecificity; } var properties = record.complexSelector.rule.properties; foreach (var property in properties) { StylePropertyId id; if (StylePropertyUtil.s_NameToId.TryGetValue(property.name, out id)) { if (IsShorthandProperty(id)) { var longhands = GetLonghandPropertyNames(id); foreach (var longhand in longhands) { var longhandId = GetStylePropertyIdFromName(longhand); result[longhandId] = specificity; } } else { result[id] = specificity; } } } } // Find inherited properties var inheritedPropId = StyleDebug.GetInheritedProperties(); foreach (var id in inheritedPropId) { if (result.ContainsKey(id)) { continue; } var value = StyleDebug.GetComputedStyleValue(computedStyle, id); var initialValue = StyleDebug.GetComputedStyleValue(InitialStyle.Get(), id); if (!value.Equals(initialValue)) { result[id] = InheritedSpecificity; } } }
public static ComputedStyle Create(bool isShared = true) { var cs = new ComputedStyle(isShared); cs.CopyFrom(InitialStyle.Get()); return(cs); }
private void ApplyAllPropertyInitial() { CopyFrom(ref InitialStyle.Get()); }
public static void FindSpecifiedStyles(ComputedStyle computedStyle, IEnumerable <SelectorMatchRecord> matchRecords, Dictionary <StylePropertyId, int> result) { result.Clear(); bool flag = computedStyle == null; if (!flag) { foreach (SelectorMatchRecord current in matchRecords) { int value = current.complexSelector.specificity; bool isUnityStyleSheet = current.sheet.isUnityStyleSheet; if (isUnityStyleSheet) { value = -1; } StyleProperty[] properties = current.complexSelector.rule.properties; StyleProperty[] array = properties; for (int i = 0; i < array.Length; i++) { StyleProperty styleProperty = array[i]; StylePropertyId stylePropertyId; bool flag2 = StylePropertyUtil.s_NameToId.TryGetValue(styleProperty.name, out stylePropertyId); if (flag2) { bool flag3 = StyleDebug.IsShorthandProperty(stylePropertyId); if (flag3) { string[] longhandPropertyNames = StyleDebug.GetLonghandPropertyNames(stylePropertyId); string[] array2 = longhandPropertyNames; for (int j = 0; j < array2.Length; j++) { string name = array2[j]; StylePropertyId stylePropertyIdFromName = StyleDebug.GetStylePropertyIdFromName(name); result[stylePropertyIdFromName] = value; } } else { result[stylePropertyId] = value; } } } } StylePropertyId[] inheritedProperties = StyleDebug.GetInheritedProperties(); StylePropertyId[] array3 = inheritedProperties; for (int k = 0; k < array3.Length; k++) { StylePropertyId stylePropertyId2 = array3[k]; bool flag4 = result.ContainsKey(stylePropertyId2); if (!flag4) { object computedStyleValue = StyleDebug.GetComputedStyleValue(computedStyle, stylePropertyId2); object computedStyleValue2 = StyleDebug.GetComputedStyleValue(InitialStyle.Get(), stylePropertyId2); bool flag5 = !computedStyleValue.Equals(computedStyleValue2); if (flag5) { result[stylePropertyId2] = 2147483646; } } } } }