Add gfx:PointF support to mate::Converter
It's needed by atom_api_screen, BuildPrototype function on Windows.
This commit is contained in:
parent
622544a902
commit
c786abf1e9
3 changed files with 36 additions and 10 deletions
|
@ -35,6 +35,28 @@ bool Converter<gfx::Point>::FromV8(v8::Isolate* isolate,
|
|||
return true;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Converter<gfx::PointF>::ToV8(v8::Isolate* isolate,
|
||||
const gfx::PointF& val) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.SetHidden("simple", true);
|
||||
dict.Set("x", val.x());
|
||||
dict.Set("y", val.y());
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
bool Converter<gfx::PointF>::FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
gfx::PointF* out) {
|
||||
mate::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
float x, y;
|
||||
if (!dict.Get("x", &x) || !dict.Get("y", &y))
|
||||
return false;
|
||||
*out = gfx::PointF(x, y);
|
||||
return true;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Converter<gfx::Size>::ToV8(v8::Isolate* isolate,
|
||||
const gfx::Size& val) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_GFX_CONVERTER_H_
|
||||
|
||||
#include "native_mate/converter.h"
|
||||
#include "ui/gfx/geometry/point_f.h"
|
||||
|
||||
namespace display {
|
||||
class Display;
|
||||
|
@ -27,6 +28,15 @@ struct Converter<gfx::Point> {
|
|||
gfx::Point* out);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<gfx::PointF> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const gfx::PointF& val);
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
gfx::PointF* out);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<gfx::Size> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, const gfx::Size& val);
|
||||
|
|
|
@ -711,8 +711,7 @@ describe('<webview> tag', function () {
|
|||
})
|
||||
})
|
||||
|
||||
// TODO(alexeykuzmin): Enable the tests.
|
||||
xdescribe('devtools-opened event', () => {
|
||||
describe('devtools-opened event', () => {
|
||||
it('should fire when webview.openDevTools() is called', async () => {
|
||||
loadWebView(webview, {
|
||||
src: `file://${fixtures}/pages/base-page.html`
|
||||
|
@ -726,8 +725,7 @@ describe('<webview> tag', function () {
|
|||
})
|
||||
})
|
||||
|
||||
// TODO(alexeykuzmin): Enable the tests.
|
||||
xdescribe('devtools-closed event', () => {
|
||||
describe('devtools-closed event', () => {
|
||||
it('should fire when webview.closeDevTools() is called', async () => {
|
||||
loadWebView(webview, {
|
||||
src: `file://${fixtures}/pages/base-page.html`
|
||||
|
@ -742,8 +740,7 @@ describe('<webview> tag', function () {
|
|||
})
|
||||
})
|
||||
|
||||
// TODO(alexeykuzmin): Enable the tests.
|
||||
xdescribe('devtools-focused event', () => {
|
||||
describe('devtools-focused event', () => {
|
||||
it('should fire when webview.openDevTools() is called', async () => {
|
||||
loadWebView(webview, {
|
||||
src: `file://${fixtures}/pages/base-page.html`
|
||||
|
@ -1212,10 +1209,7 @@ describe('<webview> tag', function () {
|
|||
})
|
||||
})
|
||||
|
||||
// TODO(alexeykuzmin): Enable the test.
|
||||
// The app crashes if this test and "devtools-opened event" tests
|
||||
// are run at the same time.
|
||||
xit('loads devtools extensions registered on the parent window', async () => {
|
||||
it('loads devtools extensions registered on the parent window', async () => {
|
||||
const w = await openTheWindow({ show: false })
|
||||
BrowserWindow.removeDevToolsExtension('foo')
|
||||
|
||||
|
|
Loading…
Reference in a new issue