diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index b7420b2ed9b8..e3fede4be1ab 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -11347,6 +11347,30 @@ nsDocShell::OnLeaveLink() return rv; } +NS_IMETHODIMP +nsDocShell::GetLinkState(nsIURI* aLinkURI, nsLinkState& aState) +{ + if (!aLinkURI) { + // No uri means not a link + aState = eLinkState_NotLink; + return NS_OK; + } + + aState = eLinkState_Unvisited; + + // no history, leave state unchanged + if (!mGlobalHistory) + return NS_OK; + + PRBool isVisited; + NS_ENSURE_SUCCESS(mGlobalHistory->IsVisited(aLinkURI, &isVisited), + NS_ERROR_FAILURE); + if (isVisited) + aState = eLinkState_Visited; + + return NS_OK; +} + //---------------------------------------------------------------------- // Web Shell Services API diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index d0fc83e03939..00c21e8952e3 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -277,6 +277,7 @@ public: nsIURI* aURI, const PRUnichar* aTargetSpec); NS_IMETHOD OnLeaveLink(); + NS_IMETHOD GetLinkState(nsIURI* aLinkURI, nsLinkState& aState); nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(PRUint32 aLoadType); PRUint32 ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType); diff --git a/webshell/public/nsILinkHandler.h b/webshell/public/nsILinkHandler.h index 4b62d4ccc6dd..b860cd34b4c9 100644 --- a/webshell/public/nsILinkHandler.h +++ b/webshell/public/nsILinkHandler.h @@ -48,7 +48,7 @@ class nsGUIEvent; // Interface ID for nsILinkHandler #define NS_ILINKHANDLER_IID \ - { 0x71627c30, 0xd3c5, 0x4ad0,{0xb5, 0x33, 0x6e, 0x01, 0x91, 0xf2, 0x79, 0x32}} + { 0x514bc565, 0x8d38, 0x4dde,{0xb4, 0xeb, 0xe7, 0xb5, 0x01, 0x2b, 0xf4, 0x64}} /** * Interface used for handling clicks on links @@ -112,6 +112,12 @@ public: * Process the mouse leaving a link. */ NS_IMETHOD OnLeaveLink() = 0; + + + /** + * Get the state of a link to a given absolute URL + */ + NS_IMETHOD GetLinkState(nsIURI* aLinkURI, nsLinkState& aState) = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsILinkHandler, NS_ILINKHANDLER_IID)