Bug 975688 part.18 Rename nsDOMMutationEvent to mozilla::dom::MutationEvent r=smaug
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -812,20 +812,16 @@ DOMInterfaces = {
'MozTimeManager': {
'nativeType': 'mozilla::dom::time::TimeManager',
},
'MozVoicemail': {
'nativeType': 'mozilla::dom::Voicemail',
},
-'MutationEvent': {
- 'nativeType': 'nsDOMMutationEvent',
-},
-
'MutationObserver': {
'nativeType': 'nsDOMMutationObserver',
},
'MutationRecord': {
'nativeType': 'nsDOMMutationRecord',
'headerFile': 'nsDOMMutationObserver.h',
'resultNotAddRefed': [ 'target', 'addedNodes', 'removedNodes',
rename from dom/events/nsDOMMutationEvent.cpp
rename to dom/events/MutationEvent.cpp
--- a/dom/events/nsDOMMutationEvent.cpp
+++ b/dom/events/MutationEvent.cpp
@@ -1,96 +1,104 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsCOMPtr.h"
-#include "nsDOMMutationEvent.h"
+#include "mozilla/dom/MutationEvent.h"
#include "mozilla/InternalMutationEvent.h"
-using namespace mozilla;
-
class nsPresContext;
-nsDOMMutationEvent::nsDOMMutationEvent(mozilla::dom::EventTarget* aOwner,
- nsPresContext* aPresContext,
- InternalMutationEvent* aEvent)
+namespace mozilla {
+namespace dom {
+
+MutationEvent::MutationEvent(EventTarget* aOwner,
+ nsPresContext* aPresContext,
+ InternalMutationEvent* aEvent)
: nsDOMEvent(aOwner, aPresContext,
aEvent ? aEvent : new InternalMutationEvent(false, 0))
{
mEventIsInternal = (aEvent == nullptr);
}
-NS_INTERFACE_MAP_BEGIN(nsDOMMutationEvent)
+NS_INTERFACE_MAP_BEGIN(MutationEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMMutationEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-NS_IMPL_ADDREF_INHERITED(nsDOMMutationEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMutationEvent, nsDOMEvent)
+NS_IMPL_ADDREF_INHERITED(MutationEvent, nsDOMEvent)
+NS_IMPL_RELEASE_INHERITED(MutationEvent, nsDOMEvent)
already_AddRefed<nsINode>
-nsDOMMutationEvent::GetRelatedNode()
+MutationEvent::GetRelatedNode()
{
nsCOMPtr<nsINode> n =
do_QueryInterface(mEvent->AsMutationEvent()->mRelatedNode);
return n.forget();
}
NS_IMETHODIMP
-nsDOMMutationEvent::GetRelatedNode(nsIDOMNode** aRelatedNode)
+MutationEvent::GetRelatedNode(nsIDOMNode** aRelatedNode)
{
nsCOMPtr<nsINode> relatedNode = GetRelatedNode();
nsCOMPtr<nsIDOMNode> relatedDOMNode = relatedNode ? relatedNode->AsDOMNode() : nullptr;
relatedDOMNode.forget(aRelatedNode);
return NS_OK;
}
NS_IMETHODIMP
-nsDOMMutationEvent::GetPrevValue(nsAString& aPrevValue)
+MutationEvent::GetPrevValue(nsAString& aPrevValue)
{
InternalMutationEvent* mutation = mEvent->AsMutationEvent();
if (mutation->mPrevAttrValue)
mutation->mPrevAttrValue->ToString(aPrevValue);
return NS_OK;
}
NS_IMETHODIMP
-nsDOMMutationEvent::GetNewValue(nsAString& aNewValue)
+MutationEvent::GetNewValue(nsAString& aNewValue)
{
InternalMutationEvent* mutation = mEvent->AsMutationEvent();
if (mutation->mNewAttrValue)
mutation->mNewAttrValue->ToString(aNewValue);
return NS_OK;
}
NS_IMETHODIMP
-nsDOMMutationEvent::GetAttrName(nsAString& aAttrName)
+MutationEvent::GetAttrName(nsAString& aAttrName)
{
InternalMutationEvent* mutation = mEvent->AsMutationEvent();
if (mutation->mAttrName)
mutation->mAttrName->ToString(aAttrName);
return NS_OK;
}
uint16_t
-nsDOMMutationEvent::AttrChange()
+MutationEvent::AttrChange()
{
return mEvent->AsMutationEvent()->mAttrChange;
}
NS_IMETHODIMP
-nsDOMMutationEvent::GetAttrChange(uint16_t* aAttrChange)
+MutationEvent::GetAttrChange(uint16_t* aAttrChange)
{
*aAttrChange = AttrChange();
return NS_OK;
}
NS_IMETHODIMP
-nsDOMMutationEvent::InitMutationEvent(const nsAString& aTypeArg, bool aCanBubbleArg, bool aCancelableArg, nsIDOMNode* aRelatedNodeArg, const nsAString& aPrevValueArg, const nsAString& aNewValueArg, const nsAString& aAttrNameArg, uint16_t aAttrChangeArg)
+MutationEvent::InitMutationEvent(const nsAString& aTypeArg,
+ bool aCanBubbleArg,
+ bool aCancelableArg,
+ nsIDOMNode* aRelatedNodeArg,
+ const nsAString& aPrevValueArg,
+ const nsAString& aNewValueArg,
+ const nsAString& aAttrNameArg,
+ uint16_t aAttrChangeArg)
{
nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
InternalMutationEvent* mutation = mEvent->AsMutationEvent();
mutation->mRelatedNode = aRelatedNodeArg;
if (!aPrevValueArg.IsEmpty())
mutation->mPrevAttrValue = do_GetAtom(aPrevValueArg);
@@ -99,17 +107,23 @@ nsDOMMutationEvent::InitMutationEvent(co
if (!aAttrNameArg.IsEmpty()) {
mutation->mAttrName = do_GetAtom(aAttrNameArg);
}
mutation->mAttrChange = aAttrChangeArg;
return NS_OK;
}
-nsresult NS_NewDOMMutationEvent(nsIDOMEvent** aInstancePtrResult,
- mozilla::dom::EventTarget* aOwner,
- nsPresContext* aPresContext,
- InternalMutationEvent* aEvent)
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMMutationEvent(nsIDOMEvent** aInstancePtrResult,
+ EventTarget* aOwner,
+ nsPresContext* aPresContext,
+ InternalMutationEvent* aEvent)
{
- nsDOMMutationEvent* it = new nsDOMMutationEvent(aOwner, aPresContext, aEvent);
-
+ MutationEvent* it = new MutationEvent(aOwner, aPresContext, aEvent);
return CallQueryInterface(it, aInstancePtrResult);
}
rename from dom/events/nsDOMMutationEvent.h
rename to dom/events/MutationEvent.h
--- a/dom/events/nsDOMMutationEvent.h
+++ b/dom/events/MutationEvent.h
@@ -1,41 +1,44 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifndef nsDOMMutationEvent_h__
-#define nsDOMMutationEvent_h__
+#ifndef mozilla_dom_MutationEvent_h_
+#define mozilla_dom_MutationEvent_h_
#include "nsIDOMMutationEvent.h"
#include "nsINode.h"
#include "nsDOMEvent.h"
#include "mozilla/dom/MutationEventBinding.h"
#include "mozilla/EventForwards.h"
-class nsDOMMutationEvent : public nsDOMEvent,
- public nsIDOMMutationEvent
+namespace mozilla {
+namespace dom {
+
+class MutationEvent : public nsDOMEvent,
+ public nsIDOMMutationEvent
{
public:
- nsDOMMutationEvent(mozilla::dom::EventTarget* aOwner,
- nsPresContext* aPresContext,
- mozilla::InternalMutationEvent* aEvent);
+ MutationEvent(EventTarget* aOwner,
+ nsPresContext* aPresContext,
+ InternalMutationEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMMUTATIONEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMEVENT
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
{
- return mozilla::dom::MutationEventBinding::Wrap(aCx, aScope, this);
+ return MutationEventBinding::Wrap(aCx, aScope, this);
}
// xpidl implementation
// GetPrevValue(nsAString& aPrevValue);
// GetNewValue(nsAString& aNewValue);
// GetAttrName(nsAString& aAttrName);
already_AddRefed<nsINode> GetRelatedNode();
@@ -43,17 +46,20 @@ public:
uint16_t AttrChange();
void InitMutationEvent(const nsAString& aType,
bool& aCanBubble, bool& aCancelable,
nsINode* aRelatedNode,
const nsAString& aPrevValue,
const nsAString& aNewValue,
const nsAString& aAttrName,
- uint16_t& aAttrChange, mozilla::ErrorResult& aRv)
+ uint16_t& aAttrChange, ErrorResult& aRv)
{
aRv = InitMutationEvent(aType, aCanBubble, aCancelable,
aRelatedNode ? aRelatedNode->AsDOMNode() : nullptr,
aPrevValue, aNewValue, aAttrName, aAttrChange);
}
};
-#endif // nsDOMMutationEvent_h__
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_MutationEvent_h_
--- a/dom/events/moz.build
+++ b/dom/events/moz.build
@@ -46,16 +46,17 @@ EXPORTS.mozilla.dom += [
'DeviceMotionEvent.h',
'DragEvent.h',
'EventTarget.h',
'FocusEvent.h',
'KeyboardEvent.h',
'MessageEvent.h',
'MouseEvent.h',
'MouseScrollEvent.h',
+ 'MutationEvent.h',
'PointerEvent.h',
'SimpleGestureEvent.h',
'Touch.h',
'WheelEvent.h',
]
if CONFIG['MOZ_WEBSPEECH']:
EXPORTS.mozilla.dom += ['SpeechRecognitionError.h']
@@ -71,20 +72,20 @@ UNIFIED_SOURCES += [
'DeviceMotionEvent.cpp',
'DragEvent.cpp',
'EventTarget.cpp',
'FocusEvent.cpp',
'KeyboardEvent.cpp',
'MessageEvent.cpp',
'MouseEvent.cpp',
'MouseScrollEvent.cpp',
+ 'MutationEvent.cpp',
'nsAsyncDOMEvent.cpp',
'nsContentEventHandler.cpp',
'nsDOMEventTargetHelper.cpp',
- 'nsDOMMutationEvent.cpp',
'nsDOMNotifyAudioAvailableEvent.cpp',
'nsDOMTextEvent.cpp',
'nsDOMTouchEvent.cpp',
'nsDOMTransitionEvent.cpp',
'nsDOMXULCommandEvent.cpp',
'nsEventDispatcher.cpp',
'nsEventListenerService.cpp',
'nsIMEStateManager.cpp',