Add support to convert gfx::Point to v8 value.

This commit is contained in:
Cheng Zhao 2014-01-07 20:00:02 +08:00
parent 3ec755e978
commit 1b1cf87115

View file

@ -18,6 +18,7 @@
#include "common/v8/scoped_persistent.h" #include "common/v8/scoped_persistent.h"
#include "common/v8/v8_value_converter.h" #include "common/v8/v8_value_converter.h"
#include "content/public/renderer/v8_value_converter.h" #include "content/public/renderer/v8_value_converter.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include "url/gurl.h" #include "url/gurl.h"
@ -154,6 +155,13 @@ v8::Handle<v8::Value> ToV8Value(const std::vector<base::FilePath>& paths) {
return result; return result;
} }
inline v8::Handle<v8::Value> ToV8Value(const gfx::Point& point) {
v8::Handle<v8::Object> obj = v8::Object::New();
obj->Set(ToV8Value("x"), ToV8Value(point.x()));
obj->Set(ToV8Value("y"), ToV8Value(point.y()));
return obj;
}
// Check if a V8 Value is of specified type. // Check if a V8 Value is of specified type.
template<class T> inline template<class T> inline
bool V8ValueCanBeConvertedTo(v8::Handle<v8::Value> value) { bool V8ValueCanBeConvertedTo(v8::Handle<v8::Value> value) {