mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1297300 - Add missing checks to GetSpec() calls in layout/. r=dholbert,heycam.
--HG-- extra : rebase_source : b3a26866746cde4337f5ffeff94f370b2eb7da3e
This commit is contained in:
parent
9554ec97fa
commit
f4ec41d9b5
@ -2019,11 +2019,15 @@ nsImageFrame::HandleEvent(nsPresContext* aPresContext,
|
||||
// mouse is over the border.
|
||||
if (p.x < 0) p.x = 0;
|
||||
if (p.y < 0) p.y = 0;
|
||||
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
nsresult rv = uri->GetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
spec += nsPrintfCString("?%d,%d", p.x, p.y);
|
||||
uri->SetSpec(spec);
|
||||
|
||||
rv = uri->SetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool clicked = false;
|
||||
if (aEvent->mMessage == eMouseClick && !aEvent->DefaultPrevented()) {
|
||||
*aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
|
@ -361,7 +361,8 @@ inCSSValueSearch::SearchStyleValue(const nsAFlatString& aValue, nsIURI* aBaseURL
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), url, nullptr, aBaseURL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
rv = uri->GetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAutoString *result = new NS_ConvertUTF8toUTF16(spec);
|
||||
if (mReturnRelativeURLs)
|
||||
EqualizeURL(result);
|
||||
|
@ -121,7 +121,8 @@ nsFontFace::GetURI(nsAString & aURI)
|
||||
NS_ASSERTION(mFontEntry->mUserFontData, "missing userFontData");
|
||||
if (mFontEntry->mUserFontData->mURI) {
|
||||
nsAutoCString spec;
|
||||
mFontEntry->mUserFontData->mURI->GetSpec(spec);
|
||||
nsresult rv = mFontEntry->mUserFontData->mURI->GetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
AppendUTF8toUTF16(spec, aURI);
|
||||
}
|
||||
}
|
||||
|
@ -1218,10 +1218,10 @@ nsPrintEngine::GetDocumentTitleAndURL(nsIDocument* aDoc,
|
||||
if (!exposableURI) return;
|
||||
|
||||
nsAutoCString urlCStr;
|
||||
exposableURI->GetSpec(urlCStr);
|
||||
nsresult rv = exposableURI->GetSpec(urlCStr);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsITextToSubURI> textToSubURI =
|
||||
nsCOMPtr<nsITextToSubURI> textToSubURI =
|
||||
do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
|
@ -1760,7 +1760,8 @@ CSSStyleSheet::GetHref(nsAString& aHref)
|
||||
{
|
||||
if (mInner->mOriginalSheetURI) {
|
||||
nsAutoCString str;
|
||||
mInner->mOriginalSheetURI->GetSpec(str);
|
||||
nsresult rv = mInner->mOriginalSheetURI->GetSpec(str);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
CopyUTF8toUTF16(str, aHref);
|
||||
} else {
|
||||
SetDOMStringToNull(aHref);
|
||||
|
@ -35,7 +35,10 @@ public:
|
||||
mURI = aURI;
|
||||
|
||||
nsAutoCString cSpec;
|
||||
mURI->GetSpec(cSpec);
|
||||
nsresult rv = mURI->GetSpec(cSpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
cSpec.AssignLiteral("[nsIURI::GetSpec failed]");
|
||||
}
|
||||
CopyUTF8toUTF16(cSpec, mSpec);
|
||||
}
|
||||
return mSpec;
|
||||
|
@ -1263,9 +1263,7 @@ FontFaceSet::LogMessage(gfxUserFontEntry* aUserFontEntry,
|
||||
CSSStyleSheet* sheet = rule->GetStyleSheet();
|
||||
// if the style sheet is removed while the font is loading can be null
|
||||
if (sheet) {
|
||||
nsAutoCString spec;
|
||||
rv = sheet->GetSheetURI()->GetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCString spec = sheet->GetSheetURI()->GetSpecOrDefault();
|
||||
CopyUTF8toUTF16(spec, href);
|
||||
} else {
|
||||
NS_WARNING("null parent stylesheet for @font-face rule");
|
||||
|
@ -1775,10 +1775,10 @@ Loader::ParseSheet(const nsAString& aInput,
|
||||
aLoadData->mSheet->Principal(),
|
||||
aLoadData->mLineNumber);
|
||||
} else {
|
||||
aLoadData->mSheet->AsServo()->ParseSheet(aInput, sheetURI, baseURI,
|
||||
aLoadData->mSheet->Principal(),
|
||||
aLoadData->mLineNumber);
|
||||
rv = NS_OK;
|
||||
rv =
|
||||
aLoadData->mSheet->AsServo()->ParseSheet(aInput, sheetURI, baseURI,
|
||||
aLoadData->mSheet->Principal(),
|
||||
aLoadData->mLineNumber);
|
||||
}
|
||||
|
||||
mParsingDatas.RemoveElementAt(mParsingDatas.Length() - 1);
|
||||
|
@ -68,7 +68,7 @@ ServoStyleSheet::AppendStyleSheet(StyleSheetHandle aSheet)
|
||||
MOZ_CRASH("stylo: not implemented");
|
||||
}
|
||||
|
||||
void
|
||||
nsresult
|
||||
ServoStyleSheet::ParseSheet(const nsAString& aInput,
|
||||
nsIURI* aSheetURI,
|
||||
nsIURI* aBaseURI,
|
||||
@ -83,7 +83,8 @@ ServoStyleSheet::ParseSheet(const nsAString& aInput,
|
||||
new ThreadSafePrincipalHolder(aSheetPrincipal);
|
||||
|
||||
nsCString baseString;
|
||||
aBaseURI->GetSpec(baseString);
|
||||
nsresult rv = aBaseURI->GetSpec(baseString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ConvertUTF16toUTF8 input(aInput);
|
||||
mSheet = Servo_StyleSheet_FromUTF8Bytes(
|
||||
@ -91,6 +92,8 @@ ServoStyleSheet::ParseSheet(const nsAString& aInput,
|
||||
mParsingMode,
|
||||
reinterpret_cast<const uint8_t*>(baseString.get()), baseString.Length(),
|
||||
base, referrer, principal).Consume();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -40,11 +40,11 @@ public:
|
||||
StyleSheetHandle GetParentSheet() const;
|
||||
void AppendStyleSheet(StyleSheetHandle aSheet);
|
||||
|
||||
void ParseSheet(const nsAString& aInput,
|
||||
nsIURI* aSheetURI,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aSheetPrincipal,
|
||||
uint32_t aLineNumber);
|
||||
MOZ_MUST_USE nsresult ParseSheet(const nsAString& aInput,
|
||||
nsIURI* aSheetURI,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aSheetPrincipal,
|
||||
uint32_t aLineNumber);
|
||||
|
||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
|
@ -1499,10 +1499,8 @@ StyleRule::List(FILE* out, int32_t aIndent) const
|
||||
if (sheet) {
|
||||
nsIURI* uri = sheet->GetSheetURI();
|
||||
if (uri) {
|
||||
nsAutoCString uristr;
|
||||
str.Append(" /* ");
|
||||
uri->GetSpec(uristr);
|
||||
str.Append(uristr);
|
||||
str.Append(uri->GetSpecOrDefault());
|
||||
str.Append(':');
|
||||
str.AppendInt(mLineNumber);
|
||||
str.Append(" */");
|
||||
|
@ -975,8 +975,11 @@ DocumentRule::UseForPresentation(nsPresContext* aPresContext)
|
||||
nsIDocument *doc = aPresContext->Document();
|
||||
nsIURI *docURI = doc->GetDocumentURI();
|
||||
nsAutoCString docURISpec;
|
||||
if (docURI)
|
||||
docURI->GetSpec(docURISpec);
|
||||
if (docURI) {
|
||||
// If GetSpec fails (due to OOM) just skip these URI-specific CSS rules.
|
||||
nsresult rv = docURI->GetSpec(docURISpec);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
}
|
||||
|
||||
for (URL *url = mURLs; url; url = url->next) {
|
||||
switch (url->func) {
|
||||
|
@ -547,7 +547,7 @@ AnnotateCrashReport(nsIURI* aURI)
|
||||
nsAutoCString scheme;
|
||||
nsDependentCSubstring filename;
|
||||
if (aURI) {
|
||||
aURI->GetSpec(spec);
|
||||
spec = aURI->GetSpecOrDefault();
|
||||
aURI->GetScheme(scheme);
|
||||
int32_t i = spec.RFindChar('/');
|
||||
if (i != -1) {
|
||||
@ -603,9 +603,8 @@ AnnotateCrashReport(nsIURI* aURI)
|
||||
if (!resolvedURI) {
|
||||
annotation.AppendLiteral("(ConvertChromeURL failed)\n");
|
||||
} else {
|
||||
nsAutoCString resolvedSpec;
|
||||
resolvedURI->GetSpec(resolvedSpec);
|
||||
annotation.Append(NS_ConvertUTF8toUTF16(resolvedSpec));
|
||||
annotation.Append(
|
||||
NS_ConvertUTF8toUTF16(resolvedURI->GetSpecOrDefault()));
|
||||
annotation.Append('\n');
|
||||
}
|
||||
}
|
||||
@ -949,7 +948,10 @@ nsLayoutStylesheetCache::BuildPreferenceSheet(StyleSheetHandle::RefPtr* aSheet,
|
||||
if (sheet->IsGecko()) {
|
||||
sheet->AsGecko()->ReparseSheet(sheetText);
|
||||
} else {
|
||||
sheet->AsServo()->ParseSheet(sheetText, uri, uri, nullptr, 0);
|
||||
nsresult rv = sheet->AsServo()->ParseSheet(sheetText, uri, uri, nullptr, 0);
|
||||
// Parsing the about:PreferenceStyleSheet URI can only fail on OOM. If we
|
||||
// are OOM before we parsed any documents we might as well abort.
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
|
||||
#undef NS_GET_R_G_B
|
||||
|
@ -100,7 +100,8 @@ nsROCSSPrimitiveValue::GetCssText(nsAString& aCssText)
|
||||
{
|
||||
if (mValue.mURI) {
|
||||
nsAutoCString specUTF8;
|
||||
mValue.mURI->GetSpec(specUTF8);
|
||||
nsresult rv = mValue.mURI->GetSpec(specUTF8);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
tmpStr.AssignLiteral("url(");
|
||||
nsStyleUtil::AppendEscapedCSSString(NS_ConvertUTF8toUTF16(specUTF8),
|
||||
@ -461,10 +462,13 @@ nsROCSSPrimitiveValue::GetStringValue(nsAString& aReturn)
|
||||
break;
|
||||
case CSS_URI: {
|
||||
nsAutoCString spec;
|
||||
if (mValue.mURI)
|
||||
mValue.mURI->GetSpec(spec);
|
||||
if (mValue.mURI) {
|
||||
nsresult rv = mValue.mURI->GetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
CopyUTF8toUTF16(spec, aReturn);
|
||||
} break;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
aReturn.Truncate();
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
|
@ -185,7 +185,12 @@ FragmentOrURL::GetSourceString(nsString &aRef) const
|
||||
mURL->GetRef(cref);
|
||||
cref.Insert('#', 0);
|
||||
} else {
|
||||
mURL->GetSpec(cref);
|
||||
// It's not entirely clear how to best handle failure here. Ensuring the
|
||||
// string is empty seems safest.
|
||||
nsresult rv = mURL->GetSpec(cref);
|
||||
if (NS_FAILED(rv)) {
|
||||
cref.Truncate();
|
||||
}
|
||||
}
|
||||
|
||||
aRef = NS_ConvertUTF8toUTF16(cref);
|
||||
|
@ -2119,7 +2119,8 @@ nsTreeBodyFrame::GetImage(int32_t aRowIndex, nsTreeColumn* aCol, bool aUseContex
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
styleRequest->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
nsresult rv = uri->GetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
CopyUTF8toUTF16(spec, imageSrc);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user