コード例 #1
0
ファイル: CssValue.cs プロジェクト: rexwhitten/CsCss
        internal CssValue[] InitFunction(CssKeyword aFunctionId, int aNumArgs)
        {
            var value = new CssValue[aNumArgs + 1];

            value[0].SetIntValue((int)aFunctionId, CssUnit.Enumerated);
            SetArrayValue(value, CssUnit.Function);
            return(value);
        }
コード例 #2
0
ファイル: nsCSSProps.cs プロジェクト: rexwhitten/CsCss
 public static bool FindKeyword(CssKeyword aKeyword, int[] aTable, ref int aResult)
 {
     int32_t index = FindIndexOfKeyword(aKeyword, aTable);
     if (index >= 0) {
         aResult = aTable[index + 1];
         return true;
     }
     return false;
 }
コード例 #3
0
        public static bool FindKeyword(CssKeyword aKeyword, int[] aTable, ref int aResult)
        {
            int32_t index = FindIndexOfKeyword(aKeyword, aTable);

            if (index >= 0)
            {
                aResult = aTable[index + 1];
                return(true);
            }
            return(false);
        }
コード例 #4
0
        private static int FindIndexOfKeyword(CssKeyword aKeyword, int[] aTable)
        {
            int32_t index = 0;

            while ((CssKeyword)(aTable[index]) != CssKeyword.Unknown)
            {
                if ((CssKeyword)(aTable[index]) == aKeyword)
                {
                    return(index);
                }
                index += 2;
            }
            return(-1);
        }
コード例 #5
0
 public static string GetStringValue(CssKeyword aKeyword)
 {
     return(kCSSRawKeywords[(int)aKeyword]);
 }
コード例 #6
0
ファイル: nsCSSKeywords.cs プロジェクト: rexwhitten/CsCss
 public static string GetStringValue(CssKeyword aKeyword)
 {
     return kCSSRawKeywords[(int)aKeyword];
 }
コード例 #7
0
ファイル: CssParser.conv.cs プロジェクト: rexwhitten/CsCss
        /**
         * Given a token, determines the minimum and maximum number of function
         * parameters to read, along with the mask that should be used to read
         * those function parameters.  If the token isn't a transform function,
         * returns an error.
         *
         * @param aToken The token identifying the function.
         * @param aMinElems [out] The minimum number of elements to read.
         * @param aMaxElems [out] The maximum number of elements to read
         * @param aVariantMask [out] The variant mask to use during parsing
         * @return Whether the information was loaded successfully.
         */
        static bool GetFunctionParseInformation(nsCSSKeyword aToken,
                                                bool aIsPrefixed,
                                                ref uint16_t aMinElems,
                                                ref uint16_t aMaxElems,
                                                ref int32_t[] aVariantMask,
                                                ref bool aIs3D)
        {
            /* These types represent the common variant masks that will be used to
               * parse out the individual functions.  The order in the enumeration
               * must match the order in which the masks are declared.
               */
              const int eLengthPercentCalc = 0;
              const int eLengthCalc = 1;
              const int eTwoLengthPercentCalcs = 2;
              const int eTwoLengthPercentCalcsOneLengthCalc = 3;
              const int eAngle = 4;
              const int eTwoAngles = 5;
              const int eNumber = 6;
              const int ePositiveLength = 7;
              const int eTwoNumbers = 8;
              const int eThreeNumbers = 9;
              const int eThreeNumbersOneAngle = 10;
              const int eMatrix = 11;
              const int eMatrixPrefixed = 12;
              const int eMatrix3d = 13;
              const int eMatrix3dPrefixed = 14;
              const int eNumVariantMasks = 15;

              const int32_t kMaxElemsPerFunction = 16;
              /*TODO: static*/ int32_t[][] kVariantMasks = {
            new[] {VARIANT_LPCALC},
            new[] {VARIANT_LENGTH|VARIANT_CALC},
            new[] {VARIANT_LPCALC, VARIANT_LPCALC},
            new[] {VARIANT_LPCALC, VARIANT_LPCALC, VARIANT_LENGTH|VARIANT_CALC},
            new[] {VARIANT_ANGLE_OR_ZERO},
            new[] {VARIANT_ANGLE_OR_ZERO, VARIANT_ANGLE_OR_ZERO},
            new[] {VARIANT_NUMBER},
            new[] {VARIANT_LENGTH|VARIANT_POSITIVE_DIMENSION},
            new[] {VARIANT_NUMBER, VARIANT_NUMBER},
            new[] {VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER},
            new[] {VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_ANGLE_OR_ZERO},
            new[] {VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
             VARIANT_NUMBER, VARIANT_NUMBER},
            new[] {VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
             VARIANT_LPNCALC, VARIANT_LPNCALC},
            new[] {VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
             VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
             VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
             VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER},
            new[] {VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
             VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
             VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER, VARIANT_NUMBER,
             VARIANT_LPNCALC, VARIANT_LPNCALC, VARIANT_LNCALC, VARIANT_NUMBER}};

            #if DEBUG
              /*TODO: static*/ uint8_t[] kVariantMaskLengths =
            {1, 1, 2, 3, 1, 2, 1, 1, 2, 3, 4, 6, 6, 16, 16};
            #endif

              int32_t variantIndex = eNumVariantMasks;

              aIs3D = false;

              switch (aToken) {
              case nsCSSKeyword.Translatex:
              case nsCSSKeyword.Translatey:
            /* Exactly one length or percent. */
            variantIndex = eLengthPercentCalc;
            aMinElems = 1;
            aMaxElems = 1;
            break;
              case nsCSSKeyword.Translatez:
            /* Exactly one length */
            variantIndex = eLengthCalc;
            aMinElems = 1;
            aMaxElems = 1;
            aIs3D = true;
            break;
              case nsCSSKeyword.Translate3d:
            /* Exactly two lengthds or percents and a number */
            variantIndex = eTwoLengthPercentCalcsOneLengthCalc;
            aMinElems = 3;
            aMaxElems = 3;
            aIs3D = true;
            break;
              case nsCSSKeyword.Scalez:
            aIs3D = true;
            goto case nsCSSKeyword.Scalex;
              case nsCSSKeyword.Scalex:
              case nsCSSKeyword.Scaley:
            /* Exactly one scale factor. */
            variantIndex = eNumber;
            aMinElems = 1;
            aMaxElems = 1;
            break;
              case nsCSSKeyword.Scale3d:
            /* Exactly three scale factors. */
            variantIndex = eThreeNumbers;
            aMinElems = 3;
            aMaxElems = 3;
            aIs3D = true;
            break;
              case nsCSSKeyword.Rotatex:
              case nsCSSKeyword.Rotatey:
            aIs3D = true;
            goto case nsCSSKeyword.Rotate;
              case nsCSSKeyword.Rotate:
              case nsCSSKeyword.Rotatez:
            /* Exactly one angle. */
            variantIndex = eAngle;
            aMinElems = 1;
            aMaxElems = 1;
            break;
              case nsCSSKeyword.Rotate3d:
            variantIndex = eThreeNumbersOneAngle;
            aMinElems = 4;
            aMaxElems = 4;
            aIs3D = true;
            break;
              case nsCSSKeyword.Translate:
            /* One or two lengths or percents. */
            variantIndex = eTwoLengthPercentCalcs;
            aMinElems = 1;
            aMaxElems = 2;
            break;
              case nsCSSKeyword.Skew:
            /* Exactly one or two angles. */
            variantIndex = eTwoAngles;
            aMinElems = 1;
            aMaxElems = 2;
            break;
              case nsCSSKeyword.Scale:
            /* One or two scale factors. */
            variantIndex = eTwoNumbers;
            aMinElems = 1;
            aMaxElems = 2;
            break;
              case nsCSSKeyword.Skewx:
            /* Exactly one angle. */
            variantIndex = eAngle;
            aMinElems = 1;
            aMaxElems = 1;
            break;
              case nsCSSKeyword.Skewy:
            /* Exactly one angle. */
            variantIndex = eAngle;
            aMinElems = 1;
            aMaxElems = 1;
            break;
              case nsCSSKeyword.Matrix:
            /* Six values, all numbers. */
            variantIndex = aIsPrefixed ? eMatrixPrefixed : eMatrix;
            aMinElems = 6;
            aMaxElems = 6;
            break;
              case nsCSSKeyword.Matrix3d:
            /* 16 matrix values, all numbers */
            variantIndex = aIsPrefixed ? eMatrix3dPrefixed : eMatrix3d;
            aMinElems = 6;
            aMaxElems = 6;
            aIs3D = true;
            break;
              case nsCSSKeyword.Perspective:
            /* Exactly one scale number. */
            variantIndex = ePositiveLength;
            aMinElems = 1;
            aMaxElems = 1;
            aIs3D = true;
            break;
              default:
            /* Oh dear, we didn't match.  Report an error. */
            return false;
              }

              Debug.Assert(aMinElems > 0, "Didn't update minimum elements!");
              Debug.Assert(aMaxElems > 0, "Didn't update maximum elements!");
              Debug.Assert(aMinElems <= aMaxElems, "aMinElems > aMaxElems!");
              Debug.Assert(variantIndex >= 0, "Invalid variant mask!");
              Debug.Assert(variantIndex < eNumVariantMasks, "Invalid variant mask!");
            #if DEBUG
              Debug.Assert(aMaxElems <= kVariantMaskLengths[variantIndex],
                       "Invalid aMaxElems for this variant mask.");
            #endif

              // Convert the index into a mask.
              aVariantMask = kVariantMasks[variantIndex];

              return true;
        }
コード例 #8
0
ファイル: nsCSSProps.cs プロジェクト: rexwhitten/CsCss
 private static int FindIndexOfKeyword(CssKeyword aKeyword, int[] aTable)
 {
     int32_t index = 0;
     while ((CssKeyword)(aTable[index]) != CssKeyword.Unknown) {
         if ((CssKeyword)(aTable[index]) == aKeyword)
             return index;
         index += 2;
     }
     return -1;
 }