Bug 629200 part 2 - Make BeforeSetAttr take an nsAttrValue; r=bz

This commit is contained in:
Brian Birtles 2012-02-07 15:54:38 +09:00
parent 046a06394e
commit e3a01c5e60
16 changed files with 29 additions and 26 deletions

View File

@ -4927,7 +4927,7 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
return NS_OK;
}
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &aValue, aNotify);
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &value, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
if (aNotify) {
@ -4976,7 +4976,7 @@ nsGenericElement::SetParsedAttr(PRInt32 aNamespaceID, nsIAtom* aName,
return NS_OK;
}
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &value, aNotify);
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &aParsedValue, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
if (aNotify) {

View File

@ -706,14 +706,15 @@ protected:
*
* @param aNamespaceID the namespace of the attr being set
* @param aName the localname of the attribute being set
* @param aValue the value it's being set to. If null, the attr is being
* removed.
* @param aValue the value it's being set to. This may be an already parsed
* nsAttrValue or simply an nsAttrValue wrapping a yet-to-be-parsed
* string. Alternatively, if the attr is being removed it will be null.
* @param aNotify Whether we plan to notify document observers.
*/
// Note that this is inlined so that when subclasses call it it gets
// inlined. Those calls don't go through a vtable.
virtual nsresult BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify)
const nsAttrValue* aValue, bool aNotify)
{
return NS_OK;
}

View File

@ -2743,7 +2743,8 @@ nsGenericHTMLFormElement::UnbindFromTree(bool aDeep, bool aNullParent)
nsresult
nsGenericHTMLFormElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify)
const nsAttrValue* aValue,
bool aNotify)
{
if (aNameSpaceID == kNameSpaceID_None) {
nsAutoString tmp;

View File

@ -950,7 +950,7 @@ public:
protected:
virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
const nsAttrValue* aValue, bool aNotify);
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);

View File

@ -135,7 +135,7 @@ public:
* Called when an attribute is about to be changed
*/
virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
const nsAttrValue* aValue, bool aNotify);
/**
* Called when an attribute has just been changed
*/
@ -598,7 +598,7 @@ nsHTMLButtonElement::DoneCreatingElement()
nsresult
nsHTMLButtonElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify)
const nsAttrValue* aValue, bool aNotify)
{
if (aNotify && aName == nsGkAtoms::disabled &&
aNameSpaceID == kNameSpaceID_None) {

View File

@ -722,8 +722,7 @@ nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
nsresult
nsHTMLInputElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue,
bool aNotify)
const nsAttrValue* aValue, bool aNotify)
{
if (aNameSpaceID == kNameSpaceID_None) {
//
@ -739,7 +738,9 @@ nsHTMLInputElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
} else if (aNotify && aName == nsGkAtoms::src &&
mType == NS_FORM_INPUT_IMAGE) {
if (aValue) {
LoadImage(*aValue, true, aNotify);
NS_ABORT_IF_FALSE(aValue->Type() == nsAttrValue::eString,
"Expected string type for src attribute");
LoadImage(aValue->GetStringValue(), true, aNotify);
} else {
// Null value means the attr got unset; drop the image
CancelImageRequests(aNotify);

View File

@ -379,7 +379,7 @@ protected:
* Called when an attribute is about to be changed
*/
virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
const nsAttrValue* aValue, bool aNotify);
/**
* Called when an attribute has just been changed
*/

View File

@ -263,7 +263,7 @@ nsHTMLOptionElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
nsresult
nsHTMLOptionElement::BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify)
const nsAttrValue* aValue, bool aNotify)
{
nsresult rv = nsGenericHTMLElement::BeforeSetAttr(aNamespaceID, aName,
aValue, aNotify);

View File

@ -91,7 +91,7 @@ public:
PRInt32 aModType) const;
virtual nsresult BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
const nsAttrValue* aValue, bool aNotify);
void SetSelectedInternal(bool aValue, bool aNotify);

View File

@ -1371,7 +1371,7 @@ nsHTMLSelectElement::UnbindFromTree(bool aDeep, bool aNullParent)
nsresult
nsHTMLSelectElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify)
const nsAttrValue* aValue, bool aNotify)
{
if (aNotify && aName == nsGkAtoms::disabled &&
aNameSpaceID == kNameSpaceID_None) {

View File

@ -392,7 +392,7 @@ public:
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep, bool aNullParent);
virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
const nsAttrValue* aValue, bool aNotify);
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,

View File

@ -1265,7 +1265,7 @@ nsHTMLTableElement::UnbindFromTree(bool aDeep, bool aNullParent)
nsresult
nsHTMLTableElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue,
const nsAttrValue* aValue,
bool aNotify)
{
if (aName == nsGkAtoms::cellpadding && aNameSpaceID == kNameSpaceID_None) {

View File

@ -84,7 +84,7 @@ public:
* Called when an attribute is about to be changed
*/
virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
const nsAttrValue* aValue, bool aNotify);
/**
* Called when an attribute has just been changed
*/

View File

@ -212,7 +212,7 @@ public:
* Called when an attribute is about to be changed
*/
virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
const nsAttrValue* aValue, bool aNotify);
// nsIMutationObserver
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
@ -1215,7 +1215,7 @@ nsHTMLTextAreaElement::UnbindFromTree(bool aDeep, bool aNullParent)
nsresult
nsHTMLTextAreaElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify)
const nsAttrValue* aValue, bool aNotify)
{
if (aNotify && aName == nsGkAtoms::disabled &&
aNameSpaceID == kNameSpaceID_None) {

View File

@ -1055,7 +1055,7 @@ nsXULElement::UnregisterAccessKey(const nsAString& aOldValue)
nsresult
nsXULElement::BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify)
const nsAttrValue* aValue, bool aNotify)
{
if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::accesskey &&
IsInDoc()) {
@ -1084,10 +1084,10 @@ nsXULElement::BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
mNodeInfo->Equals(nsGkAtoms::window) &&
aName == nsGkAtoms::chromemargin) {
nsAttrValue attrValue;
nsIntMargin margins;
// Make sure the margin format is valid first
if (!attrValue.ParseIntMarginValue(*aValue)) {
return NS_ERROR_INVALID_ARG;
if (aValue->Type() == nsAttrValue::eString &&
!attrValue.ParseIntMarginValue(aValue->GetStringValue())) {
return NS_ERROR_INVALID_ARG;
}
}

View File

@ -626,7 +626,7 @@ protected:
}
virtual nsresult BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
const nsAttrValue* aValue, bool aNotify);
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);