electron/shell/common/gin_helper/event.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.2 KiB
C++
Raw Normal View History

2023-02-13 13:39:18 -08:00
// Copyright (c) 2023 Salesforce, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/common/gin_helper/event.h"
2023-02-13 13:39:18 -08:00
#include "gin/object_template_builder.h"
#include "v8/include/cppgc/allocation.h"
#include "v8/include/v8-cppgc.h"
2023-02-13 13:39:18 -08:00
namespace gin_helper::internal {
// static
Event* Event::New(v8::Isolate* isolate) {
auto* event = cppgc::MakeGarbageCollected<Event>(
isolate->GetCppHeap()->GetAllocationHandle());
return event;
2023-02-13 13:39:18 -08:00
}
// static
v8::Local<v8::ObjectTemplate> Event::FillObjectTemplate(
v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> templ) {
return gin::ObjectTemplateBuilder(isolate, GetClassName(), templ)
2023-02-13 13:39:18 -08:00
.SetMethod("preventDefault", &Event::PreventDefault)
.SetProperty("defaultPrevented", &Event::GetDefaultPrevented)
.Build();
}
Event::Event() = default;
Event::~Event() = default;
gin::WrapperInfo Event::kWrapperInfo = {{gin::kEmbedderNativeGin},
gin::kElectronEvent};
const gin::WrapperInfo* Event::wrapper_info() const {
return &kWrapperInfo;
}
2023-02-13 13:39:18 -08:00
const char* Event::GetHumanReadableName() const {
return "Electron / Event";
}
2023-02-13 13:39:18 -08:00
} // namespace gin_helper::internal