mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 598833 part 8. Create an explicit API to request link state updates. r=smaug,sdwilsh
This is a bit of a hack to make sure that we update link state sometime when doing style resolution, pending a better setup in bug 660959 for determining when to resolve the link URI.
This commit is contained in:
parent
b5bc3817ce
commit
a66e7f8073
@ -100,6 +100,17 @@ public:
|
||||
return IntrinsicState() | mState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request an update of the link state for this element. This will
|
||||
* make sure that if the element is a link at all then either
|
||||
* NS_EVENT_STATE_VISITED or NS_EVENT_STATE_UNVISITED is set in
|
||||
* mState, and a history lookup kicked off if needed to find out
|
||||
* whether the link is really visited. This method will NOT send any
|
||||
* state change notifications. If you want them to happen for this
|
||||
* call, you need to handle them yourself.
|
||||
*/
|
||||
virtual void RequestLinkStateUpdate();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Method to get the _intrinsic_ content state of this element. This is the
|
||||
@ -109,6 +120,11 @@ protected:
|
||||
*/
|
||||
virtual nsEventStates IntrinsicState() const;
|
||||
|
||||
/**
|
||||
* Method to update mState with link state information. This does not notify.
|
||||
*/
|
||||
void UpdateLinkState(nsEventStates aState);
|
||||
|
||||
private:
|
||||
// Need to allow the ESM, nsGlobalWindow, and the focus manager to
|
||||
// set our state
|
||||
|
@ -802,6 +802,22 @@ Element::NotifyStateChange(nsEventStates aStates)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Element::RequestLinkStateUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Element::UpdateLinkState(nsEventStates aState)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!aState.HasAtLeastOneOfStates(~(NS_EVENT_STATE_VISITED |
|
||||
NS_EVENT_STATE_UNVISITED)),
|
||||
"Unexpected link state bits");
|
||||
mState =
|
||||
(mState & ~(NS_EVENT_STATE_VISITED | NS_EVENT_STATE_UNVISITED)) |
|
||||
aState;
|
||||
}
|
||||
|
||||
void
|
||||
nsIContent::UpdateEditableState()
|
||||
{
|
||||
|
@ -99,6 +99,7 @@ public:
|
||||
virtual PRBool IsLink(nsIURI** aURI) const;
|
||||
virtual void GetLinkTarget(nsAString& aTarget);
|
||||
virtual nsLinkState GetLinkState() const;
|
||||
virtual void RequestLinkStateUpdate();
|
||||
virtual already_AddRefed<nsIURI> GetHrefURI() const;
|
||||
|
||||
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
@ -368,6 +369,12 @@ nsHTMLAnchorElement::GetLinkState() const
|
||||
return Link::GetLinkState();
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLAnchorElement::RequestLinkStateUpdate()
|
||||
{
|
||||
UpdateLinkState(Link::LinkState());
|
||||
}
|
||||
|
||||
already_AddRefed<nsIURI>
|
||||
nsHTMLAnchorElement::GetHrefURI() const
|
||||
{
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
virtual PRBool IsLink(nsIURI** aURI) const;
|
||||
virtual void GetLinkTarget(nsAString& aTarget);
|
||||
virtual nsLinkState GetLinkState() const;
|
||||
virtual void RequestLinkStateUpdate();
|
||||
virtual already_AddRefed<nsIURI> GetHrefURI() const;
|
||||
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
@ -295,6 +296,12 @@ nsHTMLAreaElement::GetLinkState() const
|
||||
return Link::GetLinkState();
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLAreaElement::RequestLinkStateUpdate()
|
||||
{
|
||||
UpdateLinkState(Link::LinkState());
|
||||
}
|
||||
|
||||
already_AddRefed<nsIURI>
|
||||
nsHTMLAreaElement::GetHrefURI() const
|
||||
{
|
||||
|
@ -112,6 +112,7 @@ public:
|
||||
virtual PRBool IsLink(nsIURI** aURI) const;
|
||||
virtual void GetLinkTarget(nsAString& aTarget);
|
||||
virtual nsLinkState GetLinkState() const;
|
||||
virtual void RequestLinkStateUpdate();
|
||||
virtual already_AddRefed<nsIURI> GetHrefURI() const;
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
@ -378,6 +379,12 @@ nsHTMLLinkElement::GetLinkState() const
|
||||
return Link::GetLinkState();
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLLinkElement::RequestLinkStateUpdate()
|
||||
{
|
||||
UpdateLinkState(Link::LinkState());
|
||||
}
|
||||
|
||||
already_AddRefed<nsIURI>
|
||||
nsHTMLLinkElement::GetHrefURI() const
|
||||
{
|
||||
|
@ -160,6 +160,12 @@ nsSVGAElement::GetLinkState() const
|
||||
return Link::GetLinkState();
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGAElement::RequestLinkStateUpdate()
|
||||
{
|
||||
UpdateLinkState(Link::LinkState());
|
||||
}
|
||||
|
||||
already_AddRefed<nsIURI>
|
||||
nsSVGAElement::GetHrefURI() const
|
||||
{
|
||||
|
@ -91,6 +91,7 @@ public:
|
||||
virtual PRBool IsLink(nsIURI** aURI) const;
|
||||
virtual void GetLinkTarget(nsAString& aTarget);
|
||||
virtual nsLinkState GetLinkState() const;
|
||||
virtual void RequestLinkStateUpdate();
|
||||
virtual already_AddRefed<nsIURI> GetHrefURI() const;
|
||||
virtual nsEventStates IntrinsicState() const;
|
||||
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
|
@ -1149,6 +1149,8 @@ static void GetLang(nsIContent* aContent, nsString& aLang)
|
||||
nsEventStates
|
||||
nsCSSRuleProcessor::GetContentState(Element* aElement)
|
||||
{
|
||||
// FIXME: RequestLinkStateUpdate is a hack; see bug 660959.
|
||||
aElement->RequestLinkStateUpdate();
|
||||
nsEventStates state = aElement->State();
|
||||
|
||||
// If we are not supposed to mark visited links as such, be sure to
|
||||
@ -1168,6 +1170,8 @@ nsCSSRuleProcessor::GetContentState(Element* aElement)
|
||||
PRBool
|
||||
nsCSSRuleProcessor::IsLink(Element* aElement)
|
||||
{
|
||||
// FIXME: RequestLinkStateUpdate is a hack; see bug 660959.
|
||||
aElement->RequestLinkStateUpdate();
|
||||
nsEventStates state = aElement->State();
|
||||
return state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED | NS_EVENT_STATE_UNVISITED);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user