Backout 683c21514e28, c22a4f1815c6, adb8a322cbe3, 415f3b807d45, 25edb41d0119 (bug 629200) for Dromaeo(DOM) regressions

This commit is contained in:
Marco Bonardo 2012-02-07 15:57:03 +01:00
Родитель f62b4f1138
Коммит 9aec0fff08
36 изменённых файлов: 133 добавлений и 264 удалений

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

@ -171,10 +171,6 @@ nsAttrValue::Reset()
void
nsAttrValue::SetTo(const nsAttrValue& aOther)
{
if (this == &aOther) {
return;
}
switch (aOther.BaseType()) {
case eStringBase:
{
@ -318,19 +314,6 @@ nsAttrValue::SetTo(const nsIntMargin& aValue)
}
}
void
nsAttrValue::SetToSerialized(const nsAttrValue& aOther)
{
if (aOther.Type() != nsAttrValue::eString &&
aOther.Type() != nsAttrValue::eAtom) {
nsAutoString val;
aOther.ToString(val);
SetTo(val);
} else {
SetTo(aOther);
}
}
void
nsAttrValue::SwapValueWith(nsAttrValue& aOther)
{
@ -436,29 +419,6 @@ nsAttrValue::ToString(nsAString& aResult) const
}
}
already_AddRefed<nsIAtom>
nsAttrValue::GetAsAtom() const
{
switch (Type()) {
case eString:
return do_GetAtom(GetStringValue());
case eAtom:
{
nsIAtom* atom = GetAtomValue();
NS_ADDREF(atom);
return atom;
}
default:
{
nsAutoString val;
ToString(val);
return do_GetAtom(val);
}
}
}
const nsCheapString
nsAttrValue::GetStringValue() const
{
@ -791,25 +751,6 @@ nsAttrValue::Equals(nsIAtom* aValue, nsCaseTreatment aCaseSensitive) const
return aValue->Equals(val);
}
bool
nsAttrValue::EqualsAsStrings(const nsAttrValue& aOther) const
{
if (Type() == aOther.Type()) {
return Equals(aOther);
}
// We need to serialize at least one nsAttrValue before passing to
// Equals(const nsAString&), but we can avoid unnecessarily serializing both
// by checking if one is already of string type.
bool thisIsString = (Type() == eString);
const nsAttrValue& lhs = thisIsString ? *this : aOther;
const nsAttrValue& rhs = thisIsString ? aOther : *this;
nsAutoString val;
rhs.ToString(val);
return lhs.Equals(val, eCaseMatters);
}
bool
nsAttrValue::Contains(nsIAtom* aValue, nsCaseTreatment aCaseSensitive) const
{

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

@ -106,8 +106,6 @@ public:
explicit nsAttrValue(const nsIntMargin& aValue);
~nsAttrValue();
inline const nsAttrValue& operator=(const nsAttrValue& aOther);
static nsresult Init();
static void Shutdown();
@ -138,12 +136,9 @@ public:
void SetTo(mozilla::css::StyleRule* aValue, const nsAString* aSerialized);
void SetTo(const nsIntMargin& aValue);
void SetToSerialized(const nsAttrValue& aValue);
void SwapValueWith(nsAttrValue& aOther);
void ToString(nsAString& aResult) const;
already_AddRefed<nsIAtom> GetAsAtom() const;
// Methods to get value. These methods do not convert so only use them
// to retrieve the datatype that this nsAttrValue has.
@ -179,7 +174,6 @@ public:
bool Equals(const nsAttrValue& aOther) const;
bool Equals(const nsAString& aValue, nsCaseTreatment aCaseSensitive) const;
bool Equals(nsIAtom* aValue, nsCaseTreatment aCaseSensitive) const;
bool EqualsAsStrings(const nsAttrValue& aOther) const;
/**
* Returns true if this AttrValue is equal to the given atom, or is an
@ -399,13 +393,6 @@ private:
* Implementation of inline methods
*/
inline const nsAttrValue&
nsAttrValue::operator=(const nsAttrValue& aOther)
{
SetTo(aOther);
return *this;
}
inline nsIAtom*
nsAttrValue::GetAtomValue() const
{

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

@ -4852,14 +4852,10 @@ nsGenericElement::CopyInnerTo(nsGenericElement* aDst) const
}
bool
nsGenericElement::MaybeCheckSameAttrVal(PRInt32 aNamespaceID,
nsIAtom* aName,
nsIAtom* aPrefix,
const nsAttrValue& aValue,
bool aNotify,
nsAttrValue& aOldValue,
PRUint8* aModType,
bool* aHasListeners)
nsGenericElement::MaybeCheckSameAttrVal(PRInt32 aNamespaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify, nsAutoString* aOldValue,
PRUint8* aModType, bool* aHasListeners)
{
bool modification = false;
*aHasListeners = aNotify &&
@ -4877,19 +4873,16 @@ nsGenericElement::MaybeCheckSameAttrVal(PRInt32 aNamespaceID,
if (info.mValue) {
// Check whether the old value is the same as the new one. Note that we
// only need to actually _get_ the old value if we have listeners.
bool valueMatches;
if (*aHasListeners) {
// Need to store the old value.
//
// If the current attribute value contains a pointer to some other data
// structure that gets updated in the process of setting the attribute
// we'll no longer have the old value of the attribute. Therefore, we
// should serialize the attribute value now to keep a snapshot.
//
// We have to serialize the value anyway in order to create the
// mutation event so there's no cost in doing it now.
aOldValue.SetToSerialized(*info.mValue);
// Need to store the old value
info.mValue->ToString(*aOldValue);
valueMatches = aValue.Equals(*aOldValue);
} else {
NS_ABORT_IF_FALSE(aNotify,
"Either hasListeners or aNotify should be true.");
valueMatches = info.mValue->Equals(aValue, eCaseMatters);
}
bool valueMatches = aValue.EqualsAsStrings(*info.mValue);
if (valueMatches && aPrefix == info.mName->GetPrefix()) {
return true;
}
@ -4919,15 +4912,14 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
PRUint8 modType;
bool hasListeners;
nsAttrValue value(aValue);
nsAttrValue oldValue;
nsAutoString oldValue;
if (MaybeCheckSameAttrVal(aNamespaceID, aName, aPrefix, value, aNotify,
oldValue, &modType, &hasListeners)) {
if (MaybeCheckSameAttrVal(aNamespaceID, aName, aPrefix, aValue, aNotify,
&oldValue, &modType, &hasListeners)) {
return NS_OK;
}
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &value, aNotify);
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &aValue, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
if (aNotify) {
@ -4945,7 +4937,7 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
return SetAttrAndNotify(aNamespaceID, aName, aPrefix, oldValue,
attrValue, modType, hasListeners, aNotify,
kCallAfterSetAttr);
&aValue);
}
nsresult
@ -4963,16 +4955,19 @@ nsGenericElement::SetParsedAttr(PRInt32 aNamespaceID, nsIAtom* aName,
return NS_ERROR_FAILURE;
}
nsAutoString value;
aParsedValue.ToString(value);
PRUint8 modType;
bool hasListeners;
nsAttrValue oldValue;
nsAutoString oldValue;
if (MaybeCheckSameAttrVal(aNamespaceID, aName, aPrefix, aParsedValue, aNotify,
oldValue, &modType, &hasListeners)) {
if (MaybeCheckSameAttrVal(aNamespaceID, aName, aPrefix, value, aNotify,
&oldValue, &modType, &hasListeners)) {
return NS_OK;
}
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &aParsedValue, aNotify);
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &value, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
if (aNotify) {
@ -4981,19 +4976,19 @@ nsGenericElement::SetParsedAttr(PRInt32 aNamespaceID, nsIAtom* aName,
return SetAttrAndNotify(aNamespaceID, aName, aPrefix, oldValue,
aParsedValue, modType, hasListeners, aNotify,
kCallAfterSetAttr);
&value);
}
nsresult
nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
nsIAtom* aName,
nsIAtom* aPrefix,
const nsAttrValue& aOldValue,
const nsAString& aOldValue,
nsAttrValue& aParsedValue,
PRUint8 aModType,
bool aFireMutation,
bool aNotify,
bool aCallAfterSetAttr)
const nsAString* aValueForAfterSetAttr)
{
nsresult rv;
@ -5002,13 +4997,6 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
nsMutationGuard::DidMutate();
// Copy aParsedValue for later use since it will be lost when we call
// SetAndTakeMappedAttr below
nsAttrValue aValueForAfterSetAttr;
if (aCallAfterSetAttr) {
aValueForAfterSetAttr.SetTo(aParsedValue);
}
if (aNamespaceID == kNameSpaceID_None) {
// XXXbz Perhaps we should push up the attribute mapping function
// stuff to nsGenericElement?
@ -5046,8 +5034,8 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
aName == nsGkAtoms::event && mNodeInfo->GetDocument()) {
mNodeInfo->GetDocument()->AddXMLEventsContent(this);
}
if (aCallAfterSetAttr) {
rv = AfterSetAttr(aNamespaceID, aName, &aValueForAfterSetAttr, aNotify);
if (aValueForAfterSetAttr) {
rv = AfterSetAttr(aNamespaceID, aName, aValueForAfterSetAttr, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -5067,8 +5055,8 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
if (!newValue.IsEmpty()) {
mutation.mNewAttrValue = do_GetAtom(newValue);
}
if (!aOldValue.IsEmptyString()) {
mutation.mPrevAttrValue = aOldValue.GetAsAtom();
if (!aOldValue.IsEmpty()) {
mutation.mPrevAttrValue = do_GetAtom(aOldValue);
}
mutation.mAttrChange = aModType;

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

@ -289,17 +289,16 @@ public:
* have mutation listeners (in which case it's cheap to just return false
* and let the caller go ahead and set the value).
* @param aOldValue Set to the old value of the attribute, but only if there
* are event listeners. If set, the type of aOldValue will be either
* nsAttrValue::eString or nsAttrValue::eAtom.
* are event listeners
* @param aModType Set to nsIDOMMutationEvent::MODIFICATION or to
* nsIDOMMutationEvent::ADDITION, but only if this helper returns true
* @param aHasListeners Set to true if there are mutation event listeners
* listening for NS_EVENT_BITS_MUTATION_ATTRMODIFIED
*/
bool MaybeCheckSameAttrVal(PRInt32 aNamespaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAttrValue& aValue,
bool aNotify, nsAttrValue& aOldValue,
PRUint8* aModType, bool* aHasListeners);
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify, nsAutoString* aOldValue,
PRUint8* aModType, bool* aHasListeners);
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix,
const nsAString& aValue, bool aNotify);
virtual nsresult SetParsedAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
@ -633,17 +632,6 @@ public:
static void MarkUserDataHandler(void* aObject, nsIAtom* aKey, void* aChild,
void* aData);
protected:
/*
* Named-bools for use with SetAttrAndNotify to make call sites easier to
* read.
*/
static const bool kFireMutationEvent = true;
static const bool kDontFireMutationEvent = false;
static const bool kNotifyDocumentObservers = true;
static const bool kDontNotifyDocumentObservers = false;
static const bool kCallAfterSetAttr = true;
static const bool kDontCallAfterSetAttr = false;
/**
* Set attribute and (if needed) notify documentobservers and fire off
* mutation events. This will send the AttributeChanged notification.
@ -651,9 +639,6 @@ protected:
* since that needs to happen before the new attr value has been set, and
* in particular before it has been parsed.
*
* For the boolean parameters, consider using the named bools above to aid
* code readability.
*
* @param aNamespaceID namespace of attribute
* @param aAttribute local-name of attribute
* @param aPrefix aPrefix of attribute
@ -664,17 +649,18 @@ protected:
* needed if aFireMutation or aNotify is true.
* @param aFireMutation should mutation-events be fired?
* @param aNotify should we notify document-observers?
* @param aCallAfterSetAttr should we call AfterSetAttr?
* @param aValueForAfterSetAttr If not null, AfterSetAttr will be called
* with the value pointed by this parameter.
*/
nsresult SetAttrAndNotify(PRInt32 aNamespaceID,
nsIAtom* aName,
nsIAtom* aPrefix,
const nsAttrValue& aOldValue,
const nsAString& aOldValue,
nsAttrValue& aParsedValue,
PRUint8 aModType,
bool aFireMutation,
bool aNotify,
bool aCallAfterSetAttr);
const nsAString* aValueForAfterSetAttr);
/**
* Convert an attribute string value to attribute type based on the type of
@ -719,15 +705,14 @@ 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. 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 aValue the value it's being set to. If null, the attr is being
* removed.
* @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 nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
return NS_OK;
}
@ -747,7 +732,7 @@ protected:
// Note that this is inlined so that when subclasses call it it gets
// inlined. Those calls don't go through a vtable.
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
return NS_OK;
}

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

@ -146,7 +146,7 @@ nsStyledElementNotElementCSSInlineStyle::UnsetAttr(PRInt32 aNameSpaceID,
nsresult
nsStyledElementNotElementCSSInlineStyle::AfterSetAttr(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAttrValue* aValue,
const nsAString* aValue,
bool aNotify)
{
if (aNamespaceID == kNameSpaceID_None && !aValue &&
@ -167,7 +167,7 @@ nsStyledElementNotElementCSSInlineStyle::SetInlineStyleRule(css::StyleRule* aSty
{
SetMayHaveStyle();
bool modification = false;
nsAttrValue oldValue;
nsAutoString oldValueStr;
bool hasListeners = aNotify &&
nsContentUtils::HasMutationListeners(this,
@ -182,12 +182,8 @@ nsStyledElementNotElementCSSInlineStyle::SetInlineStyleRule(css::StyleRule* aSty
// save the old attribute so we can set up the mutation event properly
// XXXbz if the old rule points to the same declaration as the new one,
// this is getting the new attr value, not the old one....
nsAutoString oldValueStr;
modification = GetAttr(kNameSpaceID_None, nsGkAtoms::style,
oldValueStr);
if (modification) {
oldValue.SetTo(oldValueStr);
}
}
else if (aNotify && IsInDoc()) {
modification = !!mAttrsAndChildren.GetAttr(nsGkAtoms::style);
@ -201,8 +197,8 @@ nsStyledElementNotElementCSSInlineStyle::SetInlineStyleRule(css::StyleRule* aSty
static_cast<PRUint8>(nsIDOMMutationEvent::ADDITION);
return SetAttrAndNotify(kNameSpaceID_None, nsGkAtoms::style, nsnull,
oldValue, attrValue, modType, hasListeners,
aNotify, kDontCallAfterSetAttr);
oldValueStr, attrValue, modType, hasListeners,
aNotify, nsnull);
}
css::StyleRule*

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

@ -89,7 +89,7 @@ public:
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
bool aNotify);
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
nsIDOMCSSStyleDeclaration* GetStyle(nsresult* retval);

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

@ -1283,14 +1283,11 @@ nsGenericHTMLElement::GetHrefURIForAnchors() const
nsresult
nsGenericHTMLElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aNamespaceID == kNameSpaceID_None) {
if (nsContentUtils::IsEventAttributeName(aName, EventNameType_HTML) &&
aValue) {
NS_ABORT_IF_FALSE(aValue->Type() == nsAttrValue::eString,
"Expected string value for script body");
nsresult rv = AddScriptEventListener(aName, aValue->GetStringValue());
if (nsContentUtils::IsEventAttributeName(aName, EventNameType_HTML) && aValue) {
nsresult rv = AddScriptEventListener(aName, *aValue);
NS_ENSURE_SUCCESS(rv, rv);
}
else if (aNotify && aName == nsGkAtoms::spellcheck) {
@ -2746,8 +2743,7 @@ nsGenericHTMLFormElement::UnbindFromTree(bool aDeep, bool aNullParent)
nsresult
nsGenericHTMLFormElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue,
bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aNameSpaceID == kNameSpaceID_None) {
nsAutoString tmp;
@ -2803,17 +2799,16 @@ nsGenericHTMLFormElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsresult
nsGenericHTMLFormElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aNameSpaceID == kNameSpaceID_None) {
// add the control to the hashtable as needed
if (mForm && (aName == nsGkAtoms::name || aName == nsGkAtoms::id) &&
aValue && !aValue->IsEmptyString()) {
NS_ABORT_IF_FALSE(aValue->Type() == nsAttrValue::eAtom,
"Expected atom value for name/id");
mForm->AddElementToTable(this,
nsDependentAtomString(aValue->GetAtomValue()));
aValue) {
if (!aValue->IsEmpty()) {
mForm->AddElementToTable(this, *aValue);
}
}
if (mForm && aName == nsGkAtoms::type) {
@ -2845,7 +2840,7 @@ nsGenericHTMLFormElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIDocument* doc = GetCurrentDoc();
if (doc) {
Element* formIdElement = nsnull;
if (aValue && !aValue->IsEmptyString()) {
if (aValue && !aValue->IsEmpty()) {
formIdElement = AddFormIdObserver();
}

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

@ -631,7 +631,7 @@ protected:
bool IsEventName(nsIAtom* aName);
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
virtual nsEventListenerManager*
GetEventListenerManagerForAttr(nsIAtom* aAttrName, bool* aDefer);
@ -950,10 +950,10 @@ public:
protected:
virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
void UpdateEditableFormControlState(bool aNotify);

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

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

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

@ -119,7 +119,7 @@ nsHTMLFieldSetElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
nsresult
nsHTMLFieldSetElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::disabled &&
nsINode::GetFirstChild()) {

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

@ -80,7 +80,7 @@ public:
// nsIContent
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
virtual nsresult InsertChildAt(nsIContent* aChild, PRUint32 aIndex,
bool aNotify);

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

@ -378,7 +378,7 @@ nsHTMLFormElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsresult
nsHTMLFormElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aName == nsGkAtoms::novalidate && aNameSpaceID == kNameSpaceID_None) {
// Update all form elements states because they might be [no longer]

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

@ -176,7 +176,7 @@ public:
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify);
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
/**
* Forget all information about the current submission (and the fact that we

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

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

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

@ -379,12 +379,12 @@ protected:
* Called when an attribute is about to be changed
*/
virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
/**
* Called when an attribute has just been changed
*/
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
/**
* Dispatch a select event. Returns true if the event was not cancelled.

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

@ -417,7 +417,7 @@ nsHTMLMenuItemElement::GetText(nsAString& aText)
nsresult
nsHTMLMenuItemElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aNameSpaceID == kNameSpaceID_None) {
if ((aName == nsGkAtoms::radiogroup || aName == nsGkAtoms::type) &&

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

@ -106,7 +106,7 @@ public:
protected:
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
void WalkRadioGroup(Visitor* aVisitor);

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

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

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

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

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

@ -118,7 +118,7 @@ public:
// nsGenericElement
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
virtual nsXPCClassInfo* GetClassInfo();
protected:
@ -241,7 +241,7 @@ nsHTMLScriptElement::SetAsync(bool aValue)
nsresult
nsHTMLScriptElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (nsGkAtoms::async == aName && kNameSpaceID_None == aNamespaceID) {
mForceAsync = false;

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

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

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

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

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

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

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

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

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

@ -212,7 +212,7 @@ public:
* Called when an attribute is about to be changed
*/
virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
// nsIMutationObserver
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
@ -284,7 +284,7 @@ protected:
void ContentChanged(nsIContent* aContent);
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom *aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
/**
* Return if an element should have a specific validity UI
@ -1215,7 +1215,7 @@ nsHTMLTextAreaElement::UnbindFromTree(bool aDeep, bool aNullParent)
nsresult
nsHTMLTextAreaElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aNotify && aName == nsGkAtoms::disabled &&
aNameSpaceID == kNameSpaceID_None) {
@ -1276,7 +1276,7 @@ nsHTMLTextAreaElement::ContentChanged(nsIContent* aContent)
nsresult
nsHTMLTextAreaElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aNameSpaceID == kNameSpaceID_None) {
if (aName == nsGkAtoms::required || aName == nsGkAtoms::disabled ||

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

@ -376,7 +376,7 @@ nsSVGAnimationElement::ParseAttribute(PRInt32 aNamespaceID,
nsresult
nsSVGAnimationElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
nsresult rv =
nsSVGAnimationElementBase::AfterSetAttr(aNamespaceID, aName, aValue,
@ -389,9 +389,7 @@ nsSVGAnimationElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
mHrefTarget.Unlink();
AnimationTargetChanged();
} else if (IsInDoc()) {
NS_ABORT_IF_FALSE(aValue->Type() == nsAttrValue::eString,
"Expected href attribute to be string type");
UpdateHrefTarget(this, aValue->GetStringValue());
UpdateHrefTarget(this, *aValue);
} // else: we're not yet in a document -- we'll update the target on
// next BindToTree call.

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

@ -84,7 +84,7 @@ public:
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
// nsISMILAnimationElement interface
virtual const Element& AsElement() const;

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

@ -260,8 +260,8 @@ nsSVGElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsresult
nsSVGElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
{
const nsAString* aValue, bool aNotify)
{
// If this is an svg presentation attribute we need to map it into
// the content stylerule.
// XXX For some reason incremental mapping doesn't work, so for now
@ -272,10 +272,7 @@ nsSVGElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
}
if (IsEventName(aName) && aValue) {
NS_ABORT_IF_FALSE(aValue->Type() == nsAttrValue::eString,
"Expected string value for script body");
nsresult rv = AddScriptEventListener(GetEventNameForAttr(aName),
aValue->GetStringValue());
nsresult rv = AddScriptEventListener(GetEventNameForAttr(aName), *aValue);
NS_ENSURE_SUCCESS(rv, rv);
}

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

@ -250,7 +250,7 @@ public:
protected:
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
virtual bool ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute,
const nsAString& aValue, nsAttrValue& aResult);
static nsresult ReportAttributeParseFailure(nsIDocument* aDocument,

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

@ -5552,7 +5552,7 @@ nsSVGFEImageElement::IsAttributeMapped(const nsIAtom* name) const
nsresult
nsSVGFEImageElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {

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

@ -288,7 +288,7 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers);

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

@ -170,7 +170,7 @@ nsSVGImageElement::LoadSVGImage(bool aForce, bool aNotify)
nsresult
nsSVGImageElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {

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

@ -78,7 +78,7 @@ public:
// nsIContent interface
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers);

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

@ -95,7 +95,7 @@ public:
nsIContent* aBindingParent,
bool aCompileEventHandlers);
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
@ -280,7 +280,7 @@ nsSVGScriptElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsresult
nsSVGScriptElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {
MaybeProcessScript();

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

@ -1055,7 +1055,7 @@ nsXULElement::UnregisterAccessKey(const nsAString& aOldValue)
nsresult
nsXULElement::BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* 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 (aValue->Type() == nsAttrValue::eString &&
!attrValue.ParseIntMarginValue(aValue->GetStringValue())) {
return NS_ERROR_INVALID_ARG;
if (!attrValue.ParseIntMarginValue(*aValue)) {
return NS_ERROR_INVALID_ARG;
}
}
@ -1097,7 +1097,7 @@ nsXULElement::BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
nsresult
nsXULElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
const nsAString* aValue, bool aNotify)
{
if (aNamespaceID == kNameSpaceID_None) {
// XXX UnsetAttr handles more attributes than we do. See bug 233642.
@ -1113,24 +1113,17 @@ nsXULElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
// nsXULPrototypeAttribute is expensive!)
bool defer = mPrototype == nsnull ||
mPrototype->mScriptTypeID == GetScriptTypeID();
if (aValue->Type() == nsAttrValue::eString) {
AddScriptEventListener(aName, aValue->GetStringValue(), defer);
} else {
nsAutoString body;
aValue->ToString(body);
AddScriptEventListener(aName, body, defer);
}
AddScriptEventListener(aName, *aValue, defer);
}
// Hide chrome if needed
if (mNodeInfo->Equals(nsGkAtoms::window) && aValue) {
if (aName == nsGkAtoms::hidechrome) {
HideWindowChrome(
aValue->Equals(NS_LITERAL_STRING("true"), eCaseMatters));
}
else if (aName == nsGkAtoms::chromemargin) {
SetChromeMargins(aValue);
}
if (aName == nsGkAtoms::hidechrome) {
HideWindowChrome(aValue->EqualsLiteral("true"));
}
else if (aName == nsGkAtoms::chromemargin) {
SetChromeMargins(aValue);
}
}
// title, (in)activetitlebarcolor and drawintitlebar are settable on
@ -1141,22 +1134,15 @@ nsXULElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
document->NotifyPossibleTitleChange(false);
}
else if ((aName == nsGkAtoms::activetitlebarcolor ||
aName == nsGkAtoms::inactivetitlebarcolor) && aValue) {
aName == nsGkAtoms::inactivetitlebarcolor)) {
nscolor color = NS_RGBA(0, 0, 0, 0);
if (aValue->Type() == nsAttrValue::eColor) {
aValue->GetColorValue(color);
} else {
nsAutoString tmp;
nsAttrValue attrValue;
aValue->ToString(tmp);
attrValue.ParseColor(tmp);
attrValue.GetColorValue(color);
}
nsAttrValue attrValue;
attrValue.ParseColor(*aValue);
attrValue.GetColorValue(color);
SetTitlebarColor(color, aName == nsGkAtoms::activetitlebarcolor);
}
else if (aName == nsGkAtoms::drawintitlebar) {
SetDrawsInTitlebar(aValue &&
aValue->Equals(NS_LITERAL_STRING("true"), eCaseMatters));
SetDrawsInTitlebar(aValue && aValue->EqualsLiteral("true"));
}
else if (aName == nsGkAtoms::localedir) {
// if the localedir changed on the root element, reset the document direction
@ -2449,7 +2435,7 @@ private:
};
void
nsXULElement::SetChromeMargins(const nsAttrValue* aValue)
nsXULElement::SetChromeMargins(const nsAString* aValue)
{
if (!aValue)
return;
@ -2459,17 +2445,13 @@ nsXULElement::SetChromeMargins(const nsAttrValue* aValue)
return;
// top, right, bottom, left - see nsAttrValue
nsAttrValue attrValue;
nsIntMargin margins;
bool gotMargins = false;
if (aValue->Type() == nsAttrValue::eIntMarginValue) {
gotMargins = aValue->GetIntMarginValue(margins);
} else {
nsAutoString tmp;
aValue->ToString(tmp);
gotMargins = nsContentUtils::ParseIntMarginValue(tmp, margins);
}
if (gotMargins) {
nsAutoString data;
data.Assign(*aValue);
if (attrValue.ParseIntMarginValue(data) &&
attrValue.GetIntMarginValue(margins)) {
nsContentUtils::AddScriptRunner(new MarginSetter(mainWidget, margins));
}
}

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

@ -626,9 +626,9 @@ protected:
}
virtual nsresult BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify);
const nsAString* aValue, bool aNotify);
virtual void UpdateEditableState(bool aNotify);
@ -656,7 +656,7 @@ protected:
// attribute setters for widget
nsresult HideWindowChrome(bool aShouldHide);
void SetChromeMargins(const nsAttrValue* aValue);
void SetChromeMargins(const nsAString* aValue);
void ResetChromeMargins();
void SetTitlebarColor(nscolor aColor, bool aActive);