From cafeb4633915e7eefb6dd1e16d1177ae1072b6e4 Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Tue, 18 May 1999 05:21:37 +0000 Subject: [PATCH] Enable link coloring. git-svn-id: svn://10.0.0.236/trunk@32043 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 42 +++++++++++++++++++++++----- mozilla/webshell/src/makefile.win | 1 + mozilla/webshell/src/nsWebShell.cpp | 42 +++++++++++++++++++++++----- 3 files changed, 71 insertions(+), 14 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 858e5d0e571..9966aa260d0 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -57,6 +57,7 @@ #include "nsIPresShell.h" #include "nsIStreamObserver.h" #include "nsIWebShellServices.h" +#include "nsIGlobalHistory.h" #ifdef XP_PC #include @@ -2228,14 +2229,41 @@ nsWebShell:: GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState) { nsString URLSpec(aURLSpec); aState = eLinkState_Unvisited; -#ifdef NS_DEBUG - if (URLSpec.Equals("http://visited/")) { - aState = eLinkState_Visited; + + static NS_DEFINE_CID(kGlobalHistoryCID, NS_GLOBALHISTORY_CID); + + nsresult rv; + NS_WITH_SERVICE(nsIGlobalHistory, history, kGlobalHistoryCID, &rv); + if (NS_SUCCEEDED(rv)) { + // XXX aURLSpec should really be a char*, not a PRUnichar*. + nsAutoString urlStr(aURLSpec); + + char buf[256]; + char* url = buf; + + if (urlStr.Length() >= sizeof(buf)) { + url = new char[urlStr.Length() + 1]; + if (! url) return NS_ERROR_OUT_OF_MEMORY; + } + + urlStr.ToCString(url, urlStr.Length() + 1); + + PRInt64 lastVisitDate; + rv = history->GetLastVisitDate(url, &lastVisitDate); + + if (url != buf) + delete[] url; + + if (NS_FAILED(rv)) return rv; + + // a last-visit-date of zero means we've never seen it before; so + // if it's not zero, we must've seen it. + if (! LL_IS_ZERO(lastVisitDate)) + aState = eLinkState_Visited; + + // XXX how to tell if eLinkState_OutOfDate? } - else if (URLSpec.Equals("http://out-of-date/")) { - aState = eLinkState_OutOfDate; - } -#endif + return NS_OK; } diff --git a/mozilla/webshell/src/makefile.win b/mozilla/webshell/src/makefile.win index 41d4a899980..0705269d75c 100644 --- a/mozilla/webshell/src/makefile.win +++ b/mozilla/webshell/src/makefile.win @@ -42,6 +42,7 @@ LINCS=-I..\public -I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \ -I$(PUBLIC)\plugin -I$(PUBLIC)\java -I$(PUBLIC)\pref -I$(PUBLIC)\profile \ -I$(PUBLIC)\js -I$(DEPTH)\include -I$(PUBLIC)\jsurl \ -I$(PUBLIC)\editor -I$(PUBLIC)\rdf \ + -I$(PUBLIC)\xpfe\components \ -I$(PUBLIC)\walletlib \ -I$(PUBLIC)\oji \ -I$(PUBLIC)\uconv \ diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 858e5d0e571..9966aa260d0 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -57,6 +57,7 @@ #include "nsIPresShell.h" #include "nsIStreamObserver.h" #include "nsIWebShellServices.h" +#include "nsIGlobalHistory.h" #ifdef XP_PC #include @@ -2228,14 +2229,41 @@ nsWebShell:: GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState) { nsString URLSpec(aURLSpec); aState = eLinkState_Unvisited; -#ifdef NS_DEBUG - if (URLSpec.Equals("http://visited/")) { - aState = eLinkState_Visited; + + static NS_DEFINE_CID(kGlobalHistoryCID, NS_GLOBALHISTORY_CID); + + nsresult rv; + NS_WITH_SERVICE(nsIGlobalHistory, history, kGlobalHistoryCID, &rv); + if (NS_SUCCEEDED(rv)) { + // XXX aURLSpec should really be a char*, not a PRUnichar*. + nsAutoString urlStr(aURLSpec); + + char buf[256]; + char* url = buf; + + if (urlStr.Length() >= sizeof(buf)) { + url = new char[urlStr.Length() + 1]; + if (! url) return NS_ERROR_OUT_OF_MEMORY; + } + + urlStr.ToCString(url, urlStr.Length() + 1); + + PRInt64 lastVisitDate; + rv = history->GetLastVisitDate(url, &lastVisitDate); + + if (url != buf) + delete[] url; + + if (NS_FAILED(rv)) return rv; + + // a last-visit-date of zero means we've never seen it before; so + // if it's not zero, we must've seen it. + if (! LL_IS_ZERO(lastVisitDate)) + aState = eLinkState_Visited; + + // XXX how to tell if eLinkState_OutOfDate? } - else if (URLSpec.Equals("http://out-of-date/")) { - aState = eLinkState_OutOfDate; - } -#endif + return NS_OK; }