NECKO only: replacing GetBuffer with ToNewCString and some error checking
This commit is contained in:
Родитель
16e16c453a
Коммит
d968fa955b
|
@ -1226,7 +1226,7 @@ nsGenericElement::TriggerLink(nsIPresContext& aPresContext,
|
|||
|
||||
char *absUrl = nsnull;
|
||||
char *uriStr = aURLSpec.ToNewCString();
|
||||
|
||||
if (!uriStr) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(uriStr, baseUri, &absUrl);
|
||||
nsCRT::free(uriStr);
|
||||
NS_RELEASE(baseUri);
|
||||
|
|
|
@ -542,10 +542,12 @@ nsHTMLImageElement::SetSrc(const nsString& aSrc)
|
|||
if (NS_FAILED(result)) return result;
|
||||
|
||||
char *absUrlStr = nsnull;
|
||||
const char *urlSpec = aSrc.GetBuffer();
|
||||
char *urlSpec = aSrc.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
result = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
url = absUrlStr;
|
||||
nsCRT::free(urlSpec);
|
||||
delete [] absUrlStr;
|
||||
#endif // NECKO
|
||||
if (NS_FAILED(result)) {
|
||||
|
@ -567,6 +569,7 @@ nsHTMLImageElement::SetSrc(const nsString& aSrc)
|
|||
result = context->StartLoadImage(url, nsnull, specifiedSize,
|
||||
nsnull, nsnull, nsnull,
|
||||
nsnull);
|
||||
|
||||
NS_RELEASE(context);
|
||||
}
|
||||
|
||||
|
|
|
@ -2474,11 +2474,12 @@ PRBool CSSParserImpl::ParseURL(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
}
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
const char* str = tk->mIdent.GetBuffer();
|
||||
if (str == nsnull) return PR_FALSE;
|
||||
char* str = tk->mIdent.ToNewCString();
|
||||
if (!str) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = NS_MakeAbsoluteURI(str, base, absURL);
|
||||
NS_RELEASE(base);
|
||||
nsCRT::free(str);
|
||||
#else
|
||||
rv = NS_MakeAbsoluteURL(mURL, baseURL, tk->mIdent, absURL);
|
||||
#endif // NECKO
|
||||
|
|
|
@ -1485,6 +1485,7 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
|
|||
|
||||
char *absUrlStr = nsnull;
|
||||
char *urlSpec = href.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
nsCRT::free(urlSpec);
|
||||
NS_RELEASE(baseUri);
|
||||
|
|
|
@ -598,9 +598,11 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
|||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
char *absUrlStr = nsnull;
|
||||
const char *urlSpec = href.GetBuffer();
|
||||
char *urlSpec = href.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
nsCRT::free(urlSpec);
|
||||
absURLSpec = absUrlStr;
|
||||
delete [] absUrlStr;
|
||||
#endif // NECKO
|
||||
|
|
|
@ -1171,9 +1171,9 @@ nsXMLContentSink::CreateStyleSheetURL(nsIURI** aUrl,
|
|||
result = NS_NewURL(aUrl, absURL);
|
||||
}
|
||||
#else
|
||||
result = NS_MakeAbsoluteURL(docURL, nsnull, aHref, absURL);
|
||||
result = NS_MakeAbsoluteURI(aHref, docURL, absURL);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = NS_NewURL(aUrl, absURL);
|
||||
result = NS_NewURI(aUrl, absURL);
|
||||
}
|
||||
#endif // NECKO
|
||||
}
|
||||
|
|
|
@ -1881,9 +1881,11 @@ GlobalWindowImpl::OpenInternal(JSContext *cx,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *absUrl = nsnull;
|
||||
const char *urlSpec = mURL.GetBuffer();
|
||||
char *urlSpec = mURL.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrl);
|
||||
NS_RELEASE(baseUri);
|
||||
nsCRT::free(urlSpec);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mAbsURL = absUrl;
|
||||
delete [] absUrl;
|
||||
|
|
|
@ -1226,7 +1226,7 @@ nsGenericElement::TriggerLink(nsIPresContext& aPresContext,
|
|||
|
||||
char *absUrl = nsnull;
|
||||
char *uriStr = aURLSpec.ToNewCString();
|
||||
|
||||
if (!uriStr) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(uriStr, baseUri, &absUrl);
|
||||
nsCRT::free(uriStr);
|
||||
NS_RELEASE(baseUri);
|
||||
|
|
|
@ -719,10 +719,12 @@ void TempMakeAbsURL(nsIContent* aContent, nsString& aRelURL, nsString& aAbsURL)
|
|||
if (NS_FAILED(result)) return;
|
||||
|
||||
char *absUrlStr = nsnull;
|
||||
const char *urlSpec = aRelURL.GetBuffer();
|
||||
char *urlSpec = aRelURL.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
result = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
aAbsURL= absUrlStr;
|
||||
nsCRT::free(urlSpec);
|
||||
delete [] absUrlStr;
|
||||
#endif // NECKO
|
||||
NS_IF_RELEASE(baseURL);
|
||||
|
|
|
@ -681,6 +681,7 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
|
||||
char *absUrlStr = nsnull;
|
||||
char *baseSpec = src.ToNewCString();
|
||||
if (!baseSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(baseSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
absURL = absUrlStr;
|
||||
|
|
|
@ -863,8 +863,10 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
|
|||
|
||||
if ((area->mBase).Length() > 0) {
|
||||
// use the area->base as the base uri
|
||||
const char *uriStr = (area->mBase).GetBuffer();
|
||||
char *uriStr = (area->mBase).ToNewCString();
|
||||
if (!uriStr) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->NewURI(uriStr, nsnull, &baseUri);
|
||||
nsCRT::free(uriStr);
|
||||
} else {
|
||||
rv = aDocURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
|
||||
}
|
||||
|
@ -872,6 +874,7 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
|
|||
|
||||
char *absUrlStr = nsnull;
|
||||
char *urlSpec = (area->mHREF).ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
aAbsURL = absUrlStr;
|
||||
|
|
|
@ -94,6 +94,7 @@ nsHTMLImageLoader::SetURL(const nsString& aNewSpec)
|
|||
|
||||
char *absUrl = nsnull;
|
||||
char *urlSpec = mURLSpec.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrl);
|
||||
NS_RELEASE(baseUri);
|
||||
nsCRT::free(urlSpec);
|
||||
|
|
|
@ -681,6 +681,7 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
|
||||
char *absUrlStr = nsnull;
|
||||
char *baseSpec = src.ToNewCString();
|
||||
if (!baseSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(baseSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
absURL = absUrlStr;
|
||||
|
|
|
@ -863,8 +863,10 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
|
|||
|
||||
if ((area->mBase).Length() > 0) {
|
||||
// use the area->base as the base uri
|
||||
const char *uriStr = (area->mBase).GetBuffer();
|
||||
char *uriStr = (area->mBase).ToNewCString();
|
||||
if (!uriStr) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->NewURI(uriStr, nsnull, &baseUri);
|
||||
nsCRT::free(uriStr);
|
||||
} else {
|
||||
rv = aDocURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
|
||||
}
|
||||
|
@ -872,6 +874,7 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
|
|||
|
||||
char *absUrlStr = nsnull;
|
||||
char *urlSpec = (area->mHREF).ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
aAbsURL = absUrlStr;
|
||||
|
|
|
@ -542,10 +542,12 @@ nsHTMLImageElement::SetSrc(const nsString& aSrc)
|
|||
if (NS_FAILED(result)) return result;
|
||||
|
||||
char *absUrlStr = nsnull;
|
||||
const char *urlSpec = aSrc.GetBuffer();
|
||||
char *urlSpec = aSrc.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
result = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
url = absUrlStr;
|
||||
nsCRT::free(urlSpec);
|
||||
delete [] absUrlStr;
|
||||
#endif // NECKO
|
||||
if (NS_FAILED(result)) {
|
||||
|
@ -567,6 +569,7 @@ nsHTMLImageElement::SetSrc(const nsString& aSrc)
|
|||
result = context->StartLoadImage(url, nsnull, specifiedSize,
|
||||
nsnull, nsnull, nsnull,
|
||||
nsnull);
|
||||
|
||||
NS_RELEASE(context);
|
||||
}
|
||||
|
||||
|
|
|
@ -719,10 +719,12 @@ void TempMakeAbsURL(nsIContent* aContent, nsString& aRelURL, nsString& aAbsURL)
|
|||
if (NS_FAILED(result)) return;
|
||||
|
||||
char *absUrlStr = nsnull;
|
||||
const char *urlSpec = aRelURL.GetBuffer();
|
||||
char *urlSpec = aRelURL.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
result = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
aAbsURL= absUrlStr;
|
||||
nsCRT::free(urlSpec);
|
||||
delete [] absUrlStr;
|
||||
#endif // NECKO
|
||||
NS_IF_RELEASE(baseURL);
|
||||
|
|
|
@ -549,9 +549,11 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
|||
if (NS_FAILED(result)) return result;
|
||||
|
||||
char *absUrlStr = nsnull;
|
||||
const char *urlSpec = href.GetBuffer();
|
||||
char *urlSpec = href.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
result = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
nsCRT::free(urlSpec);
|
||||
absURLSpec = absUrlStr;
|
||||
delete [] absUrlStr;
|
||||
#endif // NECKO
|
||||
|
|
|
@ -2474,11 +2474,12 @@ PRBool CSSParserImpl::ParseURL(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
}
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
const char* str = tk->mIdent.GetBuffer();
|
||||
if (str == nsnull) return PR_FALSE;
|
||||
char* str = tk->mIdent.ToNewCString();
|
||||
if (!str) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = NS_MakeAbsoluteURI(str, base, absURL);
|
||||
NS_RELEASE(base);
|
||||
nsCRT::free(str);
|
||||
#else
|
||||
rv = NS_MakeAbsoluteURL(mURL, baseURL, tk->mIdent, absURL);
|
||||
#endif // NECKO
|
||||
|
|
|
@ -1485,6 +1485,7 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
|
|||
|
||||
char *absUrlStr = nsnull;
|
||||
char *urlSpec = href.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
nsCRT::free(urlSpec);
|
||||
NS_RELEASE(baseUri);
|
||||
|
|
|
@ -598,9 +598,11 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
|||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
char *absUrlStr = nsnull;
|
||||
const char *urlSpec = href.GetBuffer();
|
||||
char *urlSpec = href.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
nsCRT::free(urlSpec);
|
||||
absURLSpec = absUrlStr;
|
||||
delete [] absUrlStr;
|
||||
#endif // NECKO
|
||||
|
|
|
@ -2474,11 +2474,12 @@ PRBool CSSParserImpl::ParseURL(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
}
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
const char* str = tk->mIdent.GetBuffer();
|
||||
if (str == nsnull) return PR_FALSE;
|
||||
char* str = tk->mIdent.ToNewCString();
|
||||
if (!str) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = NS_MakeAbsoluteURI(str, base, absURL);
|
||||
NS_RELEASE(base);
|
||||
nsCRT::free(str);
|
||||
#else
|
||||
rv = NS_MakeAbsoluteURL(mURL, baseURL, tk->mIdent, absURL);
|
||||
#endif // NECKO
|
||||
|
|
|
@ -1485,6 +1485,7 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
|
|||
|
||||
char *absUrlStr = nsnull;
|
||||
char *urlSpec = href.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
nsCRT::free(urlSpec);
|
||||
NS_RELEASE(baseUri);
|
||||
|
|
|
@ -598,9 +598,11 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
|||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
char *absUrlStr = nsnull;
|
||||
const char *urlSpec = href.GetBuffer();
|
||||
char *urlSpec = href.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
nsCRT::free(urlSpec);
|
||||
absURLSpec = absUrlStr;
|
||||
delete [] absUrlStr;
|
||||
#endif // NECKO
|
||||
|
|
|
@ -1171,9 +1171,9 @@ nsXMLContentSink::CreateStyleSheetURL(nsIURI** aUrl,
|
|||
result = NS_NewURL(aUrl, absURL);
|
||||
}
|
||||
#else
|
||||
result = NS_MakeAbsoluteURL(docURL, nsnull, aHref, absURL);
|
||||
result = NS_MakeAbsoluteURI(aHref, docURL, absURL);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = NS_NewURL(aUrl, absURL);
|
||||
result = NS_NewURI(aUrl, absURL);
|
||||
}
|
||||
#endif // NECKO
|
||||
}
|
||||
|
|
|
@ -685,15 +685,18 @@ nsWebCrawler::FindURLsIn(nsIDocument* aDocument, nsIContent* aNode)
|
|||
nsIURI *baseUri = nsnull;
|
||||
|
||||
if (base.Length() > 0) {
|
||||
const char *uriStr = base.GetBuffer();
|
||||
char *uriStr = base.ToNewCString();
|
||||
if (!uriStr) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->NewURI(uriStr, nsnull, &baseUri);
|
||||
nsCRT::free(uriStr);
|
||||
} else {
|
||||
rv = docURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
|
||||
}
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
char *absUrlStr = nsnull;
|
||||
const char *urlSpec = src.GetBuffer();
|
||||
char *urlSpec = src.ToNewCString();
|
||||
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
|
||||
NS_RELEASE(baseUri);
|
||||
absURLSpec = absUrlStr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче