Add converters between gfx:: and v8
This commit is contained in:
parent
dacbf7a042
commit
2d8fe489a7
4 changed files with 99 additions and 73 deletions
|
@ -6,13 +6,11 @@
|
|||
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "native_mate/callback.h"
|
||||
#include "native_mate/constructor.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "ui/gfx/point.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include "ui/gfx/size.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
|
@ -40,23 +38,6 @@ struct Converter<PrintSettings> {
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Converter<gfx::Rect> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Handle<v8::Value> val,
|
||||
gfx::Rect* out) {
|
||||
if (!val->IsObject())
|
||||
return false;
|
||||
mate::Dictionary dict(isolate, val->ToObject());
|
||||
int x, y, width, height;
|
||||
if (!dict.Get("x", &x) || !dict.Get("y", &y) ||
|
||||
!dict.Get("width", &width) || !dict.Get("height", &height))
|
||||
return false;
|
||||
*out = gfx::Rect(x, y, width, height);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace atom {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue