nsresult result = SetMedia(aSheet, aMedia);
NS_PRECONDITION(aSheet, "Must have a sheet!"); NS_PRECONDITION(aMedia.IsEmpty() || !aMediaArr, "Can't have media array _and_ media string!");  nsresult rv = NS_OK; aSheet->ClearMedia(); if (!aMedia.IsEmpty()) { rv = EnumerateMediaString(aMedia, MediumEnumFunc, aSheet); } else if (aMediaArr) { PRUint32 count; aMediaArr->Count(&count); for (PRUint32 i = 0; i < count; ++i) { nsCOMPtr<nsIAtom> medium = do_QueryElementAt(aMediaArr, i); NS_ASSERTION(medium, "Null medium in media array!"); aSheet->AppendMedium(medium); } } 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;}