Bug 920377 part.8 Get rid of nsClipboardEvent r=roc

This commit is contained in:
Masayuki Nakano 2013-09-27 15:20:55 +09:00
parent 05e8f87b4b
commit e1d3994561
8 changed files with 21 additions and 17 deletions

View File

@ -649,7 +649,7 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres
clipboardData = new nsDOMDataTransfer(aType, aType == NS_PASTE, aClipboardType);
nsEventStatus status = nsEventStatus_eIgnore;
nsClipboardEvent evt(true, aType);
InternalClipboardEvent evt(true, aType);
evt.clipboardData = clipboardData;
nsEventDispatcher::Dispatch(content, presShell->GetPresContext(), &evt, nullptr,
&status);

View File

@ -8,11 +8,13 @@
#include "nsIClipboard.h"
#include "mozilla/ContentEvents.h"
using namespace mozilla;
nsDOMClipboardEvent::nsDOMClipboardEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
nsClipboardEvent* aEvent)
InternalClipboardEvent* aEvent)
: nsDOMEvent(aOwner, aPresContext, aEvent ? aEvent :
new nsClipboardEvent(false, 0))
new InternalClipboardEvent(false, 0))
{
if (aEvent) {
mEventIsInternal = false;
@ -25,7 +27,7 @@ nsDOMClipboardEvent::nsDOMClipboardEvent(mozilla::dom::EventTarget* aOwner,
nsDOMClipboardEvent::~nsDOMClipboardEvent()
{
if (mEventIsInternal && mEvent->eventStructType == NS_CLIPBOARD_EVENT) {
delete static_cast<nsClipboardEvent*>(mEvent);
delete static_cast<InternalClipboardEvent*>(mEvent);
mEvent = nullptr;
}
}
@ -44,7 +46,7 @@ nsDOMClipboardEvent::InitClipboardEvent(const nsAString & aType, bool aCanBubble
nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv);
nsClipboardEvent* event = static_cast<nsClipboardEvent*>(mEvent);
InternalClipboardEvent* event = static_cast<InternalClipboardEvent*>(mEvent);
event->clipboardData = clipboardData;
return NS_OK;
@ -63,7 +65,8 @@ nsDOMClipboardEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
nsRefPtr<nsDOMDataTransfer> clipboardData;
if (e->mEventIsInternal) {
nsClipboardEvent* event = static_cast<nsClipboardEvent*>(e->mEvent);
InternalClipboardEvent* event =
static_cast<InternalClipboardEvent*>(e->mEvent);
if (event) {
// Always create a clipboardData for the copy event. If this is changed to
// support other types of events, make sure that read/write privileges are
@ -89,7 +92,7 @@ nsDOMClipboardEvent::GetClipboardData(nsIDOMDataTransfer** aClipboardData)
nsIDOMDataTransfer*
nsDOMClipboardEvent::GetClipboardData()
{
nsClipboardEvent* event = static_cast<nsClipboardEvent*>(mEvent);
InternalClipboardEvent* event = static_cast<InternalClipboardEvent*>(mEvent);
if (!event->clipboardData) {
if (mEventIsInternal) {
@ -106,7 +109,7 @@ nsDOMClipboardEvent::GetClipboardData()
nsresult NS_NewDOMClipboardEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
nsClipboardEvent *aEvent)
InternalClipboardEvent* aEvent)
{
nsDOMClipboardEvent* it =
new nsDOMClipboardEvent(aOwner, aPresContext, aEvent);

View File

@ -17,7 +17,7 @@ class nsDOMClipboardEvent : public nsDOMEvent,
public:
nsDOMClipboardEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
nsClipboardEvent* aEvent);
mozilla::InternalClipboardEvent* aEvent);
virtual ~nsDOMClipboardEvent();
NS_DECL_ISUPPORTS_INHERITED

View File

@ -150,7 +150,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEvent)
static_cast<nsMouseEvent_base*>(tmp->mEvent)->relatedTarget = nullptr;
break;
case NS_CLIPBOARD_EVENT:
static_cast<nsClipboardEvent*>(tmp->mEvent)->clipboardData = nullptr;
static_cast<InternalClipboardEvent*>(tmp->mEvent)->clipboardData =
nullptr;
break;
case NS_MUTATION_EVENT:
static_cast<InternalMutationEvent*>(tmp->mEvent)->mRelatedNode =
@ -194,7 +195,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent)
case NS_CLIPBOARD_EVENT:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->clipboardData");
cb.NoteXPCOMChild(
static_cast<nsClipboardEvent*>(tmp->mEvent)->clipboardData);
static_cast<InternalClipboardEvent*>(tmp->mEvent)->clipboardData);
break;
case NS_MUTATION_EVENT:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->mRelatedNode");
@ -563,8 +564,10 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_CLIPBOARD_EVENT:
{
nsClipboardEvent* oldClipboardEvent = static_cast<nsClipboardEvent*>(mEvent);
nsClipboardEvent* clipboardEvent = new nsClipboardEvent(false, msg);
InternalClipboardEvent* oldClipboardEvent =
static_cast<InternalClipboardEvent*>(mEvent);
InternalClipboardEvent* clipboardEvent =
new InternalClipboardEvent(false, msg);
clipboardEvent->AssignClipboardEventData(*oldClipboardEvent, true);
newEvent = clipboardEvent;
break;

View File

@ -726,7 +726,7 @@ nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner,
static_cast<nsTextEvent*>(aEvent));
case NS_CLIPBOARD_EVENT:
return NS_NewDOMClipboardEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsClipboardEvent*>(aEvent));
static_cast<InternalClipboardEvent*>(aEvent));
case NS_SVGZOOM_EVENT:
return NS_NewDOMSVGZoomEvent(aDOMEvent, aOwner, aPresContext,
static_cast<nsGUIEvent*>(aEvent));

View File

@ -267,7 +267,7 @@ nsresult
NS_NewDOMClipboardEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
nsClipboardEvent *aEvent);
mozilla::InternalClipboardEvent* aEvent);
nsresult
NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult,

View File

@ -252,6 +252,5 @@ typedef mozilla::InternalScriptErrorEvent nsScriptErrorEvent;
typedef mozilla::InternalScrollPortEvent nsScrollPortEvent;
typedef mozilla::InternalScrollAreaEvent nsScrollAreaEvent;
typedef mozilla::InternalFormEvent nsFormEvent;
typedef mozilla::InternalClipboardEvent nsClipboardEvent;
#endif // mozilla_ContentEvents_h__

View File

@ -132,6 +132,5 @@ typedef mozilla::InternalScriptErrorEvent nsScriptErrorEvent;
typedef mozilla::InternalScrollPortEvent nsScrollPortEvent;
typedef mozilla::InternalScrollAreaEvent nsScrollAreaEvent;
typedef mozilla::InternalFormEvent nsFormEvent;
typedef mozilla::InternalClipboardEvent nsClipboardEvent;
#endif // mozilla_EventForwards_h__