From f7939a2c383248eaecfb5eea516e473dd6568d3e Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Tue, 14 Feb 2012 11:00:56 +0900 Subject: [PATCH] Bug 629200 part 3 - Make AfterSetAttr take an nsAttrValue; r=bz --- content/base/src/nsGenericElement.cpp | 17 ++++-- content/base/src/nsGenericElement.h | 7 +-- content/base/src/nsStyledElement.cpp | 4 +- content/base/src/nsStyledElement.h | 2 +- .../html/content/src/nsGenericHTMLElement.cpp | 22 +++++--- .../html/content/src/nsGenericHTMLElement.h | 4 +- .../html/content/src/nsHTMLButtonElement.cpp | 6 +- .../content/src/nsHTMLFieldSetElement.cpp | 2 +- .../html/content/src/nsHTMLFieldSetElement.h | 2 +- .../html/content/src/nsHTMLFormElement.cpp | 2 +- content/html/content/src/nsHTMLFormElement.h | 2 +- .../html/content/src/nsHTMLInputElement.cpp | 3 +- content/html/content/src/nsHTMLInputElement.h | 2 +- .../content/src/nsHTMLMenuItemElement.cpp | 2 +- .../html/content/src/nsHTMLMenuItemElement.h | 2 +- .../html/content/src/nsHTMLScriptElement.cpp | 4 +- .../html/content/src/nsHTMLSelectElement.cpp | 2 +- .../html/content/src/nsHTMLSelectElement.h | 2 +- .../html/content/src/nsHTMLTableElement.cpp | 2 +- content/html/content/src/nsHTMLTableElement.h | 2 +- .../content/src/nsHTMLTextAreaElement.cpp | 4 +- .../svg/content/src/nsSVGAnimationElement.cpp | 6 +- .../svg/content/src/nsSVGAnimationElement.h | 2 +- content/svg/content/src/nsSVGElement.cpp | 9 ++- content/svg/content/src/nsSVGElement.h | 2 +- content/svg/content/src/nsSVGFilters.cpp | 2 +- content/svg/content/src/nsSVGFilters.h | 2 +- content/svg/content/src/nsSVGImageElement.cpp | 2 +- content/svg/content/src/nsSVGImageElement.h | 2 +- .../svg/content/src/nsSVGScriptElement.cpp | 4 +- content/xul/content/src/nsXULElement.cpp | 56 ++++++++++++------- content/xul/content/src/nsXULElement.h | 4 +- 32 files changed, 109 insertions(+), 77 deletions(-) diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 35843225104..427ea412396 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -5073,7 +5073,7 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName, return SetAttrAndNotify(aNamespaceID, aName, aPrefix, oldValue, attrValue, modType, hasListeners, aNotify, - &aValue); + true); } nsresult @@ -5111,7 +5111,7 @@ nsGenericElement::SetParsedAttr(PRInt32 aNamespaceID, nsIAtom* aName, return SetAttrAndNotify(aNamespaceID, aName, aPrefix, oldValue, aParsedValue, modType, hasListeners, aNotify, - &value.String()); + true); } nsresult @@ -5123,7 +5123,7 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID, PRUint8 aModType, bool aFireMutation, bool aNotify, - const nsAString* aValueForAfterSetAttr) + bool aCallAfterSetAttr) { nsresult rv; @@ -5132,6 +5132,13 @@ 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? @@ -5169,8 +5176,8 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID, aName == nsGkAtoms::event && mNodeInfo->GetDocument()) { mNodeInfo->GetDocument()->AddXMLEventsContent(this); } - if (aValueForAfterSetAttr) { - rv = AfterSetAttr(aNamespaceID, aName, aValueForAfterSetAttr, aNotify); + if (aCallAfterSetAttr) { + rv = AfterSetAttr(aNamespaceID, aName, &aValueForAfterSetAttr, aNotify); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h index e83a7bdc7f8..343cb691d2c 100644 --- a/content/base/src/nsGenericElement.h +++ b/content/base/src/nsGenericElement.h @@ -653,8 +653,7 @@ protected: * needed if aFireMutation or aNotify is true. * @param aFireMutation should mutation-events be fired? * @param aNotify should we notify document-observers? - * @param aValueForAfterSetAttr If not null, AfterSetAttr will be called - * with the value pointed by this parameter. + * @param aCallAfterSetAttr should we call AfterSetAttr? */ nsresult SetAttrAndNotify(PRInt32 aNamespaceID, nsIAtom* aName, @@ -664,7 +663,7 @@ protected: PRUint8 aModType, bool aFireMutation, bool aNotify, - const nsAString* aValueForAfterSetAttr); + bool aCallAfterSetAttr); /** * Convert an attribute string value to attribute type based on the type of @@ -738,7 +737,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 nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { return NS_OK; } diff --git a/content/base/src/nsStyledElement.cpp b/content/base/src/nsStyledElement.cpp index 06f25cd0ced..900095da3a4 100644 --- a/content/base/src/nsStyledElement.cpp +++ b/content/base/src/nsStyledElement.cpp @@ -146,7 +146,7 @@ nsStyledElementNotElementCSSInlineStyle::UnsetAttr(PRInt32 aNameSpaceID, nsresult nsStyledElementNotElementCSSInlineStyle::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aAttribute, - const nsAString* aValue, + const nsAttrValue* aValue, bool aNotify) { if (aNamespaceID == kNameSpaceID_None && !aValue && @@ -202,7 +202,7 @@ nsStyledElementNotElementCSSInlineStyle::SetInlineStyleRule(css::StyleRule* aSty return SetAttrAndNotify(kNameSpaceID_None, nsGkAtoms::style, nsnull, oldValue, attrValue, modType, hasListeners, - aNotify, nsnull); + aNotify, false); } css::StyleRule* diff --git a/content/base/src/nsStyledElement.h b/content/base/src/nsStyledElement.h index 0dc74b3e1da..c1fbffedf19 100644 --- a/content/base/src/nsStyledElement.h +++ b/content/base/src/nsStyledElement.h @@ -89,7 +89,7 @@ public: virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, bool aNotify); virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); nsIDOMCSSStyleDeclaration* GetStyle(nsresult* retval); diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index d3f45deba03..252d1028ea1 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -1283,11 +1283,14 @@ nsGenericHTMLElement::GetHrefURIForAnchors() const nsresult nsGenericHTMLElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNamespaceID == kNameSpaceID_None) { - if (nsContentUtils::IsEventAttributeName(aName, EventNameType_HTML) && aValue) { - nsresult rv = AddScriptEventListener(aName, *aValue); + 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()); NS_ENSURE_SUCCESS(rv, rv); } else if (aNotify && aName == nsGkAtoms::spellcheck) { @@ -2800,16 +2803,17 @@ nsGenericHTMLFormElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsresult nsGenericHTMLFormElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { // add the control to the hashtable as needed if (mForm && (aName == nsGkAtoms::name || aName == nsGkAtoms::id) && - aValue) { - if (!aValue->IsEmpty()) { - mForm->AddElementToTable(this, *aValue); - } + aValue && !aValue->IsEmptyString()) { + NS_ABORT_IF_FALSE(aValue->Type() == nsAttrValue::eAtom, + "Expected atom value for name/id"); + mForm->AddElementToTable(this, + nsDependentAtomString(aValue->GetAtomValue())); } if (mForm && aName == nsGkAtoms::type) { @@ -2841,7 +2845,7 @@ nsGenericHTMLFormElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIDocument* doc = GetCurrentDoc(); if (doc) { Element* formIdElement = nsnull; - if (aValue && !aValue->IsEmpty()) { + if (aValue && !aValue->IsEmptyString()) { formIdElement = AddFormIdObserver(); } diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 1cb3bf2ae70..ce220ca74e0 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -631,7 +631,7 @@ protected: bool IsEventName(nsIAtom* aName); virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); virtual nsEventListenerManager* GetEventListenerManagerForAttr(nsIAtom* aAttrName, bool* aDefer); @@ -954,7 +954,7 @@ protected: bool aNotify); virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); void UpdateEditableFormControlState(bool aNotify); diff --git a/content/html/content/src/nsHTMLButtonElement.cpp b/content/html/content/src/nsHTMLButtonElement.cpp index 2aaeb0b22af..4f49dd868a4 100644 --- a/content/html/content/src/nsHTMLButtonElement.cpp +++ b/content/html/content/src/nsHTMLButtonElement.cpp @@ -141,8 +141,8 @@ public: * Called when an attribute has just been changed */ nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); - + const nsAttrValue* aValue, bool aNotify); + // nsIContent overrides... virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, PRInt32 *aTabIndex); virtual bool ParseAttribute(PRInt32 aNamespaceID, @@ -613,7 +613,7 @@ nsHTMLButtonElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsresult nsHTMLButtonElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::type) { diff --git a/content/html/content/src/nsHTMLFieldSetElement.cpp b/content/html/content/src/nsHTMLFieldSetElement.cpp index 5f36fcf9afe..1d2e4693286 100644 --- a/content/html/content/src/nsHTMLFieldSetElement.cpp +++ b/content/html/content/src/nsHTMLFieldSetElement.cpp @@ -119,7 +119,7 @@ nsHTMLFieldSetElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) nsresult nsHTMLFieldSetElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::disabled && nsINode::GetFirstChild()) { diff --git a/content/html/content/src/nsHTMLFieldSetElement.h b/content/html/content/src/nsHTMLFieldSetElement.h index e8625127321..8ed87393bdf 100644 --- a/content/html/content/src/nsHTMLFieldSetElement.h +++ b/content/html/content/src/nsHTMLFieldSetElement.h @@ -80,7 +80,7 @@ public: // nsIContent virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); virtual nsresult InsertChildAt(nsIContent* aChild, PRUint32 aIndex, bool aNotify); diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index 265e2487e46..00fc6956607 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -378,7 +378,7 @@ nsHTMLFormElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsresult nsHTMLFormElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aName == nsGkAtoms::novalidate && aNameSpaceID == kNameSpaceID_None) { // Update all form elements states because they might be [no longer] diff --git a/content/html/content/src/nsHTMLFormElement.h b/content/html/content/src/nsHTMLFormElement.h index 842d1cf2f54..618cf2f12d7 100644 --- a/content/html/content/src/nsHTMLFormElement.h +++ b/content/html/content/src/nsHTMLFormElement.h @@ -176,7 +176,7 @@ public: nsIAtom* aPrefix, const nsAString& aValue, bool aNotify); virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); /** * Forget all information about the current submission (and the fact that we diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index b4fe7cfa747..a17eb86e732 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -756,8 +756,7 @@ nsHTMLInputElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsresult nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, - bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { // diff --git a/content/html/content/src/nsHTMLInputElement.h b/content/html/content/src/nsHTMLInputElement.h index a93b409b04d..c462c85b6ea 100644 --- a/content/html/content/src/nsHTMLInputElement.h +++ b/content/html/content/src/nsHTMLInputElement.h @@ -385,7 +385,7 @@ protected: * Called when an attribute has just been changed */ virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); /** * Dispatch a select event. Returns true if the event was not cancelled. diff --git a/content/html/content/src/nsHTMLMenuItemElement.cpp b/content/html/content/src/nsHTMLMenuItemElement.cpp index 246cc353c59..edb87e24a9e 100644 --- a/content/html/content/src/nsHTMLMenuItemElement.cpp +++ b/content/html/content/src/nsHTMLMenuItemElement.cpp @@ -417,7 +417,7 @@ nsHTMLMenuItemElement::GetText(nsAString& aText) nsresult nsHTMLMenuItemElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if ((aName == nsGkAtoms::radiogroup || aName == nsGkAtoms::type) && diff --git a/content/html/content/src/nsHTMLMenuItemElement.h b/content/html/content/src/nsHTMLMenuItemElement.h index f5a9a106370..9d7b3fad83c 100644 --- a/content/html/content/src/nsHTMLMenuItemElement.h +++ b/content/html/content/src/nsHTMLMenuItemElement.h @@ -106,7 +106,7 @@ public: protected: virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); void WalkRadioGroup(Visitor* aVisitor); diff --git a/content/html/content/src/nsHTMLScriptElement.cpp b/content/html/content/src/nsHTMLScriptElement.cpp index bce7dd68c76..ec626bee430 100644 --- a/content/html/content/src/nsHTMLScriptElement.cpp +++ b/content/html/content/src/nsHTMLScriptElement.cpp @@ -118,7 +118,7 @@ public: // nsGenericElement virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); virtual nsXPCClassInfo* GetClassInfo(); protected: @@ -241,7 +241,7 @@ nsHTMLScriptElement::SetAsync(bool aValue) nsresult nsHTMLScriptElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (nsGkAtoms::async == aName && kNameSpaceID_None == aNamespaceID) { mForceAsync = false; diff --git a/content/html/content/src/nsHTMLSelectElement.cpp b/content/html/content/src/nsHTMLSelectElement.cpp index cd29304474b..288edd877e9 100644 --- a/content/html/content/src/nsHTMLSelectElement.cpp +++ b/content/html/content/src/nsHTMLSelectElement.cpp @@ -1385,7 +1385,7 @@ nsHTMLSelectElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsresult nsHTMLSelectElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::disabled) { diff --git a/content/html/content/src/nsHTMLSelectElement.h b/content/html/content/src/nsHTMLSelectElement.h index 680fd5e7c3a..7a4efc09844 100644 --- a/content/html/content/src/nsHTMLSelectElement.h +++ b/content/html/content/src/nsHTMLSelectElement.h @@ -395,7 +395,7 @@ public: const nsAttrValueOrString* aValue, bool aNotify); virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, bool aNotify); diff --git a/content/html/content/src/nsHTMLTableElement.cpp b/content/html/content/src/nsHTMLTableElement.cpp index 606df5f469e..49757a2822d 100644 --- a/content/html/content/src/nsHTMLTableElement.cpp +++ b/content/html/content/src/nsHTMLTableElement.cpp @@ -1277,7 +1277,7 @@ nsHTMLTableElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsresult nsHTMLTableElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, + const nsAttrValue* aValue, bool aNotify) { if (aName == nsGkAtoms::cellpadding && aNameSpaceID == kNameSpaceID_None) { diff --git a/content/html/content/src/nsHTMLTableElement.h b/content/html/content/src/nsHTMLTableElement.h index 909607068f8..9da2309c0fc 100644 --- a/content/html/content/src/nsHTMLTableElement.h +++ b/content/html/content/src/nsHTMLTableElement.h @@ -90,7 +90,7 @@ public: * Called when an attribute has just been changed */ virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLTableElement, nsGenericHTMLElement) diff --git a/content/html/content/src/nsHTMLTextAreaElement.cpp b/content/html/content/src/nsHTMLTextAreaElement.cpp index 008c7d2e99e..fe76755a586 100644 --- a/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -285,7 +285,7 @@ protected: void ContentChanged(nsIContent* aContent); virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom *aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); /** * Return if an element should have a specific validity UI @@ -1278,7 +1278,7 @@ nsHTMLTextAreaElement::ContentChanged(nsIContent* aContent) nsresult nsHTMLTextAreaElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::required || aName == nsGkAtoms::disabled || diff --git a/content/svg/content/src/nsSVGAnimationElement.cpp b/content/svg/content/src/nsSVGAnimationElement.cpp index 4fd529589e9..4c28ba3f85e 100644 --- a/content/svg/content/src/nsSVGAnimationElement.cpp +++ b/content/svg/content/src/nsSVGAnimationElement.cpp @@ -376,7 +376,7 @@ nsSVGAnimationElement::ParseAttribute(PRInt32 aNamespaceID, nsresult nsSVGAnimationElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { nsresult rv = nsSVGAnimationElementBase::AfterSetAttr(aNamespaceID, aName, aValue, @@ -389,7 +389,9 @@ nsSVGAnimationElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, mHrefTarget.Unlink(); AnimationTargetChanged(); } else if (IsInDoc()) { - UpdateHrefTarget(this, *aValue); + NS_ABORT_IF_FALSE(aValue->Type() == nsAttrValue::eString, + "Expected href attribute to be string type"); + UpdateHrefTarget(this, aValue->GetStringValue()); } // else: we're not yet in a document -- we'll update the target on // next BindToTree call. diff --git a/content/svg/content/src/nsSVGAnimationElement.h b/content/svg/content/src/nsSVGAnimationElement.h index e7708bbfad2..8c93c679359 100644 --- a/content/svg/content/src/nsSVGAnimationElement.h +++ b/content/svg/content/src/nsSVGAnimationElement.h @@ -84,7 +84,7 @@ public: const nsAString& aValue, nsAttrValue& aResult); virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); // nsISMILAnimationElement interface virtual const Element& AsElement() const; diff --git a/content/svg/content/src/nsSVGElement.cpp b/content/svg/content/src/nsSVGElement.cpp index 879ef4098e8..61c693aa4dd 100644 --- a/content/svg/content/src/nsSVGElement.cpp +++ b/content/svg/content/src/nsSVGElement.cpp @@ -260,8 +260,8 @@ nsSVGElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsresult nsSVGElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) -{ + const nsAttrValue* 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,7 +272,10 @@ nsSVGElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, } if (IsEventName(aName) && aValue) { - nsresult rv = AddScriptEventListener(GetEventNameForAttr(aName), *aValue); + NS_ABORT_IF_FALSE(aValue->Type() == nsAttrValue::eString, + "Expected string value for script body"); + nsresult rv = AddScriptEventListener(GetEventNameForAttr(aName), + aValue->GetStringValue()); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/content/svg/content/src/nsSVGElement.h b/content/svg/content/src/nsSVGElement.h index bab7f271405..53c9c4914bf 100644 --- a/content/svg/content/src/nsSVGElement.h +++ b/content/svg/content/src/nsSVGElement.h @@ -250,7 +250,7 @@ public: protected: virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); virtual bool ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult); static nsresult ReportAttributeParseFailure(nsIDocument* aDocument, diff --git a/content/svg/content/src/nsSVGFilters.cpp b/content/svg/content/src/nsSVGFilters.cpp index c0aafc73cbe..c5d3ec86422 100644 --- a/content/svg/content/src/nsSVGFilters.cpp +++ b/content/svg/content/src/nsSVGFilters.cpp @@ -5561,7 +5561,7 @@ nsSVGFEImageElement::IsAttributeMapped(const nsIAtom* name) const nsresult nsSVGFEImageElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) { diff --git a/content/svg/content/src/nsSVGFilters.h b/content/svg/content/src/nsSVGFilters.h index ddb734f56a8..3f5a7b1536d 100644 --- a/content/svg/content/src/nsSVGFilters.h +++ b/content/svg/content/src/nsSVGFilters.h @@ -288,7 +288,7 @@ public: virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, bool aCompileEventHandlers); diff --git a/content/svg/content/src/nsSVGImageElement.cpp b/content/svg/content/src/nsSVGImageElement.cpp index 9ee7e9f4a94..b5582e41730 100644 --- a/content/svg/content/src/nsSVGImageElement.cpp +++ b/content/svg/content/src/nsSVGImageElement.cpp @@ -170,7 +170,7 @@ nsSVGImageElement::LoadSVGImage(bool aForce, bool aNotify) nsresult nsSVGImageElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) { diff --git a/content/svg/content/src/nsSVGImageElement.h b/content/svg/content/src/nsSVGImageElement.h index 139a2a19f44..663c9ac2e84 100644 --- a/content/svg/content/src/nsSVGImageElement.h +++ b/content/svg/content/src/nsSVGImageElement.h @@ -78,7 +78,7 @@ public: // nsIContent interface virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, bool aCompileEventHandlers); diff --git a/content/svg/content/src/nsSVGScriptElement.cpp b/content/svg/content/src/nsSVGScriptElement.cpp index e380a6dd87f..932de276483 100644 --- a/content/svg/content/src/nsSVGScriptElement.cpp +++ b/content/svg/content/src/nsSVGScriptElement.cpp @@ -95,7 +95,7 @@ public: nsIContent* aBindingParent, bool aCompileEventHandlers); virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* 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 nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) { MaybeProcessScript(); diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 871b9db9991..878d65a7eee 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -1097,7 +1097,7 @@ nsXULElement::BeforeSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, nsresult nsXULElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify) + const nsAttrValue* aValue, bool aNotify) { if (aNamespaceID == kNameSpaceID_None) { // XXX UnsetAttr handles more attributes than we do. See bug 233642. @@ -1113,17 +1113,24 @@ nsXULElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, // nsXULPrototypeAttribute is expensive!) bool defer = mPrototype == nsnull || mPrototype->mScriptTypeID == GetScriptTypeID(); - AddScriptEventListener(aName, *aValue, defer); + if (aValue->Type() == nsAttrValue::eString) { + AddScriptEventListener(aName, aValue->GetStringValue(), defer); + } else { + nsAutoString body; + aValue->ToString(body); + AddScriptEventListener(aName, body, defer); + } } // Hide chrome if needed if (mNodeInfo->Equals(nsGkAtoms::window) && aValue) { - if (aName == nsGkAtoms::hidechrome) { - HideWindowChrome(aValue->EqualsLiteral("true")); - } - else if (aName == nsGkAtoms::chromemargin) { - SetChromeMargins(aValue); - } + if (aName == nsGkAtoms::hidechrome) { + HideWindowChrome( + aValue->Equals(NS_LITERAL_STRING("true"), eCaseMatters)); + } + else if (aName == nsGkAtoms::chromemargin) { + SetChromeMargins(aValue); + } } // title, (in)activetitlebarcolor and drawintitlebar are settable on @@ -1134,15 +1141,22 @@ nsXULElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, document->NotifyPossibleTitleChange(false); } else if ((aName == nsGkAtoms::activetitlebarcolor || - aName == nsGkAtoms::inactivetitlebarcolor)) { + aName == nsGkAtoms::inactivetitlebarcolor) && aValue) { nscolor color = NS_RGBA(0, 0, 0, 0); - nsAttrValue attrValue; - attrValue.ParseColor(*aValue); - attrValue.GetColorValue(color); + if (aValue->Type() == nsAttrValue::eColor) { + aValue->GetColorValue(color); + } else { + nsAutoString tmp; + nsAttrValue attrValue; + aValue->ToString(tmp); + attrValue.ParseColor(tmp); + attrValue.GetColorValue(color); + } SetTitlebarColor(color, aName == nsGkAtoms::activetitlebarcolor); } else if (aName == nsGkAtoms::drawintitlebar) { - SetDrawsInTitlebar(aValue && aValue->EqualsLiteral("true")); + SetDrawsInTitlebar(aValue && + aValue->Equals(NS_LITERAL_STRING("true"), eCaseMatters)); } else if (aName == nsGkAtoms::localedir) { // if the localedir changed on the root element, reset the document direction @@ -2435,7 +2449,7 @@ private: }; void -nsXULElement::SetChromeMargins(const nsAString* aValue) +nsXULElement::SetChromeMargins(const nsAttrValue* aValue) { if (!aValue) return; @@ -2445,13 +2459,17 @@ nsXULElement::SetChromeMargins(const nsAString* aValue) return; // top, right, bottom, left - see nsAttrValue - nsAttrValue attrValue; nsIntMargin margins; + bool gotMargins = false; - nsAutoString data; - data.Assign(*aValue); - if (attrValue.ParseIntMarginValue(data) && - attrValue.GetIntMarginValue(margins)) { + if (aValue->Type() == nsAttrValue::eIntMarginValue) { + gotMargins = aValue->GetIntMarginValue(margins); + } else { + nsAutoString tmp; + aValue->ToString(tmp); + gotMargins = nsContentUtils::ParseIntMarginValue(tmp, margins); + } + if (gotMargins) { nsContentUtils::AddScriptRunner(new MarginSetter(mainWidget, margins)); } } diff --git a/content/xul/content/src/nsXULElement.h b/content/xul/content/src/nsXULElement.h index a24ce4f9728..7428456f098 100644 --- a/content/xul/content/src/nsXULElement.h +++ b/content/xul/content/src/nsXULElement.h @@ -629,7 +629,7 @@ protected: const nsAttrValueOrString* aValue, bool aNotify); virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, - const nsAString* aValue, bool aNotify); + const nsAttrValue* aValue, bool aNotify); virtual void UpdateEditableState(bool aNotify); @@ -657,7 +657,7 @@ protected: // attribute setters for widget nsresult HideWindowChrome(bool aShouldHide); - void SetChromeMargins(const nsAString* aValue); + void SetChromeMargins(const nsAttrValue* aValue); void ResetChromeMargins(); void SetTitlebarColor(nscolor aColor, bool aActive);