private bool SetInlineStyle(StylePropertyID id, StyleInt inlineValue, StyleInt sharedValue)
        {
            var sv = new StyleValue();

            if (TryGetInlineStyleValue(id, ref sv))
            {
                if (sv.number == inlineValue.value && sv.keyword == inlineValue.keyword)
                {
                    return(false);
                }
            }

            sv.id      = id;
            sv.keyword = inlineValue.keyword;
            sv.number  = inlineValue.value;

            SetInlineStyle(sv);

            int specificity = StyleValueExtensions.InlineSpecificity;

            if (inlineValue.keyword == StyleKeyword.Null)
            {
                specificity = sharedValue.specificity;
                sv.keyword  = sharedValue.keyword;
                sv.number   = sharedValue.value;
            }

            ApplyStyleValue(sv, specificity);
            return(true);
        }
 private static void AssignRect(RectOffset rect, StyleInt left, StyleInt top, StyleInt right, StyleInt bottom)
 {
     rect.left   = left.GetSpecifiedValueOrDefault(rect.left);
     rect.top    = top.GetSpecifiedValueOrDefault(rect.top);
     rect.right  = right.GetSpecifiedValueOrDefault(rect.right);
     rect.bottom = bottom.GetSpecifiedValueOrDefault(rect.bottom);
 }
示例#3
0
 // Convert StyleInt to StyleEnum for ComputedStyle
 internal static StyleEnum <T> ToStyleEnum <T>(this StyleInt styleInt, T value) where T : struct, IConvertible
 {
     return(new StyleEnum <T>(value, styleInt.keyword)
     {
         specificity = styleInt.specificity
     });
 }
示例#4
0
        private bool SetStyleValue(StylePropertyId id, StyleInt inlineValue, StyleInt sharedValue)
        {
            var sv = new StyleValue();

            if (TryGetStyleValue(id, ref sv))
            {
                if (sv.number == inlineValue.value && sv.keyword == inlineValue.keyword)
                {
                    return(false);
                }
            }
            else if (inlineValue.keyword == StyleKeyword.Null)
            {
                return(false);
            }

            sv.id      = id;
            sv.keyword = inlineValue.keyword;
            sv.number  = inlineValue.value;

            SetStyleValue(sv);

            if (inlineValue.keyword == StyleKeyword.Null)
            {
                sv.keyword = sharedValue.keyword;
                sv.number  = sharedValue.value;
            }

            ApplyStyleValue(sv);
            return(true);
        }
示例#5
0
        public override bool Equals(object obj)
        {
            bool flag = !(obj is StyleInt);
            bool result;

            if (flag)
            {
                result = false;
            }
            else
            {
                StyleInt lhs = (StyleInt)obj;
                result = (lhs == this);
            }
            return(result);
        }
        public StyleInt GetStyleInt(StylePropertyId id)
        {
            StyleValue styleValue = default(StyleValue);
            bool       flag       = this.TryGetStyleValue(id, ref styleValue);
            StyleInt   result;

            if (flag)
            {
                result = new StyleInt((int)styleValue.number, styleValue.keyword);
            }
            else
            {
                result = StyleKeyword.Null;
            }
            return(result);
        }
        private bool SetInlineStyle <T>(StylePropertyID id, StyleEnum <T> inlineValue, StyleInt sharedValue) where T : struct, IConvertible
        {
            var sv       = new StyleValue();
            int intValue = inlineValue.value.ToInt32(CultureInfo.InvariantCulture);

            if (TryGetInlineStyleValue(id, ref sv))
            {
                if (sv.number == intValue && sv.keyword == inlineValue.keyword)
                {
                    return(false);
                }
            }

            sv.id      = id;
            sv.keyword = inlineValue.keyword;
            sv.number  = intValue;

            SetInlineStyle(sv);

            int specificity = StyleValueExtensions.InlineSpecificity;

            if (inlineValue.keyword == StyleKeyword.Null)
            {
                specificity = sharedValue.specificity;
                sv.keyword  = sharedValue.keyword;
                sv.number   = sharedValue.value;
            }

            ApplyStyleValue(sv, specificity);
            return(true);
        }
示例#8
0
 public bool Equals(StyleInt other)
 {
     return(other == this);
 }
示例#9
0
 public StyleInt(StyleKeyword keyword)
 {
     this = new StyleInt(0, keyword);
 }
示例#10
0
 public StyleInt(int v)
 {
     this = new StyleInt(v, StyleKeyword.Undefined);
 }