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',
'nsIDOMScrollAreaEvent.idl',
'nsIDOMSimpleGestureEvent.idl',
'nsIDOMSmartCardEvent.idl',
'nsIDOMStyleRuleChangeEvent.idl',
'nsIDOMStyleSheetApplicableStateChangeEvent.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/.
*/
[Constructor(DOMString type, optional SmartCardEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
[Constructor(DOMString type, optional SmartCardEventInit eventInitDict)]
interface SmartCardEvent : Event
{
readonly attribute DOMString? tokenName;

View File

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

View File

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

View File

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

View File

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

View File

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