feat: add new components to Display structure (#16870)

* feat: add new components to Display structure

* add internal property

* expose colorDepth

* add specs
This commit is contained in:
Shelley Vohr 2019-02-12 07:34:42 -08:00 committed by John Kleinschmidt
parent 5a44cc50cf
commit bf276ecc69
3 changed files with 88 additions and 6 deletions

View file

@ -105,6 +105,22 @@ bool Converter<gfx::Rect>::FromV8(v8::Isolate* isolate,
return true;
}
template <>
struct Converter<display::Display::AccelerometerSupport> {
static v8::Local<v8::Value> ToV8(
v8::Isolate* isolate,
const display::Display::AccelerometerSupport& val) {
switch (val) {
case display::Display::AccelerometerSupport::AVAILABLE:
return StringToV8(isolate, "available");
case display::Display::AccelerometerSupport::UNAVAILABLE:
return StringToV8(isolate, "unavailable");
default:
return StringToV8(isolate, "unknown");
}
}
};
template <>
struct Converter<display::Display::TouchSupport> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
@ -128,10 +144,15 @@ v8::Local<v8::Value> Converter<display::Display>::ToV8(
dict.Set("id", val.id());
dict.Set("bounds", val.bounds());
dict.Set("workArea", val.work_area());
dict.Set("accelerometerSupport", val.accelerometer_support());
dict.Set("monochrome", val.is_monochrome());
dict.Set("colorDepth", val.color_depth());
dict.Set("depthPerComponent", val.depth_per_component());
dict.Set("size", val.size());
dict.Set("workAreaSize", val.work_area_size());
dict.Set("scaleFactor", val.device_scale_factor());
dict.Set("rotation", val.RotationAsDegree());
dict.Set("internal", val.IsInternal());
dict.Set("touchSupport", val.touch_support());
return dict.GetHandle();
}