mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 847586 - Paris binding for MutationEvent, r=Ms2ger
--HG-- extra : rebase_source : ce847b7cef923334274474e34db66158c110646c
This commit is contained in:
parent
19deb1bb62
commit
bf326a58dc
@ -6,8 +6,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsDOMMutationEvent.h"
|
||||
#include "nsMutationEvent.h"
|
||||
|
||||
|
||||
class nsPresContext;
|
||||
|
||||
@ -18,6 +16,7 @@ nsDOMMutationEvent::nsDOMMutationEvent(mozilla::dom::EventTarget* aOwner,
|
||||
aEvent ? aEvent : new nsMutationEvent(false, 0))
|
||||
{
|
||||
mEventIsInternal = (aEvent == nullptr);
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
nsDOMMutationEvent::~nsDOMMutationEvent()
|
||||
@ -42,10 +41,9 @@ NS_IMPL_RELEASE_INHERITED(nsDOMMutationEvent, nsDOMEvent)
|
||||
NS_IMETHODIMP
|
||||
nsDOMMutationEvent::GetRelatedNode(nsIDOMNode** aRelatedNode)
|
||||
{
|
||||
*aRelatedNode = nullptr;
|
||||
nsMutationEvent* mutation = static_cast<nsMutationEvent*>(mEvent);
|
||||
*aRelatedNode = mutation->mRelatedNode;
|
||||
NS_IF_ADDREF(*aRelatedNode);
|
||||
nsCOMPtr<nsINode> relatedNode = GetRelatedNode();
|
||||
nsCOMPtr<nsIDOMNode> relatedDOMNode = relatedNode ? relatedNode->AsDOMNode() : nullptr;
|
||||
relatedDOMNode.forget(aRelatedNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -79,10 +77,7 @@ nsDOMMutationEvent::GetAttrName(nsAString& aAttrName)
|
||||
NS_IMETHODIMP
|
||||
nsDOMMutationEvent::GetAttrChange(uint16_t* aAttrChange)
|
||||
{
|
||||
*aAttrChange = 0;
|
||||
nsMutationEvent* mutation = static_cast<nsMutationEvent*>(mEvent);
|
||||
if (mutation->mAttrChange)
|
||||
*aAttrChange = mutation->mAttrChange;
|
||||
*aAttrChange = AttrChange();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsMutationEvent.h"
|
||||
#include "mozilla/dom/MutationEventBinding.h"
|
||||
|
||||
class nsDOMMutationEvent : public nsDOMEvent,
|
||||
public nsIDOMMutationEvent
|
||||
@ -17,13 +19,48 @@ public:
|
||||
nsPresContext* aPresContext, nsMutationEvent* aEvent);
|
||||
|
||||
virtual ~nsDOMMutationEvent();
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_DECL_NSIDOMMUTATIONEVENT
|
||||
|
||||
// Forward to base class
|
||||
NS_FORWARD_TO_NSDOMEVENT
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return mozilla::dom::MutationEventBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
// xpidl implementation
|
||||
// GetPrevValue(nsAString& aPrevValue);
|
||||
// GetNewValue(nsAString& aNewValue);
|
||||
// GetAttrName(nsAString& aAttrName);
|
||||
|
||||
already_AddRefed<nsINode> GetRelatedNode()
|
||||
{
|
||||
nsCOMPtr<nsINode> n =
|
||||
do_QueryInterface(static_cast<nsMutationEvent*>(mEvent)->mRelatedNode);
|
||||
return n.forget();
|
||||
}
|
||||
|
||||
uint16_t AttrChange()
|
||||
{
|
||||
return static_cast<nsMutationEvent*>(mEvent)->mAttrChange;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
aRv = InitMutationEvent(aType, aCanBubble, aCancelable,
|
||||
aRelatedNode ? aRelatedNode->AsDOMNode() : nullptr,
|
||||
aPrevValue, aNewValue, aAttrName, aAttrChange);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // nsDOMMutationEvent_h__
|
||||
|
@ -518,6 +518,9 @@ DOMInterfaces = {
|
||||
'workers': True,
|
||||
}],
|
||||
|
||||
'MutationEvent': {
|
||||
'nativeType': 'nsDOMMutationEvent',
|
||||
},
|
||||
|
||||
'MutationObserver': {
|
||||
'nativeType': 'nsDOMMutationObserver',
|
||||
|
33
dom/webidl/MutationEvent.webidl
Normal file
33
dom/webidl/MutationEvent.webidl
Normal file
@ -0,0 +1,33 @@
|
||||
/* -*- Mode: IDL; 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
interface MutationEvent : Event
|
||||
{
|
||||
const unsigned short MODIFICATION = 1;
|
||||
const unsigned short ADDITION = 2;
|
||||
const unsigned short REMOVAL = 3;
|
||||
|
||||
readonly attribute Node? relatedNode;
|
||||
readonly attribute DOMString prevValue;
|
||||
readonly attribute DOMString newValue;
|
||||
readonly attribute DOMString attrName;
|
||||
readonly attribute unsigned short attrChange;
|
||||
|
||||
[Throws]
|
||||
void initMutationEvent(DOMString type,
|
||||
boolean canBubble,
|
||||
boolean cancelable,
|
||||
Node? relatedNode,
|
||||
DOMString prevValue,
|
||||
DOMString newValue,
|
||||
DOMString attrName,
|
||||
unsigned short attrChange);
|
||||
};
|
@ -125,6 +125,7 @@ webidl_files = \
|
||||
Location.webidl \
|
||||
MediaStream.webidl \
|
||||
MessageEvent.webidl \
|
||||
MutationEvent.webidl \
|
||||
MutationObserver.webidl \
|
||||
Node.webidl \
|
||||
NodeFilter.webidl \
|
||||
|
Loading…
Reference in New Issue
Block a user