mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Mac:
- Add support for popup windows. - Fix select list bugs. - Add additional tests to cefclient. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@182 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -782,6 +782,17 @@ CefRefPtr<CefBrowserImpl> CefBrowserImpl::UIT_CreatePopupWindow(
|
||||
#if defined(OS_WIN)
|
||||
info.SetAsPopup(NULL, CefString());
|
||||
#endif
|
||||
|
||||
// Default to the size from the popup features.
|
||||
if(features.xSet)
|
||||
info.m_x = features.x;
|
||||
if(features.ySet)
|
||||
info.m_y = features.y;
|
||||
if(features.widthSet)
|
||||
info.m_nWidth = features.width;
|
||||
if(features.heightSet)
|
||||
info.m_nHeight = features.height;
|
||||
|
||||
CefRefPtr<CefHandler> handler = handler_;
|
||||
CefString newUrl = url;
|
||||
|
||||
@ -820,7 +831,10 @@ void CefBrowserImpl::UIT_ClosePopupWidget()
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
// Mac uses a WebPopupMenu for select lists so no closing is necessary.
|
||||
UIT_CloseView(UIT_GetPopupWndHandle());
|
||||
#endif
|
||||
popuphost_ = NULL;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ public:
|
||||
REQUIRE_UIT();
|
||||
return popuphost_->view_handle();
|
||||
}
|
||||
gfx::NativeWindow UIT_GetMainWndHandle() const;
|
||||
gfx::NativeView UIT_GetMainWndHandle() const;
|
||||
|
||||
BrowserNavigationController* UIT_GetNavigationController() {
|
||||
REQUIRE_UIT();
|
||||
|
@ -25,9 +25,9 @@ CefWindowHandle CefBrowserImpl::GetWindowHandle()
|
||||
return window_info_.m_View;
|
||||
}
|
||||
|
||||
gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() const {
|
||||
gfx::NativeView CefBrowserImpl::UIT_GetMainWndHandle() const {
|
||||
REQUIRE_UIT();
|
||||
return (NSWindow*)window_info_.m_View;
|
||||
return (NSView*)window_info_.m_View;
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
||||
@ -44,9 +44,34 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
||||
if (!settings_.developer_tools_disabled)
|
||||
dev_tools_agent_.reset(new BrowserDevToolsAgent());
|
||||
|
||||
NSWindow* newWnd = nil;
|
||||
|
||||
NSView* parentView = (NSView*)window_info_.m_ParentView;
|
||||
gfx::Rect contentRect(window_info_.m_x, window_info_.m_y,
|
||||
window_info_.m_nWidth, window_info_.m_nHeight);
|
||||
if (parentView == nil) {
|
||||
// Create a new window.
|
||||
NSRect screen_rect = [[NSScreen mainScreen] visibleFrame];
|
||||
NSRect window_rect = {{window_info_.m_x,
|
||||
screen_rect.size.height - window_info_.m_y},
|
||||
{window_info_.m_nWidth, window_info_.m_nHeight}};
|
||||
if (window_rect.size.width == 0)
|
||||
window_rect.size.width = 500;
|
||||
if (window_rect.size.height == 0)
|
||||
window_rect.size.height = 500;
|
||||
contentRect.SetRect(0, 0, window_rect.size.width, window_rect.size.height);
|
||||
|
||||
newWnd = [[NSWindow alloc]
|
||||
initWithContentRect:window_rect
|
||||
styleMask:(NSTitledWindowMask |
|
||||
NSClosableWindowMask |
|
||||
NSMiniaturizableWindowMask |
|
||||
NSResizableWindowMask )
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
parentView = [newWnd contentView];
|
||||
window_info_.m_ParentView = (void*)parentView;
|
||||
}
|
||||
|
||||
WebPreferences prefs;
|
||||
BrowserToWebSettings(settings_, prefs);
|
||||
@ -66,6 +91,11 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
||||
|
||||
Unlock();
|
||||
|
||||
if (newWnd != nil) {
|
||||
// Show the window.
|
||||
[newWnd makeKeyAndOrderFront: nil];
|
||||
}
|
||||
|
||||
if(handler_.get()) {
|
||||
// Notify the handler that we're done creating the new window
|
||||
handler_->HandleAfterCreated(this);
|
||||
|
@ -245,6 +245,10 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
|
||||
|
||||
CefBrowserImpl* GetBrowser() { return browser_; }
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void SetPopupMenuInfo(const WebKit::WebPopupMenuInfo& info);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// Default handling of JavaScript messages.
|
||||
void ShowJavaScriptAlert(WebKit::WebFrame* webframe,
|
||||
@ -319,8 +323,8 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
scoped_ptr<WebKit::WebPopupMenuInfo> popup_menu_info_;
|
||||
WebKit::WebRect popup_bounds_;
|
||||
scoped_ptr<WebKit::WebPopupMenuInfo> popup_menu_info_;
|
||||
WebKit::WebRect popup_bounds_;
|
||||
#endif
|
||||
|
||||
// true if we want to enable smart insert/delete.
|
||||
|
@ -28,7 +28,7 @@ using WebKit::WebWidget;
|
||||
WebWidget* BrowserWebViewDelegate::createPopupMenu(
|
||||
const WebPopupMenuInfo& info) {
|
||||
WebWidget* webwidget = browser_->UIT_CreatePopupWidget();
|
||||
popup_menu_info_.reset(new WebPopupMenuInfo(info));
|
||||
browser_->UIT_GetPopupDelegate()->SetPopupMenuInfo(info);
|
||||
return webwidget;
|
||||
}
|
||||
|
||||
@ -79,7 +79,8 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
|
||||
// (mouse down, keyboard activity) for this, so we calculate the proper
|
||||
// position based on the selected index and provided bounds.
|
||||
WebWidgetHost* popup = browser_->UIT_GetPopupHost();
|
||||
int window_num = [browser_->UIT_GetMainWndHandle() windowNumber];
|
||||
NSWindow* window = [browser_->UIT_GetMainWndHandle() window];
|
||||
int window_num = [window windowNumber];
|
||||
NSEvent* event =
|
||||
webkit_glue::EventWithMenuAction([menu_runner menuItemWasChosen],
|
||||
window_num, item_height,
|
||||
@ -95,6 +96,8 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
|
||||
// forward that to WebKit.
|
||||
popup->KeyEvent(event);
|
||||
}
|
||||
|
||||
browser_->UIT_ClosePopupWidget();
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
|
||||
@ -186,6 +189,10 @@ void BrowserWebViewDelegate::DidMovePlugin(
|
||||
|
||||
// Protected methods ----------------------------------------------------------
|
||||
|
||||
void BrowserWebViewDelegate::SetPopupMenuInfo(const WebPopupMenuInfo& info) {
|
||||
popup_menu_info_.reset(new WebPopupMenuInfo(info));
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::ShowJavaScriptAlert(
|
||||
WebKit::WebFrame* webframe, const CefString& message) {
|
||||
std::string messageStr(message);
|
||||
|
Reference in New Issue
Block a user