From d67ff5c3b655e696db586bc9a6970a6adcb00a59 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 25 Jul 2015 18:01:19 +1200 Subject: [PATCH] Bug 1184842. Pass aOldValue to all mutation observers. r=peterv --- accessible/generic/DocAccessible.cpp | 3 ++- docshell/shistory/nsSHEntryShared.cpp | 3 ++- dom/base/ShadowRoot.cpp | 3 ++- dom/base/nsContentList.cpp | 3 ++- dom/base/nsFrameLoader.cpp | 3 ++- dom/base/nsIMutationObserver.h | 17 +++++++++++------ dom/base/nsNodeUtils.cpp | 2 +- dom/base/nsScriptElement.cpp | 3 ++- dom/base/nsTextNode.cpp | 3 ++- dom/events/IMEContentObserver.cpp | 3 ++- dom/html/HTMLPropertiesCollection.cpp | 6 ++++-- dom/html/nsDOMStringMap.cpp | 3 ++- dom/svg/SVGMPathElement.cpp | 3 ++- dom/svg/SVGUseElement.cpp | 3 ++- dom/xml/nsXMLPrettyPrinter.cpp | 3 ++- dom/xslt/xpath/XPathResult.cpp | 3 ++- dom/xslt/xslt/txMozillaXSLTProcessor.cpp | 3 ++- dom/xul/XULDocument.cpp | 3 ++- dom/xul/templates/nsXULContentBuilder.cpp | 5 +++-- dom/xul/templates/nsXULTemplateBuilder.cpp | 3 ++- layout/base/nsPresShell.cpp | 3 ++- layout/generic/nsImageMap.cpp | 3 ++- layout/inspector/inDOMView.cpp | 3 ++- layout/svg/SVGTextFrame.cpp | 3 ++- layout/svg/nsSVGEffects.cpp | 3 ++- layout/xul/tree/nsTreeContentView.cpp | 3 ++- .../components/satchel/nsFormFillController.cpp | 3 ++- widget/cocoa/nsMenuGroupOwnerX.mm | 3 ++- 28 files changed, 67 insertions(+), 35 deletions(-) diff --git a/accessible/generic/DocAccessible.cpp b/accessible/generic/DocAccessible.cpp index 5eade3209ed..3935c82df59 100644 --- a/accessible/generic/DocAccessible.cpp +++ b/accessible/generic/DocAccessible.cpp @@ -733,7 +733,8 @@ void DocAccessible::AttributeChanged(nsIDocument* aDocument, dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { NS_ASSERTION(!IsDefunct(), "Attribute changed called on defunct document accessible!"); diff --git a/docshell/shistory/nsSHEntryShared.cpp b/docshell/shistory/nsSHEntryShared.cpp index bc527b0fdb7..dac92e7cf47 100644 --- a/docshell/shistory/nsSHEntryShared.cpp +++ b/docshell/shistory/nsSHEntryShared.cpp @@ -336,7 +336,8 @@ nsSHEntryShared::AttributeChanged(nsIDocument* aDocument, dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { RemoveFromBFCacheAsync(); } diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp index 88c822f86c2..8c5a78d8cb3 100644 --- a/dom/base/ShadowRoot.cpp +++ b/dom/base/ShadowRoot.cpp @@ -607,7 +607,8 @@ ShadowRoot::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { if (!IsPooledNode(aElement, aElement->GetParent(), mPoolHost)) { return; diff --git a/dom/base/nsContentList.cpp b/dom/base/nsContentList.cpp index 6ef5043180d..6e337cf240a 100644 --- a/dom/base/nsContentList.cpp +++ b/dom/base/nsContentList.cpp @@ -659,7 +659,8 @@ nsContentList::Item(uint32_t aIndex) void nsContentList::AttributeChanged(nsIDocument *aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { NS_PRECONDITION(aElement, "Must have a content node to work with"); diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index fd8d697fff6..75d038d850c 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -2590,7 +2590,8 @@ nsFrameLoader::AttributeChanged(nsIDocument* aDocument, mozilla::dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { MOZ_ASSERT(mObservingOwnerContent); // TODO: Implement ContentShellAdded for remote browsers (bug 658304) diff --git a/dom/base/nsIMutationObserver.h b/dom/base/nsIMutationObserver.h index 382e4656670..bee08a1ce8d 100644 --- a/dom/base/nsIMutationObserver.h +++ b/dom/base/nsIMutationObserver.h @@ -9,6 +9,7 @@ #include "nsISupports.h" +class nsAttrValue; class nsIAtom; class nsIContent; class nsIDocument; @@ -21,9 +22,8 @@ class Element; } // namespace mozilla #define NS_IMUTATION_OBSERVER_IID \ -{ 0x16fe5e3e, 0xeadc, 0x4312, \ - { 0x9d, 0x44, 0xb6, 0xbe, 0xdd, 0x6b, 0x54, 0x74 } } - +{ 0x51a4cec3, 0xb720, 0x4893, \ + { 0xb1, 0x11, 0x33, 0xca, 0xbe, 0xae, 0xbf, 0x57 } } /** * Information details about a characterdata change. Basically, we * view all changes as replacements of a length of text at some offset @@ -180,6 +180,8 @@ public: * @param aModType Whether or not the attribute was added, changed, or * removed. The constants are defined in * nsIDOMMutationEvent.h. + * @param aOldValue The old value, if either the old value or the new + * value are StoresOwnData() (or absent); null otherwise. * * @note Callers of this method might not hold a strong reference to the * observer. The observer is responsible for making sure it stays @@ -191,7 +193,8 @@ public: mozilla::dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) = 0; + int32_t aModType, + const nsAttrValue* aOldValue) = 0; /** * Notification that an attribute of an element has been @@ -343,7 +346,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIMutationObserver, NS_IMUTATION_OBSERVER_IID) mozilla::dom::Element* aElement, \ int32_t aNameSpaceID, \ nsIAtom* aAttribute, \ - int32_t aModType) override; + int32_t aModType, \ + const nsAttrValue* aOldValue) override; #define NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED \ virtual void ContentAppended(nsIDocument* aDocument, \ @@ -413,7 +417,8 @@ _class::AttributeChanged(nsIDocument* aDocument, \ mozilla::dom::Element* aElement, \ int32_t aNameSpaceID, \ nsIAtom* aAttribute, \ - int32_t aModType) \ + int32_t aModType, \ + const nsAttrValue* aOldValue) \ { \ } \ void \ diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index 301301fc3d0..68e9d814f43 100644 --- a/dom/base/nsNodeUtils.cpp +++ b/dom/base/nsNodeUtils.cpp @@ -141,7 +141,7 @@ nsNodeUtils::AttributeChanged(Element* aElement, nsIDocument* doc = aElement->OwnerDoc(); IMPL_MUTATION_NOTIFICATION(AttributeChanged, aElement, (doc, aElement, aNameSpaceID, aAttribute, - aModType)); + aModType, aOldValue)); } void diff --git a/dom/base/nsScriptElement.cpp b/dom/base/nsScriptElement.cpp index 3d1331f6031..40e44f1440b 100644 --- a/dom/base/nsScriptElement.cpp +++ b/dom/base/nsScriptElement.cpp @@ -83,7 +83,8 @@ nsScriptElement::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { MaybeProcessScript(); } diff --git a/dom/base/nsTextNode.cpp b/dom/base/nsTextNode.cpp index 5e29f2385f0..8ae17c31f59 100644 --- a/dom/base/nsTextNode.cpp +++ b/dom/base/nsTextNode.cpp @@ -268,7 +268,8 @@ nsAttributeTextNode::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { if (aNameSpaceID == mNameSpaceID && aAttribute == mAttrName && aElement == mGrandparent) { diff --git a/dom/events/IMEContentObserver.cpp b/dom/events/IMEContentObserver.cpp index 5dd212945fe..94dfd7bae50 100644 --- a/dom/events/IMEContentObserver.cpp +++ b/dom/events/IMEContentObserver.cpp @@ -756,7 +756,8 @@ IMEContentObserver::AttributeChanged(nsIDocument* aDocument, dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { mEndOfAddedTextCache.Clear(); mStartOfRemovingTextRangeCache.Clear(); diff --git a/dom/html/HTMLPropertiesCollection.cpp b/dom/html/HTMLPropertiesCollection.cpp index 19ecfa8ea7e..f309f7b57b3 100644 --- a/dom/html/HTMLPropertiesCollection.cpp +++ b/dom/html/HTMLPropertiesCollection.cpp @@ -153,7 +153,8 @@ HTMLPropertiesCollection::NamedItem(const nsAString& aName) void HTMLPropertiesCollection::AttributeChanged(nsIDocument *aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { mIsDirty = true; } @@ -427,7 +428,8 @@ PropertyNodeList::GetValues(JSContext* aCx, nsTArray& aResult, void PropertyNodeList::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { mIsDirty = true; } diff --git a/dom/html/nsDOMStringMap.cpp b/dom/html/nsDOMStringMap.cpp index 6a1e7a40629..fe2b8638865 100644 --- a/dom/html/nsDOMStringMap.cpp +++ b/dom/html/nsDOMStringMap.cpp @@ -259,7 +259,8 @@ bool nsDOMStringMap::AttrToDataProp(const nsAString& aAttr, void nsDOMStringMap::AttributeChanged(nsIDocument *aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { if ((aModType == nsIDOMMutationEvent::ADDITION || aModType == nsIDOMMutationEvent::REMOVAL) && diff --git a/dom/svg/SVGMPathElement.cpp b/dom/svg/SVGMPathElement.cpp index c6f7ebcecab..cc89c5ce368 100644 --- a/dom/svg/SVGMPathElement.cpp +++ b/dom/svg/SVGMPathElement.cpp @@ -165,7 +165,8 @@ SVGMPathElement::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { if (aNameSpaceID == kNameSpaceID_None) { if (aAttribute == nsGkAtoms::d) { diff --git a/dom/svg/SVGUseElement.cpp b/dom/svg/SVGUseElement.cpp index 4e86d40dfb2..bba487fdf57 100644 --- a/dom/svg/SVGUseElement.cpp +++ b/dom/svg/SVGUseElement.cpp @@ -156,7 +156,8 @@ SVGUseElement::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { if (nsContentUtils::IsInSameAnonymousTree(this, aElement)) { TriggerReclone(); diff --git a/dom/xml/nsXMLPrettyPrinter.cpp b/dom/xml/nsXMLPrettyPrinter.cpp index f18ff7bce71..906ffc4308a 100644 --- a/dom/xml/nsXMLPrettyPrinter.cpp +++ b/dom/xml/nsXMLPrettyPrinter.cpp @@ -218,7 +218,8 @@ nsXMLPrettyPrinter::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { MaybeUnhook(aElement); } diff --git a/dom/xslt/xpath/XPathResult.cpp b/dom/xslt/xpath/XPathResult.cpp index cd76f3083a1..f3ea155c608 100644 --- a/dom/xslt/xpath/XPathResult.cpp +++ b/dom/xslt/xpath/XPathResult.cpp @@ -136,7 +136,8 @@ XPathResult::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { Invalidate(aElement); } diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp index 44124021c96..69a91213e11 100644 --- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp +++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp @@ -1244,7 +1244,8 @@ txMozillaXSLTProcessor::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { mStylesheet = nullptr; } diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp index 5b1787bcbf6..63f7afe4276 100644 --- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -931,7 +931,8 @@ XULDocument::AttributeWillChange(nsIDocument* aDocument, void XULDocument::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, - nsIAtom* aAttribute, int32_t aModType) + nsIAtom* aAttribute, int32_t aModType, + const nsAttrValue* aOldValue) { NS_ASSERTION(aDocument == this, "unexpected doc"); diff --git a/dom/xul/templates/nsXULContentBuilder.cpp b/dom/xul/templates/nsXULContentBuilder.cpp index e6e3e050f10..890728c2feb 100644 --- a/dom/xul/templates/nsXULContentBuilder.cpp +++ b/dom/xul/templates/nsXULContentBuilder.cpp @@ -1510,7 +1510,8 @@ nsXULContentBuilder::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { nsCOMPtr kungFuDeathGrip(this); @@ -1536,7 +1537,7 @@ nsXULContentBuilder::AttributeChanged(nsIDocument* aDocument, // Pass along to the generic template builder. nsXULTemplateBuilder::AttributeChanged(aDocument, aElement, aNameSpaceID, - aAttribute, aModType); + aAttribute, aModType, aOldValue); } void diff --git a/dom/xul/templates/nsXULTemplateBuilder.cpp b/dom/xul/templates/nsXULTemplateBuilder.cpp index 82e7fcfe7e3..3dd12cf02f1 100644 --- a/dom/xul/templates/nsXULTemplateBuilder.cpp +++ b/dom/xul/templates/nsXULTemplateBuilder.cpp @@ -1093,7 +1093,8 @@ nsXULTemplateBuilder::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { if (aElement == mRoot && aNameSpaceID == kNameSpaceID_None) { // Check for a change to the 'ref' attribute on an atom, in which diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index b0aa59d8979..73e079c6711 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4257,7 +4257,8 @@ PresShell::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { NS_PRECONDITION(!mIsDocumentGone, "Unexpected AttributeChanged"); NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument"); diff --git a/layout/generic/nsImageMap.cpp b/layout/generic/nsImageMap.cpp index a333eb0d3f6..79ce5e6d81a 100644 --- a/layout/generic/nsImageMap.cpp +++ b/layout/generic/nsImageMap.cpp @@ -919,7 +919,8 @@ nsImageMap::AttributeChanged(nsIDocument* aDocument, dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { // If the parent of the changing content node is our map then update // the map. But only do this if the node is an HTML or diff --git a/layout/inspector/inDOMView.cpp b/layout/inspector/inDOMView.cpp index 025be9911e1..eee24ed6d93 100644 --- a/layout/inspector/inDOMView.cpp +++ b/layout/inspector/inDOMView.cpp @@ -632,7 +632,8 @@ inDOMView::NodeWillBeDestroyed(const nsINode* aNode) void inDOMView::AttributeChanged(nsIDocument* aDocument, dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { if (!mTree) { return; diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index 445d4f4b0ac..242152ece90 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -3467,7 +3467,8 @@ SVGTextFrame::MutationObserver::AttributeChanged( mozilla::dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { if (!aElement->IsSVGElement()) { return; diff --git a/layout/svg/nsSVGEffects.cpp b/layout/svg/nsSVGEffects.cpp index 9bf0ca173e4..123aa64f7c3 100644 --- a/layout/svg/nsSVGEffects.cpp +++ b/layout/svg/nsSVGEffects.cpp @@ -112,7 +112,8 @@ nsSVGRenderingObserver::AttributeChanged(nsIDocument* aDocument, dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { // An attribute belonging to the element that we are observing *or one of its // descendants* has changed. diff --git a/layout/xul/tree/nsTreeContentView.cpp b/layout/xul/tree/nsTreeContentView.cpp index c1e93625f2f..1730838d196 100644 --- a/layout/xul/tree/nsTreeContentView.cpp +++ b/layout/xul/tree/nsTreeContentView.cpp @@ -715,7 +715,8 @@ nsTreeContentView::AttributeChanged(nsIDocument* aDocument, dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { // Lots of codepaths under here that do all sorts of stuff, so be safe. nsCOMPtr kungFuDeathGrip(this); diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp index bd492956864..0675a2a3c42 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -114,7 +114,8 @@ void nsFormFillController::AttributeChanged(nsIDocument* aDocument, mozilla::dom::Element* aElement, int32_t aNameSpaceID, - nsIAtom* aAttribute, int32_t aModType) + nsIAtom* aAttribute, int32_t aModType, + const nsAttrValue* aOldValue) { if ((aAttribute == nsGkAtoms::type || aAttribute == nsGkAtoms::readonly || aAttribute == nsGkAtoms::autocomplete) && diff --git a/widget/cocoa/nsMenuGroupOwnerX.mm b/widget/cocoa/nsMenuGroupOwnerX.mm index 3afde7221bc..3901e0aa15e 100644 --- a/widget/cocoa/nsMenuGroupOwnerX.mm +++ b/widget/cocoa/nsMenuGroupOwnerX.mm @@ -100,7 +100,8 @@ void nsMenuGroupOwnerX::AttributeChanged(nsIDocument* aDocument, dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, - int32_t aModType) + int32_t aModType, + const nsAttrValue* aOldValue) { nsCOMPtr kungFuDeathGrip(this); nsChangeObserver* obs = LookupContentChangeObserver(aElement);