return v8::Local<v8::Value>::New(isolate, debugger_);
}
+void WebContents::OnPaint(
+ v8::Isolate* isolate,
+ const gfx::Rect& damage_rect,
+ int bitmap_width,
+ int bitmap_height,
+ void* bitmap_pixels) {
+ v8::MaybeLocal<v8::Object> buffer = node::Buffer::New(isolate,
+ reinterpret_cast<char *>(bitmap_pixels), sizeof(bitmap_pixels));
+
+ const gfx::Size bitmap_size = gfx::Size(bitmap_width, bitmap_height);
+ Emit("paint", damage_rect, buffer.ToLocalChecked(), bitmap_size);
+}
+
+void WebContents::StartPainting() {
+ if (IsOffScreen()) {
+ const auto osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
+ web_contents()->GetRenderWidgetHostView());
+ osr_rwhv->SetPainting(true);
+ osr_rwhv->Show();
+ }
+}
+
+void WebContents::StopPainting() {
+ if (IsOffScreen()) {
+ const auto osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
+ web_contents()->GetRenderWidgetHostView());
+ osr_rwhv->SetPainting(false);
+ osr_rwhv->Hide();
+ }
+}
+
+bool WebContents::IsPainting() const {
+ if (IsOffScreen()) {
+ const auto osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
+ web_contents()->GetRenderWidgetHostView());
+ return osr_rwhv->IsPainting();
+ }
+
+ return false;
+}
+
+void WebContents::SetFrameRate(int frame_rate) {
+ if (IsOffScreen()) {
+ const auto osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
+ web_contents()->GetRenderWidgetHostView());
+ osr_rwhv->SetFrameRate(frame_rate);
+ }
+}
+
+int WebContents::GetFrameRate() const {
+ if (IsOffScreen()) {
+ const auto osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
+ web_contents()->GetRenderWidgetHostView());
+ return osr_rwhv->GetFrameRate();
+ }
+ return 0;
+}
+
// static
void WebContents::BuildPrototype(v8::Isolate* isolate,
- v8::Local<v8::ObjectTemplate> prototype) {
- mate::ObjectTemplateBuilder(isolate, prototype)
+ v8::Local<v8::FunctionTemplate> prototype) {
+ prototype->SetClassName(mate::StringToV8(isolate, "WebContents"));
+ mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("getId", &WebContents::GetID)
.SetMethod("equal", &WebContents::Equal)