refactor: add gin_helper::Dictionary::CreateEmpty() helper (#39547)
This commit is contained in:
parent
9937a2bbe8
commit
09190085c0
29 changed files with 66 additions and 64 deletions
|
@ -311,7 +311,7 @@ int GetKeyLocationCode(const blink::WebInputEvent& key) {
|
|||
v8::Local<v8::Value> Converter<blink::WebKeyboardEvent>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const blink::WebKeyboardEvent& in) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
dict.Set("type", in.GetType());
|
||||
dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.dom_key));
|
||||
|
@ -468,7 +468,7 @@ Converter<blink::mojom::ContextMenuDataInputFieldType>::ToV8(
|
|||
}
|
||||
|
||||
v8::Local<v8::Value> EditFlagsToV8(v8::Isolate* isolate, int editFlags) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("canUndo",
|
||||
!!(editFlags & blink::ContextMenuDataEditFlags::kCanUndo));
|
||||
dict.Set("canRedo",
|
||||
|
@ -497,7 +497,7 @@ v8::Local<v8::Value> EditFlagsToV8(v8::Isolate* isolate, int editFlags) {
|
|||
}
|
||||
|
||||
v8::Local<v8::Value> MediaFlagsToV8(v8::Isolate* isolate, int mediaFlags) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("inError", !!(mediaFlags & blink::ContextMenuData::kMediaInError));
|
||||
dict.Set("isPaused", !!(mediaFlags & blink::ContextMenuData::kMediaPaused));
|
||||
dict.Set("isMuted", !!(mediaFlags & blink::ContextMenuData::kMediaMuted));
|
||||
|
@ -522,7 +522,7 @@ v8::Local<v8::Value> MediaFlagsToV8(v8::Isolate* isolate, int mediaFlags) {
|
|||
v8::Local<v8::Value> Converter<blink::WebCacheResourceTypeStat>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const blink::WebCacheResourceTypeStat& stat) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("count", static_cast<uint32_t>(stat.count));
|
||||
dict.Set("size", static_cast<double>(stat.size));
|
||||
dict.Set("liveSize", static_cast<double>(stat.decoded_size));
|
||||
|
@ -532,7 +532,7 @@ v8::Local<v8::Value> Converter<blink::WebCacheResourceTypeStat>::ToV8(
|
|||
v8::Local<v8::Value> Converter<blink::WebCacheResourceTypeStats>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const blink::WebCacheResourceTypeStats& stats) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("images", stats.images);
|
||||
dict.Set("scripts", stats.scripts);
|
||||
dict.Set("cssStyleSheets", stats.css_style_sheets);
|
||||
|
@ -565,7 +565,7 @@ bool Converter<network::mojom::ReferrerPolicy>::FromV8(
|
|||
v8::Local<v8::Value> Converter<blink::mojom::Referrer>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const blink::mojom::Referrer& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("url", ConvertToV8(isolate, val.url));
|
||||
dict.Set("policy", ConvertToV8(isolate, val.policy));
|
||||
return gin::ConvertToV8(isolate, dict);
|
||||
|
|
|
@ -125,7 +125,7 @@ v8::Local<v8::Value> Converter<ContextMenuParamsWithRenderFrameHost>::ToV8(
|
|||
const ContextMenuParamsWithRenderFrameHost& val) {
|
||||
const auto& params = val.first;
|
||||
content::RenderFrameHost* render_frame_host = val.second;
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetGetter("frame", render_frame_host, v8::DontEnum);
|
||||
dict.Set("x", params.x);
|
||||
dict.Set("y", params.y);
|
||||
|
@ -309,7 +309,7 @@ bool Converter<content::WebContents*>::FromV8(v8::Isolate* isolate,
|
|||
v8::Local<v8::Value> Converter<content::Referrer>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const content::Referrer& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("url", ConvertToV8(isolate, val.url));
|
||||
dict.Set("policy", ConvertToV8(isolate, val.policy));
|
||||
return gin::ConvertToV8(isolate, dict);
|
||||
|
|
|
@ -27,7 +27,7 @@ bool Converter<file_dialog::Filter>::FromV8(v8::Isolate* isolate,
|
|||
v8::Local<v8::Value> Converter<file_dialog::Filter>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const file_dialog::Filter& in) {
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
dict.Set("name", in.first);
|
||||
dict.Set("extensions", in.second);
|
||||
|
@ -58,7 +58,7 @@ bool Converter<file_dialog::DialogSettings>::FromV8(
|
|||
v8::Local<v8::Value> Converter<file_dialog::DialogSettings>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const file_dialog::DialogSettings& in) {
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
dict.Set("window",
|
||||
electron::api::BrowserWindow::From(isolate, in.parent_window));
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace gin {
|
|||
|
||||
v8::Local<v8::Value> Converter<gfx::Point>::ToV8(v8::Isolate* isolate,
|
||||
const gfx::Point& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("x", val.x());
|
||||
dict.Set("y", val.y());
|
||||
|
@ -40,7 +40,7 @@ bool Converter<gfx::Point>::FromV8(v8::Isolate* isolate,
|
|||
|
||||
v8::Local<v8::Value> Converter<gfx::PointF>::ToV8(v8::Isolate* isolate,
|
||||
const gfx::PointF& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("x", val.x());
|
||||
dict.Set("y", val.y());
|
||||
|
@ -62,7 +62,7 @@ bool Converter<gfx::PointF>::FromV8(v8::Isolate* isolate,
|
|||
|
||||
v8::Local<v8::Value> Converter<gfx::Size>::ToV8(v8::Isolate* isolate,
|
||||
const gfx::Size& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("width", val.width());
|
||||
dict.Set("height", val.height());
|
||||
|
@ -84,7 +84,7 @@ bool Converter<gfx::Size>::FromV8(v8::Isolate* isolate,
|
|||
|
||||
v8::Local<v8::Value> Converter<gfx::Rect>::ToV8(v8::Isolate* isolate,
|
||||
const gfx::Rect& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("x", val.x());
|
||||
dict.Set("y", val.y());
|
||||
|
@ -141,7 +141,7 @@ struct Converter<display::Display::TouchSupport> {
|
|||
v8::Local<v8::Value> Converter<display::Display>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const display::Display& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("id", val.id());
|
||||
dict.Set("label", val.label());
|
||||
|
|
|
@ -59,7 +59,7 @@ bool CertFromData(const std::string& data,
|
|||
v8::Local<v8::Value> Converter<net::AuthChallengeInfo>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const net::AuthChallengeInfo& val) {
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("isProxy", val.is_proxy);
|
||||
dict.Set("scheme", val.scheme);
|
||||
dict.Set("host", val.challenger.host());
|
||||
|
@ -610,7 +610,7 @@ bool Converter<scoped_refptr<network::ResourceRequestBody>>::FromV8(
|
|||
v8::Local<v8::Value> Converter<network::ResourceRequest>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const network::ResourceRequest& val) {
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("method", val.method);
|
||||
dict.Set("url", val.url.spec());
|
||||
dict.Set("referrer", val.referrer.spec());
|
||||
|
@ -624,7 +624,7 @@ v8::Local<v8::Value> Converter<network::ResourceRequest>::ToV8(
|
|||
v8::Local<v8::Value> Converter<electron::VerifyRequestParams>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
electron::VerifyRequestParams val) {
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("hostname", val.hostname);
|
||||
dict.Set("certificate", val.certificate);
|
||||
dict.Set("validatedCertificate", val.validated_certificate);
|
||||
|
@ -638,7 +638,7 @@ v8::Local<v8::Value> Converter<electron::VerifyRequestParams>::ToV8(
|
|||
v8::Local<v8::Value> Converter<net::HttpVersion>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const net::HttpVersion& val) {
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("major", static_cast<uint32_t>(val.major_value()));
|
||||
dict.Set("minor", static_cast<uint32_t>(val.minor_value()));
|
||||
return ConvertToV8(isolate, dict);
|
||||
|
@ -648,7 +648,7 @@ v8::Local<v8::Value> Converter<net::HttpVersion>::ToV8(
|
|||
v8::Local<v8::Value> Converter<net::RedirectInfo>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const net::RedirectInfo& val) {
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
|
||||
dict.Set("statusCode", val.status_code);
|
||||
dict.Set("newMethod", val.new_method);
|
||||
|
|
|
@ -16,7 +16,7 @@ struct Converter<device::mojom::SerialPortInfoPtr> {
|
|||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const device::mojom::SerialPortInfoPtr& port) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("portId", port->token.ToString());
|
||||
dict.Set("portName", port->path.BaseName().LossyDisplayName());
|
||||
if (port->display_name && !port->display_name->empty())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue