diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp
index 4ebea9b15b1..989da4b65ee 100644
--- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp
+++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp
@@ -2726,33 +2726,26 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
aPresContext->GetLinkHandler(&linkHandler);
if (linkHandler) {
if (NS_CONTENT_ATTR_HAS_VALUE == attrState) {
- nsIURI* docURL = nsnull;
- nsIHTMLContent* htmlContent;
- if (NS_SUCCEEDED(aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) {
- htmlContent->GetBaseURL(docURL);
- NS_RELEASE(htmlContent);
+ nsCOMPtr baseURI = nsnull;
+ nsCOMPtr htmlContent = do_QueryInterface(aContent);
+ if (htmlContent) {
+ // XXX why do this? will nsIHTMLContent's
+ // GetBaseURL() may return something different
+ // than the URL of the document it lives in?
+ htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
}
else {
- nsIDocument* doc = nsnull;
- aContent->GetDocument(doc);
- if (nsnull != doc) {
- doc->GetBaseURL(docURL);
- NS_RELEASE(doc);
+ nsCOMPtr doc;
+ aContent->GetDocument(*getter_AddRefs(doc));
+ if (doc) {
+ doc->GetBaseURL(*getter_AddRefs(baseURI));
}
}
- nsAutoString absURLSpec;
- nsresult rv;
- nsIURI *baseUri = nsnull;
- rv = docURL->QueryInterface(NS_GET_IID(nsIURI), (void**)&baseUri);
- if (NS_FAILED(rv)) return PR_FALSE;
+ nsCOMPtr linkURI;
+ (void) NS_NewURI(getter_AddRefs(linkURI), href, baseURI, CSSStyleSheetInner::gIOService);
- (void)NS_MakeAbsoluteURI(absURLSpec, href, baseUri, CSSStyleSheetInner::gIOService);
- // XXX what about failure of NS_MakeAbsoluteURI here?
- NS_RELEASE(baseUri);
- NS_IF_RELEASE(docURL);
-
- linkHandler->GetLinkState(absURLSpec.GetUnicode(), linkState);
+ linkHandler->GetLinkState(linkURI, linkState);
}
}
else {
diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp
index 3487fcc832d..8d2532dbfdc 100644
--- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp
+++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp
@@ -858,25 +858,17 @@ HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
}
}
else {
- nsIURI* docURL = nsnull;
-
nsIHTMLContent* htmlContent;
if (NS_SUCCEEDED(styledContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) {
- htmlContent->GetBaseURL(docURL);
+
+ nsCOMPtr baseURI;
+ htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
- nsAutoString absURLSpec;
- nsresult rv;
- nsIURI *baseUri = nsnull;
- rv = docURL->QueryInterface(NS_GET_IID(nsIURI), (void**)&baseUri);
- if (NS_FAILED(rv)) return 0;
-
- rv = NS_MakeAbsoluteURI(absURLSpec, href, baseUri);
-
- NS_RELEASE(baseUri);
- NS_IF_RELEASE(docURL);
+ nsCOMPtr linkURI;
+ (void) NS_NewURI(getter_AddRefs(linkURI), href, baseURI);
nsLinkState state;
- if (NS_OK == linkHandler->GetLinkState(absURLSpec.GetUnicode(), state)) {
+ if (NS_OK == linkHandler->GetLinkState(linkURI, state)) {
switch (state) {
case eLinkState_Unvisited:
if (nsnull != mLinkRule) {
diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp
index d0d3b94c177..b715d6b6052 100644
--- a/mozilla/docshell/base/nsWebShell.cpp
+++ b/mozilla/docshell/base/nsWebShell.cpp
@@ -274,7 +274,7 @@ public:
NS_IMETHOD OnOverLink(nsIContent* aContent,
const PRUnichar* aURLSpec,
const PRUnichar* aTargetSpec);
- NS_IMETHOD GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState);
+ NS_IMETHOD GetLinkState(nsIURI* aLinkURI, nsLinkState& aState);
// nsIProgressEventSink
NS_DECL_NSIPROGRESSEVENTSINK
@@ -1781,8 +1781,12 @@ nsWebShell::OnOverLink(nsIContent* aContent,
}
NS_IMETHODIMP
-nsWebShell::GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState)
+nsWebShell::GetLinkState(nsIURI* aLinkURI, nsLinkState& aState)
{
+ NS_PRECONDITION(aLinkURI != nsnull, "null ptr");
+ if (! aLinkURI)
+ return NS_ERROR_NULL_POINTER;
+
aState = eLinkState_Unvisited;
nsresult rv;
@@ -1800,31 +1804,11 @@ nsWebShell::GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState)
if (mHistoryService) {
// XXX aURLSpec should really be a char*, not a PRUnichar*.
- nsAutoString urlStr(aURLSpec);
-
- char buf[256];
- char* url = buf;
-
- if (urlStr.Length() >= PRInt32(sizeof buf)) {
- url = new char[urlStr.Length() + 1];
- }
+ nsXPIDLCString url;
+ aLinkURI->GetSpec(getter_Copies(url));
PRInt64 lastVisitDate;
-
- if (url) {
- urlStr.ToCString(url, urlStr.Length() + 1);
-
- rv = mHistoryService->GetLastVisitDate(url, &lastVisitDate);
-
- if (url != buf)
- delete[] url;
- }
- else {
- rv = NS_ERROR_OUT_OF_MEMORY;
- }
-
- //XXX: Moved to destructor nsServiceManager::ReleaseService(kGlobalHistoryCID, mHistoryService);
-
+ rv = mHistoryService->GetLastVisitDate(url, &lastVisitDate);
if (NS_FAILED(rv)) return rv;
// a last-visit-date of zero means we've never seen it before; so
diff --git a/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp b/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp
index 4ebea9b15b1..989da4b65ee 100644
--- a/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp
+++ b/mozilla/layout/html/style/src/nsCSSStyleSheet.cpp
@@ -2726,33 +2726,26 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
aPresContext->GetLinkHandler(&linkHandler);
if (linkHandler) {
if (NS_CONTENT_ATTR_HAS_VALUE == attrState) {
- nsIURI* docURL = nsnull;
- nsIHTMLContent* htmlContent;
- if (NS_SUCCEEDED(aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) {
- htmlContent->GetBaseURL(docURL);
- NS_RELEASE(htmlContent);
+ nsCOMPtr baseURI = nsnull;
+ nsCOMPtr htmlContent = do_QueryInterface(aContent);
+ if (htmlContent) {
+ // XXX why do this? will nsIHTMLContent's
+ // GetBaseURL() may return something different
+ // than the URL of the document it lives in?
+ htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
}
else {
- nsIDocument* doc = nsnull;
- aContent->GetDocument(doc);
- if (nsnull != doc) {
- doc->GetBaseURL(docURL);
- NS_RELEASE(doc);
+ nsCOMPtr doc;
+ aContent->GetDocument(*getter_AddRefs(doc));
+ if (doc) {
+ doc->GetBaseURL(*getter_AddRefs(baseURI));
}
}
- nsAutoString absURLSpec;
- nsresult rv;
- nsIURI *baseUri = nsnull;
- rv = docURL->QueryInterface(NS_GET_IID(nsIURI), (void**)&baseUri);
- if (NS_FAILED(rv)) return PR_FALSE;
+ nsCOMPtr linkURI;
+ (void) NS_NewURI(getter_AddRefs(linkURI), href, baseURI, CSSStyleSheetInner::gIOService);
- (void)NS_MakeAbsoluteURI(absURLSpec, href, baseUri, CSSStyleSheetInner::gIOService);
- // XXX what about failure of NS_MakeAbsoluteURI here?
- NS_RELEASE(baseUri);
- NS_IF_RELEASE(docURL);
-
- linkHandler->GetLinkState(absURLSpec.GetUnicode(), linkState);
+ linkHandler->GetLinkState(linkURI, linkState);
}
}
else {
diff --git a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp
index 3487fcc832d..8d2532dbfdc 100644
--- a/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp
+++ b/mozilla/layout/html/style/src/nsHTMLStyleSheet.cpp
@@ -858,25 +858,17 @@ HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
}
}
else {
- nsIURI* docURL = nsnull;
-
nsIHTMLContent* htmlContent;
if (NS_SUCCEEDED(styledContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) {
- htmlContent->GetBaseURL(docURL);
+
+ nsCOMPtr baseURI;
+ htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
- nsAutoString absURLSpec;
- nsresult rv;
- nsIURI *baseUri = nsnull;
- rv = docURL->QueryInterface(NS_GET_IID(nsIURI), (void**)&baseUri);
- if (NS_FAILED(rv)) return 0;
-
- rv = NS_MakeAbsoluteURI(absURLSpec, href, baseUri);
-
- NS_RELEASE(baseUri);
- NS_IF_RELEASE(docURL);
+ nsCOMPtr linkURI;
+ (void) NS_NewURI(getter_AddRefs(linkURI), href, baseURI);
nsLinkState state;
- if (NS_OK == linkHandler->GetLinkState(absURLSpec.GetUnicode(), state)) {
+ if (NS_OK == linkHandler->GetLinkState(linkURI, state)) {
switch (state) {
case eLinkState_Unvisited:
if (nsnull != mLinkRule) {
diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp
index 4ebea9b15b1..989da4b65ee 100644
--- a/mozilla/layout/style/nsCSSStyleSheet.cpp
+++ b/mozilla/layout/style/nsCSSStyleSheet.cpp
@@ -2726,33 +2726,26 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
aPresContext->GetLinkHandler(&linkHandler);
if (linkHandler) {
if (NS_CONTENT_ATTR_HAS_VALUE == attrState) {
- nsIURI* docURL = nsnull;
- nsIHTMLContent* htmlContent;
- if (NS_SUCCEEDED(aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) {
- htmlContent->GetBaseURL(docURL);
- NS_RELEASE(htmlContent);
+ nsCOMPtr baseURI = nsnull;
+ nsCOMPtr htmlContent = do_QueryInterface(aContent);
+ if (htmlContent) {
+ // XXX why do this? will nsIHTMLContent's
+ // GetBaseURL() may return something different
+ // than the URL of the document it lives in?
+ htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
}
else {
- nsIDocument* doc = nsnull;
- aContent->GetDocument(doc);
- if (nsnull != doc) {
- doc->GetBaseURL(docURL);
- NS_RELEASE(doc);
+ nsCOMPtr doc;
+ aContent->GetDocument(*getter_AddRefs(doc));
+ if (doc) {
+ doc->GetBaseURL(*getter_AddRefs(baseURI));
}
}
- nsAutoString absURLSpec;
- nsresult rv;
- nsIURI *baseUri = nsnull;
- rv = docURL->QueryInterface(NS_GET_IID(nsIURI), (void**)&baseUri);
- if (NS_FAILED(rv)) return PR_FALSE;
+ nsCOMPtr linkURI;
+ (void) NS_NewURI(getter_AddRefs(linkURI), href, baseURI, CSSStyleSheetInner::gIOService);
- (void)NS_MakeAbsoluteURI(absURLSpec, href, baseUri, CSSStyleSheetInner::gIOService);
- // XXX what about failure of NS_MakeAbsoluteURI here?
- NS_RELEASE(baseUri);
- NS_IF_RELEASE(docURL);
-
- linkHandler->GetLinkState(absURLSpec.GetUnicode(), linkState);
+ linkHandler->GetLinkState(linkURI, linkState);
}
}
else {
diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp
index 3487fcc832d..8d2532dbfdc 100644
--- a/mozilla/layout/style/nsHTMLStyleSheet.cpp
+++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp
@@ -858,25 +858,17 @@ HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
}
}
else {
- nsIURI* docURL = nsnull;
-
nsIHTMLContent* htmlContent;
if (NS_SUCCEEDED(styledContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) {
- htmlContent->GetBaseURL(docURL);
+
+ nsCOMPtr baseURI;
+ htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
- nsAutoString absURLSpec;
- nsresult rv;
- nsIURI *baseUri = nsnull;
- rv = docURL->QueryInterface(NS_GET_IID(nsIURI), (void**)&baseUri);
- if (NS_FAILED(rv)) return 0;
-
- rv = NS_MakeAbsoluteURI(absURLSpec, href, baseUri);
-
- NS_RELEASE(baseUri);
- NS_IF_RELEASE(docURL);
+ nsCOMPtr linkURI;
+ (void) NS_NewURI(getter_AddRefs(linkURI), href, baseURI);
nsLinkState state;
- if (NS_OK == linkHandler->GetLinkState(absURLSpec.GetUnicode(), state)) {
+ if (NS_OK == linkHandler->GetLinkState(linkURI, state)) {
switch (state) {
case eLinkState_Unvisited:
if (nsnull != mLinkRule) {
diff --git a/mozilla/webshell/public/nsILinkHandler.h b/mozilla/webshell/public/nsILinkHandler.h
index 582cb45a69e..8ae8240460f 100644
--- a/mozilla/webshell/public/nsILinkHandler.h
+++ b/mozilla/webshell/public/nsILinkHandler.h
@@ -27,6 +27,7 @@
class nsIInputStream;
class nsIContent;
+class nsIURI;
struct nsGUIEvent;
// Interface ID for nsILinkHandler
@@ -82,7 +83,7 @@ public:
/**
* Get the state of a link to a given absolute URL
*/
- NS_IMETHOD GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState) = 0;
+ NS_IMETHOD GetLinkState(nsIURI* aLinkURI, nsLinkState& aState) = 0;
};
#endif /* nsILinkHandler_h___ */
diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp
index d0d3b94c177..b715d6b6052 100644
--- a/mozilla/webshell/src/nsWebShell.cpp
+++ b/mozilla/webshell/src/nsWebShell.cpp
@@ -274,7 +274,7 @@ public:
NS_IMETHOD OnOverLink(nsIContent* aContent,
const PRUnichar* aURLSpec,
const PRUnichar* aTargetSpec);
- NS_IMETHOD GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState);
+ NS_IMETHOD GetLinkState(nsIURI* aLinkURI, nsLinkState& aState);
// nsIProgressEventSink
NS_DECL_NSIPROGRESSEVENTSINK
@@ -1781,8 +1781,12 @@ nsWebShell::OnOverLink(nsIContent* aContent,
}
NS_IMETHODIMP
-nsWebShell::GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState)
+nsWebShell::GetLinkState(nsIURI* aLinkURI, nsLinkState& aState)
{
+ NS_PRECONDITION(aLinkURI != nsnull, "null ptr");
+ if (! aLinkURI)
+ return NS_ERROR_NULL_POINTER;
+
aState = eLinkState_Unvisited;
nsresult rv;
@@ -1800,31 +1804,11 @@ nsWebShell::GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState)
if (mHistoryService) {
// XXX aURLSpec should really be a char*, not a PRUnichar*.
- nsAutoString urlStr(aURLSpec);
-
- char buf[256];
- char* url = buf;
-
- if (urlStr.Length() >= PRInt32(sizeof buf)) {
- url = new char[urlStr.Length() + 1];
- }
+ nsXPIDLCString url;
+ aLinkURI->GetSpec(getter_Copies(url));
PRInt64 lastVisitDate;
-
- if (url) {
- urlStr.ToCString(url, urlStr.Length() + 1);
-
- rv = mHistoryService->GetLastVisitDate(url, &lastVisitDate);
-
- if (url != buf)
- delete[] url;
- }
- else {
- rv = NS_ERROR_OUT_OF_MEMORY;
- }
-
- //XXX: Moved to destructor nsServiceManager::ReleaseService(kGlobalHistoryCID, mHistoryService);
-
+ rv = mHistoryService->GetLastVisitDate(url, &lastVisitDate);
if (NS_FAILED(rv)) return rv;
// a last-visit-date of zero means we've never seen it before; so
diff --git a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp
index 92629c9699d..b3c9d37242e 100644
--- a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp
+++ b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp
@@ -17,6 +17,9 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
+ * Original Author(s):
+ * Chris Waterson
+ *
* Contributor(s):
* Pierre Phaneuf
*/
@@ -297,84 +300,12 @@ public:
// nsIGlobalHistory
NS_DECL_NSIGLOBALHISTORY
+ // nsIRDFDataSource
+ NS_DECL_NSIRDFDATASOURCE
+
// nsIRDFRemoteDataSource
NS_DECL_NSIRDFREMOTEDATASOURCE
- // nsIRDFDataSource
- NS_IMETHOD GetURI(char* *aURI);
-
- NS_IMETHOD GetSource(nsIRDFResource* aProperty,
- nsIRDFNode* aTarget,
- PRBool aTruthValue,
- nsIRDFResource** aSource);
-
- NS_IMETHOD GetSources(nsIRDFResource* aProperty,
- nsIRDFNode* aTarget,
- PRBool aTruthValue,
- nsISimpleEnumerator** aSources);
-
- NS_IMETHOD GetTarget(nsIRDFResource* aSource,
- nsIRDFResource* aProperty,
- PRBool aTruthValue,
- nsIRDFNode** aTarget);
-
- NS_IMETHOD GetTargets(nsIRDFResource* aSource,
- nsIRDFResource* aProperty,
- PRBool aTruthValue,
- nsISimpleEnumerator** aTargets);
-
- NS_IMETHOD Assert(nsIRDFResource* aSource,
- nsIRDFResource* aProperty,
- nsIRDFNode* aTarget,
- PRBool aTruthValue);
-
- NS_IMETHOD Unassert(nsIRDFResource* aSource,
- nsIRDFResource* aProperty,
- nsIRDFNode* aTarget);
-
- NS_IMETHOD Change(nsIRDFResource* aSource,
- nsIRDFResource* aProperty,
- nsIRDFNode* aOldTarget,
- nsIRDFNode* aNewTarget);
-
- NS_IMETHOD Move(nsIRDFResource* aOldSource,
- nsIRDFResource* aNewSource,
- nsIRDFResource* aProperty,
- nsIRDFNode* aTarget);
-
- NS_IMETHOD HasAssertion(nsIRDFResource* aSource,
- nsIRDFResource* aProperty,
- nsIRDFNode* aTarget,
- PRBool aTruthValue,
- PRBool* aHasAssertion);
-
- NS_IMETHOD AddObserver(nsIRDFObserver* aObserver);
-
- NS_IMETHOD RemoveObserver(nsIRDFObserver* aObserver);
-
- NS_IMETHOD ArcLabelsIn(nsIRDFNode* aNode,
- nsISimpleEnumerator** aLabels);
-
- NS_IMETHOD ArcLabelsOut(nsIRDFResource* aSource,
- nsISimpleEnumerator** aLabels);
-
- NS_IMETHOD GetAllCommands(nsIRDFResource* aSource,
- nsIEnumerator/**/** aCommands);
-
- NS_IMETHOD GetAllCmds(nsIRDFResource* aSource,
- nsISimpleEnumerator/**/** aCommands);
-
- NS_IMETHOD IsCommandEnabled(nsISupportsArray/**/* aSources,
- nsIRDFResource* aCommand,
- nsISupportsArray/**/* aArguments,
- PRBool* aResult);
-
- NS_IMETHOD DoCommand(nsISupportsArray/**/* aSources,
- nsIRDFResource* aCommand,
- nsISupportsArray/**/* aArguments);
-
- NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult);
-
protected:
nsGlobalHistory(void);
virtual ~nsGlobalHistory();
@@ -806,6 +737,10 @@ nsGlobalHistory::RemovePage(const char *aURL)
NS_IMETHODIMP
nsGlobalHistory::GetLastVisitDate(const char *aURL, PRInt64 *_retval)
{
+ NS_PRECONDITION(aURL != nsnull, "null ptr");
+ if (! aURL)
+ return NS_ERROR_NULL_POINTER;
+
nsresult rv;
mdb_err err;