mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix for bug 499781 (Move some methods from nsILink to nsIContent). r=bz, sr=dbaron.
--HG-- extra : rebase_source : da0ec8bfb6825d2e55edd2f5b08a9e43b033a2a3
This commit is contained in:
parent
2f1f9cb597
commit
ed0899f1ce
@ -284,9 +284,9 @@ nsHTMLImageAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
|
||||
if (!domNode)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(domNode));
|
||||
nsCOMPtr<nsIContent> link(do_QueryInterface(domNode));
|
||||
if (link)
|
||||
link->GetHrefURI(aURI);
|
||||
*aURI = link->GetHrefURI();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -82,11 +82,7 @@ nsHTMLLinkAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
|
||||
*aState |= nsIAccessibleStates::STATE_SELECTABLE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILink> link = do_QueryInterface(mDOMNode);
|
||||
NS_ENSURE_STATE(link);
|
||||
|
||||
nsLinkState linkState;
|
||||
link->GetLinkState(linkState);
|
||||
nsLinkState linkState = content->GetLinkState();
|
||||
if (linkState == eLinkState_NotLink || linkState == eLinkState_Unknown) {
|
||||
// This is a either named anchor (a link with also a name attribute) or
|
||||
// it doesn't have any attributes. Check if 'click' event handler is
|
||||
@ -180,10 +176,11 @@ nsHTMLLinkAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
|
||||
if (aIndex != 0)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIContent> link(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_STATE(link);
|
||||
|
||||
return link->GetHrefURI(aURI);
|
||||
*aURI = link->GetHrefURI();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -192,13 +189,11 @@ nsHTMLLinkAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
|
||||
PRBool
|
||||
nsHTMLLinkAccessible::IsLinked()
|
||||
{
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(mDOMNode));
|
||||
nsCOMPtr<nsIContent> link(do_QueryInterface(mDOMNode));
|
||||
if (!link)
|
||||
return PR_FALSE;
|
||||
|
||||
nsLinkState linkState;
|
||||
nsresult rv = link->GetLinkState(linkState);
|
||||
nsLinkState linkState = link->GetLinkState();
|
||||
|
||||
return NS_SUCCEEDED(rv) && linkState != eLinkState_NotLink &&
|
||||
linkState != eLinkState_Unknown;
|
||||
return linkState != eLinkState_NotLink && linkState != eLinkState_Unknown;
|
||||
}
|
||||
|
@ -61,10 +61,17 @@ class nsIDocShell;
|
||||
class nsISMILAttr;
|
||||
#endif // MOZ_SMIL
|
||||
|
||||
enum nsLinkState {
|
||||
eLinkState_Unknown = 0,
|
||||
eLinkState_Unvisited = 1,
|
||||
eLinkState_Visited = 2,
|
||||
eLinkState_NotLink = 3
|
||||
};
|
||||
|
||||
// IID for the nsIContent interface
|
||||
#define NS_ICONTENT_IID \
|
||||
{ 0x08dadcc4, 0x057a, 0x4b8d, \
|
||||
{ 0x89, 0x43, 0x30, 0x0e, 0x61, 0xc6, 0x9d, 0x36 } }
|
||||
{ 0x4aaa38b8, 0x6bc1, 0x4d01, \
|
||||
{ 0xb6, 0x3d, 0xcd, 0x11, 0xc0, 0x84, 0x56, 0x9e } }
|
||||
|
||||
/**
|
||||
* A node of content in a document's content model. This interface
|
||||
@ -598,6 +605,40 @@ public:
|
||||
*/
|
||||
virtual PRBool IsLink(nsIURI** aURI) const = 0;
|
||||
|
||||
/**
|
||||
* Get the cached state of the link. If the state is unknown,
|
||||
* return eLinkState_Unknown.
|
||||
*
|
||||
* @return The cached link state of the link.
|
||||
*/
|
||||
virtual nsLinkState GetLinkState() const
|
||||
{
|
||||
return eLinkState_NotLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cached state of the link.
|
||||
*
|
||||
* @param aState The cached link state of the link.
|
||||
*/
|
||||
virtual void SetLinkState(nsLinkState aState)
|
||||
{
|
||||
NS_ASSERTION(aState == eLinkState_NotLink,
|
||||
"Need to override SetLinkState?");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pointer to the full href URI (fully resolved and canonicalized,
|
||||
* since it's an nsIURI object) for link elements.
|
||||
*
|
||||
* @return A pointer to the URI or null if the element is not a link or it
|
||||
* has no HREF attribute.
|
||||
*/
|
||||
virtual already_AddRefed<nsIURI> GetHrefURI() const
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give this element a chance to fire links that should be fired
|
||||
* automatically when loaded. If the element was an autoloading link
|
||||
|
@ -7305,10 +7305,7 @@ public:
|
||||
|
||||
// Throw away the cached link state so it gets refetched by the style
|
||||
// system
|
||||
nsCOMPtr<nsILink> link = do_QueryInterface(aContent);
|
||||
if (link) {
|
||||
link->SetLinkState(eLinkState_Unknown);
|
||||
}
|
||||
aContent->SetLinkState(eLinkState_Unknown);
|
||||
contentVisited.AppendObject(aContent);
|
||||
}
|
||||
};
|
||||
|
@ -45,8 +45,8 @@ class nsIURI;
|
||||
|
||||
// IID for the nsILink interface
|
||||
#define NS_ILINK_IID \
|
||||
{ 0x0c212bc4, 0xfcd7, 0x479d, \
|
||||
{ 0x8c, 0x3f, 0x3b, 0xe8, 0xe6, 0x78, 0x74, 0x50 } }
|
||||
{ 0x6f374a11, 0x212d, 0x47d6, \
|
||||
{ 0x94, 0xd1, 0xe6, 0x7c, 0x23, 0x4d, 0x34, 0x99 } }
|
||||
|
||||
/**
|
||||
* This interface allows SelectorMatches to get the canonical
|
||||
@ -60,31 +60,9 @@ public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINK_IID)
|
||||
|
||||
/**
|
||||
* Get the cached state of the link. If the state is unknown,
|
||||
* return eLinkState_Unknown.
|
||||
*
|
||||
* @param aState [out] The cached link state of the link.
|
||||
* @return NS_OK
|
||||
* GetLinkState/SetLinkState/GetHrefURI were moved to nsIContent.
|
||||
* @see nsIContent
|
||||
*/
|
||||
NS_IMETHOD GetLinkState(nsLinkState &aState) = 0;
|
||||
|
||||
/**
|
||||
* Set the cached state of the link.
|
||||
*
|
||||
* @param aState The cached link state of the link.
|
||||
* @return NS_OK
|
||||
*/
|
||||
NS_IMETHOD SetLinkState(nsLinkState aState) = 0;
|
||||
|
||||
/**
|
||||
* Get a pointer to the fully href URI (fully resolved and canonicalized,
|
||||
* since it's an nsIURI object).
|
||||
*
|
||||
* @param aURI [out] A pointer to be filled in with a pointer to the URI
|
||||
* If the element has no HREF attribute, it is set to nsnull.
|
||||
* @return NS_OK if the out pointer is filled in (possibly with nsnull)
|
||||
*/
|
||||
NS_IMETHOD GetHrefURI(nsIURI** aURI) = 0;
|
||||
|
||||
/**
|
||||
* Dispatch a LinkAdded event to the chrome event handler for this document.
|
||||
|
@ -1013,13 +1013,13 @@ nsGenericHTMLElement::IsHTMLLink(nsIURI** aURI) const
|
||||
{
|
||||
NS_PRECONDITION(aURI, "Must provide aURI out param");
|
||||
|
||||
GetHrefURIForAnchors(aURI);
|
||||
*aURI = GetHrefURIForAnchors().get();
|
||||
// We promise out param is non-null if we return true, so base rv on it
|
||||
return *aURI != nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetHrefURIForAnchors(nsIURI** aURI) const
|
||||
already_AddRefed<nsIURI>
|
||||
nsGenericHTMLElement::GetHrefURIForAnchors() const
|
||||
{
|
||||
// This is used by the three nsILink implementations and
|
||||
// nsHTMLStyleElement.
|
||||
@ -1027,9 +1027,10 @@ nsGenericHTMLElement::GetHrefURIForAnchors(nsIURI** aURI) const
|
||||
// Get href= attribute (relative URI).
|
||||
|
||||
// We use the nsAttrValue's copy of the URI string to avoid copying.
|
||||
GetURIAttr(nsGkAtoms::href, nsnull, PR_FALSE, aURI);
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
GetURIAttr(nsGkAtoms::href, nsnull, PR_FALSE, getter_AddRefs(uri));
|
||||
|
||||
return NS_OK;
|
||||
return uri.forget();
|
||||
}
|
||||
|
||||
void
|
||||
@ -3194,8 +3195,7 @@ nsGenericHTMLElement::SetPortInHrefURI(const nsAString &aPort)
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetProtocolFromHrefURI(nsAString& aProtocol)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
GetHrefURIForAnchors(getter_AddRefs(uri));
|
||||
nsCOMPtr<nsIURI> uri = GetHrefURIForAnchors();
|
||||
|
||||
if (!uri) {
|
||||
aProtocol.AssignLiteral("http");
|
||||
@ -3213,8 +3213,7 @@ nsGenericHTMLElement::GetHostFromHrefURI(nsAString& aHost)
|
||||
{
|
||||
aHost.Truncate();
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
GetHrefURIForAnchors(getter_AddRefs(uri));
|
||||
nsCOMPtr<nsIURI> uri = GetHrefURIForAnchors();
|
||||
if (!uri) {
|
||||
// Don't throw from these methods! Not a valid URI means return
|
||||
// empty string.
|
||||
@ -3238,8 +3237,7 @@ nsresult
|
||||
nsGenericHTMLElement::GetHostnameFromHrefURI(nsAString& aHostname)
|
||||
{
|
||||
aHostname.Truncate();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
GetHrefURIForAnchors(getter_AddRefs(uri));
|
||||
nsCOMPtr<nsIURI> uri = GetHrefURIForAnchors();
|
||||
if (!uri) {
|
||||
// Don't throw from these methods! Not a valid URI means return
|
||||
// empty string.
|
||||
@ -3264,8 +3262,7 @@ nsGenericHTMLElement::GetPathnameFromHrefURI(nsAString& aPathname)
|
||||
{
|
||||
aPathname.Truncate();
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
GetHrefURIForAnchors(getter_AddRefs(uri));
|
||||
nsCOMPtr<nsIURI> uri = GetHrefURIForAnchors();
|
||||
if (!uri) {
|
||||
// Don't throw from these methods! Not a valid URI means return
|
||||
// empty string.
|
||||
@ -3294,8 +3291,7 @@ nsresult
|
||||
nsGenericHTMLElement::GetSearchFromHrefURI(nsAString& aSearch)
|
||||
{
|
||||
aSearch.Truncate();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
GetHrefURIForAnchors(getter_AddRefs(uri));
|
||||
nsCOMPtr<nsIURI> uri = GetHrefURIForAnchors();
|
||||
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
|
||||
if (!url) {
|
||||
// Don't throw from these methods! Not a valid URI means return
|
||||
@ -3319,8 +3315,7 @@ nsresult
|
||||
nsGenericHTMLElement::GetPortFromHrefURI(nsAString& aPort)
|
||||
{
|
||||
aPort.Truncate();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
GetHrefURIForAnchors(getter_AddRefs(uri));
|
||||
nsCOMPtr<nsIURI> uri = GetHrefURIForAnchors();
|
||||
if (!uri) {
|
||||
// Don't throw from these methods! Not a valid URI means return
|
||||
// empty string.
|
||||
@ -3350,8 +3345,7 @@ nsresult
|
||||
nsGenericHTMLElement::GetHashFromHrefURI(nsAString& aHash)
|
||||
{
|
||||
aHash.Truncate();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
GetHrefURIForAnchors(getter_AddRefs(uri));
|
||||
nsCOMPtr<nsIURI> uri = GetHrefURIForAnchors();
|
||||
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
|
||||
if (!url) {
|
||||
// Don't throw from these methods! Not a valid URI means return
|
||||
|
@ -196,7 +196,7 @@ public:
|
||||
PRBool IsHTMLLink(nsIURI** aURI) const;
|
||||
|
||||
// Used by A, AREA, LINK, and STYLE.
|
||||
nsresult GetHrefURIForAnchors(nsIURI** aURI) const;
|
||||
already_AddRefed<nsIURI> GetHrefURIForAnchors() const;
|
||||
|
||||
// As above, but makes sure to return a URI object that we can mutate with
|
||||
// impunity without changing our current URI. That is, if the URI is cached
|
||||
|
@ -99,9 +99,6 @@ public:
|
||||
NS_DECL_NSIDOMNSHTMLANCHORELEMENT2
|
||||
|
||||
// nsILink
|
||||
NS_IMETHOD GetLinkState(nsLinkState &aState);
|
||||
NS_IMETHOD SetLinkState(nsLinkState aState);
|
||||
NS_IMETHOD GetHrefURI(nsIURI** aURI);
|
||||
NS_IMETHOD LinkAdded() { return NS_OK; }
|
||||
NS_IMETHOD LinkRemoved() { return NS_OK; }
|
||||
|
||||
@ -119,6 +116,9 @@ public:
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
virtual PRBool IsLink(nsIURI** aURI) const;
|
||||
virtual void GetLinkTarget(nsAString& aTarget);
|
||||
virtual nsLinkState GetLinkState() const;
|
||||
virtual void SetLinkState(nsLinkState aState);
|
||||
virtual already_AddRefed<nsIURI> GetHrefURI() const;
|
||||
|
||||
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue, PRBool aNotify)
|
||||
@ -422,24 +422,22 @@ nsHTMLAnchorElement::SetPing(const nsAString& aValue)
|
||||
return SetAttr(kNameSpaceID_None, nsGkAtoms::ping, aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::GetLinkState(nsLinkState &aState)
|
||||
nsLinkState
|
||||
nsHTMLAnchorElement::GetLinkState() const
|
||||
{
|
||||
aState = mLinkState;
|
||||
return NS_OK;
|
||||
return mLinkState;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsHTMLAnchorElement::SetLinkState(nsLinkState aState)
|
||||
{
|
||||
mLinkState = aState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::GetHrefURI(nsIURI** aURI)
|
||||
already_AddRefed<nsIURI>
|
||||
nsHTMLAnchorElement::GetHrefURI() const
|
||||
{
|
||||
return GetHrefURIForAnchors(aURI);
|
||||
return GetHrefURIForAnchors();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -81,9 +81,6 @@ public:
|
||||
NS_DECL_NSIDOMNSHTMLAREAELEMENT2
|
||||
|
||||
// nsILink
|
||||
NS_IMETHOD GetLinkState(nsLinkState &aState);
|
||||
NS_IMETHOD SetLinkState(nsLinkState aState);
|
||||
NS_IMETHOD GetHrefURI(nsIURI** aURI);
|
||||
NS_IMETHOD LinkAdded() { return NS_OK; }
|
||||
NS_IMETHOD LinkRemoved() { return NS_OK; }
|
||||
|
||||
@ -91,6 +88,9 @@ public:
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
virtual PRBool IsLink(nsIURI** aURI) const;
|
||||
virtual void GetLinkTarget(nsAString& aTarget);
|
||||
virtual nsLinkState GetLinkState() const;
|
||||
virtual void SetLinkState(nsLinkState aState);
|
||||
virtual already_AddRefed<nsIURI> GetHrefURI() const;
|
||||
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
@ -320,22 +320,20 @@ nsHTMLAreaElement::SetPing(const nsAString& aValue)
|
||||
return SetAttr(kNameSpaceID_None, nsGkAtoms::ping, aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::GetLinkState(nsLinkState &aState)
|
||||
nsLinkState
|
||||
nsHTMLAreaElement::GetLinkState() const
|
||||
{
|
||||
aState = mLinkState;
|
||||
return NS_OK;
|
||||
return mLinkState;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsHTMLAreaElement::SetLinkState(nsLinkState aState)
|
||||
{
|
||||
mLinkState = aState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLAreaElement::GetHrefURI(nsIURI** aURI)
|
||||
already_AddRefed<nsIURI>
|
||||
nsHTMLAreaElement::GetHrefURI() const
|
||||
{
|
||||
return GetHrefURIForAnchors(aURI);
|
||||
return GetHrefURIForAnchors();
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ nsHTMLDNSPrefetch::nsDeferrals::SubmitQueue()
|
||||
|
||||
if (mEntries[mTail].mElement->GetOwnerDoc()) {
|
||||
nsCOMPtr<nsIURI> hrefURI;
|
||||
mEntries[mTail].mElement->GetHrefURIForAnchors(getter_AddRefs(hrefURI));
|
||||
hrefURI = mEntries[mTail].mElement->GetHrefURIForAnchors();
|
||||
if (hrefURI)
|
||||
hrefURI->GetAsciiHost(hostName);
|
||||
|
||||
|
@ -85,9 +85,6 @@ public:
|
||||
NS_DECL_NSIDOMHTMLLINKELEMENT
|
||||
|
||||
// nsILink
|
||||
NS_IMETHOD GetLinkState(nsLinkState &aState);
|
||||
NS_IMETHOD SetLinkState(nsLinkState aState);
|
||||
NS_IMETHOD GetHrefURI(nsIURI** aURI);
|
||||
NS_IMETHOD LinkAdded();
|
||||
NS_IMETHOD LinkRemoved();
|
||||
|
||||
@ -112,6 +109,9 @@ public:
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
virtual PRBool IsLink(nsIURI** aURI) const;
|
||||
virtual void GetLinkTarget(nsAString& aTarget);
|
||||
virtual nsLinkState GetLinkState() const;
|
||||
virtual void SetLinkState(nsLinkState aState);
|
||||
virtual already_AddRefed<nsIURI> GetHrefURI() const;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
@ -377,24 +377,22 @@ nsHTMLLinkElement::GetLinkTarget(nsAString& aTarget)
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLLinkElement::GetLinkState(nsLinkState &aState)
|
||||
nsLinkState
|
||||
nsHTMLLinkElement::GetLinkState() const
|
||||
{
|
||||
aState = mLinkState;
|
||||
return NS_OK;
|
||||
return mLinkState;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsHTMLLinkElement::SetLinkState(nsLinkState aState)
|
||||
{
|
||||
mLinkState = aState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLLinkElement::GetHrefURI(nsIURI** aURI)
|
||||
already_AddRefed<nsIURI>
|
||||
nsHTMLLinkElement::GetHrefURI() const
|
||||
{
|
||||
return GetHrefURIForAnchors(aURI);
|
||||
return GetHrefURIForAnchors();
|
||||
}
|
||||
|
||||
void
|
||||
@ -402,7 +400,7 @@ nsHTMLLinkElement::GetStyleSheetURL(PRBool* aIsInline,
|
||||
nsIURI** aURI)
|
||||
{
|
||||
*aIsInline = PR_FALSE;
|
||||
GetHrefURIForAnchors(aURI);
|
||||
*aURI = GetHrefURIForAnchors().get();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ nsHTMLStyleElement::GetStyleSheetURL(PRBool* aIsInline,
|
||||
return;
|
||||
}
|
||||
|
||||
GetHrefURIForAnchors(aURI);
|
||||
*aURI = GetHrefURIForAnchors().get();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -120,33 +120,27 @@ nsSVGAElement::GetTarget(nsIDOMSVGAnimatedString * *aTarget)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsILink methods
|
||||
// nsIContent methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAElement::GetLinkState(nsLinkState &aState)
|
||||
nsLinkState
|
||||
nsSVGAElement::GetLinkState() const
|
||||
{
|
||||
aState = mLinkState;
|
||||
return NS_OK;
|
||||
return mLinkState;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsSVGAElement::SetLinkState(nsLinkState aState)
|
||||
{
|
||||
mLinkState = aState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSVGAElement::GetHrefURI(nsIURI** aURI)
|
||||
already_AddRefed<nsIURI>
|
||||
nsSVGAElement::GetHrefURI() const
|
||||
{
|
||||
*aURI = nsnull;
|
||||
return NS_OK; // XXX GetHrefURIForAnchors(aURI);
|
||||
return nsnull; // XXX GetHrefURIForAnchors();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods
|
||||
|
||||
PRBool
|
||||
nsSVGAElement::IsFocusable(PRInt32 *aTabIndex)
|
||||
{
|
||||
|
@ -71,9 +71,6 @@ public:
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
// nsILink
|
||||
NS_IMETHOD GetLinkState(nsLinkState &aState);
|
||||
NS_IMETHOD SetLinkState(nsLinkState aState);
|
||||
NS_IMETHOD GetHrefURI(nsIURI** aURI);
|
||||
NS_IMETHOD LinkAdded() { return NS_OK; }
|
||||
NS_IMETHOD LinkRemoved() { return NS_OK; }
|
||||
|
||||
@ -81,6 +78,9 @@ public:
|
||||
virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);
|
||||
virtual PRBool IsLink(nsIURI** aURI) const;
|
||||
virtual void GetLinkTarget(nsAString& aTarget);
|
||||
virtual nsLinkState GetLinkState() const;
|
||||
virtual void SetLinkState(nsLinkState aState);
|
||||
virtual already_AddRefed<nsIURI> GetHrefURI() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -1380,7 +1380,7 @@ nsImageFrame::GetAnchorHREFTargetAndNode(nsIURI** aHref, nsString& aTarget,
|
||||
content; content = content->GetParent()) {
|
||||
nsCOMPtr<nsILink> link(do_QueryInterface(content));
|
||||
if (link) {
|
||||
link->GetHrefURI(aHref);
|
||||
*aHref = content->GetHrefURI().get();
|
||||
status = (*aHref != nsnull);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(do_QueryInterface(content));
|
||||
|
@ -909,8 +909,7 @@ RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
|
||||
mPresContext ? mPresContext->GetLinkHandler() : nsnull;
|
||||
if (mIsHTMLContent && mHasAttributes) {
|
||||
// check if it is an HTML Link
|
||||
if(nsStyleUtil::IsHTMLLink(aContent, mContentTag, linkHandler,
|
||||
&mLinkState)) {
|
||||
if(nsStyleUtil::IsHTMLLink(aContent, linkHandler, &mLinkState)) {
|
||||
mIsLink = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -49,13 +49,12 @@
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsPresContext.h" // for nsCompatability
|
||||
#include "nsILinkHandler.h"
|
||||
#include "nsString.h"
|
||||
#include "nsChangeHint.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
class nsIStyleSheet;
|
||||
class nsPresContext;
|
||||
class nsIContent;
|
||||
class nsIAtom;
|
||||
class nsICSSPseudoComparator;
|
||||
class nsRuleWalker;
|
||||
|
@ -42,7 +42,6 @@
|
||||
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsILinkHandler.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
@ -429,55 +428,40 @@ GetLinkStateFromURI(nsIURI* aURI, nsIContent* aContent,
|
||||
}
|
||||
|
||||
/*static*/
|
||||
PRBool nsStyleUtil::IsHTMLLink(nsIContent *aContent, nsIAtom *aTag,
|
||||
PRBool nsStyleUtil::IsHTMLLink(nsIContent *aContent,
|
||||
nsILinkHandler *aLinkHandler,
|
||||
nsLinkState *aState)
|
||||
{
|
||||
NS_ASSERTION(aContent && aState, "null arg in IsHTMLLink");
|
||||
NS_ASSERTION(aContent->IsNodeOfType(nsINode::eHTML),
|
||||
"Only use this function with HTML elements");
|
||||
NS_ASSERTION(aState, "null arg in IsHTMLLink");
|
||||
|
||||
// check for:
|
||||
// - HTML ANCHOR with valid HREF
|
||||
// - HTML LINK with valid HREF
|
||||
// - HTML AREA with valid HREF
|
||||
nsLinkState linkState = aContent->GetLinkState();
|
||||
if (linkState == eLinkState_Unknown) {
|
||||
// if it is an anchor, area or link then check the href attribute
|
||||
// make sure this anchor has a link even if we are not testing state
|
||||
// if there is no link, then this anchor is not really a linkpseudo.
|
||||
// bug=23209
|
||||
|
||||
PRBool result = PR_FALSE;
|
||||
nsCOMPtr<nsIURI> hrefURI = aContent->GetHrefURI();
|
||||
|
||||
if ((aTag == nsGkAtoms::a) ||
|
||||
(aTag == nsGkAtoms::link) ||
|
||||
(aTag == nsGkAtoms::area)) {
|
||||
|
||||
nsCOMPtr<nsILink> link( do_QueryInterface(aContent) );
|
||||
// In XML documents, this can be null.
|
||||
if (link) {
|
||||
nsLinkState linkState;
|
||||
link->GetLinkState(linkState);
|
||||
if (linkState == eLinkState_Unknown) {
|
||||
// if it is an anchor, area or link then check the href attribute
|
||||
// make sure this anchor has a link even if we are not testing state
|
||||
// if there is no link, then this anchor is not really a linkpseudo.
|
||||
// bug=23209
|
||||
|
||||
nsCOMPtr<nsIURI> hrefURI;
|
||||
link->GetHrefURI(getter_AddRefs(hrefURI));
|
||||
|
||||
if (hrefURI) {
|
||||
linkState = GetLinkStateFromURI(hrefURI, aContent, aLinkHandler);
|
||||
} else {
|
||||
linkState = eLinkState_NotLink;
|
||||
}
|
||||
if (linkState != eLinkState_NotLink && aContent->IsInDoc()) {
|
||||
aContent->GetCurrentDoc()->AddStyleRelevantLink(aContent, hrefURI);
|
||||
}
|
||||
link->SetLinkState(linkState);
|
||||
}
|
||||
if (linkState != eLinkState_NotLink) {
|
||||
*aState = linkState;
|
||||
result = PR_TRUE;
|
||||
}
|
||||
if (hrefURI) {
|
||||
linkState = GetLinkStateFromURI(hrefURI, aContent, aLinkHandler);
|
||||
} else {
|
||||
linkState = eLinkState_NotLink;
|
||||
}
|
||||
if (linkState != eLinkState_NotLink && aContent->IsInDoc()) {
|
||||
aContent->GetCurrentDoc()->AddStyleRelevantLink(aContent, hrefURI);
|
||||
}
|
||||
aContent->SetLinkState(linkState);
|
||||
}
|
||||
if (linkState == eLinkState_NotLink) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return result;
|
||||
*aState = linkState;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/*static*/
|
||||
|
@ -69,8 +69,7 @@ public:
|
||||
|
||||
static PRInt32 ConstrainFontWeight(PRInt32 aWeight);
|
||||
|
||||
static PRBool IsHTMLLink(nsIContent *aContent, nsIAtom *aTag,
|
||||
nsILinkHandler *aLinkHandler,
|
||||
static PRBool IsHTMLLink(nsIContent *aContent, nsILinkHandler *aLinkHandler,
|
||||
nsLinkState *aState);
|
||||
static PRBool IsLink(nsIContent *aContent, nsILinkHandler *aLinkHandler,
|
||||
nsLinkState *aState);
|
||||
|
@ -38,11 +38,11 @@
|
||||
#define nsILinkHandler_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
class nsIInputStream;
|
||||
class nsIDocShell;
|
||||
class nsIRequest;
|
||||
class nsIContent;
|
||||
class nsString;
|
||||
class nsGUIEvent;
|
||||
|
||||
@ -50,13 +50,6 @@ class nsGUIEvent;
|
||||
#define NS_ILINKHANDLER_IID \
|
||||
{ 0x514bc565, 0x8d38, 0x4dde,{0xb4, 0xeb, 0xe7, 0xb5, 0x01, 0x2b, 0xf4, 0x64}}
|
||||
|
||||
enum nsLinkState {
|
||||
eLinkState_Unknown = 0,
|
||||
eLinkState_Unvisited = 1,
|
||||
eLinkState_Visited = 2,
|
||||
eLinkState_NotLink = 3
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface used for handling clicks on links
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user