mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Implement window.moveTo and window.ResizeTo. Fix #2.
This commit is contained in:
@@ -196,6 +196,12 @@ void NativeWindow::BeforeUnloadFired(content::WebContents* tab,
|
||||
WindowList::WindowCloseCancelled(this);
|
||||
}
|
||||
|
||||
void NativeWindow::MoveContents(content::WebContents* source,
|
||||
const gfx::Rect& pos) {
|
||||
SetPosition(pos.origin());
|
||||
SetSize(pos.size());
|
||||
}
|
||||
|
||||
void NativeWindow::CloseContents(content::WebContents* source) {
|
||||
// When the web contents is gone, close the window immediately, but the
|
||||
// memory will not be freed until you call delete.
|
||||
@@ -207,6 +213,11 @@ void NativeWindow::CloseContents(content::WebContents* source) {
|
||||
NotifyWindowClosed();
|
||||
}
|
||||
|
||||
bool NativeWindow::IsPopupOrPanel(const content::WebContents* source) const {
|
||||
// Only popup window can use things like window.moveTo.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(NativeWindow, message)
|
||||
|
||||
@@ -131,7 +131,11 @@ class NativeWindow : public content::WebContentsDelegate,
|
||||
virtual void BeforeUnloadFired(content::WebContents* tab,
|
||||
bool proceed,
|
||||
bool* proceed_to_fire_unload) OVERRIDE;
|
||||
virtual void MoveContents(content::WebContents* source,
|
||||
const gfx::Rect& pos) OVERRIDE;
|
||||
virtual void CloseContents(content::WebContents* source) OVERRIDE;
|
||||
virtual bool IsPopupOrPanel(
|
||||
const content::WebContents* source) const OVERRIDE;
|
||||
|
||||
// Implementations of content::WebContentsObserver.
|
||||
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
||||
|
||||
Reference in New Issue
Block a user