Exemplo n.º 1
0
        public void Add(StyleVariable sv)
        {
            m_Variables.Add(sv);

            unchecked
            {
                m_VariableHash = m_Variables.Count == 0 ? sv.GetHashCode() : (m_VariableHash * 397) ^ sv.GetHashCode();
            }
        }
Exemplo n.º 2
0
        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()));
            }
        }
Exemplo n.º 3
0
        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);
         }
     }
 }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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();
            }
        }
Exemplo n.º 8
0
 public void Add(StyleVariable sv)
 {
     m_DirtyVariableHash = true;
     m_Variables.Add(sv);
 }