diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 05:11:05 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 05:11:05 +0000 |
commit | 05158051ea881677c03a22ddf38a3e6779cebb9e (patch) | |
tree | 95c6756227e0bbea55da3c4b19abdf99d7eb3ebe /webkit/tools/test_shell/mac | |
parent | 6c14b76fede6abc592d9d65965fbdf4626e83efe (diff) | |
download | chromium_src-05158051ea881677c03a22ddf38a3e6779cebb9e.zip chromium_src-05158051ea881677c03a22ddf38a3e6779cebb9e.tar.gz chromium_src-05158051ea881677c03a22ddf38a3e6779cebb9e.tar.bz2 |
Use WebWidget from the WebKit API. This change also makes
use of WebKitClient (replacing WebWidgetDelegate from glue).
The ripple effects of this change are rather large, but most
of the impact is mechanical.
The more interesting changes include:
1- Removing the WebWidget parameter from WebWidgetClient methods. This didn't
matter at all to RenderWidget or RenderView, but it did cause some changes to
be made to TestWebViewDelegate. Now, it is not possible to share a delegate
implementation for both the WebView and a popup menu, so I have a second
instance of the delegate owned by TestShell for use with popup menus.
2- Plumbing WebNavigationPolicy in place of WindowOpenDisposition was getting
to be a pretty large change, so I stopped short of deleting WindowOpenDisposition.
That way the Chrome side can remain mostly unmodified. I then added a mapping
function to convert from WebNavigationPolicy to WindowOpenDisposition.
3- The IME methods on WebWidget were renamed (reviewed separately by hbono), and
there is now an enum to specify the composition command (WebCompositionCommand).
4- I added IPC serialization for WebCompositionCommand and WebTextDirection,
which cleaned up some code that was just using ints in IPC messages.
R=jam
BUG=16234
TEST=none
Review URL: http://codereview.chromium.org/149620
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20854 0039d316-1c4b-4281-b951-d872f2087c98
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, 44 insertions, 49 deletions
diff --git a/webkit/tools/test_shell/mac/test_webview_delegate.mm b/webkit/tools/test_shell/mac/test_webview_delegate.mm index 9939c68..7724532 100644 --- a/webkit/tools/test_shell/mac/test_webview_delegate.mm +++ b/webkit/tools/test_shell/mac/test_webview_delegate.mm @@ -16,8 +16,10 @@ #include "webkit/tools/test_shell/test_shell.h" using WebKit::WebCursorInfo; +using WebKit::WebNavigationPolicy; using WebKit::WebPopupMenuInfo; using WebKit::WebRect; +using WebKit::WebWidget; // WebViewDelegate ----------------------------------------------------------- @@ -38,7 +40,7 @@ WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate( const std::string& mime_type, const std::string& clsid, std::string* actual_mime_type) { - WebWidgetHost *host = GetHostForWidget(webview); + WebWidgetHost *host = GetWidgetHost(); if (!host) return NULL; gfx::NativeView view = host->view_handle(); @@ -56,6 +58,10 @@ 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()]; @@ -70,11 +76,10 @@ void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { // WebWidgetDelegate --------------------------------------------------------- -void TestWebViewDelegate::Show(WebWidget* webwidget, - WindowOpenDisposition disposition) { +void TestWebViewDelegate::show(WebNavigationPolicy policy) { if (!popup_menu_info_.get()) return; - if (webwidget != shell_->popup()) + if (this != shell_->popup_delegate()) return; // Display a HTML select menu. @@ -125,8 +130,8 @@ void TestWebViewDelegate::Show(WebWidget* webwidget, } } -void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) { - if (webwidget == shell_->webView()) { +void TestWebViewDelegate::closeWidgetSoon() { + if (this == shell_->delegate()) { 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 @@ -134,54 +139,50 @@ void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) { // to the event loop), so we should make sure we don't leave it dangling. [win performClose:nil]; shell_ = NULL; - } else if (webwidget == shell_->popup()) { + } else if (this == shell_->popup_delegate()) { shell_->ClosePopup(); } } -void TestWebViewDelegate::SetCursor(WebWidget* webwidget, - const WebCursorInfo& cursor_info) { +void TestWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { NSCursor* ns_cursor = WebCursor(cursor_info).GetCursor(); [ns_cursor set]; } -void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget, - WebRect* out_rect) { - DCHECK(out_rect); - if (WebWidgetHost* host = GetHostForWidget(webwidget)) { +WebRect TestWebViewDelegate::windowRect() { + if (WebWidgetHost* host = GetWidgetHost()) { NSView *view = host->view_handle(); NSRect rect = [view frame]; - *out_rect = gfx::Rect(NSRectToCGRect(rect)); + return gfx::Rect(NSRectToCGRect(rect)); } + return WebRect(); } -void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget, - const WebRect& rect) { +void TestWebViewDelegate::setWindowRect(const WebRect& rect) { // TODO: Mac window movement - if (webwidget == shell_->webView()) { + if (this == shell_->delegate()) { // ignored - } else if (webwidget == shell_->popup()) { + } else if (this == shell_->popup_delegate()) { popup_bounds_ = rect; // The initial position of the popup. } } -void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, - WebRect* out_rect) { - if (WebWidgetHost* host = GetHostForWidget(webwidget)) { +WebRect TestWebViewDelegate::rootWindowRect() { + if (WebWidgetHost* host = GetWidgetHost()) { NSView *view = host->view_handle(); NSRect rect = [[[view window] contentView] frame]; - *out_rect = gfx::Rect(NSRectToCGRect(rect)); + return gfx::Rect(NSRectToCGRect(rect)); } + return WebRect(); } @interface NSWindow(OSInternals) - (NSRect)_growBoxRect; @end -void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget, - WebRect* out_rect) { +WebRect TestWebViewDelegate::windowResizerRect() { NSRect resize_rect = NSMakeRect(0, 0, 0, 0); - WebWidgetHost* host = GetHostForWidget(webwidget); + WebWidgetHost* host = GetWidgetHost(); // 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) { @@ -199,15 +200,10 @@ void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget, [view frame].size.height - resize_rect.origin.y - resize_rect.size.height; } - *out_rect = gfx::Rect(NSRectToCGRect(resize_rect)); -} - -void TestWebViewDelegate::DidMove(WebWidget* webwidget, - const WebPluginGeometry& move) { - // TODO(port): add me once plugins work. + return gfx::Rect(NSRectToCGRect(resize_rect)); } -void TestWebViewDelegate::RunModal(WebWidget* webwidget) { +void TestWebViewDelegate::runModal() { NOTIMPLEMENTED(); } diff --git a/webkit/tools/test_shell/mac/webview_host.mm b/webkit/tools/test_shell/mac/webview_host.mm index 96b2a75..3349546 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 eb23bc1..acb98b6 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,13 +23,15 @@ 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, - WebWidgetDelegate* delegate) { + WebWidgetClient* client) { WebWidgetHost* host = new WebWidgetHost(); NSRect content_rect = [parent_view frame]; @@ -40,8 +42,8 @@ WebWidgetHost* WebWidgetHost::Create(NSView* parent_view, // win_util::SetWindowUserData(host->hwnd_, host); - host->webwidget_ = WebWidget::Create(delegate); - host->webwidget_->Resize(WebSize(content_rect.size.width, + host->webwidget_ = WebPopupMenu::create(client); + host->webwidget_->resize(WebSize(content_rect.size.width, content_rect.size.height)); return host; } @@ -149,7 +151,7 @@ WebWidgetHost::~WebWidgetHost() { TrackMouseLeave(false); - webwidget_->Close(); + webwidget_->close(); } void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { @@ -178,7 +180,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_); @@ -227,7 +229,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) { @@ -243,26 +245,23 @@ void WebWidgetHost::MouseEvent(NSEvent *event) { default: break; } - webwidget_->HandleInputEvent(&web_event); + webwidget_->handleInputEvent(web_event); } void WebWidgetHost::WheelEvent(NSEvent *event) { - const WebMouseWheelEvent& web_event = WebInputEventFactory::mouseWheelEvent( - event, view_); - webwidget_->HandleInputEvent(&web_event); + webwidget_->handleInputEvent( + WebInputEventFactory::mouseWheelEvent(event, view_)); } void WebWidgetHost::KeyEvent(NSEvent *event) { - const WebKeyboardEvent& web_event = WebInputEventFactory::keyboardEvent( - event); - webwidget_->HandleInputEvent(&web_event); + webwidget_->handleInputEvent(WebInputEventFactory::keyboardEvent(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) { @@ -281,6 +280,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); } |