add "view-painted" event to WebContent.

This commit is contained in:
liusi 2016-07-18 14:54:52 +08:00
parent 08491e1ceb
commit d335d7d706
6 changed files with 19 additions and 0 deletions

View file

@ -733,6 +733,7 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(AtomViewHostMsg_Message, OnRendererMessage)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_Message_Sync,
OnRendererMessageSync)
IPC_MESSAGE_HANDLER(AtomViewHostMsg_DidCommitCompositorFrame, OnViewPainted)
IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
handled = false)
IPC_MESSAGE_UNHANDLED(handled = false)
@ -1298,6 +1299,10 @@ void WebContents::OnCursorChange(const content::WebCursor& cursor) {
}
}
void WebContents::OnViewPainted() {
Emit("view-painted");
}
void WebContents::SetSize(const SetSizeParams& params) {
if (guest_delegate_)
guest_delegate_->SetSize(params);

View file

@ -294,6 +294,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
const base::ListValue& args,
IPC::Message* message);
// Called when the hosted view gets graphical updates.
void OnViewPainted();
v8::Global<v8::Value> session_;
v8::Global<v8::Value> devtools_web_contents_;
v8::Global<v8::Value> debugger_;

View file

@ -39,5 +39,7 @@ IPC_MESSAGE_ROUTED3(AtomViewMsg_Message,
IPC_MESSAGE_ROUTED1(AtomViewHostMsg_UpdateDraggableRegions,
std::vector<atom::DraggableRegion> /* regions */)
IPC_MESSAGE_ROUTED0(AtomViewHostMsg_DidCommitCompositorFrame)
// Update renderer process preferences.
IPC_MESSAGE_CONTROL1(AtomMsg_UpdatePreferences, base::ListValue)

View file

@ -141,6 +141,10 @@ void AtomRenderViewObserver::DraggableRegionsChanged(blink::WebFrame* frame) {
Send(new AtomViewHostMsg_UpdateDraggableRegions(routing_id(), regions));
}
void AtomRenderViewObserver::DidCommitCompositorFrame() {
Send(new AtomViewHostMsg_DidCommitCompositorFrame(routing_id()));
}
bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AtomRenderViewObserver, message)

View file

@ -28,6 +28,7 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
// content::RenderViewObserver implementation.
void DidCreateDocumentElement(blink::WebLocalFrame* frame) override;
void DraggableRegionsChanged(blink::WebFrame* frame) override;
void DidCommitCompositorFrame() override;
bool OnMessageReceived(const IPC::Message& message) override;
void OnBrowserMessage(bool send_to_all,

View file

@ -448,6 +448,10 @@ app.on('ready', () => {
})
```
#### Event: 'view-painted'
Emitted when a page's view is repainted.
### Instance Methods
#### `contents.loadURL(url[, options])`