Esempio n. 1
0
        /**
         * Parse the arguments of -moz-image-rect() function.
         * -moz-image-rect(<uri>, <top>, <right>, <bottom>, <left>)
         */
        internal bool ParseImageRect(ref nsCSSValue aImage)
        {
            // A non-iterative for loop to break out when an error occurs.
              for (;;) {
            var newFunction = new nsCSSValue();
            const uint32_t kNumArgs = 5;
            nsCSSValue[] func =
              newFunction.InitFunction(nsCSSKeyword._moz_image_rect, kNumArgs);

            // func[0] is reserved for the function name.
            nsCSSValue url    = func[1];
            nsCSSValue top    = func[2];
            nsCSSValue right  = func[3];
            nsCSSValue bottom = func[4];
            nsCSSValue left   = func[5];

            string urlString = "";
            if (!ParseURLOrString(ref urlString) ||
                !SetValueToURL(ref url, urlString) ||
                !ExpectSymbol(',', true)) {
              break;
            }

            const int32_t VARIANT_SIDE = VARIANT_NUMBER | VARIANT_PERCENT;
            if (!ParseNonNegativeVariant(ref top, VARIANT_SIDE, null) ||
                !ExpectSymbol(',', true) ||
                !ParseNonNegativeVariant(ref right, VARIANT_SIDE, null) ||
                !ExpectSymbol(',', true) ||
                !ParseNonNegativeVariant(ref bottom, VARIANT_SIDE, null) ||
                !ExpectSymbol(',', true) ||
                !ParseNonNegativeVariant(ref left, VARIANT_SIDE, null) ||
                !ExpectSymbol(')', true))
              break;

            aImage = newFunction;
            return true;
              }

              SkipUntil(')');
              return false;
        }