internal nsresult ParseMediaList(string aBuffer, Uri aURI, // for error reporting uint32_t aLineNumber, // for error reporting nsMediaList aMediaList, bool aHTMLMode) { // XXX Are there cases where the caller wants to keep what it already // has in case of parser error? If GatherMedia ever changes to return // a value other than true, we probably should avoid modifying aMediaList. aMediaList.Clear(); // fake base URI since media lists don't have URIs in them var scanner = new nsCSSScanner(aBuffer, aLineNumber); var reporter = new ErrorReporter(scanner, mSheet, mChildLoader, aURI); InitScanner(scanner, reporter, aURI, aURI, null); mHTMLMediaMode = aHTMLMode; // XXXldb We need to make the scanner not skip CSS comments! (Or // should we?) // For aHTMLMode, we used to follow the parsing rules in // http://www.w3.org/TR/1999/REC-html401-19991224/types.html#type-media-descriptors // which wouldn't work for media queries since they remove all but the // first word. However, they're changed in // http://www.whatwg.org/specs/web-apps/current-work/multipage/section-document.html#media2 // (as of 2008-05-29) which says that the media attribute just points // to a media query. (The main substative difference is the relative // precedence of commas and paretheses.) bool parsedOK = GatherMedia(aMediaList, false); Debug.Assert(parsedOK, "GatherMedia returned false; we probably want to avoid trashing aMediaList"); mReporter.ClearError(); ReleaseScanner(); mHTMLMediaMode = false; return nsresult.OK; }