diff options
Diffstat (limited to 'webkit/tools/test_shell')
20 files changed, 258 insertions, 265 deletions
diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc index 79e3d85..a29978f 100644 --- a/webkit/tools/test_shell/event_sending_controller.cc +++ b/webkit/tools/test_shell/event_sending_controller.cc @@ -248,7 +248,7 @@ void EventSendingController::mouseDown( if (result) // Could be NULL if invoked asynchronously. result->SetNull(); - webview()->Layout(); + webview()->layout(); int button_number = GetButtonNumberFromSingleArg(args); DCHECK(button_number != -1); @@ -270,7 +270,7 @@ void EventSendingController::mouseDown( pressed_button_ = button_type; InitMouseEvent(WebInputEvent::MouseDown, button_type, last_mouse_pos_, &event); - webview()->HandleInputEvent(&event); + webview()->handleInputEvent(event); } void EventSendingController::mouseUp( @@ -278,7 +278,7 @@ void EventSendingController::mouseUp( if (result) // Could be NULL if invoked asynchronously. result->SetNull(); - webview()->Layout(); + webview()->layout(); int button_number = GetButtonNumberFromSingleArg(args); DCHECK(button_number != -1); @@ -303,7 +303,7 @@ void EventSendingController::mouseUp( } /* static */ void EventSendingController::DoMouseUp(const WebMouseEvent& e) { - webview()->HandleInputEvent(&e); + webview()->handleInputEvent(e); pressed_button_ = WebMouseEvent::ButtonNone; // If we're in a drag operation, complete it. @@ -329,7 +329,7 @@ void EventSendingController::mouseMoveTo( result->SetNull(); if (args.size() >= 2 && args[0].isNumber() && args[1].isNumber()) { - webview()->Layout(); + webview()->layout(); WebMouseEvent event; last_mouse_pos_.SetPoint(args[0].ToInt32(), args[1].ToInt32()); @@ -347,7 +347,7 @@ void EventSendingController::mouseMoveTo( // static void EventSendingController::DoMouseMove(const WebMouseEvent& e) { - webview()->HandleInputEvent(&e); + webview()->handleInputEvent(e); if (pressed_button_ != WebMouseEvent::ButtonNone && !current_drag_data.isNull()) { @@ -428,20 +428,20 @@ void EventSendingController::keyDown( event_up.type = WebInputEvent::KeyUp; // EventSendingController.m forces a layout here, with at least one // test (fast\forms\focus-control-to-page.html) relying on this. - webview()->Layout(); + webview()->layout(); - webview()->HandleInputEvent(&event_down); + webview()->handleInputEvent(event_down); #if defined(OS_WIN) if (generate_char) { WebKeyboardEvent event_char = event_down; event_char.type = WebInputEvent::Char; event_char.keyIdentifier[0] = '\0'; - webview()->HandleInputEvent(&event_char); + webview()->handleInputEvent(event_char); } #endif - webview()->HandleInputEvent(&event_up); + webview()->handleInputEvent(event_up); } } @@ -460,12 +460,11 @@ void EventSendingController::dispatchMessage( if (msg == WM_DEADCHAR || msg == WM_SYSDEADCHAR) return; - webview()->Layout(); + webview()->layout(); unsigned long lparam = static_cast<unsigned long>(args[2].ToDouble()); - const WebKeyboardEvent& key_event = WebInputEventFactory::keyboardEvent( - NULL, msg, args[1].ToInt32(), lparam); - webview()->HandleInputEvent(&key_event); + webview()->handleInputEvent(WebInputEventFactory::keyboardEvent( + NULL, msg, args[1].ToInt32(), lparam)); } else { NOTREACHED() << L"Wrong number of arguments"; } @@ -543,7 +542,7 @@ void EventSendingController::contextClick( const CppArgumentList& args, CppVariant* result) { result->SetNull(); - webview()->Layout(); + webview()->layout(); if (GetCurrentEventTimeSec() - last_click_time_sec >= 1) { click_count = 1; @@ -557,11 +556,11 @@ void EventSendingController::contextClick( pressed_button_ = WebMouseEvent::ButtonRight; InitMouseEvent(WebInputEvent::MouseDown, WebMouseEvent::ButtonRight, last_mouse_pos_, &event); - webview()->HandleInputEvent(&event); + webview()->handleInputEvent(event); InitMouseEvent(WebInputEvent::MouseUp, WebMouseEvent::ButtonRight, last_mouse_pos_, &event); - webview()->HandleInputEvent(&event); + webview()->handleInputEvent(event); pressed_button_ = WebMouseEvent::ButtonNone; } 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); } diff --git a/webkit/tools/test_shell/plugin_tests.cc b/webkit/tools/test_shell/plugin_tests.cc index a0951c9..0d8d8d0 100644 --- a/webkit/tools/test_shell/plugin_tests.cc +++ b/webkit/tools/test_shell/plugin_tests.cc @@ -161,7 +161,7 @@ TEST_F(PluginTest, DeleteFrameDuringEvent) { input.x = 50; input.y = 50; input.type = WebKit::WebInputEvent::MouseUp; - test_shell_->webView()->HandleInputEvent(&input); + test_shell_->webView()->handleInputEvent(input); // No crash means we passed. } diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 50aea1f..cf63470 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -43,11 +43,11 @@ #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" -#include "webkit/glue/webwidget.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" #include "webkit/tools/test_shell/test_navigation_controller.h" #include "webkit/tools/test_shell/test_shell_switches.h" +using WebKit::WebNavigationPolicy; using WebKit::WebRect; using WebKit::WebSize; using WebKit::WebURLRequest; @@ -112,6 +112,7 @@ TestShell::TestShell() is_modal_(false), dump_stats_table_on_exit_(false) { delegate_ = new TestWebViewDelegate(this); + popup_delegate_ = new TestWebViewDelegate(this); layout_test_controller_.reset(new LayoutTestController(this)); event_sending_controller_.reset(new EventSendingController(this)); text_input_controller_.reset(new TextInputController(this)); @@ -247,13 +248,13 @@ void TestShell::Dump(TestShell* shell) { // static std::string TestShell::DumpImage(WebView* view, const std::wstring& file_name, const std::string& pixel_hash) { - view->Layout(); - const WebSize& size = view->GetSize(); + view->layout(); + const WebSize& size = view->size(); skia::PlatformCanvas canvas; if (!canvas.initialize(size.width, size.height, true)) return std::string(); - view->Paint(&canvas, WebRect(0, 0, size.width, size.height)); + view->paint(&canvas, WebRect(0, 0, size.width, size.height)); skia::BitmapPlatformDevice& device = static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice()); @@ -434,8 +435,8 @@ bool TestShell::RemoveWindowFromList(gfx::NativeWindow window) { return false; } -void TestShell::Show(WebView* webview, WindowOpenDisposition disposition) { - delegate_->Show(webview, disposition); +void TestShell::Show(WebNavigationPolicy policy) { + delegate_->show(policy); } void TestShell::BindJSObjectsToWindow(WebFrame* frame) { @@ -590,13 +591,13 @@ void TestShell::SetFocus(WebWidgetHost* host, bool enable) { if (enable) { if (m_focusedWidgetHost != host) { if (m_focusedWidgetHost) - m_focusedWidgetHost->webwidget()->SetFocus(false); - host->webwidget()->SetFocus(enable); + m_focusedWidgetHost->webwidget()->setFocus(false); + host->webwidget()->setFocus(enable); m_focusedWidgetHost = host; } } else { if (m_focusedWidgetHost == host) { - host->webwidget()->SetFocus(enable); + host->webwidget()->setFocus(enable); m_focusedWidgetHost = NULL; } } diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h index 5b20e9d..8c92ca3 100644 --- a/webkit/tools/test_shell/test_shell.h +++ b/webkit/tools/test_shell/test_shell.h @@ -93,7 +93,9 @@ public: return m_webViewHost.get() ? m_webViewHost->webview() : NULL; } WebViewHost* webViewHost() { return m_webViewHost.get(); } - WebWidget* popup() { return m_popupHost ? m_popupHost->webwidget() : NULL; } + WebKit::WebWidget* popup() { + return m_popupHost ? m_popupHost->webwidget() : NULL; + } WebWidgetHost* popupHost() { return m_popupHost; } // Called by the LayoutTestController to signal test completion. @@ -102,7 +104,7 @@ public: // Called to block the calling thread until TestFinished is called. void WaitTestFinished(); - void Show(WebView* webview, WindowOpenDisposition disposition); + void Show(WebKit::WebNavigationPolicy policy); // We use this to avoid relying on Windows focus during layout test mode. void SetFocus(WebWidgetHost* host, bool enable); @@ -111,6 +113,7 @@ public: return layout_test_controller_.get(); } TestWebViewDelegate* delegate() { return delegate_.get(); } + TestWebViewDelegate* popup_delegate() { return popup_delegate_.get(); } TestNavigationController* navigation_controller() { return navigation_controller_.get(); } @@ -175,7 +178,7 @@ public: // Implements CreateWebView for TestWebViewDelegate, which in turn // is called as a WebViewDelegate. WebView* CreateWebView(WebView* webview); - WebWidget* CreatePopupWidget(WebView* webview); + WebKit::WebWidget* CreatePopupWidget(WebView* webview); void ClosePopup(); #if defined(OS_WIN) @@ -322,6 +325,7 @@ private: scoped_ptr<TestNavigationController> navigation_controller_; scoped_refptr<TestWebViewDelegate> delegate_; + scoped_refptr<TestWebViewDelegate> popup_delegate_; const TestParams* test_params_; diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index 86a9ac9..7d904d66 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -32,6 +32,8 @@ #include "webkit/tools/test_shell/test_navigation_controller.h" #include "webkit/tools/test_shell/test_webview_delegate.h" +using WebKit::WebWidget; + namespace { // Convert a FilePath into an FcChar* (used by fontconfig). @@ -467,7 +469,7 @@ void TestShell::DestroyWindow(gfx::NativeWindow windowHandle) { WebWidget* TestShell::CreatePopupWidget(WebView* webview) { GtkWidget* popupwindow = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget* vbox = gtk_vbox_new(FALSE, 0); - WebWidgetHost* host = WebWidgetHost::Create(vbox, delegate_); + WebWidgetHost* host = WebWidgetHost::Create(vbox, popup_delegate_); gtk_container_add(GTK_CONTAINER(popupwindow), vbox); m_popupHost = host; diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm index c2640cc..aa34720 100644 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ b/webkit/tools/test_shell/test_shell_mac.mm @@ -33,7 +33,6 @@ #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webview.h" -#include "webkit/glue/webwidget.h" #include "webkit/glue/plugins/plugin_list.h" #include "webkit/tools/test_shell/mac/test_shell_webview.h" #include "webkit/tools/test_shell/resource.h" @@ -44,6 +43,8 @@ #import "mac/DumpRenderTreePasteboard.h" +using WebKit::WebWidget; + #define MAX_LOADSTRING 100 // Sizes for URL bar layout @@ -458,7 +459,7 @@ void TestShell::DestroyWindow(gfx::NativeWindow windowHandle) { WebWidget* TestShell::CreatePopupWidget(WebView* webview) { DCHECK(!m_popupHost); - m_popupHost = WebWidgetHost::Create(webViewWnd(), delegate_.get()); + m_popupHost = WebWidgetHost::Create(webViewWnd(), popup_delegate_.get()); return m_popupHost->webwidget(); } diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index 05d7bbe..06c9d13 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -215,7 +215,7 @@ int main(int argc, char* argv[]) { WebKit::registerExtension(extensions_v8::PlaybackExtension::Get()); } - shell->Show(shell->webView(), NEW_WINDOW); + shell->Show(WebKit::WebNavigationPolicyNewWindow); if (parsed_command_line.HasSwitch(test_shell::kDumpStatsTable)) shell->DumpStatsTableOnExit(); diff --git a/webkit/tools/test_shell/test_shell_test.cc b/webkit/tools/test_shell/test_shell_test.cc index c6e7ac4..87b5347 100644 --- a/webkit/tools/test_shell/test_shell_test.cc +++ b/webkit/tools/test_shell/test_shell_test.cc @@ -21,7 +21,7 @@ std::wstring TestShellTest::GetTestURL(const FilePath& test_case_path, void TestShellTest::SetUp() { // Make a test shell for use by the test. CreateEmptyWindow(); - test_shell_->Show(test_shell_->webView(), NEW_WINDOW); + test_shell_->Show(WebKit::WebNavigationPolicyNewWindow); // Point data_dir_ to the root of the test case dir ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir_)); diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index 9d6cefc..c0dc1e6 100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -36,6 +36,8 @@ #include "webkit/tools/test_shell/test_navigation_controller.h" #include "webkit/tools/test_shell/test_shell_switches.h" +using WebKit::WebWidget; + #define MAX_LOADSTRING 100 #define BUTTON_WIDTH 72 @@ -457,7 +459,7 @@ void TestShell::InteractiveSetFocus(WebWidgetHost* host, bool enable) { WebWidget* TestShell::CreatePopupWidget(WebView* webview) { DCHECK(!m_popupHost); - m_popupHost = WebWidgetHost::Create(NULL, delegate_.get()); + m_popupHost = WebWidgetHost::Create(NULL, popup_delegate_.get()); ShowWindow(popupWnd(), SW_SHOW); return m_popupHost->webwidget(); diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index d78971b..2fdf392 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -56,6 +56,7 @@ using WebKit::WebDataSource; using WebKit::WebDragData; using WebKit::WebHistoryItem; using WebKit::WebNavigationType; +using WebKit::WebNavigationPolicy; using WebKit::WebRect; using WebKit::WebScreenInfo; using WebKit::WebSize; @@ -63,6 +64,7 @@ using WebKit::WebString; using WebKit::WebURL; using WebKit::WebURLError; using WebKit::WebURLRequest; +using WebKit::WebWidget; using WebKit::WebWorker; using WebKit::WebWorkerClient; @@ -161,13 +163,11 @@ WebWorker* TestWebViewDelegate::CreateWebWorker(WebWorkerClient* client) { void TestWebViewDelegate::OpenURL(WebView* webview, const GURL& url, const GURL& referrer, - WindowOpenDisposition disposition) { - DCHECK_NE(disposition, CURRENT_TAB); // No code for this - if (disposition == SUPPRESS_OPEN) - return; + WebNavigationPolicy policy) { + DCHECK_NE(policy, WebKit::WebNavigationPolicyCurrentTab); TestShell* shell = NULL; if (TestShell::CreateNewWindow(UTF8ToWide(url.spec()), &shell)) - shell->Show(shell->webView(), disposition); + shell->Show(policy); } void TestWebViewDelegate::DidStartLoading(WebView* webview) { @@ -182,14 +182,14 @@ void TestWebViewDelegate::WindowObjectCleared(WebFrame* webframe) { shell_->BindJSObjectsToWindow(webframe); } -WindowOpenDisposition TestWebViewDelegate::DispositionForNavigationAction( +WebNavigationPolicy TestWebViewDelegate::PolicyForNavigationAction( WebView* webview, WebFrame* frame, const WebURLRequest& request, WebNavigationType type, - WindowOpenDisposition disposition, + WebNavigationPolicy default_policy, bool is_redirect) { - WindowOpenDisposition result; + WebNavigationPolicy result; if (policy_delegate_enabled_) { std::wstring frame_name = frame->GetName(); std::string url_description; @@ -201,12 +201,15 @@ WindowOpenDisposition TestWebViewDelegate::DispositionForNavigationAction( } printf("Policy delegate: attempt to load %s with navigation type '%s'\n", url_description.c_str(), WebNavigationTypeToString(type)); - result = policy_delegate_is_permissive_ ? CURRENT_TAB : IGNORE_ACTION; + if (policy_delegate_is_permissive_) { + result = WebKit::WebNavigationPolicyCurrentTab; + } else { + result = WebKit::WebNavigationPolicyIgnore; + } if (policy_delegate_should_notify_done_) shell_->layout_test_controller()->PolicyDelegateDone(); } else { - result = WebViewDelegate::DispositionForNavigationAction( - webview, frame, request, type, disposition, is_redirect); + result = default_policy; } return result; } @@ -744,34 +747,29 @@ void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) { // WebWidgetDelegate --------------------------------------------------------- -void TestWebViewDelegate::DidInvalidateRect(WebWidget* webwidget, - const WebRect& rect) { - if (WebWidgetHost* host = GetHostForWidget(webwidget)) +void TestWebViewDelegate::didInvalidateRect(const WebRect& rect) { + if (WebWidgetHost* host = GetWidgetHost()) host->DidInvalidateRect(rect); } -void TestWebViewDelegate::DidScrollRect(WebWidget* webwidget, int dx, int dy, +void TestWebViewDelegate::didScrollRect(int dx, int dy, const WebRect& clip_rect) { - if (WebWidgetHost* host = GetHostForWidget(webwidget)) + if (WebWidgetHost* host = GetWidgetHost()) host->DidScrollRect(dx, dy, clip_rect); } -void TestWebViewDelegate::Focus(WebWidget* webwidget) { - if (WebWidgetHost* host = GetHostForWidget(webwidget)) +void TestWebViewDelegate::didFocus() { + if (WebWidgetHost* host = GetWidgetHost()) shell_->SetFocus(host, true); } -void TestWebViewDelegate::Blur(WebWidget* webwidget) { - if (WebWidgetHost* host = GetHostForWidget(webwidget)) +void TestWebViewDelegate::didBlur() { + if (WebWidgetHost* host = GetWidgetHost()) shell_->SetFocus(host, false); } -bool TestWebViewDelegate::IsHidden(WebWidget* webwidget) { - return false; -} - -WebScreenInfo TestWebViewDelegate::GetScreenInfo(WebWidget* webwidget) { - if (WebWidgetHost* host = GetHostForWidget(webwidget)) +WebScreenInfo TestWebViewDelegate::screenInfo() { + if (WebWidgetHost* host = GetWidgetHost()) return host->GetScreenInfo(); return WebScreenInfo(); @@ -835,10 +833,10 @@ void TestWebViewDelegate::LocationChangeDone(WebFrame* frame) { } } -WebWidgetHost* TestWebViewDelegate::GetHostForWidget(WebWidget* webwidget) { - if (webwidget == shell_->webView()) +WebWidgetHost* TestWebViewDelegate::GetWidgetHost() { + if (this == shell_->delegate()) return shell_->webViewHost(); - if (webwidget == shell_->popup()) + if (this == shell_->popup_delegate()) return shell_->popupHost(); return NULL; } diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 208c8e6a..e70ede9 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -29,7 +29,6 @@ #endif #include "webkit/glue/webcursor.h" #include "webkit/glue/webview_delegate.h" -#include "webkit/glue/webwidget_delegate.h" #if defined(OS_WIN) #include "webkit/tools/test_shell/drag_delegate.h" #include "webkit/tools/test_shell/drop_delegate.h" @@ -85,9 +84,11 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, virtual WebView* CreateWebView(WebView* webview, bool user_gesture, const GURL& creator_url); - virtual WebWidget* CreatePopupWidget(WebView* webview, bool activatable); + virtual WebKit::WebWidget* CreatePopupWidget( + WebView* webview, + bool activatable); #if defined(OS_MACOSX) - virtual WebWidget* CreatePopupWidgetWithInfo( + virtual WebKit::WebWidget* CreatePopupWidgetWithInfo( WebView* webview, const WebKit::WebPopupMenuInfo& info); #endif @@ -107,7 +108,8 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, virtual void OpenURL(WebView* webview, const GURL& url, const GURL& referrer, - WindowOpenDisposition disposition); + WebKit::WebNavigationPolicy policy); + virtual void DidMovePlugin(const WebPluginGeometry& move); virtual void RunJavaScriptAlert(WebFrame* webframe, const std::wstring& message); virtual bool RunJavaScriptConfirm(WebFrame* webframe, @@ -219,38 +221,32 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, virtual void DidStopLoading(WebView* webview); virtual void WindowObjectCleared(WebFrame* webframe); - virtual WindowOpenDisposition DispositionForNavigationAction( + virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( WebView* webview, WebFrame* frame, const WebKit::WebURLRequest& request, WebKit::WebNavigationType type, - WindowOpenDisposition disposition, + WebKit::WebNavigationPolicy default_policy, bool is_redirect); virtual void NavigateBackForwardSoon(int offset); virtual int GetHistoryBackListCount(); virtual int GetHistoryForwardListCount(); - // WebWidgetDelegate - virtual void DidInvalidateRect(WebWidget* webwidget, - const WebKit::WebRect& rect); - virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy, + // WebWidgetClient + virtual void didInvalidateRect(const WebKit::WebRect& rect); + virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clip_rect); - virtual void Show(WebWidget* webview, WindowOpenDisposition disposition); - virtual void CloseWidgetSoon(WebWidget* webwidget); - virtual void Focus(WebWidget* webwidget); - virtual void Blur(WebWidget* webwidget); - virtual void SetCursor(WebWidget* webwidget, - const WebKit::WebCursorInfo& cursor); - virtual void GetWindowRect(WebWidget* webwidget, WebKit::WebRect* rect); - virtual void SetWindowRect(WebWidget* webwidget, - const WebKit::WebRect& rect); - virtual void GetRootWindowRect(WebWidget *, WebKit::WebRect *); - virtual void GetRootWindowResizerRect(WebWidget* webwidget, - WebKit::WebRect* rect); - virtual void DidMove(WebWidget* webwidget, const WebPluginGeometry& move); - virtual void RunModal(WebWidget* webwidget); - virtual bool IsHidden(WebWidget* webwidget); - virtual WebKit::WebScreenInfo GetScreenInfo(WebWidget* webwidget); + virtual void didFocus(); + virtual void didBlur(); + virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor); + virtual void closeWidgetSoon(); + virtual void show(WebKit::WebNavigationPolicy policy); + virtual void runModal(); + virtual WebKit::WebRect windowRect(); + virtual void setWindowRect(const WebKit::WebRect& rect); + virtual WebKit::WebRect rootWindowRect(); + virtual WebKit::WebRect windowResizerRect(); + virtual WebKit::WebScreenInfo screenInfo(); void SetSmartInsertDeleteEnabled(bool enabled); void SetSelectTrailingWhitespaceEnabled(bool enabled); @@ -305,7 +301,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, // test. void LocationChangeDone(WebFrame*); - WebWidgetHost* GetHostForWidget(WebWidget* webwidget); + WebWidgetHost* GetWidgetHost(); void UpdateForCommittedLoad(WebFrame* webframe, bool is_new_navigation); void UpdateURL(WebFrame* frame); diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc index 1257145..28d2956 100644 --- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc +++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc @@ -32,6 +32,7 @@ #include "webkit/tools/test_shell/test_shell.h" using WebKit::WebCursorInfo; +using WebKit::WebNavigationPolicy; using WebKit::WebRect; namespace { @@ -119,26 +120,24 @@ void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { gtk_widget_destroy(dialog); } -void TestWebViewDelegate::Show(WebWidget* webwidget, - WindowOpenDisposition disposition) { - WebWidgetHost* host = GetHostForWidget(webwidget); +void TestWebViewDelegate::show(WebNavigationPolicy policy) { + WebWidgetHost* host = GetWidgetHost(); GtkWidget* drawing_area = host->view_handle(); GtkWidget* window = gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); gtk_widget_show_all(window); } -void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) { - if (webwidget == shell_->webView()) { +void TestWebViewDelegate::closeWidgetSoon() { + if (this == shell_->delegate()) { MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction( >k_widget_destroy, GTK_WIDGET(shell_->mainWnd()))); - } 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) { current_cursor_.InitFromCursorInfo(cursor_info); GdkCursorType cursor_type = current_cursor_.GetCursorType(); GdkCursor* gdk_cursor; @@ -165,10 +164,8 @@ void TestWebViewDelegate::SetCursor(WebWidget* webwidget, gdk_cursor_unref(gdk_cursor); } -void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget, - WebRect* out_rect) { - DCHECK(out_rect); - WebWidgetHost* host = GetHostForWidget(webwidget); +WebRect TestWebViewDelegate::windowRect() { + WebWidgetHost* host = GetWidgetHost(); GtkWidget* drawing_area = host->view_handle(); GtkWidget* vbox = gtk_widget_get_parent(drawing_area); GtkWidget* window = gtk_widget_get_parent(vbox); @@ -178,17 +175,16 @@ void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget, x += vbox->allocation.x + drawing_area->allocation.x; y += vbox->allocation.y + drawing_area->allocation.y; - *out_rect = WebRect(x, y, - drawing_area->allocation.width, - drawing_area->allocation.height); + return WebRect(x, y, + drawing_area->allocation.width, + drawing_area->allocation.height); } -void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget, - const WebRect& rect) { - if (webwidget == shell_->webView()) { +void TestWebViewDelegate::setWindowRect(const WebRect& rect) { + if (this == shell_->delegate()) { // ignored - } else if (webwidget == shell_->popup()) { - WebWidgetHost* host = GetHostForWidget(webwidget); + } else if (this == shell_->popup_delegate()) { + WebWidgetHost* host = GetWidgetHost(); GtkWidget* drawing_area = host->view_handle(); GtkWidget* window = gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); @@ -197,9 +193,8 @@ void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget, } } -void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, - WebRect* out_rect) { - if (WebWidgetHost* host = GetHostForWidget(webwidget)) { +WebRect TestWebViewDelegate::rootWindowRect() { + if (WebWidgetHost* host = GetWidgetHost()) { // We are being asked for the x/y and width/height of the entire browser // window. This means the x/y is the distance from the corner of the // screen, and the width/height is the size of the entire browser window. @@ -210,25 +205,24 @@ void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, gint x, y, width, height; gtk_window_get_position(GTK_WINDOW(window), &x, &y); gtk_window_get_size(GTK_WINDOW(window), &width, &height); - *out_rect = WebRect(x, y, width, height); + return WebRect(x, y, width, height); } + return WebRect(); } -void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget, - WebRect* out_rect) { +WebRect TestWebViewDelegate::windowResizerRect() { // Not necessary on Linux. - *out_rect = WebRect(); + return WebRect(); } -void TestWebViewDelegate::DidMove(WebWidget* webwidget, - const WebPluginGeometry& move) { - WebWidgetHost* host = GetHostForWidget(webwidget); +void TestWebViewDelegate::DidMovePlugin(const WebPluginGeometry& move) { + WebWidgetHost* host = GetWidgetHost(); GtkPluginContainerManager* plugin_container_manager = static_cast<WebViewHost*>(host)->plugin_container_manager(); plugin_container_manager->MovePluginContainer(move); } -void TestWebViewDelegate::RunModal(WebWidget* webwidget) { +void TestWebViewDelegate::runModal() { NOTIMPLEMENTED(); } diff --git a/webkit/tools/test_shell/test_webview_delegate_win.cc b/webkit/tools/test_shell/test_webview_delegate_win.cc index f33c95f..592802b 100644 --- a/webkit/tools/test_shell/test_webview_delegate_win.cc +++ b/webkit/tools/test_shell/test_webview_delegate_win.cc @@ -36,6 +36,7 @@ #include "webkit/tools/test_shell/test_shell.h" using WebKit::WebCursorInfo; +using WebKit::WebNavigationPolicy; using WebKit::WebRect; // WebViewDelegate ----------------------------------------------------------- @@ -67,100 +68,98 @@ WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate( return WebPluginDelegateImpl::Create(info.path, mime_type, hwnd); } +void TestWebViewDelegate::DidMovePlugin(const WebPluginGeometry& move) { + HRGN hrgn = ::CreateRectRgn(move.clip_rect.x(), + move.clip_rect.y(), + move.clip_rect.right(), + move.clip_rect.bottom()); + gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects); + + // Note: System will own the hrgn after we call SetWindowRgn, + // so we don't need to call DeleteObject(hrgn) + ::SetWindowRgn(move.window, hrgn, FALSE); + unsigned long flags = 0; + if (move.visible) + flags |= SWP_SHOWWINDOW; + else + flags |= SWP_HIDEWINDOW; + + ::SetWindowPos(move.window, + NULL, + move.window_rect.x(), + move.window_rect.y(), + move.window_rect.width(), + move.window_rect.height(), + flags); +} + void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) { MessageBox(NULL, message.c_str(), L"JavaScript Alert", MB_OK); } -void TestWebViewDelegate::Show(WebWidget* webwidget, WindowOpenDisposition) { - if (webwidget == shell_->webView()) { - ShowWindow(shell_->mainWnd(), SW_SHOW); - UpdateWindow(shell_->mainWnd()); - } else if (webwidget == shell_->popup()) { - ShowWindow(shell_->popupWnd(), SW_SHOW); - UpdateWindow(shell_->popupWnd()); +void TestWebViewDelegate::show(WebNavigationPolicy) { + if (WebWidgetHost* host = GetWidgetHost()) { + HWND root = GetAncestor(host->view_handle(), GA_ROOT); + ShowWindow(root, SW_SHOW); + UpdateWindow(root); } } -void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) { - if (webwidget == shell_->webView()) { +void TestWebViewDelegate::closeWidgetSoon() { + if (this == shell_->delegate()) { PostMessage(shell_->mainWnd(), WM_CLOSE, 0, 0); - } else if (webwidget == shell_->popup()) { + } else if (this == shell_->popup_delegate()) { shell_->ClosePopup(); } } -void TestWebViewDelegate::SetCursor(WebWidget* webwidget, - const WebCursorInfo& cursor_info) { - if (WebWidgetHost* host = GetHostForWidget(webwidget)) { +void TestWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { + if (WebWidgetHost* host = GetWidgetHost()) { current_cursor_.InitFromCursorInfo(cursor_info); HINSTANCE mod_handle = GetModuleHandle(NULL); host->SetCursor(current_cursor_.GetCursor(mod_handle)); } } -void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget, - WebRect* out_rect) { - if (WebWidgetHost* host = GetHostForWidget(webwidget)) { +WebRect TestWebViewDelegate::windowRect() { + if (WebWidgetHost* host = GetWidgetHost()) { RECT rect; ::GetWindowRect(host->view_handle(), &rect); - *out_rect = gfx::Rect(rect); + return gfx::Rect(rect); } + return WebRect(); } -void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget, - const WebRect& rect) { - if (webwidget == shell_->webView()) { +void TestWebViewDelegate::setWindowRect(const WebRect& rect) { + if (this == shell_->delegate()) { // ignored - } else if (webwidget == shell_->popup()) { + } else if (this == shell_->popup_delegate()) { MoveWindow(shell_->popupWnd(), rect.x, rect.y, rect.width, rect.height, FALSE); } } -void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, - WebRect* out_rect) { - if (WebWidgetHost* host = GetHostForWidget(webwidget)) { +WebRect TestWebViewDelegate::rootWindowRect() { + if (WebWidgetHost* host = GetWidgetHost()) { RECT rect; HWND root_window = ::GetAncestor(host->view_handle(), GA_ROOT); ::GetWindowRect(root_window, &rect); - *out_rect = gfx::Rect(rect); + return gfx::Rect(rect); } + return WebRect(); } -void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget, - WebRect* out_rect) { +WebRect TestWebViewDelegate::windowResizerRect() { // Not necessary on Windows. - *out_rect = gfx::Rect(); + return WebRect(); } -void TestWebViewDelegate::DidMove(WebWidget* webwidget, - const WebPluginGeometry& move) { - HRGN hrgn = ::CreateRectRgn(move.clip_rect.x(), - move.clip_rect.y(), - move.clip_rect.right(), - move.clip_rect.bottom()); - gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects); - - // Note: System will own the hrgn after we call SetWindowRgn, - // so we don't need to call DeleteObject(hrgn) - ::SetWindowRgn(move.window, hrgn, FALSE); - unsigned long flags = 0; - if (move.visible) - flags |= SWP_SHOWWINDOW; - else - flags |= SWP_HIDEWINDOW; - - ::SetWindowPos(move.window, - NULL, - move.window_rect.x(), - move.window_rect.y(), - move.window_rect.width(), - move.window_rect.height(), - flags); -} +void TestWebViewDelegate::runModal() { + WebWidgetHost* host = GetWidgetHost(); + if (!host) + return; -void TestWebViewDelegate::RunModal(WebWidget* webwidget) { - Show(webwidget, NEW_WINDOW); + show(WebNavigationPolicy() /*XXX NEW_WINDOW*/); WindowList* wl = TestShell::windowList(); for (WindowList::const_iterator i = wl->begin(); i != wl->end(); ++i) { diff --git a/webkit/tools/test_shell/webview_host_gtk.cc b/webkit/tools/test_shell/webview_host_gtk.cc index 53c42d9..71d6d4b 100644 --- a/webkit/tools/test_shell/webview_host_gtk.cc +++ b/webkit/tools/test_shell/webview_host_gtk.cc @@ -24,7 +24,7 @@ WebViewHost* WebViewHost::Create(GtkWidget* parent_view, g_object_set_data(G_OBJECT(host->view_), "webwidgethost", host); host->webwidget_ = WebView::Create(delegate, prefs); - host->webwidget_->Layout(); + host->webwidget_->layout(); return host; } diff --git a/webkit/tools/test_shell/webwidget_host.h b/webkit/tools/test_shell/webwidget_host.h index e74638e..2fc2a10 100644 --- a/webkit/tools/test_shell/webwidget_host.h +++ b/webkit/tools/test_shell/webwidget_host.h @@ -11,14 +11,13 @@ #include "base/scoped_ptr.h" #include "skia/ext/platform_canvas.h" -class WebWidget; -class WebWidgetDelegate; - namespace gfx { class Size; } namespace WebKit { +class WebWidget; +class WebWidgetClient; struct WebScreenInfo; } @@ -37,14 +36,14 @@ class WebWidgetHost { // The newly created window should be resized after it is created, using the // MoveWindow (or equivalent) function. static WebWidgetHost* Create(gfx::NativeView parent_view, - WebWidgetDelegate* delegate); + WebKit::WebWidgetClient* client); #if defined(OS_MACOSX) static void HandleEvent(gfx::NativeView view, NSEvent* event); #endif gfx::NativeView view_handle() const { return view_; } - WebWidget* webwidget() const { return webwidget_; } + WebKit::WebWidget* webwidget() const { return webwidget_; } void DidInvalidateRect(const gfx::Rect& rect); void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect); @@ -115,7 +114,7 @@ class WebWidgetHost { } gfx::NativeView view_; - WebWidget* webwidget_; + WebKit::WebWidget* webwidget_; scoped_ptr<skia::PlatformCanvas> canvas_; // specifies the portion of the webwidget that needs painting diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc index dd5b311..432f661 100644 --- a/webkit/tools/test_shell/webwidget_host_gtk.cc +++ b/webkit/tools/test_shell/webwidget_host_gtk.cc @@ -15,9 +15,9 @@ #include "webkit/api/public/gtk/WebInputEventFactory.h" #include "webkit/api/public/x11/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" #include "webkit/tools/test_shell/test_shell_x11.h" @@ -25,9 +25,11 @@ 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; namespace { @@ -159,9 +161,8 @@ class WebWidgetHostGtkWidget { static gboolean HandleKeyPress(GtkWidget* widget, GdkEventKey* event, WebWidgetHost* host) { - const WebKeyboardEvent& wke = WebInputEventFactory::keyboardEvent(event); - host->webwidget()->HandleInputEvent(&wke); - + host->webwidget()->handleInputEvent( + WebInputEventFactory::keyboardEvent(event)); return FALSE; } @@ -189,7 +190,7 @@ class WebWidgetHostGtkWidget { // 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()) - host->webwidget()->SetFocus(true); + host->webwidget()->setFocus(true); return FALSE; } @@ -200,7 +201,7 @@ class WebWidgetHostGtkWidget { // 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()) - host->webwidget()->SetFocus(false); + host->webwidget()->setFocus(false); return FALSE; } @@ -208,8 +209,8 @@ class WebWidgetHostGtkWidget { static gboolean HandleButtonPress(GtkWidget* widget, GdkEventButton* event, WebWidgetHost* host) { - const WebMouseEvent& wme = WebInputEventFactory::mouseEvent(event); - host->webwidget()->HandleInputEvent(&wme); + host->webwidget()->handleInputEvent( + WebInputEventFactory::mouseEvent(event)); return FALSE; } @@ -224,8 +225,8 @@ class WebWidgetHostGtkWidget { static gboolean HandleMotionNotify(GtkWidget* widget, GdkEventMotion* event, WebWidgetHost* host) { - const WebMouseEvent& wme = WebInputEventFactory::mouseEvent(event); - host->webwidget()->HandleInputEvent(&wme); + host->webwidget()->handleInputEvent( + WebInputEventFactory::mouseEvent(event)); return FALSE; } @@ -233,9 +234,8 @@ class WebWidgetHostGtkWidget { static gboolean HandleScroll(GtkWidget* widget, GdkEventScroll* event, WebWidgetHost* host) { - const WebMouseWheelEvent& wmwe = - WebInputEventFactory::mouseWheelEvent(event); - host->webwidget()->HandleInputEvent(&wmwe); + host->webwidget()->handleInputEvent( + WebInputEventFactory::mouseWheelEvent(event)); return FALSE; } @@ -253,10 +253,10 @@ gfx::NativeView WebWidgetHost::CreateWidget( // static WebWidgetHost* WebWidgetHost::Create(GtkWidget* parent_view, - WebWidgetDelegate* delegate) { + WebWidgetClient* client) { WebWidgetHost* host = new WebWidgetHost(); host->view_ = CreateWidget(parent_view, host); - host->webwidget_ = WebWidget::Create(delegate); + host->webwidget_ = WebPopupMenu::create(client); // We manage our own double buffering because we need to be able to update // the expose area in an ExposeEvent within the lifetime of the event handler. gtk_widget_set_double_buffered(GTK_WIDGET(host->view_), false); @@ -295,14 +295,14 @@ WebWidgetHost::WebWidgetHost() } WebWidgetHost::~WebWidgetHost() { - webwidget_->Close(); + webwidget_->close(); } void WebWidgetHost::Resize(const gfx::Size &newsize) { // The pixel buffer backing us is now the wrong size canvas_.reset(); - webwidget_->Resize(gfx::Size(newsize.width(), newsize.height())); + webwidget_->resize(newsize); } void WebWidgetHost::Paint() { @@ -323,7 +323,7 @@ void WebWidgetHost::Paint() { } // This may result in more invalidation - webwidget_->Layout(); + webwidget_->layout(); // Paint the canvas if necessary. Allow painting to generate extra rects the // first time we call it. This is necessary because some WebCore rendering @@ -381,7 +381,7 @@ void WebWidgetHost::ResetScrollRect() { void WebWidgetHost::PaintRect(const gfx::Rect& rect) { set_painting(true); - webwidget_->Paint(canvas_.get(), rect); + webwidget_->paint(canvas_.get(), rect); set_painting(false); } diff --git a/webkit/tools/test_shell/webwidget_host_win.cc b/webkit/tools/test_shell/webwidget_host_win.cc index 164a051..66b283e 100644 --- a/webkit/tools/test_shell/webwidget_host_win.cc +++ b/webkit/tools/test_shell/webwidget_host_win.cc @@ -9,11 +9,11 @@ #include "base/win_util.h" #include "skia/ext/platform_canvas.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/api/public/win/WebInputEventFactory.h" #include "webkit/api/public/win/WebScreenInfoFactory.h" -#include "webkit/glue/webwidget.h" #include "webkit/tools/test_shell/test_shell.h" using WebKit::WebInputEvent; @@ -21,15 +21,18 @@ 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::WebWidget; +using WebKit::WebWidgetClient; static const wchar_t kWindowClassName[] = L"WebWidgetHost"; /*static*/ WebWidgetHost* WebWidgetHost::Create(HWND parent_view, - WebWidgetDelegate* delegate) { + WebWidgetClient* client) { WebWidgetHost* host = new WebWidgetHost(); static bool registered_class = false; @@ -51,7 +54,7 @@ WebWidgetHost* WebWidgetHost::Create(HWND parent_view, parent_view, NULL, GetModuleHandle(NULL), NULL); win_util::SetWindowUserData(host->view_, host); - host->webwidget_ = WebWidget::Create(delegate); + host->webwidget_ = WebPopupMenu::create(client); return host; } @@ -198,7 +201,7 @@ WebWidgetHost::~WebWidgetHost() { TrackMouseLeave(false); - webwidget_->Close(); + webwidget_->close(); } bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) { @@ -232,7 +235,7 @@ void WebWidgetHost::Paint() { } // This may result in more invalidation - webwidget_->Layout(); + webwidget_->layout(); // Scroll the canvas if necessary scroll_rect_ = client_rect.Intersect(scroll_rect_); @@ -282,7 +285,7 @@ void WebWidgetHost::Resize(LPARAM lparam) { // Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer. DiscardBackingStore(); - webwidget_->Resize(WebSize(LOWORD(lparam), HIWORD(lparam))); + webwidget_->resize(WebSize(LOWORD(lparam), HIWORD(lparam))); } void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) { @@ -308,30 +311,30 @@ void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) { ReleaseCapture(); break; } - webwidget_->HandleInputEvent(&event); + webwidget_->handleInputEvent(event); } void WebWidgetHost::WheelEvent(WPARAM wparam, LPARAM lparam) { const WebMouseWheelEvent& event = WebInputEventFactory::mouseWheelEvent( view_, WM_MOUSEWHEEL, wparam, lparam); - webwidget_->HandleInputEvent(&event); + webwidget_->handleInputEvent(event); } void WebWidgetHost::KeyEvent(UINT message, WPARAM wparam, LPARAM lparam) { const WebKeyboardEvent& event = WebInputEventFactory::keyboardEvent( view_, message, wparam, lparam); - webwidget_->HandleInputEvent(&event); + webwidget_->handleInputEvent(event); } void WebWidgetHost::CaptureLostEvent() { - webwidget_->MouseCaptureLost(); + webwidget_->mouseCaptureLost(); } 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) { @@ -364,6 +367,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); } |