- Fix initial state of the |is_showing_| flag in CefRenderWidgetHostViewOSR (issue #1363).

- Windows: Modify the cefclient OSR example to call WasHidden(true) when the app is minimized.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1818 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2014-09-04 22:15:16 +00:00
parent 0b78461f5b
commit df2242aff2
5 changed files with 46 additions and 12 deletions

View File

@ -155,7 +155,7 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
render_widget_host_(content::RenderWidgetHostImpl::From(widget)),
parent_host_view_(NULL),
popup_host_view_(NULL),
is_showing_(false),
is_showing_(true),
is_destroyed_(false),
#if defined(OS_MACOSX)
text_input_context_osr_mac_(NULL),

View File

@ -18,7 +18,13 @@
#include "cefclient/string_util.h"
CefRefPtr<ClientHandler> g_handler;
namespace {
CefRefPtr<CefCommandLine> g_command_line;
int g_offscreen_state = 0;
} // namespace
CefRefPtr<CefBrowser> AppGetBrowser() {
if (!g_handler.get())
@ -78,11 +84,15 @@ void AppGetBrowserSettings(CefBrowserSettings& settings) {
}
bool AppIsOffScreenRenderingEnabled() {
DCHECK(g_command_line.get());
if (!g_command_line.get())
return false;
if (g_offscreen_state == 0) {
// Store the value so it isn't queried multiple times.
DCHECK(g_command_line.get());
g_offscreen_state =
g_command_line->HasSwitch(cefclient::kOffScreenRenderingEnabled) ?
1 : 2;
}
return g_command_line->HasSwitch(cefclient::kOffScreenRenderingEnabled);
return (g_offscreen_state == 1);
}
void RunGetSourceTest(CefRefPtr<CefBrowser> browser) {

View File

@ -192,6 +192,16 @@ void OSRWindow::Invalidate() {
kRenderDelay);
}
void OSRWindow::WasHidden(bool hidden) {
if (hidden == hidden_)
return;
CefRefPtr<CefBrowser> browser = browser_provider_->GetBrowser();
if (!browser)
return;
browser->GetHost()->WasHidden(hidden);
hidden_ = hidden;
}
CefBrowserHost::DragOperationsMask
OSRWindow::OnDragEnter(CefRefPtr<CefDragData> drag_data,
CefMouseEvent ev,
@ -226,9 +236,10 @@ OSRWindow::OSRWindow(OSRBrowserProvider* browser_provider, bool transparent)
hWnd_(NULL),
hDC_(NULL),
hRC_(NULL),
current_drag_op_(DRAG_OPERATION_NONE),
painting_popup_(false),
render_task_pending_(false),
current_drag_op_(DRAG_OPERATION_NONE) {
hidden_(false) {
}
OSRWindow::~OSRWindow() {

View File

@ -87,6 +87,7 @@ class OSRWindow : public ClientHandler::RenderHandler,
CefBrowserHost::DragOperationsMask effect) OVERRIDE;
void Invalidate();
void WasHidden(bool hidden);
static int GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam);
static int GetCefMouseModifiers(WPARAM wparam);
@ -119,6 +120,7 @@ class OSRWindow : public ClientHandler::RenderHandler,
bool painting_popup_;
bool render_task_pending_;
bool hidden_;
IMPLEMENT_REFCOUNTING(OSRWindow);
};

View File

@ -597,15 +597,26 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
return 0;
case WM_SIZE:
// Minimizing resizes the window to 0x0 which causes our layout to go all
// screwy, so we just ignore it.
if (wParam != SIZE_MINIMIZED && g_handler.get() &&
g_handler->GetBrowser()) {
if (!g_handler.get())
break;
// Mark the off-screen browser as hidden when the frame window is
// minimized to reduce resource usage.
if (AppIsOffScreenRenderingEnabled()) {
CefRefPtr<OSRWindow> osr_window =
static_cast<OSRWindow*>(g_handler->GetOSRHandler().get());
if (osr_window)
osr_window->WasHidden(wParam == SIZE_MINIMIZED);
}
// Don't resize the window if minimizing because the resulting size of 0x0
// causes the layout to go all screwy.
if (wParam != SIZE_MINIMIZED && g_handler->GetBrowser()) {
// Retrieve the window handle (parent window with off-screen rendering).
CefWindowHandle hwnd =
g_handler->GetBrowser()->GetHost()->GetWindowHandle();
if (hwnd) {
// Resize the browser window and address bar to match the new frame
// window size
// Resize the window and address bar to match the new frame size.
RECT rect;
GetClientRect(hWnd, &rect);
rect.top += URLBAR_HEIGHT;