From 7356be01647f170dbfc5911b94ed28af456e2a3c Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 18 Dec 2017 15:14:50 +1100 Subject: [PATCH] Convert optional webpoint --- .../native_mate_converters/blink_converter.cc | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index a262e9b1ba43..b2fb1113bb23 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -305,13 +305,21 @@ bool Converter::FromV8( return dict.Get("x", &out->x) && dict.Get("y", &out->y); } -bool Converter::FromV8( - v8::Isolate* isolate, v8::Local val, blink::WebPoint* out) { - mate::Dictionary dict; - if (!ConvertFromV8(isolate, val, &dict)) - return false; - return dict.Get("x", &out->x) && dict.Get("y", &out->y); -} +template<> +struct Converter> { + static bool FromV8( + v8::Isolate* isolate, v8::Local val, + base::Optional* out) { + mate::Dictionary dict; + if (!ConvertFromV8(isolate, val, &dict)) + return false; + blink::WebPoint point; + bool success = dict.Get("x", &point.x) && dict.Get("y", &point.y); + if (!success) return false; + out->emplace(point); + return true; + } +}; bool Converter::FromV8( v8::Isolate* isolate, v8::Local val, blink::WebSize* out) {