// font-face-rule: '@font-face' '{' font-description '}' // font-description: font-descriptor+ internal bool ParseFontFaceRule(RuleAppendFunc aAppendFunc, object aData) { if (!ExpectSymbol('{', true)) { { if (!mSuppressErrors) mReporter.ReportUnexpected("PEBadFontBlockStart", mToken); }; return false; } var rule = new nsCSSFontFaceRule(); for (;;) { if (!GetToken(true)) { { if (!mSuppressErrors) mReporter.ReportUnexpected("PEFontFaceEOF"); }; break; } if (mToken.IsSymbol('}')) { // done! UngetToken(); break; } // ignore extra semicolons if (mToken.IsSymbol(';')) continue; if (!ParseFontDescriptor(rule)) { { if (!mSuppressErrors) mReporter.ReportUnexpected("PEDeclSkipped"); }; mReporter.OutputError(); if (!SkipDeclaration(true)) break; } } if (!ExpectSymbol('}', true)) { { if (!mSuppressErrors) mReporter.ReportUnexpected("PEBadFontBlockEnd", mToken); }; return false; } aAppendFunc(rule, aData); return true; }
// font-descriptor: font-family-desc // | font-style-desc // | font-weight-desc // | font-stretch-desc // | font-src-desc // | unicode-range-desc // // All font-*-desc productions follow the pattern // IDENT ':' value ';' // // On entry to this function, mToken is the IDENT. internal bool ParseFontDescriptor(nsCSSFontFaceRule aRule) { if (nsCSSTokenType.Ident != mToken.mType) { { if (!mSuppressErrors) mReporter.ReportUnexpected("PEFontDescExpected", mToken); }; return false; } string descName = mToken.mIdentStr; if (!ExpectSymbol(':', true)) { { if (!mSuppressErrors) mReporter.ReportUnexpected("PEParseDeclarationNoColon", mToken); }; mReporter.OutputError(); return false; } nsCSSFontDesc descID = nsCSSProps.LookupFontDesc(descName); var value = new nsCSSValue(); if (descID == nsCSSFontDesc.UNKNOWN) { if (NonMozillaVendorIdentifier(descName)) { // silently skip other vendors' extensions SkipDeclaration(true); return true; } else { { if (!mSuppressErrors) mReporter.ReportUnexpected("PEUnknownFontDesc", descName); }; return false; } } if (!ParseFontDescriptorValue(descID, ref value)) { { if (!mSuppressErrors) mReporter.ReportUnexpected("PEValueParsingError", descName); }; return false; } if (!ExpectEndProperty()) return false; aRule.SetDesc(descID, value); return true; }