mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-04-14 02:42:09 +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:
parent
5911e7027c
commit
02bd128046
@ -782,6 +782,17 @@ CefRefPtr<CefBrowserImpl> CefBrowserImpl::UIT_CreatePopupWindow(
|
|||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
info.SetAsPopup(NULL, CefString());
|
info.SetAsPopup(NULL, CefString());
|
||||||
#endif
|
#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_;
|
CefRefPtr<CefHandler> handler = handler_;
|
||||||
CefString newUrl = url;
|
CefString newUrl = url;
|
||||||
|
|
||||||
@ -820,7 +831,10 @@ void CefBrowserImpl::UIT_ClosePopupWidget()
|
|||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
|
#if !defined(OS_MACOSX)
|
||||||
|
// Mac uses a WebPopupMenu for select lists so no closing is necessary.
|
||||||
UIT_CloseView(UIT_GetPopupWndHandle());
|
UIT_CloseView(UIT_GetPopupWndHandle());
|
||||||
|
#endif
|
||||||
popuphost_ = NULL;
|
popuphost_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public:
|
|||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
return popuphost_->view_handle();
|
return popuphost_->view_handle();
|
||||||
}
|
}
|
||||||
gfx::NativeWindow UIT_GetMainWndHandle() const;
|
gfx::NativeView UIT_GetMainWndHandle() const;
|
||||||
|
|
||||||
BrowserNavigationController* UIT_GetNavigationController() {
|
BrowserNavigationController* UIT_GetNavigationController() {
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
@ -25,9 +25,9 @@ CefWindowHandle CefBrowserImpl::GetWindowHandle()
|
|||||||
return window_info_.m_View;
|
return window_info_.m_View;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() const {
|
gfx::NativeView CefBrowserImpl::UIT_GetMainWndHandle() const {
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
return (NSWindow*)window_info_.m_View;
|
return (NSView*)window_info_.m_View;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
||||||
@ -44,9 +44,34 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
|||||||
if (!settings_.developer_tools_disabled)
|
if (!settings_.developer_tools_disabled)
|
||||||
dev_tools_agent_.reset(new BrowserDevToolsAgent());
|
dev_tools_agent_.reset(new BrowserDevToolsAgent());
|
||||||
|
|
||||||
|
NSWindow* newWnd = nil;
|
||||||
|
|
||||||
NSView* parentView = (NSView*)window_info_.m_ParentView;
|
NSView* parentView = (NSView*)window_info_.m_ParentView;
|
||||||
gfx::Rect contentRect(window_info_.m_x, window_info_.m_y,
|
gfx::Rect contentRect(window_info_.m_x, window_info_.m_y,
|
||||||
window_info_.m_nWidth, window_info_.m_nHeight);
|
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;
|
WebPreferences prefs;
|
||||||
BrowserToWebSettings(settings_, prefs);
|
BrowserToWebSettings(settings_, prefs);
|
||||||
@ -66,6 +91,11 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
|||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
|
if (newWnd != nil) {
|
||||||
|
// Show the window.
|
||||||
|
[newWnd makeKeyAndOrderFront: nil];
|
||||||
|
}
|
||||||
|
|
||||||
if(handler_.get()) {
|
if(handler_.get()) {
|
||||||
// Notify the handler that we're done creating the new window
|
// Notify the handler that we're done creating the new window
|
||||||
handler_->HandleAfterCreated(this);
|
handler_->HandleAfterCreated(this);
|
||||||
|
@ -245,6 +245,10 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
|
|||||||
|
|
||||||
CefBrowserImpl* GetBrowser() { return browser_; }
|
CefBrowserImpl* GetBrowser() { return browser_; }
|
||||||
|
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
void SetPopupMenuInfo(const WebKit::WebPopupMenuInfo& info);
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Default handling of JavaScript messages.
|
// Default handling of JavaScript messages.
|
||||||
void ShowJavaScriptAlert(WebKit::WebFrame* webframe,
|
void ShowJavaScriptAlert(WebKit::WebFrame* webframe,
|
||||||
@ -319,8 +323,8 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
scoped_ptr<WebKit::WebPopupMenuInfo> popup_menu_info_;
|
scoped_ptr<WebKit::WebPopupMenuInfo> popup_menu_info_;
|
||||||
WebKit::WebRect popup_bounds_;
|
WebKit::WebRect popup_bounds_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// true if we want to enable smart insert/delete.
|
// true if we want to enable smart insert/delete.
|
||||||
|
@ -28,7 +28,7 @@ using WebKit::WebWidget;
|
|||||||
WebWidget* BrowserWebViewDelegate::createPopupMenu(
|
WebWidget* BrowserWebViewDelegate::createPopupMenu(
|
||||||
const WebPopupMenuInfo& info) {
|
const WebPopupMenuInfo& info) {
|
||||||
WebWidget* webwidget = browser_->UIT_CreatePopupWidget();
|
WebWidget* webwidget = browser_->UIT_CreatePopupWidget();
|
||||||
popup_menu_info_.reset(new WebPopupMenuInfo(info));
|
browser_->UIT_GetPopupDelegate()->SetPopupMenuInfo(info);
|
||||||
return webwidget;
|
return webwidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,8 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
|
|||||||
// (mouse down, keyboard activity) for this, so we calculate the proper
|
// (mouse down, keyboard activity) for this, so we calculate the proper
|
||||||
// position based on the selected index and provided bounds.
|
// position based on the selected index and provided bounds.
|
||||||
WebWidgetHost* popup = browser_->UIT_GetPopupHost();
|
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 =
|
NSEvent* event =
|
||||||
webkit_glue::EventWithMenuAction([menu_runner menuItemWasChosen],
|
webkit_glue::EventWithMenuAction([menu_runner menuItemWasChosen],
|
||||||
window_num, item_height,
|
window_num, item_height,
|
||||||
@ -95,6 +96,8 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
|
|||||||
// forward that to WebKit.
|
// forward that to WebKit.
|
||||||
popup->KeyEvent(event);
|
popup->KeyEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
browser_->UIT_ClosePopupWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
|
void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
|
||||||
@ -186,6 +189,10 @@ void BrowserWebViewDelegate::DidMovePlugin(
|
|||||||
|
|
||||||
// Protected methods ----------------------------------------------------------
|
// Protected methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
void BrowserWebViewDelegate::SetPopupMenuInfo(const WebPopupMenuInfo& info) {
|
||||||
|
popup_menu_info_.reset(new WebPopupMenuInfo(info));
|
||||||
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::ShowJavaScriptAlert(
|
void BrowserWebViewDelegate::ShowJavaScriptAlert(
|
||||||
WebKit::WebFrame* webframe, const CefString& message) {
|
WebKit::WebFrame* webframe, const CefString& message) {
|
||||||
std::string messageStr(message);
|
std::string messageStr(message);
|
||||||
|
@ -47,7 +47,11 @@ public:
|
|||||||
const CefPopupFeatures& popupFeatures,
|
const CefPopupFeatures& popupFeatures,
|
||||||
CefRefPtr<CefHandler>& handler,
|
CefRefPtr<CefHandler>& handler,
|
||||||
CefString& url,
|
CefString& url,
|
||||||
CefBrowserSettings& settings);
|
CefBrowserSettings& settings)
|
||||||
|
{
|
||||||
|
REQUIRE_UI_THREAD();
|
||||||
|
return RV_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
// Called on the UI thread after a new window is created. The return value is
|
// Called on the UI thread after a new window is created. The return value is
|
||||||
// currently ignored.
|
// currently ignored.
|
||||||
|
@ -164,6 +164,14 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
|||||||
- (IBAction)testJSExecute:(id)sender;
|
- (IBAction)testJSExecute:(id)sender;
|
||||||
- (IBAction)testRequest:(id)sender;
|
- (IBAction)testRequest:(id)sender;
|
||||||
- (IBAction)testSchemeHandler:(id)sender;
|
- (IBAction)testSchemeHandler:(id)sender;
|
||||||
|
- (IBAction)testPopupWindow:(id)sender;
|
||||||
|
- (IBAction)testAccelerated2DCanvas:(id)sender;
|
||||||
|
- (IBAction)testAcceleratedLayers:(id)sender;
|
||||||
|
- (IBAction)testWebGL:(id)sender;
|
||||||
|
- (IBAction)testHTML5Video:(id)sender;
|
||||||
|
- (IBAction)testZoomIn:(id)sender;
|
||||||
|
- (IBAction)testZoomOut:(id)sender;
|
||||||
|
- (IBAction)testZoomReset:(id)sender;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation ClientAppDelegate
|
@implementation ClientAppDelegate
|
||||||
@ -203,6 +211,30 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
|||||||
[testMenu addItemWithTitle:@"Scheme Handler"
|
[testMenu addItemWithTitle:@"Scheme Handler"
|
||||||
action:@selector(testSchemeHandler:)
|
action:@selector(testSchemeHandler:)
|
||||||
keyEquivalent:@""];
|
keyEquivalent:@""];
|
||||||
|
[testMenu addItemWithTitle:@"Popup Window"
|
||||||
|
action:@selector(testPopupWindow:)
|
||||||
|
keyEquivalent:@""];
|
||||||
|
[testMenu addItemWithTitle:@"Accelerated 2D Canvas"
|
||||||
|
action:@selector(testAccelerated2DCanvas:)
|
||||||
|
keyEquivalent:@""];
|
||||||
|
[testMenu addItemWithTitle:@"Acceledated Layers"
|
||||||
|
action:@selector(testAcceleratedLayers:)
|
||||||
|
keyEquivalent:@""];
|
||||||
|
[testMenu addItemWithTitle:@"WebGL"
|
||||||
|
action:@selector(testWebGL:)
|
||||||
|
keyEquivalent:@""];
|
||||||
|
[testMenu addItemWithTitle:@"HTML5 Video"
|
||||||
|
action:@selector(testHTML5Video:)
|
||||||
|
keyEquivalent:@""];
|
||||||
|
[testMenu addItemWithTitle:@"Zoom In"
|
||||||
|
action:@selector(testZoomIn:)
|
||||||
|
keyEquivalent:@""];
|
||||||
|
[testMenu addItemWithTitle:@"Zoom Out"
|
||||||
|
action:@selector(testZoomOut:)
|
||||||
|
keyEquivalent:@""];
|
||||||
|
[testMenu addItemWithTitle:@"Zoom Reset"
|
||||||
|
action:@selector(testZoomReset:)
|
||||||
|
keyEquivalent:@""];
|
||||||
[testItem setSubmenu:testMenu];
|
[testItem setSubmenu:testMenu];
|
||||||
[menubar addItem:testItem];
|
[menubar addItem:testItem];
|
||||||
|
|
||||||
@ -325,6 +357,52 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
|||||||
RunSchemeTest(g_handler->GetBrowser());
|
RunSchemeTest(g_handler->GetBrowser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (IBAction)testPopupWindow:(id)sender {
|
||||||
|
if(g_handler.get() && g_handler->GetBrowserHwnd())
|
||||||
|
RunPopupTest(g_handler->GetBrowser());
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)testAccelerated2DCanvas:(id)sender {
|
||||||
|
if(g_handler.get() && g_handler->GetBrowserHwnd())
|
||||||
|
RunAccelerated2DCanvasTest(g_handler->GetBrowser());
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)testAcceleratedLayers:(id)sender {
|
||||||
|
if(g_handler.get() && g_handler->GetBrowserHwnd())
|
||||||
|
RunAcceleratedLayersTest(g_handler->GetBrowser());
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)testWebGL:(id)sender {
|
||||||
|
if(g_handler.get() && g_handler->GetBrowserHwnd())
|
||||||
|
RunWebGLTest(g_handler->GetBrowser());
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)testHTML5Video:(id)sender {
|
||||||
|
if(g_handler.get() && g_handler->GetBrowserHwnd())
|
||||||
|
RunHTML5VideoTest(g_handler->GetBrowser());
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)testZoomIn:(id)sender {
|
||||||
|
if(g_handler.get() && g_handler->GetBrowserHwnd()) {
|
||||||
|
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
||||||
|
browser->SetZoomLevel(browser->GetZoomLevel() + 0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)testZoomOut:(id)sender {
|
||||||
|
if(g_handler.get() && g_handler->GetBrowserHwnd()) {
|
||||||
|
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
||||||
|
browser->SetZoomLevel(browser->GetZoomLevel() - 0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)testZoomReset:(id)sender {
|
||||||
|
if(g_handler.get() && g_handler->GetBrowserHwnd()) {
|
||||||
|
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
||||||
|
browser->SetZoomLevel(0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Sent by the default notification center immediately before the application
|
// Sent by the default notification center immediately before the application
|
||||||
// terminates.
|
// terminates.
|
||||||
- (void)applicationWillTerminate:(NSNotification *)aNotification {
|
- (void)applicationWillTerminate:(NSNotification *)aNotification {
|
||||||
@ -367,15 +445,6 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// ClientHandler implementation
|
// ClientHandler implementation
|
||||||
|
|
||||||
CefHandler::RetVal ClientHandler::HandleBeforeCreated(
|
|
||||||
CefRefPtr<CefBrowser> parentBrowser, CefWindowInfo& createInfo, bool popup,
|
|
||||||
const CefPopupFeatures& popupFeatures, CefRefPtr<CefHandler>& handler,
|
|
||||||
CefString& url, CefBrowserSettings& settings)
|
|
||||||
{
|
|
||||||
REQUIRE_UI_THREAD();
|
|
||||||
return RV_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefHandler::RetVal ClientHandler::HandleAddressChange(
|
CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||||
const CefString& url)
|
const CefString& url)
|
||||||
@ -399,7 +468,8 @@ CefHandler::RetVal ClientHandler::HandleTitleChange(
|
|||||||
REQUIRE_UI_THREAD();
|
REQUIRE_UI_THREAD();
|
||||||
|
|
||||||
// Set the frame window title bar
|
// Set the frame window title bar
|
||||||
NSWindow* window = (NSWindow*)m_MainHwnd;
|
NSView* view = (NSView*)browser->GetWindowHandle();
|
||||||
|
NSWindow* window = [view window];
|
||||||
std::string titleStr(title);
|
std::string titleStr(title);
|
||||||
NSString* str = [NSString stringWithUTF8String:titleStr.c_str()];
|
NSString* str = [NSString stringWithUTF8String:titleStr.c_str()];
|
||||||
[window setTitle:str];
|
[window setTitle:str];
|
||||||
|
@ -636,27 +636,6 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
// ClientHandler implementation
|
// ClientHandler implementation
|
||||||
|
|
||||||
CefHandler::RetVal ClientHandler::HandleBeforeCreated(
|
|
||||||
CefRefPtr<CefBrowser> parentBrowser, CefWindowInfo& createInfo, bool popup,
|
|
||||||
const CefPopupFeatures& popupFeatures, CefRefPtr<CefHandler>& handler,
|
|
||||||
CefString& url, CefBrowserSettings& settings)
|
|
||||||
{
|
|
||||||
REQUIRE_UI_THREAD();
|
|
||||||
|
|
||||||
if(popup) {
|
|
||||||
if(popupFeatures.xSet)
|
|
||||||
createInfo.m_x = popupFeatures.x;
|
|
||||||
if(popupFeatures.ySet)
|
|
||||||
createInfo.m_y = popupFeatures.y;
|
|
||||||
if(popupFeatures.widthSet)
|
|
||||||
createInfo.m_nWidth = popupFeatures.width;
|
|
||||||
if(popupFeatures.heightSet)
|
|
||||||
createInfo.m_nHeight = popupFeatures.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RV_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefHandler::RetVal ClientHandler::HandleAddressChange(
|
CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||||
const CefString& url)
|
const CefString& url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user