Bug 461199 (Part 30) - Fixes invalidation issues when changing the href attribute.

r=bz
This commit is contained in:
Shawn Wilsher 2010-02-24 08:37:38 -08:00
Родитель 44f75ebc87
Коммит 4dce570127
6 изменённых файлов: 48 добавлений и 17 удалений

Просмотреть файл

@ -60,7 +60,7 @@ public:
static const nsLinkState defaultState = eLinkState_Unknown;
Link();
virtual nsLinkState GetLinkState() const;
nsLinkState GetLinkState() const;
virtual void SetLinkState(nsLinkState aState);
/**
@ -100,7 +100,7 @@ public:
* true if ResetLinkState should notify the owning document about style
* changes or false if it should not.
*/
virtual void ResetLinkState(bool aNotify);
void ResetLinkState(bool aNotify);
protected:
virtual ~Link();

Просмотреть файл

@ -431,21 +431,31 @@ nsHTMLAnchorElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify)
{
if (aName == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
nsAutoString val;
GetHref(val);
if (!val.Equals(aValue)) {
Link::ResetLinkState(!!aNotify);
}
}
if (aName == nsGkAtoms::accesskey && kNameSpaceID_None == aNameSpaceID) {
RegUnRegAccessKey(PR_FALSE);
}
bool reset = false;
if (aName == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
nsAutoString val;
GetHref(val);
if (!val.Equals(aValue)) {
reset = true;
}
}
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
// The ordering of the parent class's SetAttr call and Link::ResetLinkState
// is important here! The attribute is not set until SetAttr returns, and
// we will need the updated attribute value because notifying the document
// that content states have changed will call IntrinsicState, which will try
// to get updated information about the visitedness from Link.
if (reset) {
Link::ResetLinkState(!!aNotify);
}
if (aName == nsGkAtoms::accesskey && kNameSpaceID_None == aNameSpaceID &&
!aValue.IsEmpty()) {
RegUnRegAccessKey(PR_TRUE);

Просмотреть файл

@ -243,13 +243,18 @@ nsHTMLAreaElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
RegUnRegAccessKey(PR_FALSE);
}
nsresult rv =
nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue, aNotify);
// The ordering of the parent class's SetAttr call and Link::ResetLinkState
// is important here! The attribute is not set until SetAttr returns, and
// we will need the updated attribute value because notifying the document
// that content states have changed will call IntrinsicState, which will try
// to get updated information about the visitedness from Link.
if (aName == nsGkAtoms::href && aNameSpaceID == kNameSpaceID_None) {
Link::ResetLinkState(!!aNotify);
}
nsresult rv =
nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue, aNotify);
if (aName == nsGkAtoms::accesskey && aNameSpaceID == kNameSpaceID_None &&
!aValue.IsEmpty()) {
RegUnRegAccessKey(PR_TRUE);

Просмотреть файл

@ -285,12 +285,18 @@ nsHTMLLinkElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify)
{
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
// The ordering of the parent class's SetAttr call and Link::ResetLinkState
// is important here! The attribute is not set until SetAttr returns, and
// we will need the updated attribute value because notifying the document
// that content states have changed will call IntrinsicState, which will try
// to get updated information about the visitedness from Link.
if (aName == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
Link::ResetLinkState(!!aNotify);
}
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
if (NS_SUCCEEDED(rv)) {
PRBool dropSheet = PR_FALSE;
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::rel &&

Просмотреть файл

@ -22,6 +22,9 @@ $("x").href = "http://www.example.com";
is($("x").href, "http://www.example.com/");
is($("x").host, "www.example.com");
$("x").setAttribute("href", "http://www.example.net/");
is($("x").host, "www.example.net");
</script>
</pre>
</body>

Просмотреть файл

@ -267,12 +267,19 @@ nsSVGAElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify)
{
nsresult rv = nsSVGAElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
// The ordering of the parent class's SetAttr call and Link::ResetLinkState
// is important here! The attribute is not set until SetAttr returns, and
// we will need the updated attribute value because notifying the document
// that content states have changed will call IntrinsicState, which will try
// to get updated information about the visitedness from Link.
if (aName == nsGkAtoms::href && aNameSpaceID == kNameSpaceID_XLink) {
Link::ResetLinkState(!!aNotify);
}
return nsSVGAElementBase::SetAttr(aNameSpaceID, aName, aPrefix, aValue,
aNotify);
return rv;
}
nsresult