Skip to content

Commit

Permalink
Remove mURL from nsWebShell, and GetURL from nsIWebShell.
Browse files Browse the repository at this point in the history
r=travis
  • Loading branch information
norris%netscape.com committed Mar 11, 2000
1 parent d1cfaee commit 9b2edd3
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 141 deletions.
18 changes: 6 additions & 12 deletions content/html/document/src/nsHTMLContentSink.cpp
Expand Up @@ -3761,7 +3761,10 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
// XXX necko isn't going to process headers coming in from the parser
//NS_WARNING("need to fix how necko adds mime headers (in HTMLContentSink::ProcessMETATag)");

// see if we have a refresh "header".
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(mWebShell, &rv);
if (NS_FAILED(rv)) return rv;

// see if we have a refresh "header".
if (!header.Compare("refresh", PR_TRUE)) {
// Refresh headers are parsed with the following format in mind
// <META HTTP-EQUIV=REFRESH CONTENT="5; URL=http://uri">
Expand Down Expand Up @@ -3796,12 +3799,8 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
// quotes.

// first get our baseURI
const PRUnichar *loadedURI = nsnull;
rv = mWebShell->GetURL(&loadedURI);
if (NS_FAILED(rv)) return rv;

nsCOMPtr<nsIURI> baseURI;
rv = NS_NewURI(getter_AddRefs(baseURI), loadedURI, nsnull);
rv = docShell->GetCurrentURI(getter_AddRefs(baseURI));
if (NS_FAILED(rv)) return rv;

PRInt32 millis = -1;
Expand Down Expand Up @@ -3890,13 +3889,8 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
nsCOMPtr<nsICookieService> cookieServ = do_GetService(NS_COOKIESERVICE_PROGID, &rv);
if (NS_FAILED(rv)) return rv;

// first get our baseURI
const PRUnichar *uriCStr = nsnull;
rv = mWebShell->GetURL(&uriCStr);
if (NS_FAILED(rv)) return rv;

nsCOMPtr<nsIURI> baseURI;
rv = NS_NewURI(getter_AddRefs(baseURI), uriCStr, nsnull);
rv = docShell->GetCurrentURI(getter_AddRefs(baseURI));
if (NS_FAILED(rv)) return rv;

rv = cookieServ->SetCookieString(baseURI, result);
Expand Down
52 changes: 13 additions & 39 deletions docshell/base/nsWebShell.cpp
Expand Up @@ -337,7 +337,6 @@ class nsWebShell : public nsDocShell,

// nsIDocShell
NS_IMETHOD SetDocument(nsIDOMDocument *aDOMDoc, nsIDOMElement *aRootNode);
void SetCurrentURI(nsIURI* aURI);

// nsWebShell
nsIEventQueue* GetEventQueue(void);
Expand All @@ -360,7 +359,6 @@ class nsWebShell : public nsDocShell,
NS_IMETHOD GetSessionHistory(nsISessionHistory *& aResult);
NS_IMETHOD SetIsInSHist(PRBool aIsFrame);
NS_IMETHOD GetIsInSHist(PRBool& aIsFrame);
NS_IMETHOD GetURL(const PRUnichar** aURL);
NS_IMETHOD SetURL(const PRUnichar* aURL);

protected:
Expand Down Expand Up @@ -389,8 +387,6 @@ class nsWebShell : public nsDocShell,
nsISessionHistory * mSHist;

nsRect mBounds;
nsString mURL;

nsString mOverURL;
nsString mOverTarget;

Expand Down Expand Up @@ -919,15 +915,6 @@ nsWebShell::SetReferrer(const PRUnichar* aReferrer)
NS_NewURI(getter_AddRefs(mReferrerURI), aReferrer, nsnull);
}

NS_IMETHODIMP
nsWebShell::GetURL(const PRUnichar** aURL)
{
// XXX This is wrong unless the parameter is marked "shared".
// It should otherwise be copied and freed by the caller.
*aURL = mURL.GetUnicode();
return NS_OK;
}

NS_IMETHODIMP
nsWebShell::SetURL(const PRUnichar* aURL)
{
Expand All @@ -938,17 +925,6 @@ nsWebShell::SetURL(const PRUnichar* aURL)
return NS_OK;
}

void
nsWebShell::SetCurrentURI(nsIURI* aURI)
{
nsXPIDLCString spec;
if (NS_SUCCEEDED(aURI->GetSpec(getter_Copies(spec)))) {
mURL = spec;
nsDocShell::SetCurrentURI(aURI);
}
}


NS_IMETHODIMP
nsWebShell::GetIsInSHist(PRBool& aResult)
{
Expand Down Expand Up @@ -1119,7 +1095,6 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
if (NS_SUCCEEDED(rv))
{
SetCurrentURI(aUri);
mURL = urlSpec;
SetReferrer(aReferrer);
}
// Pass on status of scrolling/anchor visit to docloaderobserver
Expand All @@ -1146,7 +1121,6 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
if(NS_SUCCEEDED(rv))
{
SetCurrentURI(aUri);
mURL = urlSpec;
SetReferrer(aReferrer);
}
mProcessedEndDocumentLoad = PR_FALSE;
Expand Down Expand Up @@ -1279,7 +1253,6 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
// the document load succeeds.
if (NS_SUCCEEDED(rv)) {
SetCurrentURI(aUri);
mURL = urlSpec;
SetReferrer(aReferrer);
}

Expand Down Expand Up @@ -1732,27 +1705,25 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,

nsCOMPtr<nsIWebShell> parent;
nsresult res = GetParent(*getter_AddRefs(parent));
nsAutoString urlstr;
nsCOMPtr<nsIURI> newURI;

if ((isLoadingHistory)) {
/* if LoadURL() got called from SH, AND If we are going "Back/Forward"
* to a frame page,SH will change the mURL to the right value
* for smoother redraw. So, create a new nsIURI based on mURL,
* so that it will work right in such situations.
* to a frame page,SH will change the current uri to the right value
* for smoother redraw.
*/
urlstr = mURL;
res = GetCurrentURI(getter_AddRefs(newURI));
}
else{
/* If the call is not from SH, use the url passed by the caller
* so that things like JS will work right. This is for bug # 1646.
* May regress in other situations.
* What a hack
*/
urlstr=spec;
nsAutoString urlstr = spec;
res = NS_NewURI(getter_AddRefs(newURI), urlstr, nsnull);
}

nsCOMPtr<nsIURI> newURI;
res = NS_NewURI(getter_AddRefs(newURI), urlstr, nsnull);

if (NS_SUCCEEDED(res)) {
// now that we have a uri, call the REAL LoadURI method which requires a nsIURI.
Expand Down Expand Up @@ -2185,9 +2156,12 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
// for now, just hack the verb to be view-link-clicked
// and down in the load document code we'll detect this and
// set the correct uri loader command
nsXPIDLCString spec;
mCurrentURI->GetSpec(getter_Copies(spec));
nsAutoString specString(spec);
LoadURL(aURLSpec, "view-link-click", aPostDataStream,
PR_TRUE, nsIChannel::LOAD_NORMAL,
0, nsnull, mURL.GetUnicode(), nsCAutoString(aTargetSpec));
0, nsnull, specString.GetUnicode(), nsCAutoString(aTargetSpec));
}
break;
case eLinkVerb_Embed:
Expand Down Expand Up @@ -2592,9 +2566,8 @@ nsWebShell::OnStartURLLoad(nsIDocumentLoader* loader,

// Stop loading of the earlier document completely when the document url
// load starts. Now we know that this url is valid and available.
nsXPIDLCString url;
aURL->GetSpec(getter_Copies(url));
if (0 == PL_strcmp(url, mURL.GetBuffer()))
PRBool equals = PR_FALSE;
if (NS_SUCCEEDED(aURL->Equals(mCurrentURI, &equals)) && equals)
Stop();

/*
Expand Down Expand Up @@ -3115,6 +3088,7 @@ NS_IMETHODIMP nsWebShell::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx,
mBounds.SetRect(x, y, cx, cy);
return nsDocShell::SetPositionAndSize(x, y, cx, cy, fRepaint);
}

NS_IMETHODIMP nsWebShell::GetPositionAndSize(PRInt32* x, PRInt32* y,
PRInt32* cx, PRInt32* cy)
{
Expand Down
13 changes: 8 additions & 5 deletions dom/src/base/nsLocation.cpp
Expand Up @@ -330,14 +330,17 @@ LocationImpl::SetHostname(const nsString& aHostname)
NS_IMETHODIMP
LocationImpl::GetHref(nsString& aHref)
{
// PRInt32 index;
nsresult result = NS_OK;

if (mDocShell) {
const PRUnichar *href;
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
result = webShell->GetURL (&href);
aHref = href;
nsCOMPtr<nsIURI> uri;
result = mDocShell->GetCurrentURI(getter_AddRefs(uri));
if (NS_SUCCEEDED(result)) {
nsXPIDLCString uriString;
result = uri->GetSpec(getter_Copies(uriString));
if (NS_SUCCEEDED(result))
aHref = uriString;
}
}

return result;
Expand Down
14 changes: 5 additions & 9 deletions dom/src/jsurl/nsJSProtocolHandler.cpp
Expand Up @@ -38,7 +38,7 @@
#include "nsIPrincipal.h"
#include "nsIScriptSecurityManager.h"
#include "nsProxyObjectManager.h"
#include "nsIWebShell.h"
#include "nsIDocShell.h"
#include "nsDOMError.h"
#include "nsIInterfaceRequestor.h"
#include "nsIEvaluateStringProxy.h"
Expand Down Expand Up @@ -229,15 +229,11 @@ nsJSProtocolHandler::NewChannel(const char* verb,
if (originalURI) {
referringUri = originalURI;
} else {
nsCOMPtr<nsIWebShell> webShell;
webShell = do_QueryInterface(globalOwner);
if (!webShell)
nsCOMPtr<nsIDocShell> docShell;
docShell = do_QueryInterface(globalOwner);
if (!docShell)
return NS_ERROR_FAILURE;
const PRUnichar* url;
if (NS_FAILED(webShell->GetURL(&url)))
return NS_ERROR_FAILURE;
nsString urlStr(url);
if (NS_FAILED(NS_NewURI(getter_AddRefs(referringUri), urlStr, nsnull)))
if (NS_FAILED(docShell->GetCurrentURI(getter_AddRefs(referringUri))))
return NS_ERROR_FAILURE;
}
if (NS_FAILED(securityManager->GetCodebasePrincipal(referringUri,
Expand Down
18 changes: 6 additions & 12 deletions layout/html/document/src/nsHTMLContentSink.cpp
Expand Up @@ -3761,7 +3761,10 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
// XXX necko isn't going to process headers coming in from the parser
//NS_WARNING("need to fix how necko adds mime headers (in HTMLContentSink::ProcessMETATag)");

// see if we have a refresh "header".
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(mWebShell, &rv);
if (NS_FAILED(rv)) return rv;

// see if we have a refresh "header".
if (!header.Compare("refresh", PR_TRUE)) {
// Refresh headers are parsed with the following format in mind
// <META HTTP-EQUIV=REFRESH CONTENT="5; URL=http://uri">
Expand Down Expand Up @@ -3796,12 +3799,8 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
// quotes.

// first get our baseURI
const PRUnichar *loadedURI = nsnull;
rv = mWebShell->GetURL(&loadedURI);
if (NS_FAILED(rv)) return rv;

nsCOMPtr<nsIURI> baseURI;
rv = NS_NewURI(getter_AddRefs(baseURI), loadedURI, nsnull);
rv = docShell->GetCurrentURI(getter_AddRefs(baseURI));
if (NS_FAILED(rv)) return rv;

PRInt32 millis = -1;
Expand Down Expand Up @@ -3890,13 +3889,8 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
nsCOMPtr<nsICookieService> cookieServ = do_GetService(NS_COOKIESERVICE_PROGID, &rv);
if (NS_FAILED(rv)) return rv;

// first get our baseURI
const PRUnichar *uriCStr = nsnull;
rv = mWebShell->GetURL(&uriCStr);
if (NS_FAILED(rv)) return rv;

nsCOMPtr<nsIURI> baseURI;
rv = NS_NewURI(getter_AddRefs(baseURI), uriCStr, nsnull);
rv = docShell->GetCurrentURI(getter_AddRefs(baseURI));
if (NS_FAILED(rv)) return rv;

rv = cookieServ->SetCookieString(baseURI, result);
Expand Down
5 changes: 0 additions & 5 deletions webshell/public/nsIWebShell.h
Expand Up @@ -211,11 +211,6 @@ class nsIWebShell : public nsIContentViewerContainer {
*/
NS_IMETHOD FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound) = 0;

/**
* Return the URL of the current WebShell.
*/
NS_IMETHOD GetURL(const PRUnichar** aURL) = 0;

/**
* Set the URL of the current WebShell.
*/
Expand Down

0 comments on commit 9b2edd3

Please sign in to comment.