Exemplo n.º 1
0
        internal nsresult ParseStyleAttribute(string aAttributeValue,
                                           Uri          aDocURI,
                                           Uri          aBaseURI,
                                           nsIPrincipal    aNodePrincipal,
                                           ref StyleRule aResult)
        {
            if (aNodePrincipal == null) throw new ArgumentException("Must have principal here!");
              if (aBaseURI == null) throw new ArgumentException("need base URI");

              // XXX line number?
              var scanner = new nsCSSScanner(aAttributeValue, 0);
              var reporter = new ErrorReporter(scanner, mSheet, mChildLoader, aDocURI);
              InitScanner(scanner, reporter, aDocURI, aBaseURI, aNodePrincipal);

              mSection = nsCSSSection.General;

              // In quirks mode, allow style declarations to have braces or not
              // (bug 99554).
              bool haveBraces;
              if (mNavQuirkMode && GetToken(true)) {
            haveBraces = nsCSSTokenType.Symbol == mToken.mType &&
                         '{' == mToken.mSymbol;
            UngetToken();
              }
              else {
            haveBraces = false;
              }

              nsParseDeclaration parseFlags = nsParseDeclaration.AllowImportant;
              if (haveBraces) {
            parseFlags |= nsParseDeclaration.InBraces;
              }

              Declaration declaration = ParseDeclarationBlock(parseFlags);
              if (declaration != null) {
            // Create a style rule for the declaration
            aResult = new StyleRule(null, declaration);
              } else {
            aResult = null;
              }

              ReleaseScanner();

              // XXX check for low level errors
              return nsresult.OK;
        }
Exemplo n.º 2
0
        internal bool ParseRuleSet(RuleAppendFunc aAppendFunc, object aData,
                                    bool aInsideBraces = false)
        {
            // First get the list of selectors for the rule
              nsCSSSelectorList slist = null;
              uint32_t linenum = mScanner.GetLineNumber();
              if (! ParseSelectorList(ref slist, '{')) {
            { if (!mSuppressErrors) mReporter.ReportUnexpected("PEBadSelectorRSIgnored"); };
            mReporter.OutputError();
            SkipRuleSet(aInsideBraces);
            return false;
              }
              Debug.Assert(null != slist, "null selector list");
              mReporter.ClearError();

              // Next parse the declaration block
              nsParseDeclaration parseFlags = nsParseDeclaration.InBraces |
                                nsParseDeclaration.AllowImportant;
              Declaration declaration = ParseDeclarationBlock(parseFlags);
              if (null == declaration) {
            return false;
              }

              // Translate the selector list and declaration block into style data

              StyleRule rule = new StyleRule(slist, declaration);
              rule.SetLineNumber(linenum);
              aAppendFunc(rule, aData);

              return true;
        }