Do not activate the select list window on Windows (issue #169).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@179 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2011-02-01 15:37:47 +00:00
parent 915f3673f8
commit d2ce65040e
13 changed files with 109 additions and 135 deletions

View File

@ -545,6 +545,12 @@ void CefBrowserImpl::UIT_DestroyBrowser()
_Context->RemoveBrowser(this); _Context->RemoveBrowser(this);
} }
void CefBrowserImpl::UIT_CloseBrowser()
{
REQUIRE_UIT();
UIT_CloseView(UIT_GetMainWndHandle());
}
void CefBrowserImpl::UIT_LoadURL(CefRefPtr<CefFrame> frame, void CefBrowserImpl::UIT_LoadURL(CefRefPtr<CefFrame> frame,
const CefString& url) const CefString& url)
{ {
@ -798,6 +804,25 @@ CefRefPtr<CefBrowserImpl> CefBrowserImpl::UIT_CreatePopupWindow(
return browser; return browser;
} }
WebKit::WebWidget* CefBrowserImpl::UIT_CreatePopupWidget()
{
REQUIRE_UIT();
DCHECK(!popuphost_);
popuphost_ = WebWidgetHost::Create(UIT_GetMainWndHandle(),
popup_delegate_.get());
popuphost_->set_popup(true);
return popuphost_->webwidget();
}
void CefBrowserImpl::UIT_ClosePopupWidget()
{
REQUIRE_UIT();
UIT_CloseView(UIT_GetPopupWndHandle());
popuphost_ = NULL;
}
void CefBrowserImpl::UIT_Show(WebKit::WebNavigationPolicy policy) void CefBrowserImpl::UIT_Show(WebKit::WebNavigationPolicy policy)
{ {
REQUIRE_UIT(); REQUIRE_UIT();

View File

@ -269,6 +269,8 @@ public:
static bool ImplementsThreadSafeReferenceCounting() { return true; } static bool ImplementsThreadSafeReferenceCounting() { return true; }
protected: protected:
static void UIT_CloseView(gfx::NativeView view);
void UIT_CreateDevToolsClient(BrowserDevToolsAgent* agent); void UIT_CreateDevToolsClient(BrowserDevToolsAgent* agent);
void UIT_DestroyDevToolsClient(); void UIT_DestroyDevToolsClient();

View File

@ -70,15 +70,6 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
UIT_LoadURL(GetMainFrame(), url); UIT_LoadURL(GetMainFrame(), url);
} }
void CefBrowserImpl::UIT_CloseBrowser()
{
REQUIRE_UIT();
DCHECK(!_Context->shutting_down());
// TODO(port): Close the browser window.
NOTREACHED();
}
void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable) void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
@ -89,26 +80,6 @@ void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
gtk_widget_grab_focus(host->view_handle()); gtk_widget_grab_focus(host->view_handle());
} }
WebKit::WebWidget* CefBrowserImpl::UIT_CreatePopupWidget()
{
REQUIRE_UIT();
DCHECK(!popuphost_);
popuphost_ = WebWidgetHost::Create(NULL, popup_delegate_.get());
// TODO(port): Show window.
return popuphost_->webwidget();
}
void CefBrowserImpl::UIT_ClosePopupWidget()
{
REQUIRE_UIT();
// TODO(port): Close window.
popuphost_ = NULL;
}
bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame) bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
@ -142,3 +113,10 @@ int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame)
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return 0; return 0;
} }
// static
void CefBrowserImpl::UIT_CloseView(gfx::NativeView view)
{
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
&gtk_widget_destroy, GTK_WIDGET(view)));
}

View File

@ -75,15 +75,6 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
UIT_LoadURL(GetMainFrame(), url); UIT_LoadURL(GetMainFrame(), url);
} }
void CefBrowserImpl::UIT_CloseBrowser()
{
REQUIRE_UIT();
DCHECK(!_Context->shutting_down());
// TODO(port): Close the browser window.
NOTREACHED();
}
void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable) void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
@ -98,26 +89,6 @@ void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
[[view window] makeFirstResponder:view]; [[view window] makeFirstResponder:view];
} }
WebKit::WebWidget* CefBrowserImpl::UIT_CreatePopupWidget()
{
REQUIRE_UIT();
DCHECK(!popuphost_);
popuphost_ = WebWidgetHost::Create(NULL, popup_delegate_.get());
// TODO(port): Show window.
return popuphost_->webwidget();
}
void CefBrowserImpl::UIT_ClosePopupWidget()
{
REQUIRE_UIT();
// TODO(port): Close window.
popuphost_ = NULL;
}
bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame) bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
@ -151,3 +122,9 @@ int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame)
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return 0; return 0;
} }
// static
void CefBrowserImpl::UIT_CloseView(gfx::NativeView view)
{
[view performSelector:@selector(performClose:) withObject:nil afterDelay:0];
}

View File

@ -153,14 +153,6 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
UIT_LoadURL(GetMainFrame(), url); UIT_LoadURL(GetMainFrame(), url);
} }
void CefBrowserImpl::UIT_CloseBrowser()
{
REQUIRE_UIT();
DCHECK(!_Context->shutting_down());
PostMessage(UIT_GetMainWndHandle(), WM_CLOSE, 0, 0);
}
void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable) void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
@ -173,26 +165,6 @@ void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
::SetFocus(NULL); ::SetFocus(NULL);
} }
WebKit::WebWidget* CefBrowserImpl::UIT_CreatePopupWidget()
{
REQUIRE_UIT();
DCHECK(!popuphost_);
popuphost_ = WebWidgetHost::Create(NULL, popup_delegate_.get());
ShowWindow(UIT_GetPopupWndHandle(), SW_SHOW);
return popuphost_->webwidget();
}
void CefBrowserImpl::UIT_ClosePopupWidget()
{
REQUIRE_UIT();
PostMessage(UIT_GetPopupWndHandle(), WM_CLOSE, 0, 0);
popuphost_ = NULL;
}
static void WriteTextToFile(const std::string& data, static void WriteTextToFile(const std::string& data,
const std::wstring& file_path) const std::wstring& file_path)
{ {
@ -252,8 +224,10 @@ void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
const int src_size_x = canvas_size.width(); const int src_size_x = canvas_size.width();
const int src_size_y = canvas_size.height(); const int src_size_y = canvas_size.height();
const int dest_size_x = settings.page_setup_pixels().printable_area().width(); const int dest_size_x =
const int dest_size_y = settings.page_setup_pixels().printable_area().height(); settings.page_setup_pixels().printable_area().width();
const int dest_size_y =
settings.page_setup_pixels().printable_area().height();
print_context_.NewPage(); print_context_.NewPage();
@ -267,11 +241,13 @@ void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
skia::VectorCanvas canvas(hDC, dest_size_x, dest_size_y); skia::VectorCanvas canvas(hDC, dest_size_x, dest_size_y);
//The hDC 0 coord is the left most printeable area and not physical area of the paper // The hDC 0 coord is the left most printeable area and not physical area of
//so subtract that out of our canvas translate. // the paper so subtract that out of our canvas translate.
const int left_margin_offset = settings.page_setup_pixels().effective_margins().left - const int left_margin_offset =
settings.page_setup_pixels().effective_margins().left -
settings.page_setup_pixels().printable_area().x(); settings.page_setup_pixels().printable_area().x();
const int top_margin_offset = settings.page_setup_pixels().effective_margins().top - const int top_margin_offset =
settings.page_setup_pixels().effective_margins().top -
settings.page_setup_pixels().printable_area().y(); settings.page_setup_pixels().printable_area().y();
// Adjust for the margin offset. // Adjust for the margin offset.
@ -279,9 +255,11 @@ void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
static_cast<float>(top_margin_offset)); static_cast<float>(top_margin_offset));
// Apply the print scaling factor. // Apply the print scaling factor.
const float print_scale_x = static_cast<float>(settings.page_setup_pixels().content_area().width()) const float print_scale_x =
static_cast<float>(settings.page_setup_pixels().content_area().width())
/ src_size_x; / src_size_x;
const float print_scale_y = static_cast<float>(settings.page_setup_pixels().content_area().height()) const float print_scale_y =
static_cast<float>(settings.page_setup_pixels().content_area().height())
/ src_size_y; / src_size_y;
canvas.scale(print_scale_x, print_scale_y); canvas.scale(print_scale_x, print_scale_y);
@ -306,7 +284,8 @@ void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
rect.left = left_margin_offset; rect.left = left_margin_offset;
rect.top = settings.page_setup_pixels().effective_margins().header - rect.top = settings.page_setup_pixels().effective_margins().header -
settings.page_setup_pixels().printable_area().y(); settings.page_setup_pixels().printable_area().y();
rect.right = left_margin_offset + settings.page_setup_pixels().content_area().width(); rect.right = left_margin_offset +
settings.page_setup_pixels().content_area().width();
rect.bottom = settings.page_setup_pixels().printable_area().height() - rect.bottom = settings.page_setup_pixels().printable_area().height() -
(settings.page_setup_pixels().effective_margins().footer - (settings.page_setup_pixels().effective_margins().footer -
(settings.page_setup_pixels().physical_size().height() - (settings.page_setup_pixels().physical_size().height() -
@ -408,7 +387,8 @@ void CefBrowserImpl::UIT_PrintPages(WebKit::WebFrame* frame) {
settings.UpdatePrintOptions(print_options); settings.UpdatePrintOptions(print_options);
// Ask the handler if they want to update the print options. // Ask the handler if they want to update the print options.
if (handler_.get() && RV_HANDLED == handler_->HandlePrintOptions(this, print_options)) { if (handler_.get() && RV_HANDLED ==
handler_->HandlePrintOptions(this, print_options)) {
settings.UpdateFromPrintOptions(print_options); settings.UpdateFromPrintOptions(print_options);
print_context_.InitWithSettings(settings); print_context_.InitWithSettings(settings);
} }
@ -494,3 +474,9 @@ int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame)
return page_count; return page_count;
} }
// static
void CefBrowserImpl::UIT_CloseView(gfx::NativeView view)
{
PostMessage(view, WM_CLOSE, 0, 0);
}

View File

@ -506,6 +506,14 @@ void BrowserWebViewDelegate::didBlur() {
browser_->UIT_SetFocus(host, false); browser_->UIT_SetFocus(host, false);
} }
void BrowserWebViewDelegate::closeWidgetSoon() {
if (this == browser_->UIT_GetWebViewDelegate()) {
browser_->UIT_CloseBrowser();
} else if (this == browser_->UIT_GetPopupDelegate()) {
browser_->UIT_ClosePopupWidget();
}
}
WebScreenInfo BrowserWebViewDelegate::screenInfo() { WebScreenInfo BrowserWebViewDelegate::screenInfo() {
if (WebWidgetHost* host = GetWidgetHost()) if (WebWidgetHost* host = GetWidgetHost())
return host->GetScreenInfo(); return host->GetScreenInfo();

View File

@ -101,15 +101,6 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
gtk_widget_show_all(window); gtk_widget_show_all(window);
} }
void BrowserWebViewDelegate::closeWidgetSoon() {
if (this == browser_->UIT_GetWebViewDelegate()) {
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
&gtk_widget_destroy, GTK_WIDGET(browser_->UIT_GetMainWndHandle())));
} else if (this == browser_->UIT_GetPopupDelegate()) {
browser_->UIT_ClosePopupWidget();
}
}
void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
current_cursor_.InitFromCursorInfo(cursor_info); current_cursor_.InitFromCursorInfo(cursor_info);
GdkCursorType cursor_type = GdkCursorType cursor_type =

View File

@ -97,15 +97,6 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
} }
} }
void BrowserWebViewDelegate::closeWidgetSoon() {
if (this == browser_->UIT_GetWebViewDelegate()) {
NSWindow *win = browser_->UIT_GetMainWndHandle();
[win performSelector:@selector(performClose:) withObject:nil afterDelay:0];
} else if (this == browser_->UIT_GetPopupDelegate()) {
browser_->UIT_ClosePopupWidget();
}
}
void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
NSCursor* ns_cursor = WebCursor(cursor_info).GetCursor(); NSCursor* ns_cursor = WebCursor(cursor_info).GetCursor();
[ns_cursor set]; [ns_cursor set];

View File

@ -56,18 +56,14 @@ WebWidget* BrowserWebViewDelegate::createPopupMenu(
// WebWidgetClient ------------------------------------------------------------ // WebWidgetClient ------------------------------------------------------------
void BrowserWebViewDelegate::show(WebNavigationPolicy) { void BrowserWebViewDelegate::show(WebNavigationPolicy) {
if (WebWidgetHost* host = GetWidgetHost()) { if (this == browser_->UIT_GetWebViewDelegate()) {
HWND root = GetAncestor(host->view_handle(), GA_ROOT); // Restore the window and bring it to the top.
HWND root = GetAncestor(browser_->UIT_GetMainWndHandle(), GA_ROOT);
ShowWindow(root, SW_SHOWNORMAL); ShowWindow(root, SW_SHOWNORMAL);
SetWindowPos(root, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); SetWindowPos(root, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
}
}
void BrowserWebViewDelegate::closeWidgetSoon() {
if (this == browser_->UIT_GetWebViewDelegate()) {
PostMessage(browser_->UIT_GetMainWndHandle(), WM_CLOSE, 0, 0);
} else if (this == browser_->UIT_GetPopupDelegate()) { } else if (this == browser_->UIT_GetPopupDelegate()) {
browser_->UIT_ClosePopupWidget(); // Show popup widgets without activation.
ShowWindow(browser_->UIT_GetPopupWndHandle(), SW_SHOWNA);
} }
} }

View File

@ -72,6 +72,9 @@ class WebWidgetHost {
void SetTooltipText(const CefString& tooltip_text); void SetTooltipText(const CefString& tooltip_text);
void set_popup(bool popup) { popup_ = popup; }
bool popup() { return popup_; }
protected: protected:
WebWidgetHost(); WebWidgetHost();
~WebWidgetHost(); ~WebWidgetHost();
@ -134,6 +137,9 @@ class WebWidgetHost {
WebKit::WebWidget* webwidget_; WebKit::WebWidget* webwidget_;
scoped_ptr<skia::PlatformCanvas> canvas_; scoped_ptr<skia::PlatformCanvas> canvas_;
// True if this widget is a popup widget.
bool popup_;
// specifies the portion of the webwidget that needs painting // specifies the portion of the webwidget that needs painting
gfx::Rect paint_rect_; gfx::Rect paint_rect_;

View File

@ -332,6 +332,7 @@ void WebWidgetHost::ScheduleComposite() {
WebWidgetHost::WebWidgetHost() WebWidgetHost::WebWidgetHost()
: view_(NULL), : view_(NULL),
webwidget_(NULL), webwidget_(NULL),
popup_(false),
scroll_dx_(0), scroll_dx_(0),
scroll_dy_(0) { scroll_dy_(0) {
set_painting(false); set_painting(false);

View File

@ -140,6 +140,7 @@ void WebWidgetHost::DiscardBackingStore() {
WebWidgetHost::WebWidgetHost() WebWidgetHost::WebWidgetHost()
: view_(NULL), : view_(NULL),
webwidget_(NULL), webwidget_(NULL),
popup_(false),
scroll_dx_(0), scroll_dx_(0),
scroll_dy_(0) { scroll_dy_(0) {
set_painting(false); set_painting(false);

View File

@ -108,6 +108,13 @@ LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam,
host->WheelEvent(wparam, lparam); host->WheelEvent(wparam, lparam);
break; break;
case WM_MOUSEACTIVATE:
if (host->popup()) {
// Do not activate popup widgets on mouse click.
return MA_NOACTIVATE;
}
break;
case WM_CAPTURECHANGED: case WM_CAPTURECHANGED:
case WM_CANCELMODE: case WM_CANCELMODE:
host->CaptureLostEvent(); host->CaptureLostEvent();
@ -206,6 +213,7 @@ void WebWidgetHost::DiscardBackingStore() {
WebWidgetHost::WebWidgetHost() WebWidgetHost::WebWidgetHost()
: view_(NULL), : view_(NULL),
webwidget_(NULL), webwidget_(NULL),
popup_(false),
track_mouse_leave_(false), track_mouse_leave_(false),
scroll_dx_(0), scroll_dx_(0),
scroll_dy_(0), scroll_dy_(0),
@ -317,16 +325,20 @@ void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) {
TrackMouseLeave(false); TrackMouseLeave(false);
break; break;
case WebInputEvent::MouseDown: case WebInputEvent::MouseDown:
if (!popup()) {
SetCapture(view_); SetCapture(view_);
// This mimics a temporary workaround in RenderWidgetHostViewWin // This mimics a temporary workaround in RenderWidgetHostViewWin
// for bug 765011 to get focus when the mouse is clicked. This // for bug 765011 to get focus when the mouse is clicked. This
// happens after the mouse down event is sent to the renderer // happens after the mouse down event is sent to the renderer
// because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN. // because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN.
::SetFocus(view_); ::SetFocus(view_);
}
break; break;
case WebInputEvent::MouseUp: case WebInputEvent::MouseUp:
if (!popup()) {
if (GetCapture() == view_) if (GetCapture() == view_)
ReleaseCapture(); ReleaseCapture();
}
break; break;
} }
webwidget_->handleInputEvent(event); webwidget_->handleInputEvent(event);