Bug 920425 part.8 Use mozilla::WidgetEvent::AsClipboardEvent() r=smaug

This commit is contained in:
Masayuki Nakano 2013-10-18 15:10:22 +09:00
parent d853b14747
commit abc75d0db8
3 changed files with 11 additions and 14 deletions

View File

@ -32,14 +32,15 @@ NS_IMPL_ADDREF_INHERITED(nsDOMClipboardEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMClipboardEvent, nsDOMEvent)
nsresult
nsDOMClipboardEvent::InitClipboardEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
nsIDOMDataTransfer* clipboardData)
nsDOMClipboardEvent::InitClipboardEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
nsIDOMDataTransfer* aClipboardData)
{
nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv);
InternalClipboardEvent* event = static_cast<InternalClipboardEvent*>(mEvent);
event->clipboardData = clipboardData;
mEvent->AsClipboardEvent()->clipboardData = aClipboardData;
return NS_OK;
}
@ -57,8 +58,7 @@ nsDOMClipboardEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
nsRefPtr<nsDOMDataTransfer> clipboardData;
if (e->mEventIsInternal) {
InternalClipboardEvent* event =
static_cast<InternalClipboardEvent*>(e->mEvent);
InternalClipboardEvent* event = e->mEvent->AsClipboardEvent();
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
@ -84,7 +84,7 @@ nsDOMClipboardEvent::GetClipboardData(nsIDOMDataTransfer** aClipboardData)
nsIDOMDataTransfer*
nsDOMClipboardEvent::GetClipboardData()
{
InternalClipboardEvent* event = static_cast<InternalClipboardEvent*>(mEvent);
InternalClipboardEvent* event = mEvent->AsClipboardEvent();
if (!event->clipboardData) {
if (mEventIsInternal) {

View File

@ -152,8 +152,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEvent)
nullptr;
break;
case NS_CLIPBOARD_EVENT:
static_cast<InternalClipboardEvent*>(tmp->mEvent)->clipboardData =
nullptr;
tmp->mEvent->AsClipboardEvent()->clipboardData = nullptr;
break;
case NS_MUTATION_EVENT:
static_cast<InternalMutationEvent*>(tmp->mEvent)->mRelatedNode =
@ -196,8 +195,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent)
break;
case NS_CLIPBOARD_EVENT:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->clipboardData");
cb.NoteXPCOMChild(
static_cast<InternalClipboardEvent*>(tmp->mEvent)->clipboardData);
cb.NoteXPCOMChild(tmp->mEvent->AsClipboardEvent()->clipboardData);
break;
case NS_MUTATION_EVENT:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->mRelatedNode");
@ -567,8 +565,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_CLIPBOARD_EVENT:
{
InternalClipboardEvent* oldClipboardEvent =
static_cast<InternalClipboardEvent*>(mEvent);
InternalClipboardEvent* oldClipboardEvent = mEvent->AsClipboardEvent();
InternalClipboardEvent* clipboardEvent =
new InternalClipboardEvent(false, msg);
clipboardEvent->AssignClipboardEventData(*oldClipboardEvent, true);

View File

@ -728,7 +728,7 @@ nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner,
static_cast<WidgetTextEvent*>(aEvent));
case NS_CLIPBOARD_EVENT:
return NS_NewDOMClipboardEvent(aDOMEvent, aOwner, aPresContext,
static_cast<InternalClipboardEvent*>(aEvent));
aEvent->AsClipboardEvent());
case NS_SVGZOOM_EVENT:
return NS_NewDOMSVGZoomEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetGUIEvent*>(aEvent));