Set sender in EventEmitter.emit
This commit is contained in:
parent
fb5fe7a714
commit
2ea2413752
3 changed files with 6 additions and 6 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "atom/browser/api/event.h"
|
||||
#include "native_mate/arguments.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
|
||||
namespace mate {
|
||||
|
@ -15,8 +16,8 @@ namespace {
|
|||
v8::Persistent<v8::ObjectTemplate> event_template;
|
||||
|
||||
void PreventDefault(mate::Arguments* args) {
|
||||
args->GetThis()->Set(StringToV8(args->isolate(), "defaultPrevented"),
|
||||
v8::True(args->isolate()));
|
||||
mate::Dictionary self(args->isolate(), args->GetThis());
|
||||
self.Set("defaultPrevented", true);
|
||||
}
|
||||
|
||||
// Create a pure JavaScript Event object.
|
||||
|
@ -38,7 +39,7 @@ EventEmitter::EventEmitter() {
|
|||
|
||||
v8::Local<v8::Object> EventEmitter::CreateEvent(v8::Isolate* isolate,
|
||||
content::WebContents* sender,
|
||||
IPC::Message* message) const {
|
||||
IPC::Message* message) {
|
||||
v8::Local<v8::Object> event;
|
||||
bool use_native_event = sender && message;
|
||||
|
||||
|
@ -49,6 +50,7 @@ v8::Local<v8::Object> EventEmitter::CreateEvent(v8::Isolate* isolate,
|
|||
} else {
|
||||
event = CreateEventObject(isolate);
|
||||
}
|
||||
mate::Dictionary(isolate, event).Set("sender", GetWrapper(isolate));
|
||||
return event;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class EventEmitter : public Wrappable {
|
|||
private:
|
||||
v8::Local<v8::Object> CreateEvent(v8::Isolate* isolate,
|
||||
content::WebContents* sender,
|
||||
IPC::Message* message) const;
|
||||
IPC::Message* message);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(EventEmitter);
|
||||
};
|
||||
|
|
|
@ -33,12 +33,10 @@ wrapWebContents = (webContents) ->
|
|||
# Dispatch IPC messages to the ipc module.
|
||||
webContents.on 'ipc-message', (event, packed) ->
|
||||
[channel, args...] = packed
|
||||
Object.defineProperty event, 'sender', value: webContents
|
||||
ipc.emit channel, event, args...
|
||||
webContents.on 'ipc-message-sync', (event, packed) ->
|
||||
[channel, args...] = packed
|
||||
Object.defineProperty event, 'returnValue', set: (value) -> event.sendReply JSON.stringify(value)
|
||||
Object.defineProperty event, 'sender', value: webContents
|
||||
ipc.emit channel, event, args...
|
||||
|
||||
webContents.printToPDF = (options, callback) ->
|
||||
|
|
Loading…
Reference in a new issue