diff --git a/mozilla/webshell/public/nsILinkHandler.h b/mozilla/webshell/public/nsILinkHandler.h index 8163ef04eed..9acd5d550c7 100644 --- a/mozilla/webshell/public/nsILinkHandler.h +++ b/mozilla/webshell/public/nsILinkHandler.h @@ -29,6 +29,14 @@ struct nsGUIEvent; { 0x52bd1e30, 0xce3f, 0x11d1, \ {0x93, 0x28, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } +enum nsLinkState { + eLinkState_Unvisited = 0, + eLinkState_Visited = 1, + eLinkState_OutOfDate = 2, // visited, but the cache is stale + eLinkState_Active = 3, // mouse is down on link + eLinkState_Hover = 4 // mouse is hovering over link +}; + /** * Interface used for handling clicks on links */ @@ -46,6 +54,11 @@ public: */ NS_IMETHOD OnLinkClick(nsIFrame* aFrame, const nsString& aURLSpec, const nsString& aTargetSpec) = 0; + + /** + * Get the state of a link to a given absolute URL + */ + NS_IMETHOD GetLinkState(const nsString& aURLSpec, nsLinkState& aState) = 0; }; // Standard link handler that does what you would expect (XXX doc...) diff --git a/mozilla/webshell/src/nsLinkHandler.cpp b/mozilla/webshell/src/nsLinkHandler.cpp index a540ee16af9..57eb551cebd 100644 --- a/mozilla/webshell/src/nsLinkHandler.cpp +++ b/mozilla/webshell/src/nsLinkHandler.cpp @@ -42,6 +42,7 @@ public: NS_IMETHOD GetWebWidget(nsIWebWidget** aResult); NS_IMETHOD OnLinkClick(nsIFrame* aFrame, const nsString& aURLSpec, const nsString& aTargetSpec); + NS_IMETHOD GetLinkState(const nsString& aURLSpec, nsLinkState& aState); void HandleLinkClickEvent(const nsString& aURLSpec, const nsString& aTargetSpec); @@ -153,6 +154,28 @@ NS_IMETHODIMP LinkHandlerImpl::OnLinkClick(nsIFrame* aFrame, return NS_OK; } +NS_IMETHODIMP LinkHandlerImpl::GetLinkState(const nsString& aURLSpec, nsLinkState& aState) +{ + // XXX not yet implemented + aState = eLinkState_Unvisited; + +#ifdef NS_DEBUG + if (aURLSpec.Equals("http://visited/")) { + aState = eLinkState_Visited; + } + else if (aURLSpec.Equals("http://out-of-date/")) { + aState = eLinkState_OutOfDate; + } + else if (aURLSpec.Equals("http://active/")) { + aState = eLinkState_Active; + } + else if (aURLSpec.Equals("http://hover/")) { + aState = eLinkState_Hover; + } +#endif + return NS_OK; +} + void LinkHandlerImpl::HandleLinkClickEvent(const nsString& aURLSpec, const nsString& aTargetSpec) { diff --git a/mozilla/webshell/tests/viewer/samples/test1.html b/mozilla/webshell/tests/viewer/samples/test1.html index ece2a9deae6..7056367ade3 100644 --- a/mozilla/webshell/tests/viewer/samples/test1.html +++ b/mozilla/webshell/tests/viewer/samples/test1.html @@ -58,6 +58,12 @@ H4 { color: yellow;


Here is an example of bold, italic and bold-italic


+

Some links to test pseudo-classes

+

link

+

visited

+

outofdate

+

active

+

hover

Bulleted List