Esempio n. 1
0
 internal bool ParseQuotes()
 {
     var value = new nsCSSValue();
       if (!ParseVariant(ref value, VARIANT_HOS, null)) {
     return false;
       }
       if (value.GetUnit() != nsCSSUnit.String) {
     if (!ExpectEndProperty()) {
       return false;
     }
       } else {
     nsCSSValue open = value;
     nsCSSValuePairList quotes = value.SetPairListValue();
     for (;;) {
       quotes.mXValue = open;
       // get mandatory close
       if (!ParseVariant(ref quotes.mYValue, VARIANT_STRING, null)) {
         return false;
       }
       if (CheckEndProperty()) {
         break;
       }
       // look for another open
       if (!ParseVariant(ref open, VARIANT_STRING, null)) {
         return false;
       }
       quotes.mNext = new nsCSSValuePairList();
       quotes = quotes.mNext;
     }
       }
       AppendValue(nsCSSProperty.Quotes, value);
       return true;
 }
Esempio n. 2
0
        internal bool ParseFontFeatureSettings(ref nsCSSValue aValue)
        {
            if (ParseVariant(ref aValue, VARIANT_INHERIT | VARIANT_NORMAL, null)) {
            return true;
              }

              nsCSSValuePairList cur = aValue.SetPairListValue();
              for (;;) {
            // feature tag
            if (!GetToken(true)) {
              return false;
            }

            if (mToken.mType != nsCSSTokenType.String ||
                !ValidFontFeatureTag(mToken.mIdentStr)) {
              UngetToken();
              return false;
            }
            cur.mXValue.SetStringValue(mToken.mIdentStr, nsCSSUnit.String);

            if (!GetToken(true)) {
              cur.mYValue.SetIntValue(1, nsCSSUnit.Integer);
              break;
            }

            // optional value or on/off keyword
            if (mToken.mType == nsCSSTokenType.Number && mToken.mIntegerValid &&
                mToken.mInteger >= 0) {
              cur.mYValue.SetIntValue(mToken.mInteger, nsCSSUnit.Integer);
            } else if (mToken.mType == nsCSSTokenType.Ident &&
                       mToken.mIdentStr.LowerCaseEqualsLiteral("on")) {
              cur.mYValue.SetIntValue(1, nsCSSUnit.Integer);
            } else if (mToken.mType == nsCSSTokenType.Ident &&
                       mToken.mIdentStr.LowerCaseEqualsLiteral("off")) {
              cur.mYValue.SetIntValue(0, nsCSSUnit.Integer);
            } else {
              // something other than value/on/off, set default value
              cur.mYValue.SetIntValue(1, nsCSSUnit.Integer);
              UngetToken();
            }

            if (!ExpectSymbol(',', true)) {
              break;
            }

            cur.mNext = new nsCSSValuePairList();
            cur = cur.mNext;
              }

              return true;
        }
Esempio n. 3
0
 // This function is very similar to ParseBackgroundList and
 // ParseBackgroundPosition.
 internal bool ParseBackgroundSize()
 {
     var value = new nsCSSValue();
       if (ParseVariant(ref value, VARIANT_INHERIT, null)) {
     // 'initial' and 'inherit' stand alone, no list permitted.
     if (!ExpectEndProperty()) {
       return false;
     }
       } else {
     var valuePair = new nsCSSValuePair();
     if (!ParseBackgroundSizeValues(ref valuePair)) {
       return false;
     }
     nsCSSValuePairList item = value.SetPairListValue();
     for (;;) {
       item.mXValue = valuePair.mXValue;
       item.mYValue = valuePair.mYValue;
       if (CheckEndProperty()) {
         break;
       }
       if (!ExpectSymbol(',', true)) {
         return false;
       }
       if (!ParseBackgroundSizeValues(ref valuePair)) {
         return false;
       }
       item.mNext = new nsCSSValuePairList();
       item = item.mNext;
     }
       }
       AppendValue(nsCSSProperty.BackgroundSize, value);
       return true;
 }
Esempio n. 4
0
        internal bool ParseCounterData(nsCSSProperty aPropID)
        {
            var value = new nsCSSValue();
              if (!ParseVariant(ref value, VARIANT_INHERIT | VARIANT_NONE, null)) {
            if (!GetToken(true) || mToken.mType != nsCSSTokenType.Ident) {
              return false;
            }

            nsCSSValuePairList cur = value.SetPairListValue();
            for (;;) {
              cur.mXValue.SetStringValue(mToken.mIdentStr, nsCSSUnit.Ident);
              if (!GetToken(true)) {
                break;
              }
              if (mToken.mType == nsCSSTokenType.Number && mToken.mIntegerValid) {
                cur.mYValue.SetIntValue(mToken.mInteger, nsCSSUnit.Integer);
              } else {
                UngetToken();
              }
              if (CheckEndProperty()) {
                break;
              }
              if (!GetToken(true) || mToken.mType != nsCSSTokenType.Ident) {
                return false;
              }
              cur.mNext = new nsCSSValuePairList();
              cur = cur.mNext;
            }
              }
              AppendValue(aPropID, value);
              return true;
        }
Esempio n. 5
0
        internal bool ParseBackground()
        {
            using (/*var compound = */new nsAutoParseCompoundProperty(this)) {

            // background-color can only be set once, so it's not a list.
            var color = new nsCSSValue();

            // Check first for inherit/initial.
            if (ParseVariant(ref color, VARIANT_INHERIT, null)) {
              // must be alone
              if (!ExpectEndProperty()) {
                return false;
              }
              AppendValues(nsCSSProps.SubpropertyEntryFor(nsCSSProperty.Background), color);
              return true;
            }

            nsCSSValue image = new nsCSSValue(), repeat = new nsCSSValue(), attachment = new nsCSSValue(), clip = new nsCSSValue(), origin = new nsCSSValue(), position = new nsCSSValue(), size = new nsCSSValue();
            var state = new BackgroundParseState(color, image.SetListValue(),
                                       repeat.SetPairListValue(),
                                       attachment.SetListValue(), clip.SetListValue(),
                                       origin.SetListValue(), position.SetListValue(),
                                       size.SetPairListValue());

            for (;;) {
              if (!ParseBackgroundItem(state)) {
                return false;
              }
              if (CheckEndProperty()) {
                break;
              }
              // If we saw a color, this must be the last item.
              if (color.GetUnit() != nsCSSUnit.Null) {
                { if (!mSuppressErrors) mReporter.ReportUnexpected("PEExpectEndValue", mToken); };
                return false;
              }
              // Otherwise, a comma is mandatory.
              if (!ExpectSymbol(',', true)) {
                return false;
              }
              // Chain another entry on all the lists.
              state.mImage.mNext = new nsCSSValueList();
              state.mImage = state.mImage.mNext;
              state.mRepeat.mNext = new nsCSSValuePairList();
              state.mRepeat = state.mRepeat.mNext;
              state.mAttachment.mNext = new nsCSSValueList();
              state.mAttachment = state.mAttachment.mNext;
              state.mClip.mNext = new nsCSSValueList();
              state.mClip = state.mClip.mNext;
              state.mOrigin.mNext = new nsCSSValueList();
              state.mOrigin = state.mOrigin.mNext;
              state.mPosition.mNext = new nsCSSValueList();
              state.mPosition = state.mPosition.mNext;
              state.mSize.mNext = new nsCSSValuePairList();
              state.mSize = state.mSize.mNext;
            }

            // If we get to this point without seeing a color, provide a default.
            if (color.GetUnit() == nsCSSUnit.Null) {
              color.SetColorValue(nscolor.RGBA(0,0,0,0));
            }

            AppendValue(nsCSSProperty.BackgroundImage,      image);
            AppendValue(nsCSSProperty.BackgroundRepeat,     repeat);
            AppendValue(nsCSSProperty.BackgroundAttachment, attachment);
            AppendValue(nsCSSProperty.BackgroundClip,       clip);
            AppendValue(nsCSSProperty.BackgroundOrigin,     origin);
            AppendValue(nsCSSProperty.BackgroundPosition,   position);
            AppendValue(nsCSSProperty.BackgroundSize,       size);
            AppendValue(nsCSSProperty.BackgroundColor,      color);
            return true;
              }
        }