diff options
Diffstat (limited to 'webkit/tools/test_shell/mac')
-rw-r--r-- | webkit/tools/test_shell/mac/test_webview_delegate.mm | 60 | ||||
-rw-r--r-- | webkit/tools/test_shell/mac/webview_host.mm | 2 | ||||
-rw-r--r-- | webkit/tools/test_shell/mac/webwidget_host.mm | 31 |
3 files changed, 49 insertions, 44 deletions
diff --git a/webkit/tools/test_shell/mac/test_webview_delegate.mm b/webkit/tools/test_shell/mac/test_webview_delegate.mm index 7724532..9939c68 100644 --- a/webkit/tools/test_shell/mac/test_webview_delegate.mm +++ b/webkit/tools/test_shell/mac/test_webview_delegate.mm @@ -16,10 +16,8 @@ #include "webkit/tools/test_shell/test_shell.h" using WebKit::WebCursorInfo; -using WebKit::WebNavigationPolicy; using WebKit::WebPopupMenuInfo; using WebKit::WebRect; -using WebKit::WebWidget; // WebViewDelegate ----------------------------------------------------------- @@ -40,7 +38,7 @@ WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate( const std::string& mime_type, const std::string& clsid, std::string* actual_mime_type) { - WebWidgetHost *host = GetWidgetHost(); + WebWidgetHost *host = GetHostForWidget(webview); if (!host) return NULL; gfx::NativeView view = host->view_handle(); @@ -58,10 +56,6 @@ WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate( return WebPluginDelegateImpl::Create(info.path, mime_type, view); } -void TestWebViewDelegate::DidMovePlugin(const WebPluginGeometry& move) { - // TODO(port): add me once plugins work. -} - void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { NSString *text = [NSString stringWithUTF8String:WideToUTF8(message).c_str()]; @@ -76,10 +70,11 @@ void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { // WebWidgetDelegate --------------------------------------------------------- -void TestWebViewDelegate::show(WebNavigationPolicy policy) { +void TestWebViewDelegate::Show(WebWidget* webwidget, + WindowOpenDisposition disposition) { if (!popup_menu_info_.get()) return; - if (this != shell_->popup_delegate()) + if (webwidget != shell_->popup()) return; // Display a HTML select menu. @@ -130,8 +125,8 @@ void TestWebViewDelegate::show(WebNavigationPolicy policy) { } } -void TestWebViewDelegate::closeWidgetSoon() { - if (this == shell_->delegate()) { +void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) { + if (webwidget == shell_->webView()) { NSWindow *win = shell_->mainWnd(); // Tell Cocoa to close the window, which will let the window's delegate // handle getting rid of the shell. |shell_| will still be alive for a short @@ -139,50 +134,54 @@ void TestWebViewDelegate::closeWidgetSoon() { // to the event loop), so we should make sure we don't leave it dangling. [win performClose:nil]; shell_ = NULL; - } else if (this == shell_->popup_delegate()) { + } else if (webwidget == shell_->popup()) { shell_->ClosePopup(); } } -void TestWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { +void TestWebViewDelegate::SetCursor(WebWidget* webwidget, + const WebCursorInfo& cursor_info) { NSCursor* ns_cursor = WebCursor(cursor_info).GetCursor(); [ns_cursor set]; } -WebRect TestWebViewDelegate::windowRect() { - if (WebWidgetHost* host = GetWidgetHost()) { +void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget, + WebRect* out_rect) { + DCHECK(out_rect); + if (WebWidgetHost* host = GetHostForWidget(webwidget)) { NSView *view = host->view_handle(); NSRect rect = [view frame]; - return gfx::Rect(NSRectToCGRect(rect)); + *out_rect = gfx::Rect(NSRectToCGRect(rect)); } - return WebRect(); } -void TestWebViewDelegate::setWindowRect(const WebRect& rect) { +void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget, + const WebRect& rect) { // TODO: Mac window movement - if (this == shell_->delegate()) { + if (webwidget == shell_->webView()) { // ignored - } else if (this == shell_->popup_delegate()) { + } else if (webwidget == shell_->popup()) { popup_bounds_ = rect; // The initial position of the popup. } } -WebRect TestWebViewDelegate::rootWindowRect() { - if (WebWidgetHost* host = GetWidgetHost()) { +void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, + WebRect* out_rect) { + if (WebWidgetHost* host = GetHostForWidget(webwidget)) { NSView *view = host->view_handle(); NSRect rect = [[[view window] contentView] frame]; - return gfx::Rect(NSRectToCGRect(rect)); + *out_rect = gfx::Rect(NSRectToCGRect(rect)); } - return WebRect(); } @interface NSWindow(OSInternals) - (NSRect)_growBoxRect; @end -WebRect TestWebViewDelegate::windowResizerRect() { +void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget, + WebRect* out_rect) { NSRect resize_rect = NSMakeRect(0, 0, 0, 0); - WebWidgetHost* host = GetWidgetHost(); + WebWidgetHost* host = GetHostForWidget(webwidget); // To match the WebKit screen shots, we need the resize area to overlap // the scroll arrows, so in layout test mode, we don't return a real rect. if (!(shell_->layout_test_mode()) && host) { @@ -200,10 +199,15 @@ WebRect TestWebViewDelegate::windowResizerRect() { [view frame].size.height - resize_rect.origin.y - resize_rect.size.height; } - return gfx::Rect(NSRectToCGRect(resize_rect)); + *out_rect = gfx::Rect(NSRectToCGRect(resize_rect)); +} + +void TestWebViewDelegate::DidMove(WebWidget* webwidget, + const WebPluginGeometry& move) { + // TODO(port): add me once plugins work. } -void TestWebViewDelegate::runModal() { +void TestWebViewDelegate::RunModal(WebWidget* webwidget) { NOTIMPLEMENTED(); } diff --git a/webkit/tools/test_shell/mac/webview_host.mm b/webkit/tools/test_shell/mac/webview_host.mm index 3349546..96b2a75 100644 --- a/webkit/tools/test_shell/mac/webview_host.mm +++ b/webkit/tools/test_shell/mac/webview_host.mm @@ -34,7 +34,7 @@ WebViewHost* WebViewHost::Create(NSView* parent_view, [host->view_ release]; host->webwidget_ = WebView::Create(delegate, prefs); - host->webwidget_->resize(WebSize(content_rect.size.width, + host->webwidget_->Resize(WebSize(content_rect.size.width, content_rect.size.height)); return host; diff --git a/webkit/tools/test_shell/mac/webwidget_host.mm b/webkit/tools/test_shell/mac/webwidget_host.mm index acb98b6..eb23bc1 100644 --- a/webkit/tools/test_shell/mac/webwidget_host.mm +++ b/webkit/tools/test_shell/mac/webwidget_host.mm @@ -13,9 +13,9 @@ #include "webkit/api/public/mac/WebInputEventFactory.h" #include "webkit/api/public/mac/WebScreenInfoFactory.h" #include "webkit/api/public/WebInputEvent.h" -#include "webkit/api/public/WebPopupMenu.h" #include "webkit/api/public/WebScreenInfo.h" #include "webkit/api/public/WebSize.h" +#include "webkit/glue/webwidget.h" #include "webkit/tools/test_shell/test_shell.h" using WebKit::WebInputEvent; @@ -23,15 +23,13 @@ using WebKit::WebInputEventFactory; using WebKit::WebKeyboardEvent; using WebKit::WebMouseEvent; using WebKit::WebMouseWheelEvent; -using WebKit::WebPopupMenu; using WebKit::WebScreenInfo; using WebKit::WebScreenInfoFactory; using WebKit::WebSize; -using WebKit::WebWidgetClient; /*static*/ WebWidgetHost* WebWidgetHost::Create(NSView* parent_view, - WebWidgetClient* client) { + WebWidgetDelegate* delegate) { WebWidgetHost* host = new WebWidgetHost(); NSRect content_rect = [parent_view frame]; @@ -42,8 +40,8 @@ WebWidgetHost* WebWidgetHost::Create(NSView* parent_view, // win_util::SetWindowUserData(host->hwnd_, host); - host->webwidget_ = WebPopupMenu::create(client); - host->webwidget_->resize(WebSize(content_rect.size.width, + host->webwidget_ = WebWidget::Create(delegate); + host->webwidget_->Resize(WebSize(content_rect.size.width, content_rect.size.height)); return host; } @@ -151,7 +149,7 @@ WebWidgetHost::~WebWidgetHost() { TrackMouseLeave(false); - webwidget_->close(); + webwidget_->Close(); } void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { @@ -180,7 +178,7 @@ void WebWidgetHost::Paint() { flipped:NO]]; // This may result in more invalidation - webwidget_->layout(); + webwidget_->Layout(); // Scroll the canvas if necessary scroll_rect_ = client_rect.Intersect(scroll_rect_); @@ -229,7 +227,7 @@ WebScreenInfo WebWidgetHost::GetScreenInfo() { void WebWidgetHost::Resize(const gfx::Rect& rect) { // Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer. DiscardBackingStore(); - webwidget_->resize(WebSize(rect.width(), rect.height())); + webwidget_->Resize(WebSize(rect.width(), rect.height())); } void WebWidgetHost::MouseEvent(NSEvent *event) { @@ -245,23 +243,26 @@ void WebWidgetHost::MouseEvent(NSEvent *event) { default: break; } - webwidget_->handleInputEvent(web_event); + webwidget_->HandleInputEvent(&web_event); } void WebWidgetHost::WheelEvent(NSEvent *event) { - webwidget_->handleInputEvent( - WebInputEventFactory::mouseWheelEvent(event, view_)); + const WebMouseWheelEvent& web_event = WebInputEventFactory::mouseWheelEvent( + event, view_); + webwidget_->HandleInputEvent(&web_event); } void WebWidgetHost::KeyEvent(NSEvent *event) { - webwidget_->handleInputEvent(WebInputEventFactory::keyboardEvent(event)); + const WebKeyboardEvent& web_event = WebInputEventFactory::keyboardEvent( + event); + webwidget_->HandleInputEvent(&web_event); } void WebWidgetHost::SetFocus(bool enable) { // Ignore focus calls in layout test mode so that tests don't mess with each // other's focus when running in parallel. if (!TestShell::layout_test_mode()) - webwidget_->setFocus(enable); + webwidget_->SetFocus(enable); } void WebWidgetHost::TrackMouseLeave(bool track) { @@ -280,6 +281,6 @@ void WebWidgetHost::PaintRect(const gfx::Rect& rect) { DCHECK(canvas_.get()); set_painting(true); - webwidget_->paint(canvas_.get(), rect); + webwidget_->Paint(canvas_.get(), rect); set_painting(false); } |