Ejemplo n.º 1
0
        /// <summary>Called to get a this properties value from the given style.
        /// This exists as it may be an alias property.</summary>
        /// <param name="hostValue">This can return aliased values. The 'host' value is the actual property.
        /// Think the value of 'margin' (host) when calling GetValue on 'margin-left' (returned).</param>
        public virtual Css.Value GetOrCreateValue(Node context, Style styleBlock, bool allowInherit, out Css.Value hostValue)
        {
            // Pull the value from the block:
            Css.Value result;
            styleBlock.Properties.TryGetValue(this, out result);

            if (result == null)
            {
                // Does it inherit?
                if (Inherits)
                {
                    // Create the keyword:
                    Css.Keywords.Inherit inherit = new Css.Keywords.Inherit(context, this);

                    if (allowInherit)
                    {
                        // Yep - inherit is our result:
                        result = inherit;
                    }
                    else
                    {
                        // Clone it instead (using special inherit copy):
                        result = inherit.SetCopy();
                    }
                }
                else
                {
                    // Apply the initial value (must copy because it's likely to be changed):
                    result = InitialValue.Copy();
                }

                // Add it:
                OnReadValue(styleBlock, result);
            }

            // Host is the same as result:
            hostValue = result;

            return(result);
        }