nsresult result = SetMedia(aSheet, aMedia);
NS_PRECONDITION(aSheet, "Must have a sheet!");  nsresult rv; nsCOMPtr<nsMediaList> mediaList(aMediaList);  if (!aMediaString.IsEmpty()) { NS_ASSERTION(!aMediaList, "must not provide both aMediaString and aMediaList"); mediaList = new nsMediaList(); NS_ENSURE_TRUE(mediaList, NS_ERROR_OUT_OF_MEMORY); nsCOMPtr<nsICSSParser> mediumParser; nsresult rv = GetParserFor(nsnull, getter_AddRefs(mediumParser)); NS_ENSURE_SUCCESS(rv, rv);   rv = mediumParser->ParseMediaList(aMediaString, nsnull, 0, mediaList, PR_TRUE); NS_ENSURE_SUCCESS(rv, rv); RecycleParser(mediumParser); }  rv = aSheet->SetMedia(mediaList); NS_ENSURE_SUCCESS(rv, rv);
CSSLoaderImpl::PrepareSheet(nsICSSStyleSheet* aSheet, const nsString& aTitle,                             const nsString& aMedia){  nsresult result = SetMedia(aSheet, aMedia);    aSheet->SetTitle(aTitle);  return result;}