public void Add(StyleVariable sv) { m_Variables.Add(sv); unchecked { m_VariableHash = m_Variables.Count == 0 ? sv.GetHashCode() : (m_VariableHash * 397) ^ sv.GetHashCode(); } }
public void Add(StyleVariable sv) { int hashCode = sv.GetHashCode(); int num = this.m_SortedHash.BinarySearch(hashCode); bool flag = num >= 0; if (!flag) { this.m_SortedHash.Insert(~num, hashCode); this.m_Variables.Add(sv); this.m_VariableHash = ((this.m_Variables.Count == 0) ? sv.GetHashCode() : (this.m_VariableHash * 397 ^ sv.GetHashCode())); } }
public bool TryFindVariable(string name, out StyleVariable v) { for (int i = m_Variables.Count - 1; i >= 0; --i) { if (m_Variables[i].name == name) { v = m_Variables[i]; return(true); } } v = default(StyleVariable); return(false); }
private void ProcessMatchedVariables(StyleSheet sheet, StyleRule rule) { foreach (var property in rule.properties) { if (property.isCustomProperty) { var sv = new StyleVariable( property.name, sheet, property.values ); m_ProcessVarContext.Add(sv); } } }
public bool TryFindVariable(string name, out StyleVariable v) { bool result; for (int i = this.m_Variables.Count - 1; i >= 0; i--) { bool flag = this.m_Variables[i].name == name; if (flag) { v = this.m_Variables[i]; result = true; return(result); } } v = default(StyleVariable); result = false; return(result); }
private Result ResolveVariable(string variableName) { StyleVariable sv; if (!variableContext.TryFindVariable(variableName, out sv)) { return(Result.NotFound); } if (m_ResolvedVarStack.Contains(sv.name)) { // Cyclic dependencies : https://drafts.csswg.org/css-variables/#cycles sv = new StyleVariable(); return(Result.NotFound); } m_ResolvedVarStack.Push(sv.name); var result = Result.Valid; for (int i = 0; i < sv.handles.Length && result == Result.Valid; ++i) { var h = sv.handles[i]; if (h.IsVarFunction()) { int argc; string varName; ParseVarFunction(sv.sheet, sv.handles, ref i, out argc, out varName); result = ResolveVariable(varName); } else { var spv = new StylePropertyValue() { sheet = sv.sheet, handle = h }; result = ValidateResolve(spv); } } m_ResolvedVarStack.Pop(); return(result); }
public void Add(StyleVariable sv) { // Avoid duplicates. Otherwise the variable context explodes as hierarchy gets deeper. var hash = sv.GetHashCode(); var hashIndex = m_SortedHash.BinarySearch(hash); if (hashIndex >= 0) { return; } m_SortedHash.Insert(~hashIndex, hash); m_Variables.Add(sv); unchecked { m_VariableHash = m_Variables.Count == 0 ? sv.GetHashCode() : (m_VariableHash * 397) ^ sv.GetHashCode(); } }
public void Add(StyleVariable sv) { m_DirtyVariableHash = true; m_Variables.Add(sv); }