NECKO only: Using helper function NS_MakeAbsoluteURI A: chofmann R:valeski

This commit is contained in:
andreas.otte%primus-online.de 1999-07-11 15:46:10 +00:00
parent 1a343482da
commit 838f5a972b
17 changed files with 45 additions and 183 deletions

View File

@ -41,6 +41,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
@ -539,21 +540,7 @@ nsHTMLImageElement::SetSrc(const nsString& aSrc)
#ifndef NECKO
result = NS_MakeAbsoluteURL(baseURL, empty, aSrc, url);
#else
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &result);
if (NS_FAILED(result)) return result;
nsIURI *baseUri = nsnull;
result = baseURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(result)) return result;
char *absUrlStr = nsnull;
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;
result = NS_MakeAbsoluteURI(aSrc, baseURL, url);
#endif // NECKO
if (NS_FAILED(result)) {
url = aSrc;

View File

@ -2492,7 +2492,7 @@ PRBool CSSParserImpl::ParseURL(PRInt32& aErrorCode, nsCSSValue& aValue)
rv = NS_MakeAbsoluteURI(str, base, absURL);
NS_RELEASE(base);
nsCRT::free(str);
delete [] str;
#else
rv = NS_MakeAbsoluteURL(mURL, baseURL, tk->mIdent, absURL);
#endif // NECKO

View File

@ -25,6 +25,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsISupportsArray.h"
@ -1476,24 +1477,12 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
NS_MakeAbsoluteURL(docURL, base, href, absURLSpec);
#else
nsresult rv;
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return PR_FALSE;
nsIURI *baseUri = nsnull;
rv = docURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(rv)) return PR_FALSE;
char *absUrlStr = nsnull;
char *urlSpec = href.ToNewCString();
if (!urlSpec) {
NS_RELEASE(baseUri);
return PR_FALSE;
}
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
nsCRT::free(urlSpec);
NS_MakeAbsoluteURI(href, baseUri, absURLSpec);
NS_RELEASE(baseUri);
absURLSpec = absUrlStr;
delete [] absUrlStr;
#endif // NECKO
NS_IF_RELEASE(docURL);

View File

@ -25,6 +25,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsISupportsArray.h"
@ -630,24 +631,13 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
#ifndef NECKO
rv = NS_MakeAbsoluteURL(docURL, base, href, absURLSpec);
#else
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return 0;
nsIURI *baseUri = nsnull;
rv = docURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(rv)) return 0;
char *absUrlStr = nsnull;
char *urlSpec = href.ToNewCString();
if (!urlSpec) {
NS_RELEASE(baseUri);
return 0;
}
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
rv = NS_MakeAbsoluteURI(href, baseUri, absURLSpec);
NS_RELEASE(baseUri);
nsCRT::free(urlSpec);
absURLSpec = absUrlStr;
delete [] absUrlStr;
#endif // NECKO
NS_IF_RELEASE(docURL);

View File

@ -70,6 +70,7 @@
#else
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
@ -1910,22 +1911,13 @@ GlobalWindowImpl::OpenInternal(JSContext *cx,
}
#else
nsresult rv;
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsIURI *baseUri = nsnull;
rv = mDocURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(rv)) return rv;
char *absUrl = nsnull;
char *urlSpec = mURL.ToNewCString();
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrl);
rv = NS_MakeAbsoluteURI(mURL, baseUri, mAbsURL);
NS_RELEASE(baseUri);
nsCRT::free(urlSpec);
if (NS_FAILED(rv)) return rv;
mAbsURL = absUrl;
delete [] absUrl;
#endif // NECKO
}

View File

@ -39,6 +39,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsIView.h"
@ -725,23 +726,7 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
nsString empty;
NS_MakeAbsoluteURL(baseURL, empty, src, absURL);
#else
// XXX Should be a component local subroutine....
nsresult rv;
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsIURI *baseUri = nsnull;
rv = baseURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(rv)) return rv;
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;
nsCRT::free(baseSpec);
delete [] absUrlStr;
NS_MakeAbsoluteURI(src, baseURL, absURL);
#endif // NECKO
NS_IF_RELEASE(baseURL);

View File

@ -26,6 +26,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsXIFConverter.h"
@ -864,22 +865,19 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
if ((area->mBase).Length() > 0) {
// use the area->base as the base uri
char *uriStr = (area->mBase).ToNewCString();
if (!uriStr) return NS_ERROR_OUT_OF_MEMORY;
if (!uriStr) {
return PR_FALSE;
}
rv = service->NewURI(uriStr, nsnull, &baseUri);
nsCRT::free(uriStr);
delete [] uriStr;
} else {
rv = aDocURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
}
if (NS_FAILED(rv)) return PR_FALSE;
char *absUrlStr = nsnull;
char *urlSpec = (area->mHREF).ToNewCString();
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
NS_MakeAbsoluteURI(area->mHREF, baseUri, aAbsURL);
NS_RELEASE(baseUri);
aAbsURL = absUrlStr;
nsCRT::free(urlSpec);
delete [] absUrlStr;
#endif // NECKO
aTarget = area->mTarget;
aAltText = area->mAltText;

View File

@ -39,6 +39,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsIView.h"
@ -725,23 +726,7 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
nsString empty;
NS_MakeAbsoluteURL(baseURL, empty, src, absURL);
#else
// XXX Should be a component local subroutine....
nsresult rv;
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsIURI *baseUri = nsnull;
rv = baseURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(rv)) return rv;
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;
nsCRT::free(baseSpec);
delete [] absUrlStr;
NS_MakeAbsoluteURI(src, baseURL, absURL);
#endif // NECKO
NS_IF_RELEASE(baseURL);

View File

@ -26,6 +26,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsXIFConverter.h"
@ -864,22 +865,19 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
if ((area->mBase).Length() > 0) {
// use the area->base as the base uri
char *uriStr = (area->mBase).ToNewCString();
if (!uriStr) return NS_ERROR_OUT_OF_MEMORY;
if (!uriStr) {
return PR_FALSE;
}
rv = service->NewURI(uriStr, nsnull, &baseUri);
nsCRT::free(uriStr);
delete [] uriStr;
} else {
rv = aDocURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
}
if (NS_FAILED(rv)) return PR_FALSE;
char *absUrlStr = nsnull;
char *urlSpec = (area->mHREF).ToNewCString();
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
NS_MakeAbsoluteURI(area->mHREF, baseUri, aAbsURL);
NS_RELEASE(baseUri);
aAbsURL = absUrlStr;
nsCRT::free(urlSpec);
delete [] absUrlStr;
#endif // NECKO
aTarget = area->mTarget;
aAltText = area->mAltText;

View File

@ -41,6 +41,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
@ -539,21 +540,7 @@ nsHTMLImageElement::SetSrc(const nsString& aSrc)
#ifndef NECKO
result = NS_MakeAbsoluteURL(baseURL, empty, aSrc, url);
#else
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &result);
if (NS_FAILED(result)) return result;
nsIURI *baseUri = nsnull;
result = baseURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(result)) return result;
char *absUrlStr = nsnull;
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;
result = NS_MakeAbsoluteURI(aSrc, baseURL, url);
#endif // NECKO
if (NS_FAILED(result)) {
url = aSrc;

View File

@ -51,6 +51,7 @@
#ifdef NECKO
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsIDocument.h"
@ -540,22 +541,14 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
#ifndef NECKO
NS_MakeAbsoluteURL(docURL, base, href, absURLSpec);
#else
nsresult result;
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &result);
if (NS_FAILED(result)) return result;
nsIURI *baseUri = nsnull;
result = docURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(result)) return result;
char *absUrlStr = nsnull;
char *urlSpec = href.ToNewCString();
if (!urlSpec) return NS_ERROR_OUT_OF_MEMORY;
result = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
NS_MakeAbsoluteURI(href, baseUri, absURLSpec);
NS_RELEASE(baseUri);
nsCRT::free(urlSpec);
absURLSpec = absUrlStr;
delete [] absUrlStr;
#endif // NECKO
NS_IF_RELEASE(docURL);

View File

@ -2492,7 +2492,7 @@ PRBool CSSParserImpl::ParseURL(PRInt32& aErrorCode, nsCSSValue& aValue)
rv = NS_MakeAbsoluteURI(str, base, absURL);
NS_RELEASE(base);
nsCRT::free(str);
delete [] str;
#else
rv = NS_MakeAbsoluteURL(mURL, baseURL, tk->mIdent, absURL);
#endif // NECKO

View File

@ -25,6 +25,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsISupportsArray.h"
@ -1476,24 +1477,12 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
NS_MakeAbsoluteURL(docURL, base, href, absURLSpec);
#else
nsresult rv;
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return PR_FALSE;
nsIURI *baseUri = nsnull;
rv = docURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(rv)) return PR_FALSE;
char *absUrlStr = nsnull;
char *urlSpec = href.ToNewCString();
if (!urlSpec) {
NS_RELEASE(baseUri);
return PR_FALSE;
}
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
nsCRT::free(urlSpec);
NS_MakeAbsoluteURI(href, baseUri, absURLSpec);
NS_RELEASE(baseUri);
absURLSpec = absUrlStr;
delete [] absUrlStr;
#endif // NECKO
NS_IF_RELEASE(docURL);

View File

@ -25,6 +25,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsISupportsArray.h"
@ -630,24 +631,13 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
#ifndef NECKO
rv = NS_MakeAbsoluteURL(docURL, base, href, absURLSpec);
#else
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return 0;
nsIURI *baseUri = nsnull;
rv = docURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(rv)) return 0;
char *absUrlStr = nsnull;
char *urlSpec = href.ToNewCString();
if (!urlSpec) {
NS_RELEASE(baseUri);
return 0;
}
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
rv = NS_MakeAbsoluteURI(href, baseUri, absURLSpec);
NS_RELEASE(baseUri);
nsCRT::free(urlSpec);
absURLSpec = absUrlStr;
delete [] absUrlStr;
#endif // NECKO
NS_IF_RELEASE(docURL);

View File

@ -2492,7 +2492,7 @@ PRBool CSSParserImpl::ParseURL(PRInt32& aErrorCode, nsCSSValue& aValue)
rv = NS_MakeAbsoluteURI(str, base, absURL);
NS_RELEASE(base);
nsCRT::free(str);
delete [] str;
#else
rv = NS_MakeAbsoluteURL(mURL, baseURL, tk->mIdent, absURL);
#endif // NECKO

View File

@ -25,6 +25,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsISupportsArray.h"
@ -1476,24 +1477,12 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
NS_MakeAbsoluteURL(docURL, base, href, absURLSpec);
#else
nsresult rv;
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return PR_FALSE;
nsIURI *baseUri = nsnull;
rv = docURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(rv)) return PR_FALSE;
char *absUrlStr = nsnull;
char *urlSpec = href.ToNewCString();
if (!urlSpec) {
NS_RELEASE(baseUri);
return PR_FALSE;
}
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
nsCRT::free(urlSpec);
NS_MakeAbsoluteURI(href, baseUri, absURLSpec);
NS_RELEASE(baseUri);
absURLSpec = absUrlStr;
delete [] absUrlStr;
#endif // NECKO
NS_IF_RELEASE(docURL);

View File

@ -25,6 +25,7 @@
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNeckoUtil.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#endif // NECKO
#include "nsISupportsArray.h"
@ -630,24 +631,13 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
#ifndef NECKO
rv = NS_MakeAbsoluteURL(docURL, base, href, absURLSpec);
#else
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return 0;
nsIURI *baseUri = nsnull;
rv = docURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
if (NS_FAILED(rv)) return 0;
char *absUrlStr = nsnull;
char *urlSpec = href.ToNewCString();
if (!urlSpec) {
NS_RELEASE(baseUri);
return 0;
}
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrlStr);
rv = NS_MakeAbsoluteURI(href, baseUri, absURLSpec);
NS_RELEASE(baseUri);
nsCRT::free(urlSpec);
absURLSpec = absUrlStr;
delete [] absUrlStr;
#endif // NECKO
NS_IF_RELEASE(docURL);