Esempio n. 1
0
        // Assigns to aValue iff it returns true.
        internal bool ParseVariant(ref nsCSSValue aValue,
                                    int32_t aVariantMask,
                                    int32_t[] aKeywordTable)
        {
            Debug.Assert(!(mHashlessColorQuirk && ((aVariantMask & VARIANT_COLOR) != 0)) ||
                       !((aVariantMask & VARIANT_NUMBER) != 0),
                       "can't distinguish colors from numbers");
              Debug.Assert(!(mHashlessColorQuirk && ((aVariantMask & VARIANT_COLOR) != 0)) ||
                       !(mUnitlessLengthQuirk && ((aVariantMask & VARIANT_LENGTH) != 0)),
                       "can't distinguish colors from lengths");
              Debug.Assert(!(mUnitlessLengthQuirk && ((aVariantMask & VARIANT_LENGTH) != 0)) ||
                       !((aVariantMask & VARIANT_NUMBER) != 0),
                       "can't distinguish lengths from numbers");
              Debug.Assert(!((aVariantMask & VARIANT_IDENTIFIER) != 0) ||
                            !((aVariantMask & VARIANT_IDENTIFIER_NO_INHERIT) != 0),
                            "must not set both VARIANT_IDENTIFIER and VARIANT_IDENTIFIER_NO_INHERIT");

              if (!GetToken(true)) {
            return false;
              }
              nsCSSToken tk = mToken;
              if (((aVariantMask & (VARIANT_AHK | VARIANT_NORMAL | VARIANT_NONE | VARIANT_ALL)) != 0) &&
              (nsCSSTokenType.Ident == tk.mType)) {
            nsCSSKeyword keyword = nsCSSKeywords.LookupKeyword(tk.mIdentStr);
            if (nsCSSKeyword.UNKNOWN < keyword) { // known keyword
              if ((aVariantMask & VARIANT_AUTO) != 0) {
                if (nsCSSKeyword.auto == keyword) {
                  aValue.SetAutoValue();
                  return true;
                }
              }
              if ((aVariantMask & VARIANT_INHERIT) != 0) {
                // XXX Should we check IsParsingCompoundProperty, or do all
                // callers handle it?  (Not all callers set it, though, since
                // they want the quirks that are disabled by setting it.)
                if (nsCSSKeyword.inherit == keyword) {
                  aValue.SetInheritValue();
                  return true;
                }
                else if (nsCSSKeyword._moz_initial == keyword ||
                         nsCSSKeyword.initial == keyword) { // anything that can inherit can also take an initial val.
                  aValue.SetInitialValue();
                  return true;
                }
              }
              if ((aVariantMask & VARIANT_NONE) != 0) {
                if (nsCSSKeyword.none == keyword) {
                  aValue.SetNoneValue();
                  return true;
                }
              }
              if ((aVariantMask & VARIANT_ALL) != 0) {
                if (nsCSSKeyword.all == keyword) {
                  aValue.SetAllValue();
                  return true;
                }
              }
              if ((aVariantMask & VARIANT_NORMAL) != 0) {
                if (nsCSSKeyword.normal == keyword) {
                  aValue.SetNormalValue();
                  return true;
                }
              }
              if ((aVariantMask & VARIANT_SYSFONT) != 0) {
                if (nsCSSKeyword._moz_use_system_font == keyword &&
                    !IsParsingCompoundProperty()) {
                  aValue.SetSystemFontValue();
                  return true;
                }
              }
              if ((aVariantMask & VARIANT_KEYWORD) != 0) {
                int32_t value = 0;
                if (nsCSSProps.FindKeyword(keyword, aKeywordTable, ref value)) {
                  aValue.SetIntValue(value, nsCSSUnit.Enumerated);
                  return true;
                }
              }
            }
              }
              // Check VARIANT_NUMBER and VARIANT_INTEGER before VARIANT_LENGTH or
              // VARIANT_ZERO_ANGLE.
              if (((aVariantMask & VARIANT_NUMBER) != 0) &&
              (nsCSSTokenType.Number == tk.mType)) {
            aValue.SetFloatValue(tk.mNumber, nsCSSUnit.Number);
            return true;
              }
              if (((aVariantMask & VARIANT_INTEGER) != 0) &&
              (nsCSSTokenType.Number == tk.mType) && tk.mIntegerValid) {
            aValue.SetIntValue(tk.mInteger, nsCSSUnit.Integer);
            return true;
              }
              if (((aVariantMask & (VARIANT_LENGTH | VARIANT_ANGLE |
                                VARIANT_FREQUENCY | VARIANT_TIME)) != 0 &&
               nsCSSTokenType.Dimension == tk.mType) ||
              ((aVariantMask & (VARIANT_LENGTH | VARIANT_ZERO_ANGLE)) != 0 &&
               nsCSSTokenType.Number == tk.mType &&
               tk.mNumber == 0.0f)) {
            if (((aVariantMask & VARIANT_POSITIVE_DIMENSION) != 0 &&
                 tk.mNumber <= 0.0) ||
                ((aVariantMask & VARIANT_NONNEGATIVE_DIMENSION) != 0 &&
                 tk.mNumber < 0.0)) {
                UngetToken();
                return false;
            }
            if (TranslateDimension(ref aValue, aVariantMask, tk.mNumber, tk.mIdentStr)) {
              return true;
            }
            // Put the token back; we didn't parse it, so we shouldn't consume it
            UngetToken();
            return false;
              }
              if (((aVariantMask & VARIANT_PERCENT) != 0) &&
              (nsCSSTokenType.Percentage == tk.mType)) {
            aValue.SetPercentValue(tk.mNumber);
            return true;
              }
              if (mUnitlessLengthQuirk) { // NONSTANDARD: Nav interprets unitless numbers as px
            if (((aVariantMask & VARIANT_LENGTH) != 0) &&
                (nsCSSTokenType.Number == tk.mType)) {
              aValue.SetFloatValue(tk.mNumber, nsCSSUnit.Pixel);
              return true;
            }
              }

              if (IsSVGMode() && !IsParsingCompoundProperty()) {
            // STANDARD: SVG Spec states that lengths and coordinates can be unitless
            // in which case they default to user-units (1 px = 1 user unit)
            if (((aVariantMask & VARIANT_LENGTH) != 0) &&
                (nsCSSTokenType.Number == tk.mType)) {
              aValue.SetFloatValue(tk.mNumber, nsCSSUnit.Pixel);
              return true;
            }
              }

              if (((aVariantMask & VARIANT_URL) != 0) &&
              nsCSSTokenType.URL == tk.mType) {
            SetValueToURL(ref aValue, tk.mIdentStr);
            return true;
              }
              if ((aVariantMask & VARIANT_GRADIENT) != 0 &&
              nsCSSTokenType.Function == tk.mType) {
            // a generated gradient
            string tmp = tk.mIdentStr;
            bool isLegacy = false;
            if (StringBeginsWith(tmp, "-moz-")) {
              tmp = tmp.Substring(5);
              isLegacy = true;
            }
            bool isRepeating = false;
            if (StringBeginsWith(tmp, "repeating-")) {
              tmp = tmp.Substring(10);
              isRepeating = true;
            }

            if (tmp.LowerCaseEqualsLiteral("linear-gradient")) {
              return ParseLinearGradient(ref aValue, isRepeating, isLegacy);
            }
            if (tmp.LowerCaseEqualsLiteral("radial-gradient")) {
              return ParseRadialGradient(ref aValue, isRepeating, isLegacy);
            }
              }
              if ((aVariantMask & VARIANT_IMAGE_RECT) != 0 &&
              nsCSSTokenType.Function == tk.mType &&
              tk.mIdentStr.LowerCaseEqualsLiteral("-moz-image-rect")) {
            return ParseImageRect(ref aValue);
              }
              if ((aVariantMask & VARIANT_ELEMENT) != 0 &&
              nsCSSTokenType.Function == tk.mType &&
              tk.mIdentStr.LowerCaseEqualsLiteral("-moz-element")) {
            return ParseElement(ref aValue);
              }
              if ((aVariantMask & VARIANT_COLOR) != 0) {
            if (mHashlessColorQuirk || // NONSTANDARD: Nav interprets 'xxyyzz' values even without '#' prefix
                (nsCSSTokenType.ID == tk.mType) ||
                (nsCSSTokenType.Hash == tk.mType) ||
                (nsCSSTokenType.Ident == tk.mType) ||
                ((nsCSSTokenType.Function == tk.mType) &&
                 (tk.mIdentStr.LowerCaseEqualsLiteral("rgb") ||
                  tk.mIdentStr.LowerCaseEqualsLiteral("hsl") ||
                  tk.mIdentStr.LowerCaseEqualsLiteral("-moz-rgba") ||
                  tk.mIdentStr.LowerCaseEqualsLiteral("-moz-hsla") ||
                  tk.mIdentStr.LowerCaseEqualsLiteral("rgba") ||
                  tk.mIdentStr.LowerCaseEqualsLiteral("hsla"))))
            {
              // Put token back so that parse color can get it
              UngetToken();
              if (ParseColor(ref aValue)) {
                return true;
              }
              return false;
            }
              }
              if (((aVariantMask & VARIANT_STRING) != 0) &&
              (nsCSSTokenType.String == tk.mType)) {
            string  buffer;
            buffer = tk.mIdentStr;
            aValue.SetStringValue(buffer, nsCSSUnit.String);
            return true;
              }
              if (((aVariantMask &
                (VARIANT_IDENTIFIER | VARIANT_IDENTIFIER_NO_INHERIT)) != 0) &&
              (nsCSSTokenType.Ident == tk.mType) &&
              ((aVariantMask & VARIANT_IDENTIFIER) != 0 ||
               !(tk.mIdentStr.LowerCaseEqualsLiteral("inherit") ||
                 tk.mIdentStr.LowerCaseEqualsLiteral("initial")))) {
            aValue.SetStringValue(tk.mIdentStr, nsCSSUnit.Ident);
            return true;
              }
              if (((aVariantMask & VARIANT_COUNTER) != 0) &&
              (nsCSSTokenType.Function == tk.mType) &&
              (tk.mIdentStr.LowerCaseEqualsLiteral("counter") ||
               tk.mIdentStr.LowerCaseEqualsLiteral("counters"))) {
            return ParseCounter(ref aValue);
              }
              if (((aVariantMask & VARIANT_ATTR) != 0) &&
              (nsCSSTokenType.Function == tk.mType) &&
              tk.mIdentStr.LowerCaseEqualsLiteral("attr")) {
            if (!ParseAttr(ref aValue)) {
              SkipUntil(')');
              return false;
            }
            return true;
              }
              if (((aVariantMask & VARIANT_TIMING_FUNCTION) != 0) &&
              (nsCSSTokenType.Function == tk.mType)) {
            if (tk.mIdentStr.LowerCaseEqualsLiteral("cubic-bezier")) {
              if (!ParseTransitionTimingFunctionValues(ref aValue)) {
                SkipUntil(')');
                return false;
              }
              return true;
            }
            if (tk.mIdentStr.LowerCaseEqualsLiteral("steps")) {
              if (!ParseTransitionStepTimingFunctionValues(ref aValue)) {
                SkipUntil(')');
                return false;
              }
              return true;
            }
              }
              if (((aVariantMask & VARIANT_CALC) != 0) &&
              (nsCSSTokenType.Function == tk.mType) &&
              (tk.mIdentStr.LowerCaseEqualsLiteral("calc") ||
               tk.mIdentStr.LowerCaseEqualsLiteral("-moz-calc"))) {
            // calc() currently allows only lengths and percents inside it.
            return ParseCalc(ref aValue, aVariantMask & VARIANT_LP);
              }

              UngetToken();
              return false;
        }
Esempio n. 2
0
        internal bool ParseTextDecoration()
        {
            const int eDecorationNone         = nsStyle.TEXT_DECORATION_LINE_NONE;
              const int eDecorationUnderline    = nsStyle.TEXT_DECORATION_LINE_UNDERLINE;
              const int eDecorationOverline     = nsStyle.TEXT_DECORATION_LINE_OVERLINE;
              const int eDecorationLineThrough  = nsStyle.TEXT_DECORATION_LINE_LINE_THROUGH;
              const int eDecorationBlink        = nsStyle.TEXT_DECORATION_LINE_BLINK;
              const int eDecorationPrefAnchors  = nsStyle.TEXT_DECORATION_LINE_PREF_ANCHORS;

              /*TODO: static*/ int32_t[] kTextDecorationKTable = {
            (int32_t)nsCSSKeyword.none,                   eDecorationNone,
            (int32_t)nsCSSKeyword.underline,              eDecorationUnderline,
            (int32_t)nsCSSKeyword.overline,               eDecorationOverline,
            (int32_t)nsCSSKeyword.line_through,           eDecorationLineThrough,
            (int32_t)nsCSSKeyword.blink,                  eDecorationBlink,
            (int32_t)nsCSSKeyword._moz_anchor_decoration, eDecorationPrefAnchors,
            (int32_t)nsCSSKeyword.UNKNOWN,-1
              };

              var value = new nsCSSValue();
              if (!ParseVariant(ref value, VARIANT_HK, kTextDecorationKTable)) {
            return false;
              }

              nsCSSValue blink = new nsCSSValue(), line = new nsCSSValue(), style = new nsCSSValue(), color = new nsCSSValue();
              switch (value.GetUnit()) {
            case nsCSSUnit.Enumerated: {
              // We shouldn't accept decoration line style and color via
              // text-decoration.
              color.SetIntValue(nsStyle.COLOR_MOZ_USE_TEXT_COLOR,
                                nsCSSUnit.Enumerated);
              style.SetIntValue(nsStyle.TEXT_DECORATION_STYLE_SOLID,
                                nsCSSUnit.Enumerated);

              int32_t intValue = value.GetIntValue();
              if (intValue == eDecorationNone) {
                blink.SetIntValue(nsStyle.TEXT_BLINK_NONE, nsCSSUnit.Enumerated);
                line.SetIntValue(nsStyle.TEXT_DECORATION_LINE_NONE,
                                 nsCSSUnit.Enumerated);
                break;
              }

              // look for more keywords
              var keyword = new nsCSSValue();
              int32_t index = 0;
              for (index = 0; index < 3; index++) {
                if (!ParseEnum(ref keyword, kTextDecorationKTable)) {
                  break;
                }
                int32_t newValue = keyword.GetIntValue();
                if (newValue == eDecorationNone || ((newValue & intValue) != 0)) {
                  // 'none' keyword in conjuction with others is not allowed, and
                  // duplicate keyword is not allowed.
                  return false;
                }
                intValue |= newValue;
              }

              blink.SetIntValue((intValue & eDecorationBlink) != 0 ?
                                  nsStyle.TEXT_BLINK_BLINK : nsStyle.TEXT_BLINK_NONE,
                                nsCSSUnit.Enumerated);
              line.SetIntValue((intValue & ~eDecorationBlink), nsCSSUnit.Enumerated);
              break;
            }
              goto default;
            default:
              blink = line = color = style = value;
              break;
              }

              AppendValue(nsCSSProperty.TextBlink, blink);
              AppendValue(nsCSSProperty.TextDecorationLine, line);
              AppendValue(nsCSSProperty.TextDecorationColor, color);
              AppendValue(nsCSSProperty.TextDecorationStyle, style);

              return true;
        }
Esempio n. 3
0
 internal bool ParseTextDecorationLine(ref nsCSSValue aValue)
 {
     if (ParseVariant(ref aValue, VARIANT_HK, nsCSSProps.kTextDecorationLineKTable)) {
     if (nsCSSUnit.Enumerated == aValue.GetUnit()) {
       int32_t intValue = aValue.GetIntValue();
       if (intValue != nsStyle.TEXT_DECORATION_LINE_NONE) {
         // look for more keywords
         var keyword = new nsCSSValue();
         int32_t index = 0;
         for (index = 0; index < 2; index++) {
           if (ParseEnum(ref keyword, nsCSSProps.kTextDecorationLineKTable)) {
             int32_t newValue = keyword.GetIntValue();
             if (newValue == nsStyle.TEXT_DECORATION_LINE_NONE ||
                 ((newValue & intValue) != 0)) {
               // 'none' keyword in conjuction with others is not allowed, and
               // duplicate keyword is not allowed.
               return false;
             }
             intValue |= newValue;
           }
           else {
             break;
           }
         }
         aValue.SetIntValue(intValue, nsCSSUnit.Enumerated);
       }
     }
     return true;
       }
       return false;
 }
Esempio n. 4
0
        internal bool ParseOverflow()
        {
            var overflow = new nsCSSValue();
              if (!ParseVariant(ref overflow, VARIANT_HK,
                            nsCSSProps.kOverflowKTable) ||
              !ExpectEndProperty())
            return false;

              var overflowX = new nsCSSValue(overflow);
              var overflowY = new nsCSSValue(overflow);
              if (nsCSSUnit.Enumerated == overflow.GetUnit())
            switch(overflow.GetIntValue()) {
              case nsStyle.OVERFLOW_SCROLLBARS_HORIZONTAL:
                overflowX.SetIntValue(nsStyle.OVERFLOW_SCROLL, nsCSSUnit.Enumerated);
                overflowY.SetIntValue(nsStyle.OVERFLOW_HIDDEN, nsCSSUnit.Enumerated);
                break;
              case nsStyle.OVERFLOW_SCROLLBARS_VERTICAL:
                overflowX.SetIntValue(nsStyle.OVERFLOW_HIDDEN, nsCSSUnit.Enumerated);
                overflowY.SetIntValue(nsStyle.OVERFLOW_SCROLL, nsCSSUnit.Enumerated);
                break;
            }
              AppendValue(nsCSSProperty.OverflowX, overflowX);
              AppendValue(nsCSSProperty.OverflowY, overflowY);
              return true;
        }
Esempio n. 5
0
        internal bool ParsePaintOrder()
        {
            /*TODO: static*/ int32_t[] kPaintOrderKTable = {
            (int32_t)nsCSSKeyword.normal,  nsStyle.PAINT_ORDER_NORMAL,
            (int32_t)nsCSSKeyword.fill,    nsStyle.PAINT_ORDER_FILL,
            (int32_t)nsCSSKeyword.stroke,  nsStyle.PAINT_ORDER_STROKE,
            (int32_t)nsCSSKeyword.markers, nsStyle.PAINT_ORDER_MARKERS,
            (int32_t)nsCSSKeyword.UNKNOWN,-1
              };

              var value = new nsCSSValue();
              if (!ParseVariant(ref value, VARIANT_HK, kPaintOrderKTable)) {
            return false;
              }

              uint32_t seen = 0;
              uint32_t order = 0;
              uint32_t position = 0;

              // Ensure that even cast to a signed int32_t when stored in CSSValue,
              // we have enough space for the entire paint-order value.

              if (value.GetUnit() == nsCSSUnit.Enumerated) {
            uint32_t component = ((uint32_t)(value.GetIntValue()));
            if (component != nsStyle.PAINT_ORDER_NORMAL) {
              bool parsedOK = true;
              for (;;) {
                if (((seen & (1 << component)) != 0)) {
                  // Already seen this component.
                  UngetToken();
                  parsedOK = false;
                  break;
                }
                seen |= (1 << component);
                order |= (component << position);
                position += nsStyle.PAINT_ORDER_BITWIDTH;
                if (!ParseEnum(ref value, kPaintOrderKTable)) {
                  break;
                }
                component = value.GetIntValue();
                if (component == nsStyle.PAINT_ORDER_NORMAL) {
                  // Can't have "normal" in the middle of the list of paint components.
                  UngetToken();
                  parsedOK = false;
                  break;
                }
              }

              // Fill in the remaining paint-order components in the order of their
              // constant values.
              if (parsedOK) {
                for (component = 1;
                     component <= nsStyle.PAINT_ORDER_LAST_VALUE;
                     component++) {
                  if (!(((seen & (1 << component)) != 0))) {
                    order |= (component << position);
                    position += nsStyle.PAINT_ORDER_BITWIDTH;
                  }
                }
              }
            }
            value.SetIntValue(((int32_t)(order)), nsCSSUnit.Enumerated);
              }

              if (!ExpectEndProperty()) {
            return false;
              }

              AppendValue(nsCSSProperty.PaintOrder, value);
              return true;
        }
Esempio n. 6
0
 internal bool ParseMarks(ref nsCSSValue aValue)
 {
     if (ParseVariant(ref aValue, VARIANT_HK, nsCSSProps.kPageMarksKTable)) {
     if (nsCSSUnit.Enumerated == aValue.GetUnit()) {
       if (nsStyle.PAGE_MARKS_NONE != aValue.GetIntValue() &&
           false == CheckEndProperty()) {
         var second = new nsCSSValue();
         if (ParseEnum(ref second, nsCSSProps.kPageMarksKTable)) {
           // 'none' keyword in conjuction with others is not allowed
           if (nsStyle.PAGE_MARKS_NONE != second.GetIntValue()) {
             aValue.SetIntValue(aValue.GetIntValue() | second.GetIntValue(),
                                nsCSSUnit.Enumerated);
             return true;
           }
         }
         return false;
       }
     }
     return true;
       }
       return false;
 }
Esempio n. 7
0
        internal bool ParseEnum(ref nsCSSValue aValue,
                                 int32_t[] aKeywordTable)
        {
            string ident = NextIdent();
              if (null == ident) {
            return false;
              }
              nsCSSKeyword keyword = nsCSSKeywords.LookupKeyword(ident);
              if (nsCSSKeyword.UNKNOWN < keyword) {
            int32_t value = 0;
            if (nsCSSProps.FindKeyword(keyword, aKeywordTable, ref value)) {
              aValue.SetIntValue(value, nsCSSUnit.Enumerated);
              return true;
            }
              }

              // Put the unknown identifier back and return
              UngetToken();
              return false;
        }
Esempio n. 8
0
        // The types to pass to ParseColorComponent.  These correspond to the
        // various datatypes that can go within rgb().
        internal bool ParseColor(ref nsCSSValue aValue)
        {
            if (!GetToken(true)) {
            { if (!mSuppressErrors) mReporter.ReportUnexpected("PEColorEOF"); };
            return false;
              }

              nsCSSToken tk = mToken;
              var rgba = new nscolor();
              switch (tk.mType) {
            case nsCSSTokenType.ID:
            case nsCSSTokenType.Hash:
              // #xxyyzz
              if (nscolor.HexToRGB(tk.mIdentStr, ref rgba)) {
                aValue.SetColorValue(rgba);
                return true;
              }
              break;

            case nsCSSTokenType.Ident:
              if (nscolor.ColorNameToRGB(tk.mIdentStr, ref rgba)) {
                aValue.SetStringValue(tk.mIdentStr, nsCSSUnit.Ident);
                return true;
              }
              else {
                nsCSSKeyword keyword = nsCSSKeywords.LookupKeyword(tk.mIdentStr);
                if (nsCSSKeyword.UNKNOWN < keyword) { // known keyword
                  int32_t value = 0;
                  if (nsCSSProps.FindKeyword(keyword, nsCSSProps.kColorKTable, ref value)) {
                    aValue.SetIntValue(value, nsCSSUnit.EnumColor);
                    return true;
                  }
                }
              }
              break;
            case nsCSSTokenType.Function:
              if (mToken.mIdentStr.LowerCaseEqualsLiteral("rgb")) {
                // rgb ( component , component , component )
                uint8_t r = 0, g = 0, b = 0;
                int32_t type = COLOR_TYPE_UNKNOWN;
                if (ParseColorComponent(ref r, ref type, ',') &&
                    ParseColorComponent(ref g, ref type, ',') &&
                    ParseColorComponent(ref b, ref type, ')')) {
                  aValue.SetColorValue(nscolor.RGB(r,g,b));
                  return true;
                }
                SkipUntil(')');
                return false;
              }
              else if (mToken.mIdentStr.LowerCaseEqualsLiteral("-moz-rgba") ||
                       mToken.mIdentStr.LowerCaseEqualsLiteral("rgba")) {
                // rgba ( component , component , component , opacity )
                uint8_t r = 0, g = 0, b = 0, a = 0;
                int32_t type = COLOR_TYPE_UNKNOWN;
                if (ParseColorComponent(ref r, ref type, ',') &&
                    ParseColorComponent(ref g, ref type, ',') &&
                    ParseColorComponent(ref b, ref type, ',') &&
                    ParseColorOpacity(ref a)) {
                  aValue.SetColorValue(nscolor.RGBA(r, g, b, a));
                  return true;
                }
                SkipUntil(')');
                return false;
              }
              else if (mToken.mIdentStr.LowerCaseEqualsLiteral("hsl")) {
                // hsl ( hue , saturation , lightness )
                // "hue" is a number, "saturation" and "lightness" are percentages.
                if (ParseHSLColor(ref rgba, ')')) {
                  aValue.SetColorValue(rgba);
                  return true;
                }
                SkipUntil(')');
                return false;
              }
              else if (mToken.mIdentStr.LowerCaseEqualsLiteral("-moz-hsla") ||
                       mToken.mIdentStr.LowerCaseEqualsLiteral("hsla")) {
                // hsla ( hue , saturation , lightness , opacity )
                // "hue" is a number, "saturation" and "lightness" are percentages,
                // "opacity" is a number.
                uint8_t a = 0;
                if (ParseHSLColor(ref rgba, ',') &&
                    ParseColorOpacity(ref a)) {
                  aValue.SetColorValue(nscolor.RGBA(rgba.R, rgba.G,
                                               rgba.B, a));
                  return true;
                }
                SkipUntil(')');
                return false;
              }
              break;
            default:
              break;
              }

              // try 'xxyyzz' without '#' prefix for compatibility with IE and Nav4x (bug 23236 and 45804)
              // TODO support hashless colors

              // It's not a color
              { if (!mSuppressErrors) mReporter.ReportUnexpected("PEColorNotColor", mToken); };
              UngetToken();
              return false;
        }
Esempio n. 9
0
        internal bool ParseTextDecoration()
        {
            const int eDecorationNone         = nsStyle.TextDecorationLineNone;
              const int eDecorationUnderline    = nsStyle.TextDecorationLineUnderline;
              const int eDecorationOverline     = nsStyle.TextDecorationLineOverline;
              const int eDecorationLineThrough  = nsStyle.TextDecorationLineLineThrough;
              const int eDecorationBlink        = nsStyle.TextDecorationLineBlink;
              const int eDecorationPrefAnchors  = nsStyle.TextDecorationLinePrefAnchors;

              /*TODO: static*/ int32_t[] kTextDecorationKTable = {
            (int32_t)nsCSSKeyword.None,                   eDecorationNone,
            (int32_t)nsCSSKeyword.Underline,              eDecorationUnderline,
            (int32_t)nsCSSKeyword.Overline,               eDecorationOverline,
            (int32_t)nsCSSKeyword.LineThrough,           eDecorationLineThrough,
            (int32_t)nsCSSKeyword.Blink,                  eDecorationBlink,
            (int32_t)nsCSSKeyword.MozAnchorDecoration, eDecorationPrefAnchors,
            (int32_t)nsCSSKeyword.Unknown,-1
              };

              var value = new nsCSSValue();
              if (!ParseVariant(ref value, VARIANT_HK, kTextDecorationKTable)) {
            return false;
              }

              nsCSSValue blink = new nsCSSValue(), line = new nsCSSValue(), style = new nsCSSValue(), color = new nsCSSValue();
              switch (value.GetUnit()) {
            case nsCSSUnit.Enumerated: {
              // We shouldn't accept decoration line style and color via
              // text-decoration.
              color.SetIntValue(nsStyle.ColorMozUseTextColor,
                                nsCSSUnit.Enumerated);
              style.SetIntValue(nsStyle.TextDecorationStyleSolid,
                                nsCSSUnit.Enumerated);

              int32_t intValue = value.GetIntValue();
              if (intValue == eDecorationNone) {
                blink.SetIntValue(nsStyle.TextBlinkNone, nsCSSUnit.Enumerated);
                line.SetIntValue(nsStyle.TextDecorationLineNone,
                                 nsCSSUnit.Enumerated);
                break;
              }

              // look for more keywords
              var keyword = new nsCSSValue();
              int32_t index = 0;
              for (index = 0; index < 3; index++) {
                if (!ParseEnum(ref keyword, kTextDecorationKTable)) {
                  break;
                }
                int32_t newValue = keyword.GetIntValue();
                if (newValue == eDecorationNone || ((newValue & intValue) != 0)) {
                  // 'none' keyword in conjuction with others is not allowed, and
                  // duplicate keyword is not allowed.
                  return false;
                }
                intValue |= newValue;
              }

              blink.SetIntValue((intValue & eDecorationBlink) != 0 ?
                                  nsStyle.TextBlinkBlink : nsStyle.TextBlinkNone,
                                nsCSSUnit.Enumerated);
              line.SetIntValue((intValue & ~eDecorationBlink), nsCSSUnit.Enumerated);
              break;
            }
              goto default;
            default:
              blink = line = color = style = value;
              break;
              }

              AppendValue(nsCSSProperty.TextBlink, blink);
              AppendValue(nsCSSProperty.TextDecorationLine, line);
              AppendValue(nsCSSProperty.TextDecorationColor, color);
              AppendValue(nsCSSProperty.TextDecorationStyle, style);

              return true;
        }
Esempio n. 10
0
        internal bool ParseOverflow()
        {
            var overflow = new nsCSSValue();
              if (!ParseVariant(ref overflow, VARIANT_HK,
                            nsCSSProps.kOverflowKTable) ||
              !ExpectEndProperty())
            return false;

              var overflowX = new nsCSSValue(overflow);
              var overflowY = new nsCSSValue(overflow);
              if (nsCSSUnit.Enumerated == overflow.GetUnit())
            switch(overflow.GetIntValue()) {
              case nsStyle.OverflowScrollbarsHorizontal:
                overflowX.SetIntValue(nsStyle.OverflowScroll, nsCSSUnit.Enumerated);
                overflowY.SetIntValue(nsStyle.OverflowHidden, nsCSSUnit.Enumerated);
                break;
              case nsStyle.OverflowScrollbarsVertical:
                overflowX.SetIntValue(nsStyle.OverflowHidden, nsCSSUnit.Enumerated);
                overflowY.SetIntValue(nsStyle.OverflowScroll, nsCSSUnit.Enumerated);
                break;
            }
              AppendValue(nsCSSProperty.OverflowX, overflowX);
              AppendValue(nsCSSProperty.OverflowY, overflowY);
              return true;
        }