Bug 15423: Check for a base href when forming the URL for an image map; r=harishd

git-svn-id: svn://10.0.0.236/trunk@50541 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pollmann%netscape.com 1999-10-13 01:37:30 +00:00
parent e96f49b91f
commit 489f3fc875
2 changed files with 32 additions and 24 deletions

View File

@ -877,19 +877,23 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
nsresult rv;
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return PR_FALSE;
nsIURI *baseUri = nsnull;
if ((area->mBase).Length() > 0) {
// use the area->base as the base uri
char *uriStr = (area->mBase).ToNewCString();
if (!uriStr) {
return PR_FALSE;
// Set the image loader's source URL and base URL
nsIURI* baseUri = nsnull;
nsIHTMLContent* htmlContent;
if (mMap) {
rv = mMap->QueryInterface(kIHTMLContentIID, (void**)&htmlContent);
if (NS_SUCCEEDED(rv)) {
htmlContent->GetBaseURL(baseUri);
NS_RELEASE(htmlContent);
}
else {
nsIDocument* doc;
rv = mMap->GetDocument(doc);
if (NS_SUCCEEDED(rv)) {
doc->GetBaseURL(baseUri); // Could just use mDocument here...
NS_RELEASE(doc);
}
}
rv = service->NewURI(uriStr, nsnull, &baseUri);
delete [] uriStr;
} else {
rv = aDocURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
}
if (NS_FAILED(rv)) return PR_FALSE;

View File

@ -877,19 +877,23 @@ nsImageMap::IsInside(nscoord aX, nscoord aY,
nsresult rv;
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return PR_FALSE;
nsIURI *baseUri = nsnull;
if ((area->mBase).Length() > 0) {
// use the area->base as the base uri
char *uriStr = (area->mBase).ToNewCString();
if (!uriStr) {
return PR_FALSE;
// Set the image loader's source URL and base URL
nsIURI* baseUri = nsnull;
nsIHTMLContent* htmlContent;
if (mMap) {
rv = mMap->QueryInterface(kIHTMLContentIID, (void**)&htmlContent);
if (NS_SUCCEEDED(rv)) {
htmlContent->GetBaseURL(baseUri);
NS_RELEASE(htmlContent);
}
else {
nsIDocument* doc;
rv = mMap->GetDocument(doc);
if (NS_SUCCEEDED(rv)) {
doc->GetBaseURL(baseUri); // Could just use mDocument here...
NS_RELEASE(doc);
}
}
rv = service->NewURI(uriStr, nsnull, &baseUri);
delete [] uriStr;
} else {
rv = aDocURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
}
if (NS_FAILED(rv)) return PR_FALSE;