Ejemplo n.º 1
0
        internal CssRect SetRectValue()
        {
            var value = new CssRect();

            mUnit  = CssUnit.Rect;
            mValue = value;
            return(value);
        }
Ejemplo n.º 2
0
        /**
         * Parse a "box" property. Box properties have 1 to 4 values. When less
         * than 4 values are provided a standard mapping is used to replicate
         * existing values.
         */
        internal bool ParseBoxProperties(nsCSSProperty[] aPropIDs)
        {
            // Get up to four values for the property
              int32_t count = 0;
              var result = new nsCSSRect();
              for (Side index = nsStyle.SIDE_TOP; index <= nsStyle.SIDE_LEFT; index++) {
            if (! ParseSingleValueProperty(result.GetSide(index), v => result.SetSide(index, v),
                                           aPropIDs[(int)index])) {
              break;
            }
            count++;
              }
              if ((count == 0) || (false == ExpectEndProperty())) {
            return false;
              }

              if (1 < count) { // verify no more than single inherit or initial
            for (Side index = nsStyle.SIDE_TOP; index <= nsStyle.SIDE_LEFT; index++) {
              nsCSSUnit unit = (result.GetSide(index)).GetUnit();
              if (nsCSSUnit.Inherit == unit || nsCSSUnit.Initial == unit) {
                return false;
              }
            }
              }

              // Provide missing values by replicating some of the values found
              switch (count) {
            case 1: // Make right == top
              result.mRight = result.mTop;
              goto case 2;
            case 2: // Make bottom == top
              result.mBottom = result.mTop;
              goto case 3;
            case 3: // Make left == right
              result.mLeft = result.mRight;
            break;
              }

              for (Side index = nsStyle.SIDE_TOP; index <= nsStyle.SIDE_LEFT; index++) {
            AppendValue(aPropIDs[(int)index], result.GetSide(index));
              }
              return true;
        }
Ejemplo n.º 3
0
        internal bool ParseBoxCornerRadii(nsCSSProperty[] aPropIDs)
        {
            // Rectangles are used as scratch storage.
              // top => top-left, right => top-right,
              // bottom => bottom-right, left => bottom-left.
              nsCSSRect dimenX = new nsCSSRect(), dimenY = new nsCSSRect();
              int32_t countX = 0, countY = 0;

              for (Side side = nsStyle.SIDE_TOP; side <= nsStyle.SIDE_LEFT; side++) {
            if (! ParseNonNegativeVariant(dimenX.GetSide(side), v => dimenX.SetSide(side, v),
                                          (side > 0 ? 0 : VARIANT_INHERIT) |
                                            VARIANT_LP | VARIANT_CALC,
                                          null))
              break;
            countX++;
              }
              if (countX == 0)
            return false;

              if (ExpectSymbol('/', true)) {
            for (Side side = nsStyle.SIDE_TOP; side <= nsStyle.SIDE_LEFT; side++) {
              if (! ParseNonNegativeVariant(dimenY.GetSide(side), v => dimenY.SetSide(side, v),
                                            VARIANT_LP | VARIANT_CALC, null))
                break;
              countY++;
            }
            if (countY == 0)
              return false;
              }
              if (!ExpectEndProperty())
            return false;

              // if 'initial' or 'inherit' was used, it must be the only value
              if (countX > 1 || countY > 0) {
            nsCSSUnit unit = dimenX.mTop.GetUnit();
            if (nsCSSUnit.Inherit == unit || nsCSSUnit.Initial == unit)
              return false;
              }

              // if we have no Y-values, use the X-values
              if (countY == 0) {
            dimenY = dimenX;
            countY = countX;
              }

              // Provide missing values by replicating some of the values found
              switch (countX) {
            case 1: dimenX.mRight = dimenX.mTop;  // top-right same as top-left, and
              goto case 2;
            case 2: dimenX.mBottom = dimenX.mTop; // bottom-right same as top-left, and
              goto case 3;
            case 3: dimenX.mLeft = dimenX.mRight; // bottom-left same as top-right
            break;
              }

              switch (countY) {
            case 1: dimenY.mRight = dimenY.mTop;  // top-right same as top-left, and
              goto case 2;
            case 2: dimenY.mBottom = dimenY.mTop; // bottom-right same as top-left, and
              goto case 3;
            case 3: dimenY.mLeft = dimenY.mRight; // bottom-left same as top-right
            break;
              }

              for (Side side = nsStyle.SIDE_TOP; side <= nsStyle.SIDE_LEFT; side++) {
            nsCSSValue x = dimenX.GetSide(side);
            nsCSSValue y = dimenY.GetSide(side);

            if (x == y) {
              AppendValue(aPropIDs[(int)side], x);
            } else {
              var pair = new nsCSSValue();
              pair.SetPairValue(x, y);
              AppendValue(aPropIDs[(int)side], pair);
            }
              }
              return true;
        }