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

This commit is contained in:
Brian Birtles 2012-02-14 11:00:56 +09:00
parent 3ed762da7b
commit 8e36f98441
16 changed files with 44 additions and 28 deletions

View File

@ -5055,7 +5055,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) {
@ -5102,7 +5102,7 @@ nsGenericElement::SetParsedAttr(PRInt32 aNamespaceID, nsIAtom* aName,
return NS_OK;
}
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &value.String(), aNotify);
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &value, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
if (aNotify) {
@ -5341,8 +5341,8 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsresult rv = BeforeSetAttr(aNameSpaceID, aName, nsnull, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
nsIDocument *document = GetCurrentDoc();
nsIDocument *document = GetCurrentDoc();
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
if (aNotify) {

View File

@ -709,14 +709,16 @@ 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 represented as either a string or
* a parsed nsAttrValue. 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 nsAttrValueOrString* 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 nsAttrValueOrString* aValue,
bool aNotify)
{
if (aNameSpaceID == kNameSpaceID_None) {
nsAutoString tmp;

View File

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

View File

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

View File

@ -75,6 +75,7 @@
#include "nsGUIEvent.h"
#include "nsIIOService.h"
#include "nsDocument.h"
#include "nsAttrValueOrString.h"
#include "nsPresState.h"
#include "nsLayoutErrors.h"
@ -722,7 +723,7 @@ nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
nsresult
nsHTMLInputElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue,
const nsAttrValueOrString* aValue,
bool aNotify)
{
if (aNameSpaceID == kNameSpaceID_None) {
@ -739,7 +740,7 @@ nsHTMLInputElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
} else if (aNotify && aName == nsGkAtoms::src &&
mType == NS_FORM_INPUT_IMAGE) {
if (aValue) {
LoadImage(*aValue, true, aNotify);
LoadImage(aValue->String(), true, aNotify);
} else {
// Null value means the attr got unset; drop the image
CancelImageRequests(aNotify);

View File

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

View File

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

View File

@ -91,8 +91,9 @@ public:
PRInt32 aModType) const;
virtual nsresult BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
const nsAttrValueOrString* aValue,
bool aNotify);
void SetSelectedInternal(bool aValue, bool aNotify);
// nsIContent

View File

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

View File

@ -392,7 +392,8 @@ public:
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep, bool aNullParent);
virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
const nsAttrValueOrString* 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 nsAttrValueOrString* aValue,
bool aNotify)
{
if (aName == nsGkAtoms::cellpadding && aNameSpaceID == kNameSpaceID_None) {

View File

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

View File

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

View File

@ -126,6 +126,7 @@
#include "prlog.h"
#include "rdf.h"
#include "nsIControllers.h"
#include "nsAttrValueOrString.h"
// The XUL doc interface
#include "nsIDOMXULDocument.h"
@ -1055,7 +1056,7 @@ nsXULElement::UnregisterAccessKey(const nsAString& aOldValue)
nsresult
nsXULElement::BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify)
const nsAttrValueOrString* aValue, bool aNotify)
{
if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::accesskey &&
IsInDoc()) {
@ -1084,10 +1085,9 @@ 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 (!attrValue.ParseIntMarginValue(aValue->String())) {
return NS_ERROR_INVALID_ARG;
}
}

View File

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