Bug 1031051: Part 8 - Migrate SmartCardEvent to the WebIDL code generator. r=smaug

This commit is contained in:
Kyle Huey 2014-06-30 16:02:02 -07:00
parent e2e1171cb1
commit bf1fd04304
8 changed files with 14 additions and 46 deletions

View File

@ -31,7 +31,6 @@ XPIDL_SOURCES += [
'nsIDOMRecordErrorEvent.idl', 'nsIDOMRecordErrorEvent.idl',
'nsIDOMScrollAreaEvent.idl', 'nsIDOMScrollAreaEvent.idl',
'nsIDOMSimpleGestureEvent.idl', 'nsIDOMSimpleGestureEvent.idl',
'nsIDOMSmartCardEvent.idl',
'nsIDOMStyleRuleChangeEvent.idl', 'nsIDOMStyleRuleChangeEvent.idl',
'nsIDOMStyleSheetApplicableStateChangeEvent.idl', 'nsIDOMStyleSheetApplicableStateChangeEvent.idl',
'nsIDOMStyleSheetChangeEvent.idl', 'nsIDOMStyleSheetChangeEvent.idl',

View File

@ -1,21 +0,0 @@
/* -*- 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/. */
#include "nsIDOMEvent.idl"
%{C++
#define SMARTCARDEVENT_INSERT "smartcard-insert"
#define SMARTCARDEVENT_REMOVE "smartcard-remove"
%}
[builtinclass, uuid(cd251f11-7020-4f85-a7bd-94c98d884fa7)]
interface nsIDOMSmartCardEvent : nsIDOMEvent
{
readonly attribute DOMString tokenName;
[noscript] void initSmartCardEvent(in DOMString aTypeArg,
in boolean aCanBubbleArg,
in boolean aCancelableArg,
in DOMString aTokenNAme);
};

View File

@ -4,7 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. * You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
[Constructor(DOMString type, optional SmartCardEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] [Constructor(DOMString type, optional SmartCardEventInit eventInitDict)]
interface SmartCardEvent : Event interface SmartCardEvent : Event
{ {
readonly attribute DOMString? tokenName; readonly attribute DOMString? tokenName;

View File

@ -655,6 +655,7 @@ GENERATED_EVENTS_WEBIDL_FILES = [
'RTCPeerConnectionIceEvent.webidl', 'RTCPeerConnectionIceEvent.webidl',
'RTCPeerConnectionIdentityErrorEvent.webidl', 'RTCPeerConnectionIdentityErrorEvent.webidl',
'RTCPeerConnectionIdentityEvent.webidl', 'RTCPeerConnectionIdentityEvent.webidl',
'SmartCardEvent.webidl',
'TrackEvent.webidl', 'TrackEvent.webidl',
'UserProximityEvent.webidl', 'UserProximityEvent.webidl',
'USSDReceivedEvent.webidl', 'USSDReceivedEvent.webidl',

View File

@ -13,7 +13,6 @@ simple_events = [
'DOMTransactionEvent', 'DOMTransactionEvent',
'DeviceOrientationEvent', 'DeviceOrientationEvent',
'MozApplicationEvent', 'MozApplicationEvent',
'SmartCardEvent',
'StyleRuleChangeEvent', 'StyleRuleChangeEvent',
'StyleSheetChangeEvent', 'StyleSheetChangeEvent',
'StyleSheetApplicableStateChangeEvent', 'StyleSheetApplicableStateChangeEvent',

View File

@ -30,7 +30,7 @@
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsIDOMWindowCollection.h" #include "nsIDOMWindowCollection.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDOMSmartCardEvent.h" #include "mozilla/dom/SmartCardEvent.h"
#include "nsSmartCardMonitor.h" #include "nsSmartCardMonitor.h"
#include "nsIDOMCryptoLegacy.h" #include "nsIDOMCryptoLegacy.h"
#else #else
@ -437,23 +437,17 @@ nsNSSComponent::DispatchEventToWindow(nsIDOMWindow* domWin,
return NS_FAILED(rv) ? rv : NS_ERROR_FAILURE; return NS_FAILED(rv) ? rv : NS_ERROR_FAILURE;
} }
nsCOMPtr<nsIDocument> d = do_QueryInterface(doc); nsCOMPtr<EventTarget> d = do_QueryInterface(doc);
// create the event SmartCardEventInit init;
nsCOMPtr<nsIDOMEvent> event; init.mBubbles = false;
NS_NewDOMSmartCardEvent(getter_AddRefs(event), d, nullptr, nullptr); init.mCancelable = true;
nsCOMPtr<nsIDOMSmartCardEvent> smartCardEvent = do_QueryInterface(event); init.mTokenName = tokenName;
rv = smartCardEvent->InitSmartCardEvent(eventType, false, true, tokenName);
NS_ENSURE_SUCCESS(rv, rv);
smartCardEvent->SetTrusted(true);
// Send it nsRefPtr<SmartCardEvent> event = SmartCardEvent::Constructor(d, eventType, init);
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(doc, &rv); event->SetTrusted(true);
if (NS_FAILED(rv)) {
return rv;
}
return target->DispatchEvent(smartCardEvent, &boolrv); return d->DispatchEvent(event, &boolrv);
} }
#endif // MOZ_DISABLE_CRYPTOLEGACY #endif // MOZ_DISABLE_CRYPTOLEGACY

View File

@ -6,7 +6,6 @@
#include "pk11func.h" #include "pk11func.h"
#include "nsNSSComponent.h" #include "nsNSSComponent.h"
#include "nsSmartCardMonitor.h" #include "nsSmartCardMonitor.h"
#include "nsIDOMSmartCardEvent.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "mozilla/unused.h" #include "mozilla/unused.h"
@ -292,12 +291,12 @@ void SmartCardMonitoringThread::Execute()
// event for the previous token, do so now... // event for the previous token, do so now...
tokenName = GetTokenName(slotID); tokenName = GetTokenName(slotID);
if (tokenName) { if (tokenName) {
SendEvent(NS_LITERAL_STRING(SMARTCARDEVENT_REMOVE), tokenName); SendEvent(NS_LITERAL_STRING("smartcard-remove"), tokenName);
} }
tokenName = PK11_GetTokenName(slot); tokenName = PK11_GetTokenName(slot);
// save the token name and series // save the token name and series
SetTokenName(slotID, tokenName, series); SetTokenName(slotID, tokenName, series);
SendEvent(NS_LITERAL_STRING(SMARTCARDEVENT_INSERT), tokenName); SendEvent(NS_LITERAL_STRING("smartcard-insert"), tokenName);
} }
} else { } else {
// retrieve token name // retrieve token name
@ -306,7 +305,7 @@ void SmartCardMonitoringThread::Execute()
// if there's not a token name, then the software isn't expecting // if there's not a token name, then the software isn't expecting
// a (or another) remove event. // a (or another) remove event.
if (tokenName) { if (tokenName) {
SendEvent(NS_LITERAL_STRING(SMARTCARDEVENT_REMOVE), tokenName); SendEvent(NS_LITERAL_STRING("smartcard-remove"), tokenName);
// clear the token name (after we send it) // clear the token name (after we send it)
SetTokenName(slotID, nullptr, 0); SetTokenName(slotID, nullptr, 0);
} }

View File

@ -130,7 +130,6 @@
#include "nsIDOMScrollAreaEvent.h" #include "nsIDOMScrollAreaEvent.h"
#include "nsIDOMSerializer.h" #include "nsIDOMSerializer.h"
#include "nsIDOMSimpleGestureEvent.h" #include "nsIDOMSimpleGestureEvent.h"
#include "nsIDOMSmartCardEvent.h"
#ifdef MOZ_WEBSPEECH #ifdef MOZ_WEBSPEECH
#include "nsIDOMSpeechRecognitionEvent.h" #include "nsIDOMSpeechRecognitionEvent.h"
#include "nsIDOMSpeechSynthesisEvent.h" #include "nsIDOMSpeechSynthesisEvent.h"
@ -284,7 +283,6 @@
#include "mozilla/dom/SelectionBinding.h" #include "mozilla/dom/SelectionBinding.h"
#include "mozilla/dom/ScrollAreaEventBinding.h" #include "mozilla/dom/ScrollAreaEventBinding.h"
#include "mozilla/dom/SimpleGestureEventBinding.h" #include "mozilla/dom/SimpleGestureEventBinding.h"
#include "mozilla/dom/SmartCardEventBinding.h"
#ifdef MOZ_WEBSPEECH #ifdef MOZ_WEBSPEECH
#include "mozilla/dom/SpeechRecognitionEventBinding.h" #include "mozilla/dom/SpeechRecognitionEventBinding.h"
#include "mozilla/dom/SpeechSynthesisEventBinding.h" #include "mozilla/dom/SpeechSynthesisEventBinding.h"
@ -489,7 +487,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] =
DEFINE_SHIM(ScrollAreaEvent), DEFINE_SHIM(ScrollAreaEvent),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMSerializer, XMLSerializer), DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMSerializer, XMLSerializer),
DEFINE_SHIM(SimpleGestureEvent), DEFINE_SHIM(SimpleGestureEvent),
DEFINE_SHIM(SmartCardEvent),
#ifdef MOZ_WEBSPEECH #ifdef MOZ_WEBSPEECH
DEFINE_SHIM(SpeechRecognitionEvent), DEFINE_SHIM(SpeechRecognitionEvent),
DEFINE_SHIM(SpeechSynthesisEvent), DEFINE_SHIM(SpeechSynthesisEvent),