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:
parent
915f3673f8
commit
d2ce65040e
|
@ -545,6 +545,12 @@ void CefBrowserImpl::UIT_DestroyBrowser()
|
|||
_Context->RemoveBrowser(this);
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_CloseBrowser()
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
UIT_CloseView(UIT_GetMainWndHandle());
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_LoadURL(CefRefPtr<CefFrame> frame,
|
||||
const CefString& url)
|
||||
{
|
||||
|
@ -798,6 +804,25 @@ CefRefPtr<CefBrowserImpl> CefBrowserImpl::UIT_CreatePopupWindow(
|
|||
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)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
|
|
@ -269,6 +269,8 @@ public:
|
|||
static bool ImplementsThreadSafeReferenceCounting() { return true; }
|
||||
|
||||
protected:
|
||||
static void UIT_CloseView(gfx::NativeView view);
|
||||
|
||||
void UIT_CreateDevToolsClient(BrowserDevToolsAgent* agent);
|
||||
void UIT_DestroyDevToolsClient();
|
||||
|
||||
|
|
|
@ -70,15 +70,6 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& 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)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
@ -89,26 +80,6 @@ void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
|
|||
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)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
@ -142,3 +113,10 @@ int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame)
|
|||
NOTIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// static
|
||||
void CefBrowserImpl::UIT_CloseView(gfx::NativeView view)
|
||||
{
|
||||
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
|
||||
>k_widget_destroy, GTK_WIDGET(view)));
|
||||
}
|
||||
|
|
|
@ -75,15 +75,6 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& 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)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
@ -98,26 +89,6 @@ void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
|
|||
[[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)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
@ -151,3 +122,9 @@ int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame)
|
|||
NOTIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// static
|
||||
void CefBrowserImpl::UIT_CloseView(gfx::NativeView view)
|
||||
{
|
||||
[view performSelector:@selector(performClose:) withObject:nil afterDelay:0];
|
||||
}
|
||||
|
|
|
@ -153,14 +153,6 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& 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)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
@ -173,26 +165,6 @@ void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
|
|||
::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,
|
||||
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_y = canvas_size.height();
|
||||
|
||||
const int dest_size_x = settings.page_setup_pixels().printable_area().width();
|
||||
const int dest_size_y = settings.page_setup_pixels().printable_area().height();
|
||||
const int dest_size_x =
|
||||
settings.page_setup_pixels().printable_area().width();
|
||||
const int dest_size_y =
|
||||
settings.page_setup_pixels().printable_area().height();
|
||||
|
||||
print_context_.NewPage();
|
||||
|
||||
|
@ -267,21 +241,25 @@ void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
|
|||
|
||||
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
|
||||
//so subtract that out of our canvas translate.
|
||||
const int left_margin_offset = settings.page_setup_pixels().effective_margins().left -
|
||||
settings.page_setup_pixels().printable_area().x();
|
||||
const int top_margin_offset = settings.page_setup_pixels().effective_margins().top -
|
||||
settings.page_setup_pixels().printable_area().y();
|
||||
// The hDC 0 coord is the left most printeable area and not physical area of
|
||||
// the paper so subtract that out of our canvas translate.
|
||||
const int left_margin_offset =
|
||||
settings.page_setup_pixels().effective_margins().left -
|
||||
settings.page_setup_pixels().printable_area().x();
|
||||
const int top_margin_offset =
|
||||
settings.page_setup_pixels().effective_margins().top -
|
||||
settings.page_setup_pixels().printable_area().y();
|
||||
|
||||
// Adjust for the margin offset.
|
||||
canvas.translate(static_cast<float>(left_margin_offset),
|
||||
static_cast<float>(top_margin_offset));
|
||||
|
||||
// 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;
|
||||
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;
|
||||
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.top = settings.page_setup_pixels().effective_margins().header -
|
||||
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() -
|
||||
(settings.page_setup_pixels().effective_margins().footer -
|
||||
(settings.page_setup_pixels().physical_size().height() -
|
||||
|
@ -408,7 +387,8 @@ void CefBrowserImpl::UIT_PrintPages(WebKit::WebFrame* frame) {
|
|||
settings.UpdatePrintOptions(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);
|
||||
print_context_.InitWithSettings(settings);
|
||||
}
|
||||
|
@ -465,7 +445,7 @@ void CefBrowserImpl::UIT_PrintPages(WebKit::WebFrame* frame) {
|
|||
|
||||
int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
REQUIRE_UIT();
|
||||
|
||||
printing::PrintParams params;
|
||||
const printing::PrintSettings &settings = print_context_.settings();
|
||||
|
@ -494,3 +474,9 @@ int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame)
|
|||
|
||||
return page_count;
|
||||
}
|
||||
|
||||
// static
|
||||
void CefBrowserImpl::UIT_CloseView(gfx::NativeView view)
|
||||
{
|
||||
PostMessage(view, WM_CLOSE, 0, 0);
|
||||
}
|
||||
|
|
|
@ -506,6 +506,14 @@ void BrowserWebViewDelegate::didBlur() {
|
|||
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() {
|
||||
if (WebWidgetHost* host = GetWidgetHost())
|
||||
return host->GetScreenInfo();
|
||||
|
|
|
@ -101,15 +101,6 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
|
|||
gtk_widget_show_all(window);
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::closeWidgetSoon() {
|
||||
if (this == browser_->UIT_GetWebViewDelegate()) {
|
||||
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
|
||||
>k_widget_destroy, GTK_WIDGET(browser_->UIT_GetMainWndHandle())));
|
||||
} else if (this == browser_->UIT_GetPopupDelegate()) {
|
||||
browser_->UIT_ClosePopupWidget();
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
|
||||
current_cursor_.InitFromCursorInfo(cursor_info);
|
||||
GdkCursorType cursor_type =
|
||||
|
|
|
@ -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) {
|
||||
NSCursor* ns_cursor = WebCursor(cursor_info).GetCursor();
|
||||
[ns_cursor set];
|
||||
|
|
|
@ -56,18 +56,14 @@ WebWidget* BrowserWebViewDelegate::createPopupMenu(
|
|||
// WebWidgetClient ------------------------------------------------------------
|
||||
|
||||
void BrowserWebViewDelegate::show(WebNavigationPolicy) {
|
||||
if (WebWidgetHost* host = GetWidgetHost()) {
|
||||
HWND root = GetAncestor(host->view_handle(), GA_ROOT);
|
||||
if (this == browser_->UIT_GetWebViewDelegate()) {
|
||||
// Restore the window and bring it to the top.
|
||||
HWND root = GetAncestor(browser_->UIT_GetMainWndHandle(), GA_ROOT);
|
||||
ShowWindow(root, SW_SHOWNORMAL);
|
||||
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()) {
|
||||
browser_->UIT_ClosePopupWidget();
|
||||
// Show popup widgets without activation.
|
||||
ShowWindow(browser_->UIT_GetPopupWndHandle(), SW_SHOWNA);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,9 @@ class WebWidgetHost {
|
|||
|
||||
void SetTooltipText(const CefString& tooltip_text);
|
||||
|
||||
void set_popup(bool popup) { popup_ = popup; }
|
||||
bool popup() { return popup_; }
|
||||
|
||||
protected:
|
||||
WebWidgetHost();
|
||||
~WebWidgetHost();
|
||||
|
@ -126,7 +129,7 @@ class WebWidgetHost {
|
|||
painting_ = value;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void EnsureTooltip();
|
||||
void ResetTooltip();
|
||||
|
||||
|
@ -134,6 +137,9 @@ class WebWidgetHost {
|
|||
WebKit::WebWidget* webwidget_;
|
||||
scoped_ptr<skia::PlatformCanvas> canvas_;
|
||||
|
||||
// True if this widget is a popup widget.
|
||||
bool popup_;
|
||||
|
||||
// specifies the portion of the webwidget that needs painting
|
||||
gfx::Rect paint_rect_;
|
||||
|
||||
|
|
|
@ -332,6 +332,7 @@ void WebWidgetHost::ScheduleComposite() {
|
|||
WebWidgetHost::WebWidgetHost()
|
||||
: view_(NULL),
|
||||
webwidget_(NULL),
|
||||
popup_(false),
|
||||
scroll_dx_(0),
|
||||
scroll_dy_(0) {
|
||||
set_painting(false);
|
||||
|
|
|
@ -140,6 +140,7 @@ void WebWidgetHost::DiscardBackingStore() {
|
|||
WebWidgetHost::WebWidgetHost()
|
||||
: view_(NULL),
|
||||
webwidget_(NULL),
|
||||
popup_(false),
|
||||
scroll_dx_(0),
|
||||
scroll_dy_(0) {
|
||||
set_painting(false);
|
||||
|
|
|
@ -108,6 +108,13 @@ LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam,
|
|||
host->WheelEvent(wparam, lparam);
|
||||
break;
|
||||
|
||||
case WM_MOUSEACTIVATE:
|
||||
if (host->popup()) {
|
||||
// Do not activate popup widgets on mouse click.
|
||||
return MA_NOACTIVATE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CAPTURECHANGED:
|
||||
case WM_CANCELMODE:
|
||||
host->CaptureLostEvent();
|
||||
|
@ -206,6 +213,7 @@ void WebWidgetHost::DiscardBackingStore() {
|
|||
WebWidgetHost::WebWidgetHost()
|
||||
: view_(NULL),
|
||||
webwidget_(NULL),
|
||||
popup_(false),
|
||||
track_mouse_leave_(false),
|
||||
scroll_dx_(0),
|
||||
scroll_dy_(0),
|
||||
|
@ -317,16 +325,20 @@ void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) {
|
|||
TrackMouseLeave(false);
|
||||
break;
|
||||
case WebInputEvent::MouseDown:
|
||||
SetCapture(view_);
|
||||
// This mimics a temporary workaround in RenderWidgetHostViewWin
|
||||
// for bug 765011 to get focus when the mouse is clicked. This
|
||||
// happens after the mouse down event is sent to the renderer
|
||||
// because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN.
|
||||
::SetFocus(view_);
|
||||
if (!popup()) {
|
||||
SetCapture(view_);
|
||||
// This mimics a temporary workaround in RenderWidgetHostViewWin
|
||||
// for bug 765011 to get focus when the mouse is clicked. This
|
||||
// happens after the mouse down event is sent to the renderer
|
||||
// because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN.
|
||||
::SetFocus(view_);
|
||||
}
|
||||
break;
|
||||
case WebInputEvent::MouseUp:
|
||||
if (GetCapture() == view_)
|
||||
ReleaseCapture();
|
||||
if (!popup()) {
|
||||
if (GetCapture() == view_)
|
||||
ReleaseCapture();
|
||||
}
|
||||
break;
|
||||
}
|
||||
webwidget_->handleInputEvent(event);
|
||||
|
|
Loading…
Reference in New Issue