internal void ApplyShorthandProperty(StylePropertyReader reader)
        {
            switch (reader.propertyID)
            {
            case StylePropertyID.BorderColor:
                ShorthandApplicator.ApplyBorderColor(reader, this);
                break;

            case StylePropertyID.BorderRadius:
                ShorthandApplicator.ApplyBorderRadius(reader, this);
                break;

            case StylePropertyID.BorderWidth:
                ShorthandApplicator.ApplyBorderWidth(reader, this);
                break;

            case StylePropertyID.Flex:
                ShorthandApplicator.ApplyFlex(reader, this);
                break;

            case StylePropertyID.Margin:
                ShorthandApplicator.ApplyMargin(reader, this);
                break;

            case StylePropertyID.Padding:
                ShorthandApplicator.ApplyPadding(reader, this);
                break;

            default:
                throw new ArgumentException(string.Format("Non exhaustive switch statement (value={0})", reader.propertyID));
            }
        }
        private static void CompileBoxAreaNoKeyword(StylePropertyReader reader, out StyleLength top, out StyleLength right, out StyleLength bottom, out StyleLength left)
        {
            ShorthandApplicator.CompileBoxArea(reader, out top, out right, out bottom, out left);
            bool flag = top.keyword > StyleKeyword.Undefined;

            if (flag)
            {
                top.value = 0f;
            }
            bool flag2 = right.keyword > StyleKeyword.Undefined;

            if (flag2)
            {
                right.value = 0f;
            }
            bool flag3 = bottom.keyword > StyleKeyword.Undefined;

            if (flag3)
            {
                bottom.value = 0f;
            }
            bool flag4 = left.keyword > StyleKeyword.Undefined;

            if (flag4)
            {
                left.value = 0f;
            }
        }
Exemple #3
0
        internal void ApplyShorthandProperty(StyleSheet sheet, StylePropertyID propertyID, StyleValueHandle[] handles, int specificity)
        {
            switch (propertyID)
            {
            case StylePropertyID.BorderColor:
                ShorthandApplicator.ApplyBorderColor(sheet, handles, specificity, this);
                break;

            case StylePropertyID.BorderRadius:
                ShorthandApplicator.ApplyBorderRadius(sheet, handles, specificity, this);
                break;

            case StylePropertyID.BorderWidth:
                ShorthandApplicator.ApplyBorderWidth(sheet, handles, specificity, this);
                break;

            case StylePropertyID.Flex:
                ShorthandApplicator.ApplyFlex(sheet, handles, specificity, this);
                break;

            case StylePropertyID.Margin:
                ShorthandApplicator.ApplyMargin(sheet, handles, specificity, this);
                break;

            case StylePropertyID.Padding:
                ShorthandApplicator.ApplyPadding(sheet, handles, specificity, this);
                break;

            default:
                throw new ArgumentException(string.Format("Non exhaustive switch statement (value={0})", propertyID));
            }
        }
        public static void ApplyFlex(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            StyleFloat  flexGrow;
            StyleFloat  flexShrink;
            StyleLength flexBasis;

            ShorthandApplicator.CompileFlexShorthand(reader, out flexGrow, out flexShrink, out flexBasis);
            computedStyle.nonInheritedData.flexGrow   = flexGrow;
            computedStyle.nonInheritedData.flexShrink = flexShrink;
            computedStyle.nonInheritedData.flexBasis  = flexBasis;
        }
        public static void ApplyPadding(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            StyleLength paddingTop;
            StyleLength paddingRight;
            StyleLength paddingBottom;
            StyleLength paddingLeft;

            ShorthandApplicator.CompileBoxAreaNoKeyword(reader, out paddingTop, out paddingRight, out paddingBottom, out paddingLeft);
            computedStyle.nonInheritedData.paddingTop    = paddingTop;
            computedStyle.nonInheritedData.paddingRight  = paddingRight;
            computedStyle.nonInheritedData.paddingBottom = paddingBottom;
            computedStyle.nonInheritedData.paddingLeft   = paddingLeft;
        }
        public static void ApplyMargin(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            StyleLength marginTop;
            StyleLength marginRight;
            StyleLength marginBottom;
            StyleLength marginLeft;

            ShorthandApplicator.CompileBoxArea(reader, out marginTop, out marginRight, out marginBottom, out marginLeft);
            computedStyle.nonInheritedData.marginTop    = marginTop;
            computedStyle.nonInheritedData.marginRight  = marginRight;
            computedStyle.nonInheritedData.marginBottom = marginBottom;
            computedStyle.nonInheritedData.marginLeft   = marginLeft;
        }
        public static void ApplyBorderColor(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            StyleColor borderTopColor;
            StyleColor borderRightColor;
            StyleColor borderBottomColor;
            StyleColor borderLeftColor;

            ShorthandApplicator.CompileBoxAreaNoKeyword(reader, out borderTopColor, out borderRightColor, out borderBottomColor, out borderLeftColor);
            computedStyle.nonInheritedData.borderTopColor    = borderTopColor;
            computedStyle.nonInheritedData.borderRightColor  = borderRightColor;
            computedStyle.nonInheritedData.borderBottomColor = borderBottomColor;
            computedStyle.nonInheritedData.borderLeftColor   = borderLeftColor;
        }
        public static void ApplyBorderWidth(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            StyleFloat borderTopWidth;
            StyleFloat borderRightWidth;
            StyleFloat borderBottomWidth;
            StyleFloat borderLeftWidth;

            ShorthandApplicator.CompileBoxAreaNoKeyword(reader, out borderTopWidth, out borderRightWidth, out borderBottomWidth, out borderLeftWidth);
            computedStyle.nonInheritedData.borderTopWidth    = borderTopWidth;
            computedStyle.nonInheritedData.borderRightWidth  = borderRightWidth;
            computedStyle.nonInheritedData.borderBottomWidth = borderBottomWidth;
            computedStyle.nonInheritedData.borderLeftWidth   = borderLeftWidth;
        }
        private static void CompileBoxAreaNoKeyword(StylePropertyReader reader, out StyleFloat top, out StyleFloat right, out StyleFloat bottom, out StyleFloat left)
        {
            StyleLength styleLength;
            StyleLength styleLength2;
            StyleLength styleLength3;
            StyleLength styleLength4;

            ShorthandApplicator.CompileBoxAreaNoKeyword(reader, out styleLength, out styleLength2, out styleLength3, out styleLength4);
            top    = styleLength.ToStyleFloat();
            right  = styleLength2.ToStyleFloat();
            bottom = styleLength3.ToStyleFloat();
            left   = styleLength4.ToStyleFloat();
        }
        public static void ApplyBorderRadius(StylePropertyReader reader, ComputedStyle computedStyle)
        {
            StyleLength borderTopLeftRadius;
            StyleLength borderTopRightRadius;
            StyleLength borderBottomRightRadius;
            StyleLength borderBottomLeftRadius;

            ShorthandApplicator.CompileBoxAreaNoKeyword(reader, out borderTopLeftRadius, out borderTopRightRadius, out borderBottomRightRadius, out borderBottomLeftRadius);
            computedStyle.nonInheritedData.borderTopLeftRadius     = borderTopLeftRadius;
            computedStyle.nonInheritedData.borderTopRightRadius    = borderTopRightRadius;
            computedStyle.nonInheritedData.borderBottomRightRadius = borderBottomRightRadius;
            computedStyle.nonInheritedData.borderBottomLeftRadius  = borderBottomLeftRadius;
        }