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 | |
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')
46 files changed, 797 insertions, 939 deletions
diff --git a/webkit/api/public/WebCompositionCommand.h b/webkit/api/public/WebCompositionCommand.h index d7acbfd..a7be66c 100644 --- a/webkit/api/public/WebCompositionCommand.h +++ b/webkit/api/public/WebCompositionCommand.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -31,8 +31,6 @@ #ifndef WebCompositionCommand_h #define WebCompositionCommand_h -#error "This header file is still a work in progress; do not include!" - namespace WebKit { enum WebCompositionCommand { diff --git a/webkit/api/public/WebNavigationPolicy.h b/webkit/api/public/WebNavigationPolicy.h index 707f56d..14f72da 100644 --- a/webkit/api/public/WebNavigationPolicy.h +++ b/webkit/api/public/WebNavigationPolicy.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -31,8 +31,6 @@ #ifndef WebNavigationPolicy_h #define WebNavigationPolicy_h -#error "This header file is still a work in progress; do not include!" - namespace WebKit { enum WebNavigationPolicy { @@ -41,8 +39,8 @@ namespace WebKit { WebNavigationPolicyCurrentTab, WebNavigationPolicyNewBackgroundTab, WebNavigationPolicyNewForegroundTab, - WebNavigationPolicyNewForegroundTabInNewWindow, - WebNavigationPolicyNewPopupWindow, + WebNavigationPolicyNewWindow, + WebNavigationPolicyNewPopup, }; } // namespace WebKit diff --git a/webkit/api/public/WebPopupMenu.h b/webkit/api/public/WebPopupMenu.h index 521ecec..65f2cc4 100644 --- a/webkit/api/public/WebPopupMenu.h +++ b/webkit/api/public/WebPopupMenu.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -31,12 +31,11 @@ #ifndef WebPopupMenu_h #define WebPopupMenu_h -#error "This header file is still a work in progress; do not include!" - #include "WebCommon.h" #include "WebWidget.h" namespace WebKit { + class WebWidgetClient; class WebPopupMenu : public WebWidget { public: @@ -44,3 +43,5 @@ namespace WebKit { }; } // namespace WebKit + +#endif diff --git a/webkit/api/public/WebTextDirection.h b/webkit/api/public/WebTextDirection.h index 8136402..901a700 100644 --- a/webkit/api/public/WebTextDirection.h +++ b/webkit/api/public/WebTextDirection.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -31,13 +31,11 @@ #ifndef WebTextDirection_h #define WebTextDirection_h -#error "This header file is still a work in progress; do not include!" - namespace WebKit { // Represents text directions (or writing directions) of a DOM node. enum WebTextDirection { - WebTextDirectionDefault, + WebTextDirectionDefault, // Natural writing direction ("inherit") WebTextDirectionLeftToRight, WebTextDirectionRightToLeft, }; diff --git a/webkit/api/public/WebWidget.h b/webkit/api/public/WebWidget.h index 30f0601..262ac79 100644 --- a/webkit/api/public/WebWidget.h +++ b/webkit/api/public/WebWidget.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -31,12 +31,16 @@ #ifndef WebWidget_h #define WebWidget_h -#error "This header file is still a work in progress; do not include!" - +#include "WebCanvas.h" #include "WebCommon.h" +#include "WebCompositionCommand.h" #include "WebTextDirection.h" namespace WebKit { + class WebInputEvent; + class WebString; + struct WebRect; + struct WebSize; class WebWidget { public: @@ -63,7 +67,7 @@ namespace WebKit { // Called to inform the WebWidget of an input event. Returns true if // the event has been processed, false otherwise. - virtual void handleInputEvent(const WebInputEvent&) = 0; + virtual bool handleInputEvent(const WebInputEvent&) = 0; // Called to inform the WebWidget that mouse capture was lost. virtual void mouseCaptureLost() = 0; diff --git a/webkit/api/public/WebWidgetClient.h b/webkit/api/public/WebWidgetClient.h index 02815e7..7ac0a6a 100644 --- a/webkit/api/public/WebWidgetClient.h +++ b/webkit/api/public/WebWidgetClient.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -31,63 +31,56 @@ #ifndef WebWidgetClient_h #define WebWidgetClient_h -#error "This header file is still a work in progress; do not include!" - #include "WebCommon.h" #include "WebNavigationPolicy.h" namespace WebKit { class WebWidget; struct WebCursorInfo; - struct WebPluginGeometry; struct WebRect; struct WebScreenInfo; class WebWidgetClient { public: // Called when a region of the WebWidget needs to be re-painted. - virtual void didInvalidateRect(WebWidget*, const WebRect&) = 0; + virtual void didInvalidateRect(const WebRect&) = 0; // Called when a region of the WebWidget, given by clipRect, should be // scrolled by the specified dx and dy amounts. - virtual void didScrollRect(WebWidget*, int dx, int dy, const WebRect& clipRect) = 0; - - // Called when a plugin is moved relative to its containing window. - // This typically happens as a result of scrolling the page. - virtual void didMovePlugin(WebWidget*, const WebPluginGeometry&) = 0; + virtual void didScrollRect(int dx, int dy, const WebRect& clipRect) = 0; // Called when the widget acquires or loses focus, respectively. - virtual void didFocus(WebWidget*) = 0; - virtual void didBlur(WebWidget*) = 0; + virtual void didFocus() = 0; + virtual void didBlur() = 0; // Called when the cursor for the widget changes. - virtual void didChangeCursor(WebWidget*, const WebCursorInfo&) = 0; + virtual void didChangeCursor(const WebCursorInfo&) = 0; // Called when the widget should be closed. WebWidget::close() should // be called asynchronously as a result of this notification. - virtual void closeWidgetSoon(WebWidget*) = 0; + virtual void closeWidgetSoon() = 0; // Called to show the widget according to the given policy. - virtual void show(WebWidget*, WebNavigationPolicy) = 0; + virtual void show(WebNavigationPolicy) = 0; // Called to block execution of the current thread until the widget is // closed. - virtual void runModal(WebWidget*) = 0; + virtual void runModal() = 0; // Called to get/set the position of the widget in screen coordinates. - virtual WebRect windowRect(WebWidget*) = 0; - virtual void setWindowRect(WebWidget*, const WebRect&) = 0; + virtual WebRect windowRect() = 0; + virtual void setWindowRect(const WebRect&) = 0; // Called to get the position of the resizer rect in window coordinates. - virtual WebRect windowResizerRect(WebWidget*) = 0; + virtual WebRect windowResizerRect() = 0; // Called to get the position of the root window containing the widget // in screen coordinates. - virtual WebRect rootWindowRect(WebWidget*) = 0; + virtual WebRect rootWindowRect() = 0; // Called to query information about the screen where this widget is // displayed. - virtual WebScreenInfo screenInfo(WebWidget*) = 0; + virtual WebScreenInfo screenInfo() = 0; }; } // namespace WebKit diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc index 4c233f2..d6f4fda 100644 --- a/webkit/glue/chrome_client_impl.cc +++ b/webkit/glue/chrome_client_impl.cc @@ -46,9 +46,9 @@ MSVC_POP_WARNING(); #include "webkit/glue/glue_util.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webkit_glue.h" +#include "webkit/glue/webpopupmenu_impl.h" #include "webkit/glue/webview_delegate.h" #include "webkit/glue/webview_impl.h" -#include "webkit/glue/webwidget_impl.h" using WebCore::PopupContainer; using WebCore::PopupItem; @@ -56,10 +56,12 @@ using WebCore::PopupItem; using WebKit::WebCursorInfo; using WebKit::WebInputEvent; using WebKit::WebMouseEvent; +using WebKit::WebNavigationPolicy; using WebKit::WebPopupMenuInfo; using WebKit::WebRect; using WebKit::WebURLRequest; using WebKit::WebVector; +using WebKit::WebWidget; using WebKit::WrappedResourceRequest; // Callback class that's given to the WebViewDelegate during a file choose @@ -110,16 +112,15 @@ void ChromeClientImpl::chromeDestroyed() { void ChromeClientImpl::setWindowRect(const WebCore::FloatRect& r) { WebViewDelegate* delegate = webview_->delegate(); if (delegate) { - WebCore::IntRect ir(r); - delegate->SetWindowRect(webview_, - gfx::Rect(ir.x(), ir.y(), ir.width(), ir.height())); + delegate->setWindowRect( + webkit_glue::IntRectToWebRect(WebCore::IntRect(r))); } } WebCore::FloatRect ChromeClientImpl::windowRect() { WebRect rect; if (webview_->delegate()) { - webview_->delegate()->GetRootWindowRect(webview_, &rect); + rect = webview_->delegate()->rootWindowRect(); } else { // These numbers will be fairly wrong. The window's x/y coordinates will // be the top left corner of the screen and the size will be the content @@ -127,10 +128,7 @@ WebCore::FloatRect ChromeClientImpl::windowRect() { rect.width = webview_->size().width; rect.height = webview_->size().height; } - return WebCore::FloatRect(static_cast<float>(rect.x), - static_cast<float>(rect.y), - static_cast<float>(rect.width), - static_cast<float>(rect.height)); + return WebCore::FloatRect(webkit_glue::WebRectToIntRect(rect)); } WebCore::FloatRect ChromeClientImpl::pageRect() { @@ -154,7 +152,7 @@ float ChromeClientImpl::scaleFactor() { void ChromeClientImpl::focus() { WebViewDelegate* delegate = webview_->delegate(); if (delegate) - delegate->Focus(webview_); + delegate->didFocus(); // If accessibility is enabled, we should notify assistive technology that the // active AccessibilityObject changed. @@ -182,7 +180,7 @@ void ChromeClientImpl::focus() { void ChromeClientImpl::unfocus() { WebViewDelegate* delegate = webview_->delegate(); if (delegate) - delegate->Blur(webview_); + delegate->didBlur(); } bool ChromeClientImpl::canTakeFocus(WebCore::FocusDirection) { @@ -257,13 +255,13 @@ void ChromeClientImpl::show() { !resizable_ || !delegate->WasOpenedByUserGesture(); - WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; + WebNavigationPolicy policy = WebKit::WebNavigationPolicyNewForegroundTab; if (as_popup) - disposition = NEW_POPUP; + policy = WebKit::WebNavigationPolicyNewPopup; if (CurrentEventShouldCauseBackgroundTab(WebViewImpl::current_input_event())) - disposition = NEW_BACKGROUND_TAB; + policy = WebKit::WebNavigationPolicyNewBackgroundTab; - delegate->Show(webview_, disposition); + delegate->show(policy); } } @@ -274,7 +272,7 @@ bool ChromeClientImpl::canRunModal() { void ChromeClientImpl::runModal() { WebViewDelegate* delegate = webview_->delegate(); if (delegate) - delegate->RunModal(webview_); + delegate->runModal(); } void ChromeClientImpl::setToolbarsVisible(bool value) { @@ -357,7 +355,7 @@ void ChromeClientImpl::closeWindowSoon() { WebViewDelegate* delegate = webview_->delegate(); if (delegate) - delegate->CloseWidgetSoon(webview_); + delegate->closeWidgetSoon(); } // Although a WebCore::Frame is passed in, we don't actually use it, since we @@ -434,9 +432,8 @@ bool ChromeClientImpl::tabsToLinks() const { WebCore::IntRect ChromeClientImpl::windowResizerRect() const { WebCore::IntRect result; if (webview_->delegate()) { - WebRect resizer_rect; - webview_->delegate()->GetRootWindowResizerRect(webview_, &resizer_rect); - result = webkit_glue::WebRectToIntRect(resizer_rect); + result = webkit_glue::WebRectToIntRect( + webview_->delegate()->windowResizerRect()); } return result; } @@ -449,8 +446,7 @@ void ChromeClientImpl::repaint( return; WebViewDelegate* delegate = webview_->delegate(); if (delegate) - delegate->DidInvalidateRect(webview_, - webkit_glue::IntRectToWebRect(paint_rect)); + delegate->didInvalidateRect(webkit_glue::IntRectToWebRect(paint_rect)); } void ChromeClientImpl::scroll( @@ -460,8 +456,8 @@ void ChromeClientImpl::scroll( if (delegate) { int dx = scroll_delta.width(); int dy = scroll_delta.height(); - delegate->DidScrollRect(webview_, dx, dy, - webkit_glue::IntRectToWebRect(clip_rect)); + delegate->didScrollRect( + dx, dy, webkit_glue::IntRectToWebRect(clip_rect)); } } @@ -477,8 +473,7 @@ WebCore::IntRect ChromeClientImpl::windowToScreen( WebViewDelegate* delegate = webview_->delegate(); if (delegate) { - WebRect window_rect; - delegate->GetWindowRect(webview_, &window_rect); + WebRect window_rect = delegate->windowRect(); screen_rect.move(window_rect.x, window_rect.y); } @@ -567,7 +562,7 @@ void ChromeClientImpl::popupOpened(PopupContainer* popup_container, webwidget = delegate->CreatePopupWidget(webview_, activatable); } - static_cast<WebWidgetImpl*>(webwidget)->Init( + static_cast<WebPopupMenuImpl*>(webwidget)->Init( popup_container, webkit_glue::IntRectToWebRect(bounds)); } @@ -579,7 +574,7 @@ void ChromeClientImpl::SetCursor(const WebCursorInfo& cursor) { WebViewDelegate* delegate = webview_->delegate(); if (delegate) - delegate->SetCursor(webview_, cursor); + delegate->didChangeCursor(cursor); } void ChromeClientImpl::SetCursorForPlugin(const WebCursorInfo& cursor) { diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc index e033fcb..04acbd8 100644 --- a/webkit/glue/chromium_bridge_impl.cc +++ b/webkit/glue/chromium_bridge_impl.cc @@ -47,6 +47,7 @@ #endif using WebKit::WebCursorInfo; +using WebKit::WebWidgetClient; namespace { @@ -73,11 +74,11 @@ ChromeClientImpl* ToChromeClient(WebCore::Widget* widget) { return static_cast<ChromeClientImpl*>(page->chrome()->client()); } -WebViewImpl* ToWebView(WebCore::Widget* widget) { +WebWidgetClient* ToWebWidgetClient(WebCore::Widget* widget) { ChromeClientImpl* chrome_client = ToChromeClient(widget); - if (!chrome_client) + if (!chrome_client || !chrome_client->webview()) return NULL; - return chrome_client->webview(); + return chrome_client->webview()->delegate(); } WebCore::IntRect ToIntRect(const WebKit::WebRect& input) { @@ -95,14 +96,10 @@ void ChromiumBridge::notifyJSOutOfMemory(Frame* frame) { return; // Dispatch to the delegate of the view that owns the frame. - WebFrame* webframe = WebFrameImpl::FromFrame(frame); - WebView* webview = webframe->GetView(); - if (!webview) + WebViewImpl* webview = WebFrameImpl::FromFrame(frame)->GetWebViewImpl(); + if (!webview || !webview->delegate()) return; - WebViewDelegate* delegate = webview->GetDelegate(); - if (!delegate) - return; - delegate->JSOutOfMemory(); + webview->delegate()->JSOutOfMemory(); } // Plugin --------------------------------------------------------------------- @@ -138,38 +135,38 @@ String ChromiumBridge::uiResourceProtocol() { // Screen --------------------------------------------------------------------- int ChromiumBridge::screenDepth(Widget* widget) { - WebViewImpl* view = ToWebView(widget); - if (!view || !view->delegate()) - return NULL; - return view->delegate()->GetScreenInfo(view).depth; + WebWidgetClient* client = ToWebWidgetClient(widget); + if (!client) + return 0; + return client->screenInfo().depth; } int ChromiumBridge::screenDepthPerComponent(Widget* widget) { - WebViewImpl* view = ToWebView(widget); - if (!view || !view->delegate()) - return NULL; - return view->delegate()->GetScreenInfo(view).depthPerComponent; + WebWidgetClient* client = ToWebWidgetClient(widget); + if (!client) + return 0; + return client->screenInfo().depthPerComponent; } bool ChromiumBridge::screenIsMonochrome(Widget* widget) { - WebViewImpl* view = ToWebView(widget); - if (!view || !view->delegate()) - return NULL; - return view->delegate()->GetScreenInfo(view).isMonochrome; + WebWidgetClient* client = ToWebWidgetClient(widget); + if (!client) + return false; + return client->screenInfo().isMonochrome; } IntRect ChromiumBridge::screenRect(Widget* widget) { - WebViewImpl* view = ToWebView(widget); - if (!view || !view->delegate()) + WebWidgetClient* client = ToWebWidgetClient(widget); + if (!client) return IntRect(); - return ToIntRect(view->delegate()->GetScreenInfo(view).rect); + return ToIntRect(client->screenInfo().rect); } IntRect ChromiumBridge::screenAvailableRect(Widget* widget) { - WebViewImpl* view = ToWebView(widget); - if (!view || !view->delegate()) + WebWidgetClient* client = ToWebWidgetClient(widget); + if (!client) return IntRect(); - return ToIntRect(view->delegate()->GetScreenInfo(view).availableRect); + return ToIntRect(client->screenInfo().availableRect); } // Widget --------------------------------------------------------------------- diff --git a/webkit/glue/context_menu_unittest.cc b/webkit/glue/context_menu_unittest.cc index 8e62c2c..0905a97 100644 --- a/webkit/glue/context_menu_unittest.cc +++ b/webkit/glue/context_menu_unittest.cc @@ -56,11 +56,11 @@ TEST_F(ContextMenuCapturing, ContextMenuCapturing) { mouse_event.globalY = 250; WebView* webview = test_shell_->webView(); - webview->HandleInputEvent(&mouse_event); + webview->handleInputEvent(mouse_event); // Now simulate the corresponding up event which should display the menu mouse_event.type = WebInputEvent::MouseUp; - webview->HandleInputEvent(&mouse_event); + webview->handleInputEvent(mouse_event); EXPECT_EQ(1U, test_delegate->captured_context_menu_events().size()); } diff --git a/webkit/glue/inspector_client_impl.cc b/webkit/glue/inspector_client_impl.cc index 1e9873a..493a646 100644 --- a/webkit/glue/inspector_client_impl.cc +++ b/webkit/glue/inspector_client_impl.cc @@ -162,7 +162,7 @@ static void invalidateNodeBoundingRect(WebViewImpl* web_view) { const WebSize& size = web_view->size(); WebRect damaged_rect(0, 0, size.width, size.height); if (web_view->GetDelegate()) - web_view->GetDelegate()->DidInvalidateRect(web_view, damaged_rect); + web_view->GetDelegate()->didInvalidateRect(damaged_rect); } void WebInspectorClient::highlight(Node* node) { diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 19f1096..ffafec3 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -73,6 +73,7 @@ using base::TimeDelta; using WebKit::WebData; using WebKit::WebNavigationType; +using WebKit::WebNavigationPolicy; using WebKit::WebString; using WebKit::WebURL; using WebKit::WebVector; @@ -95,7 +96,7 @@ WebFrameLoaderClient::WebFrameLoaderClient(WebFrameImpl* frame) : postpone_loading_data_(false), has_representation_(false), sent_initial_response_to_plugin_(false), - next_window_open_disposition_(IGNORE_ACTION) { + next_navigation_policy_(WebKit::WebNavigationPolicyIgnore) { } WebFrameLoaderClient::~WebFrameLoaderClient() { @@ -810,15 +811,15 @@ Frame* WebFrameLoaderClient::dispatchCreatePage() { // Make sure that we have a valid disposition. This should have been set in // the preceeding call to dispatchDecidePolicyForNewWindowAction. - DCHECK(next_window_open_disposition_ != IGNORE_ACTION); - WindowOpenDisposition disp = next_window_open_disposition_; - next_window_open_disposition_ = IGNORE_ACTION; + DCHECK(next_navigation_policy_ != WebKit::WebNavigationPolicyIgnore); + WebNavigationPolicy policy = next_navigation_policy_; + next_navigation_policy_ = WebKit::WebNavigationPolicyIgnore; // createWindow can return NULL (e.g., popup blocker denies the window). if (!new_page) return NULL; - WebViewImpl::FromPage(new_page)->set_window_open_disposition(disp); + WebViewImpl::FromPage(new_page)->set_initial_navigation_policy(policy); return new_page->mainFrame(); } @@ -826,7 +827,7 @@ void WebFrameLoaderClient::dispatchShow() { WebViewImpl* webview = webframe_->GetWebViewImpl(); WebViewDelegate* d = webview->delegate(); if (d) - d->Show(webview, webview->window_open_disposition()); + d->show(webview->initial_navigation_policy()); } static bool TreatAsAttachment(const ResourceResponse& response) { @@ -896,12 +897,12 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction( const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState> form_state, const WebCore::String& frame_name) { - WindowOpenDisposition disposition; - if (!ActionSpecifiesDisposition(action, &disposition)) - disposition = NEW_FOREGROUND_TAB; + WebNavigationPolicy navigation_policy; + if (!ActionSpecifiesNavigationPolicy(action, &navigation_policy)) + navigation_policy = WebKit::WebNavigationPolicyNewForegroundTab; PolicyAction policy_action; - if (disposition == SAVE_TO_DISK) { + if (navigation_policy == WebKit::WebNavigationPolicyDownload) { policy_action = PolicyDownload; } else { policy_action = PolicyUse; @@ -910,7 +911,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction( // unfortunate that WebCore does not provide us with any context when // creating or showing the new window that would allow us to avoid having // to keep this state. - next_window_open_disposition_ = disposition; + next_navigation_policy_ = navigation_policy; } (webframe_->frame()->loader()->*function)(policy_action); } @@ -929,40 +930,42 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( // The NULL check here is to fix a crash that seems strange // (see - https://bugs.webkit.org/show_bug.cgi?id=23554). if (d && !request.url().isNull()) { - WindowOpenDisposition disposition = CURRENT_TAB; - ActionSpecifiesDisposition(action, &disposition); + WebNavigationPolicy navigation_policy = + WebKit::WebNavigationPolicyCurrentTab; + ActionSpecifiesNavigationPolicy(action, &navigation_policy); - // Give the delegate a chance to change the disposition. + // Give the delegate a chance to change the navigation policy. const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); if (ds) { GURL url = ds->request().url(); if (url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)) { HandleBackForwardNavigation(url); - disposition = IGNORE_ACTION; + navigation_policy = WebKit::WebNavigationPolicyIgnore; } else { bool is_redirect = ds->HasRedirectChain(); WebNavigationType webnav_type = WebDataSourceImpl::NavigationTypeToWebNavigationType(action.type()); - disposition = d->DispositionForNavigationAction( - wv, webframe_, ds->request(), webnav_type, disposition, is_redirect); + navigation_policy = d->PolicyForNavigationAction( + wv, webframe_, ds->request(), webnav_type, navigation_policy, + is_redirect); } } - if (disposition == CURRENT_TAB) { + if (navigation_policy == WebKit::WebNavigationPolicyCurrentTab) { policy_action = PolicyUse; - } else if (disposition == SAVE_TO_DISK) { + } else if (navigation_policy == WebKit::WebNavigationPolicyDownload) { policy_action = PolicyDownload; } else { - if (disposition != IGNORE_ACTION) { + if (navigation_policy != WebKit::WebNavigationPolicyIgnore) { GURL referrer = webkit_glue::StringToGURL( request.httpHeaderField("Referer")); d->OpenURL(webframe_->GetWebViewImpl(), webkit_glue::KURLToGURL(request.url()), referrer, - disposition); + navigation_policy); } policy_action = PolicyIgnore; } @@ -1475,9 +1478,9 @@ String WebFrameLoaderClient::overrideMediaType() const { return rv; } -bool WebFrameLoaderClient::ActionSpecifiesDisposition( +bool WebFrameLoaderClient::ActionSpecifiesNavigationPolicy( const WebCore::NavigationAction& action, - WindowOpenDisposition* disposition) { + WebNavigationPolicy* policy) { if ((action.type() != NavigationTypeLinkClicked) || !action.event()->isMouseEvent()) return false; @@ -1493,11 +1496,20 @@ bool WebFrameLoaderClient::ActionSpecifiesDisposition( if (!new_tab_modifier && !shift && !alt) return false; - DCHECK(disposition); - if (new_tab_modifier) - *disposition = shift ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; - else - *disposition = shift ? NEW_WINDOW : SAVE_TO_DISK; + DCHECK(policy); + if (new_tab_modifier) { + if (shift) { + *policy = WebKit::WebNavigationPolicyNewForegroundTab; + } else { + *policy = WebKit::WebNavigationPolicyNewBackgroundTab; + } + } else { + if (shift) { + *policy = WebKit::WebNavigationPolicyNewWindow; + } else { + *policy = WebKit::WebNavigationPolicyDownload; + } + } return true; } diff --git a/webkit/glue/webframeloaderclient_impl.h b/webkit/glue/webframeloaderclient_impl.h index 80e5d3b..e031fae 100644 --- a/webkit/glue/webframeloaderclient_impl.h +++ b/webkit/glue/webframeloaderclient_impl.h @@ -5,18 +5,13 @@ #ifndef WEBKIT_GLUE_WEBFRAMELOADERCLIENT_IMPL_H__ #define WEBKIT_GLUE_WEBFRAMELOADERCLIENT_IMPL_H__ -#include "base/compiler_specific.h" - -MSVC_PUSH_WARNING_LEVEL(0); #include "FrameLoaderClient.h" #include <wtf/RefPtr.h> -MSVC_POP_WARNING(); -#include "build/build_config.h" #include "base/scoped_ptr.h" #include "googleurl/src/gurl.h" +#include "webkit/api/public/WebNavigationPolicy.h" #include "webkit/glue/webview_delegate.h" -#include "webkit/glue/window_open_disposition.h" namespace WebCore { class Frame; @@ -217,11 +212,11 @@ class WebFrameLoaderClient : public WebCore::FrameLoaderClient { private: void makeDocumentView(); - // Given a NavigationAction, determine the associated window opening - // disposition. For example, a middle click means "open in background tab". - static bool ActionSpecifiesDisposition( + // Given a NavigationAction, determine the associated WebNavigationPolicy. + // For example, a middle click means "open in background tab". + static bool ActionSpecifiesNavigationPolicy( const WebCore::NavigationAction& action, - WindowOpenDisposition* disposition); + WebKit::WebNavigationPolicy* policy); // Returns a valid GURL if we have an alt 404 server URL. GURL GetAlt404PageUrl(WebCore::DocumentLoader* loader); @@ -264,8 +259,8 @@ class WebFrameLoaderClient : public WebCore::FrameLoaderClient { // which specifies that the plugin should be ready to accept data. bool sent_initial_response_to_plugin_; - // The disposition to use for the next call to dispatchCreatePage. - WindowOpenDisposition next_window_open_disposition_; + // The navigation policy to use for the next call to dispatchCreatePage. + WebKit::WebNavigationPolicy next_navigation_policy_; }; #endif // #ifndef WEBKIT_GLUE_WEBFRAMELOADERCLIENT_IMPL_H__ diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index 83ee2bc..826bfb9 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -740,7 +740,7 @@ void WebPluginImpl::setFrameRect(const WebCore::IntRect& rect) { move.rects_valid = true; move.visible = widget_->isVisible(); - webview->delegate()->DidMove(webview, move); + webview->delegate()->DidMovePlugin(move); } // Notify the plugin that its parameters have changed. @@ -1435,5 +1435,5 @@ void WebPluginImpl::UpdateVisibility() { move.rects_valid = false; move.visible = widget_->isVisible(); - webview->delegate()->DidMove(webview, move); + webview->delegate()->DidMovePlugin(move); } diff --git a/webkit/glue/webwidget_impl.cc b/webkit/glue/webpopupmenu_impl.cc index 618a9bf..74b40ab 100644 --- a/webkit/glue/webwidget_impl.cc +++ b/webkit/glue/webpopupmenu_impl.cc @@ -4,9 +4,6 @@ #include "config.h" -#include "base/compiler_specific.h" - -MSVC_PUSH_WARNING_LEVEL(0); #include "Cursor.h" #include "FramelessScrollView.h" #include "FrameView.h" @@ -16,61 +13,70 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "PlatformMouseEvent.h" #include "PlatformWheelEvent.h" #include "SkiaUtils.h" -MSVC_POP_WARNING(); - #undef LOG + #include "base/logging.h" #include "skia/ext/platform_canvas.h" #include "webkit/api/public/WebInputEvent.h" #include "webkit/api/public/WebRect.h" +#include "webkit/api/public/WebWidgetClient.h" #include "webkit/glue/event_conversion.h" #include "webkit/glue/glue_util.h" -#include "webkit/glue/webwidget_delegate.h" -#include "webkit/glue/webwidget_impl.h" +#include "webkit/glue/webpopupmenu_impl.h" using namespace WebCore; +using WebKit::WebCanvas; +using WebKit::WebCompositionCommand; using WebKit::WebInputEvent; using WebKit::WebKeyboardEvent; using WebKit::WebMouseEvent; using WebKit::WebMouseWheelEvent; +using WebKit::WebNavigationPolicy; using WebKit::WebPoint; +using WebKit::WebPopupMenu; using WebKit::WebRect; using WebKit::WebSize; +using WebKit::WebString; +using WebKit::WebTextDirection; +using WebKit::WebWidget; +using WebKit::WebWidgetClient; -// WebWidget ---------------------------------------------------------------- +// WebPopupMenu --------------------------------------------------------------- -/*static*/ -WebWidget* WebWidget::Create(WebWidgetDelegate* delegate) { - WebWidgetImpl* instance = new WebWidgetImpl(delegate); +// static +WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client) { + WebPopupMenuImpl* instance = new WebPopupMenuImpl(client); instance->AddRef(); return instance; } -WebWidgetImpl::WebWidgetImpl(WebWidgetDelegate* delegate) - : delegate_(delegate), +// WebWidget ------------------------------------------------------------------ + +WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client) + : client_(client), widget_(NULL) { // set to impossible point so we always get the first mouse pos last_mouse_position_ = WebPoint(-1, -1); } -WebWidgetImpl::~WebWidgetImpl() { +WebPopupMenuImpl::~WebPopupMenuImpl() { if (widget_) widget_->setClient(NULL); } -void WebWidgetImpl::Init(WebCore::FramelessScrollView* widget, - const WebRect& bounds) { +void WebPopupMenuImpl::Init(WebCore::FramelessScrollView* widget, + const WebRect& bounds) { widget_ = widget; widget_->setClient(this); - if (delegate_) { - delegate_->SetWindowRect(this, bounds); - delegate_->Show(this, WindowOpenDisposition()); + if (client_) { + client_->setWindowRect(bounds); + client_->show(WebNavigationPolicy()); // Policy is ignored } } -void WebWidgetImpl::MouseMove(const WebMouseEvent& event) { +void WebPopupMenuImpl::MouseMove(const WebMouseEvent& event) { // don't send mouse move messages if the mouse hasn't moved. if (event.x != last_mouse_position_.x || event.y != last_mouse_position_.y) { @@ -79,39 +85,39 @@ void WebWidgetImpl::MouseMove(const WebMouseEvent& event) { } } -void WebWidgetImpl::MouseLeave(const WebMouseEvent& event) { +void WebPopupMenuImpl::MouseLeave(const WebMouseEvent& event) { widget_->handleMouseMoveEvent(MakePlatformMouseEvent(widget_, event)); } -void WebWidgetImpl::MouseDown(const WebMouseEvent& event) { +void WebPopupMenuImpl::MouseDown(const WebMouseEvent& event) { widget_->handleMouseDownEvent(MakePlatformMouseEvent(widget_, event)); } -void WebWidgetImpl::MouseUp(const WebMouseEvent& event) { - MouseCaptureLost(); +void WebPopupMenuImpl::MouseUp(const WebMouseEvent& event) { + mouseCaptureLost(); widget_->handleMouseReleaseEvent(MakePlatformMouseEvent(widget_, event)); } -void WebWidgetImpl::MouseWheel(const WebMouseWheelEvent& event) { +void WebPopupMenuImpl::MouseWheel(const WebMouseWheelEvent& event) { widget_->handleWheelEvent(MakePlatformWheelEvent(widget_, event)); } -bool WebWidgetImpl::KeyEvent(const WebKeyboardEvent& event) { +bool WebPopupMenuImpl::KeyEvent(const WebKeyboardEvent& event) { return widget_->handleKeyEvent(MakePlatformKeyboardEvent(event)); } // WebWidget ------------------------------------------------------------------- -void WebWidgetImpl::Close() { +void WebPopupMenuImpl::close() { if (widget_) widget_->hide(); - delegate_ = NULL; + client_ = NULL; Release(); // Balances AddRef from WebWidget::Create } -void WebWidgetImpl::Resize(const WebSize& new_size) { +void WebPopupMenuImpl::resize(const WebSize& new_size) { if (size_ == new_size) return; size_ = new_size; @@ -121,16 +127,16 @@ void WebWidgetImpl::Resize(const WebSize& new_size) { widget_->setFrameRect(new_geometry); } - if (delegate_) { + if (client_) { WebRect damaged_rect(0, 0, size_.width, size_.height); - delegate_->DidInvalidateRect(this, damaged_rect); + client_->didInvalidateRect(damaged_rect); } } -void WebWidgetImpl::Layout() { +void WebPopupMenuImpl::layout() { } -void WebWidgetImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) { +void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect) { if (!widget_) return; @@ -148,32 +154,32 @@ void WebWidgetImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) { } } -bool WebWidgetImpl::HandleInputEvent(const WebInputEvent* input_event) { +bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& input_event) { if (!widget_) return false; // TODO (jcampan): WebKit seems to always return false on mouse events // methods. For now we'll assume it has processed them (as we are only // interested in whether keyboard events are processed). - switch (input_event->type) { + switch (input_event.type) { case WebInputEvent::MouseMove: - MouseMove(*static_cast<const WebMouseEvent*>(input_event)); + MouseMove(*static_cast<const WebMouseEvent*>(&input_event)); return true; case WebInputEvent::MouseLeave: - MouseLeave(*static_cast<const WebMouseEvent*>(input_event)); + MouseLeave(*static_cast<const WebMouseEvent*>(&input_event)); return true; case WebInputEvent::MouseWheel: - MouseWheel(*static_cast<const WebMouseWheelEvent*>(input_event)); + MouseWheel(*static_cast<const WebMouseWheelEvent*>(&input_event)); return true; case WebInputEvent::MouseDown: - MouseDown(*static_cast<const WebMouseEvent*>(input_event)); + MouseDown(*static_cast<const WebMouseEvent*>(&input_event)); return true; case WebInputEvent::MouseUp: - MouseUp(*static_cast<const WebMouseEvent*>(input_event)); + MouseUp(*static_cast<const WebMouseEvent*>(&input_event)); return true; // In Windows, RawKeyDown only has information about the physical key, but @@ -188,7 +194,7 @@ bool WebWidgetImpl::HandleInputEvent(const WebInputEvent* input_event) { case WebInputEvent::KeyDown: case WebInputEvent::KeyUp: case WebInputEvent::Char: - return KeyEvent(*static_cast<const WebKeyboardEvent*>(input_event)); + return KeyEvent(*static_cast<const WebKeyboardEvent*>(&input_event)); default: break; @@ -196,71 +202,70 @@ bool WebWidgetImpl::HandleInputEvent(const WebInputEvent* input_event) { return false; } -void WebWidgetImpl::MouseCaptureLost() { +void WebPopupMenuImpl::mouseCaptureLost() { } -void WebWidgetImpl::SetFocus(bool enable) { +void WebPopupMenuImpl::setFocus(bool enable) { } -bool WebWidgetImpl::ImeSetComposition(int string_type, - int cursor_position, - int target_start, - int target_end, - const std::wstring& ime_string) { +bool WebPopupMenuImpl::handleCompositionEvent( + WebCompositionCommand command, + int cursor_position, + int target_start, + int target_end, + const WebString& ime_string) { return false; } -bool WebWidgetImpl::ImeUpdateStatus(bool* enable_ime, - WebRect* caret_rect) { +bool WebPopupMenuImpl::queryCompositionStatus(bool* enabled, + WebRect* caret_rect) { return false; } -void WebWidgetImpl::SetTextDirection(WebTextDirection direction) { +void WebPopupMenuImpl::setTextDirection(WebTextDirection direction) { } //----------------------------------------------------------------------------- // WebCore::HostWindow -void WebWidgetImpl::repaint(const WebCore::IntRect& paint_rect, +void WebPopupMenuImpl::repaint(const WebCore::IntRect& paint_rect, bool content_changed, bool immediate, bool repaint_content_only) { // Ignore spurious calls. if (!content_changed || paint_rect.isEmpty()) return; - if (delegate_) - delegate_->DidInvalidateRect(this, - webkit_glue::IntRectToWebRect(paint_rect)); + if (client_) + client_->didInvalidateRect(webkit_glue::IntRectToWebRect(paint_rect)); } -void WebWidgetImpl::scroll(const WebCore::IntSize& scroll_delta, +void WebPopupMenuImpl::scroll(const WebCore::IntSize& scroll_delta, const WebCore::IntRect& scroll_rect, const WebCore::IntRect& clip_rect) { - if (delegate_) { + if (client_) { int dx = scroll_delta.width(); int dy = scroll_delta.height(); - delegate_->DidScrollRect(this, dx, dy, - webkit_glue::IntRectToWebRect(clip_rect)); + client_->didScrollRect(dx, dy, webkit_glue::IntRectToWebRect(clip_rect)); } } -WebCore::IntPoint WebWidgetImpl::screenToWindow( +WebCore::IntPoint WebPopupMenuImpl::screenToWindow( const WebCore::IntPoint& point) const { NOTIMPLEMENTED(); return WebCore::IntPoint(); } -WebCore::IntRect WebWidgetImpl::windowToScreen( +WebCore::IntRect WebPopupMenuImpl::windowToScreen( const WebCore::IntRect& rect) const { NOTIMPLEMENTED(); return WebCore::IntRect(); } -PlatformWidget WebWidgetImpl::platformWindow() const { +PlatformWidget WebPopupMenuImpl::platformWindow() const { return NULL; } -void WebWidgetImpl::scrollRectIntoView( +void WebPopupMenuImpl::scrollRectIntoView( const WebCore::IntRect&, const WebCore::ScrollView*) const { // Nothing to be done here since we do not have the concept of a container // that implements its own scrolling. @@ -269,11 +274,11 @@ void WebWidgetImpl::scrollRectIntoView( //----------------------------------------------------------------------------- // WebCore::FramelessScrollViewClient -void WebWidgetImpl::popupClosed(WebCore::FramelessScrollView* widget) { +void WebPopupMenuImpl::popupClosed(WebCore::FramelessScrollView* widget) { DCHECK(widget == widget_); if (widget_) { widget_->setClient(NULL); widget_ = NULL; } - delegate_->CloseWidgetSoon(this); + client_->closeWidgetSoon(); } diff --git a/webkit/glue/webwidget_impl.h b/webkit/glue/webpopupmenu_impl.h index a1a1b18..b6ef6ed 100644 --- a/webkit/glue/webwidget_impl.h +++ b/webkit/glue/webpopupmenu_impl.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBKIT_GLUE_WEBWIDGET_IMPL_H__ -#define WEBKIT_GLUE_WEBWIDGET_IMPL_H__ +#ifndef WEBKIT_GLUE_WEBPOPUPMENU_IMPL_H_ +#define WEBKIT_GLUE_WEBPOPUPMENU_IMPL_H_ #include "base/basictypes.h" #include "base/ref_counted.h" #include "webkit/api/public/WebPoint.h" +#include "webkit/api/public/WebPopupMenu.h" #include "webkit/api/public/WebSize.h" -#include "webkit/glue/webwidget.h" #include "FramelessScrollViewClient.h" @@ -31,39 +31,36 @@ struct WebRect; } struct MenuItem; -class WebWidgetDelegate; -class WebWidgetImpl : public WebWidget, - public WebCore::FramelessScrollViewClient, - public base::RefCounted<WebWidgetImpl> { +class WebPopupMenuImpl : public WebKit::WebPopupMenu, + public WebCore::FramelessScrollViewClient, + public base::RefCounted<WebPopupMenuImpl> { public: // WebWidget - virtual void Close(); - virtual void Resize(const WebKit::WebSize& new_size); - virtual WebKit::WebSize GetSize() { return size(); } - virtual void Layout(); - virtual void Paint(skia::PlatformCanvas* canvas, + virtual void close(); + virtual WebKit::WebSize size() { return size_; } + virtual void resize(const WebKit::WebSize& new_size); + virtual void layout(); + virtual void paint(WebKit::WebCanvas* canvas, const WebKit::WebRect& rect); - virtual bool HandleInputEvent(const WebKit::WebInputEvent* input_event); - virtual void MouseCaptureLost(); - virtual void SetFocus(bool enable); - virtual bool ImeSetComposition(int string_type, - int cursor_position, - int target_start, - int target_end, - const std::wstring& ime_string); - virtual bool ImeUpdateStatus(bool* enable_ime, - WebKit::WebRect* caret_rect); - virtual void SetTextDirection(WebTextDirection direction); - - // WebWidgetImpl + virtual bool handleInputEvent(const WebKit::WebInputEvent& input_event); + virtual void mouseCaptureLost(); + virtual void setFocus(bool enable); + virtual bool handleCompositionEvent(WebKit::WebCompositionCommand command, + int cursor_position, + int target_start, + int target_end, + const WebKit::WebString& text); + virtual bool queryCompositionStatus(bool* enabled, + WebKit::WebRect* caret_rect); + virtual void setTextDirection(WebKit::WebTextDirection direction); + + // WebPopupMenuImpl void Init(WebCore::FramelessScrollView* widget, const WebKit::WebRect& bounds); - const WebKit::WebSize& size() const { return size_; } - - WebWidgetDelegate* delegate() { - return delegate_; + WebKit::WebWidgetClient* client() { + return client_; } void MouseMove(const WebKit::WebMouseEvent& mouse_event); @@ -75,11 +72,11 @@ class WebWidgetImpl : public WebWidget, bool KeyEvent(const WebKit::WebKeyboardEvent& key_event); protected: - friend class WebWidget; // So WebWidget::Create can call our constructor - friend class base::RefCounted<WebWidgetImpl>; + friend class WebKit::WebPopupMenu; // For WebPopupMenu::create + friend class base::RefCounted<WebPopupMenuImpl>; - WebWidgetImpl(WebWidgetDelegate* delegate); - ~WebWidgetImpl(); + WebPopupMenuImpl(WebKit::WebWidgetClient* client); + ~WebPopupMenuImpl(); // WebCore::HostWindow methods: virtual void repaint(const WebCore::IntRect&, @@ -98,7 +95,7 @@ class WebWidgetImpl : public WebWidget, // WebCore::FramelessScrollViewClient methods: virtual void popupClosed(WebCore::FramelessScrollView* popup_view); - WebWidgetDelegate* delegate_; + WebKit::WebWidgetClient* client_; WebKit::WebSize size_; WebKit::WebPoint last_mouse_position_; @@ -108,7 +105,7 @@ class WebWidgetImpl : public WebWidget, WebCore::FramelessScrollView* widget_; private: - DISALLOW_COPY_AND_ASSIGN(WebWidgetImpl); + DISALLOW_COPY_AND_ASSIGN(WebPopupMenuImpl); }; -#endif // WEBKIT_GLUE_WEBWIDGET_IMPL_H__ +#endif // WEBKIT_GLUE_WEBPOPUPMENU_IMPL_H_ diff --git a/webkit/glue/webtextdirection.h b/webkit/glue/webtextdirection.h deleted file mode 100644 index 822eb34..0000000 --- a/webkit/glue/webtextdirection.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_GLUE_WEBTEXTDIRECTION_H_ -#define WEBKIT_GLUE_WEBTEXTDIRECTION_H_ - -// Represents text directions (or writing directions) of a DOM node. -// This type is used as the input parameter of WebWidget::SetTextDirection(). -// This function converts these values to WebCore::WritingDirection values and -// call the Editor::setBaseWritingDirection() function. -// TODO(hbono): Add WEB_TEXT_DIRECTION_ORIGINAL that represents "revert the -// previous changes and set back to the original one" and implement it. -// TODO(hbono): Add WEB_TEXT_DIRECTION_TOGGLE that represents "toggle the text -// direction" and implement it. -enum WebTextDirection { - WEB_TEXT_DIRECTION_DEFAULT, // WebCore::NaturalWritingDirection - WEB_TEXT_DIRECTION_LTR, // WebCore::LeftToRightWritingDirection - WEB_TEXT_DIRECTION_RTL, // WebCore::RightToLeftWritingDirection -}; - -#endif // WEBKIT_GLUE_WEBTEXTDIRECTION_H_ diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h index 7468e0a..81d0094 100644 --- a/webkit/glue/webview.h +++ b/webkit/glue/webview.h @@ -9,7 +9,7 @@ #include <vector> #include "base/basictypes.h" -#include "webkit/glue/webwidget.h" +#include "webkit/api/public/WebWidget.h" namespace WebKit { class WebDragData; @@ -42,7 +42,7 @@ class WebViewDelegate; // user interface elements in those windows, monitoring the progress of loads, // monitoring URL changes, and making determinations about how content of // certain types should be handled. -class WebView : public WebWidget { +class WebView : public WebKit::WebWidget { public: WebView() {} virtual ~WebView() {} diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 1ccc761..e41a7bf 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -29,9 +29,10 @@ #include <vector> #include "base/gfx/native_widget_types.h" +#include "webkit/api/public/WebNavigationPolicy.h" #include "webkit/api/public/WebNavigationType.h" +#include "webkit/api/public/WebWidgetClient.h" #include "webkit/glue/context_menu.h" -#include "webkit/glue/webwidget_delegate.h" namespace webkit_glue { class WebMediaPlayerDelegate; @@ -51,13 +52,13 @@ class WebMediaPlayer; class WebMediaPlayerClient; class WebURLRequest; class WebURLResponse; +class WebWidget; struct WebPoint; struct WebPopupMenuInfo; struct WebRect; struct WebURLError; } -struct WebPreferences; class FilePath; class SkBitmap; class WebDevToolsAgentDelegate; @@ -65,7 +66,8 @@ class WebFrame; class WebMediaPlayerDelegate; class WebPluginDelegate; class WebView; -class WebWidget; +struct WebPluginGeometry; +struct WebPreferences; enum NavigationGesture { NavigationGestureUser, // User initiated navigation/load. This is not @@ -96,8 +98,8 @@ class WebFileChooserCallback { // Inheritance here is somewhat weird, but since a WebView is a WebWidget, -// it makes sense that a WebViewDelegate is a WebWidgetDelegate. -class WebViewDelegate : virtual public WebWidgetDelegate { +// it makes sense that a WebViewDelegate is a WebWidgetClient. +class WebViewDelegate : virtual public WebKit::WebWidgetClient { public: // WebView additions ------------------------------------------------------- @@ -116,13 +118,15 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // This method is called to create a new WebWidget to act as a popup // (like a drop-down menu). - virtual WebWidget* CreatePopupWidget(WebView* webview, bool activatable) { + virtual WebKit::WebWidget* CreatePopupWidget( + WebView* webview, + bool activatable) { return NULL; } // Like CreatePopupWidget, except the actual widget is rendered by the // embedder using the supplied info. - virtual WebWidget* CreatePopupWidgetWithInfo( + virtual WebKit::WebWidget* CreatePopupWidgetWithInfo( WebView* webview, const WebKit::WebPopupMenuInfo& info) { return NULL; @@ -164,7 +168,7 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // This method is called to open a URL in the specified manner. virtual void OpenURL(WebView* webview, const GURL& url, const GURL& referrer, - WindowOpenDisposition disposition) { + WebKit::WebNavigationPolicy policy) { } // Notifies how many matches have been found so far, for a given request_id. @@ -197,6 +201,12 @@ class WebViewDelegate : virtual public WebWidgetDelegate { virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj) { } + // Keeps track of the necessary window move for a plugin window that resulted + // from a scroll operation. That way, all plugin windows can be moved at the + // same time as each other and the page. + virtual void DidMovePlugin(const WebPluginGeometry& move) { + } + // FrameLoaderClient ------------------------------------------------------- virtual bool CanAcceptLoadDrops() const { @@ -248,20 +258,20 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // proposed navigation. It will be called before loading starts, and // on every redirect. // - // disposition specifies what should normally happen for this + // default_policy specifies what should normally happen for this // navigation (open in current tab, start a new tab, start a new - // window, etc). This method can return an altered disposition, and + // window, etc). This method can return an altered policy, and // take any additional separate action it wants to. // // is_redirect is true if this is a redirect rather than user action. - 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) { - return disposition; + return default_policy; } // FrameLoadDelegate ------------------------------------------------------- @@ -525,8 +535,8 @@ class WebViewDelegate : virtual public WebWidgetDelegate { const std::wstring& value) { } - virtual void DidContentsSizeChange(WebWidget* webwidget, int new_width, - int new_height) { + virtual void DidContentsSizeChange(WebKit::WebWidget* webwidget, + int new_width, int new_height) { } // UIDelegate -------------------------------------------------------------- diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index a29836d..29152bd 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -91,6 +91,7 @@ MSVC_POP_WARNING(); #include "webkit/api/public/WebInputEvent.h" #include "webkit/api/public/WebPoint.h" #include "webkit/api/public/WebRect.h" +#include "webkit/api/public/WebString.h" #include "webkit/glue/chrome_client_impl.h" #include "webkit/glue/context_menu_client_impl.h" #include "webkit/glue/dom_operations.h" @@ -105,12 +106,12 @@ MSVC_POP_WARNING(); #include "webkit/glue/webdevtoolsagent_impl.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/webkit_glue.h" +#include "webkit/glue/webpopupmenu_impl.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webdevtoolsagent.h" #include "webkit/glue/webdevtoolsclient.h" #include "webkit/glue/webview_delegate.h" #include "webkit/glue/webview_impl.h" -#include "webkit/glue/webwidget_impl.h" // Get rid of WTF's pow define so we can use std::pow. #undef pow @@ -118,6 +119,10 @@ MSVC_POP_WARNING(); using namespace WebCore; +using WebKit::WebCanvas; +using WebKit::WebCompositionCommand; +using WebKit::WebCompositionCommandConfirm; +using WebKit::WebCompositionCommandDiscard; using WebKit::WebDragData; using WebKit::WebInputEvent; using WebKit::WebKeyboardEvent; @@ -126,6 +131,11 @@ using WebKit::WebMouseWheelEvent; using WebKit::WebPoint; using WebKit::WebRect; using WebKit::WebSize; +using WebKit::WebString; +using WebKit::WebTextDirection; +using WebKit::WebTextDirectionDefault; +using WebKit::WebTextDirectionLeftToRight; +using WebKit::WebTextDirectionRightToLeft; using webkit_glue::ImageResourceFetcher; @@ -374,7 +384,7 @@ WebViewImpl::WebViewImpl() doing_drag_and_drop_(false), ignore_input_events_(false), suppress_next_keypress_event_(false), - window_open_disposition_(IGNORE_ACTION), + initial_navigation_policy_(WebKit::WebNavigationPolicyIgnore), ime_accept_events_(true), drag_target_dispatch_(false), drag_identity_(0), @@ -532,7 +542,7 @@ void WebViewImpl::MouseUp(const WebMouseEvent& event) { if (!main_frame() || !main_frame()->frameview()) return; - MouseCaptureLost(); + mouseCaptureLost(); main_frame()->frame()->eventHandler()->handleMouseReleaseEvent( MakePlatformMouseEvent(main_frame()->frameview(), event)); @@ -915,20 +925,9 @@ WebViewImpl* WebViewImpl::FromPage(WebCore::Page* page) { return WebFrameImpl::FromFrame(page->mainFrame())->GetWebViewImpl(); } -// WebView -------------------------------------------------------------------- - -bool WebViewImpl::ShouldClose() { - // TODO(creis): This should really cause a recursive depth-first walk of all - // frames in the tree, calling each frame's onbeforeunload. At the moment, - // we're consistent with Safari 3.1, not IE/FF. - Frame* frame = page_->focusController()->focusedOrMainFrame(); - if (!frame) - return true; +// WebWidget ------------------------------------------------------------------ - return frame->shouldClose(); -} - -void WebViewImpl::Close() { +void WebViewImpl::close() { if (page_.get()) { // Initiate shutdown for the entire frameset. This will cause a lot of // notifications to be sent. @@ -948,57 +947,7 @@ void WebViewImpl::Close() { Release(); // Balances AddRef from WebView::Create } -WebViewDelegate* WebViewImpl::GetDelegate() { - return delegate_; -} - -void WebViewImpl::SetDelegate(WebViewDelegate* delegate) { - delegate_ = delegate; -} - -WebFrame* WebViewImpl::GetMainFrame() { - return main_frame(); -} - -WebFrame* WebViewImpl::GetFocusedFrame() { - Frame* frame = GetFocusedWebCoreFrame(); - return frame ? WebFrameImpl::FromFrame(frame) : NULL; -} - -void WebViewImpl::SetFocusedFrame(WebFrame* frame) { - if (!frame) { - // Clears the focused frame if any. - Frame* frame = GetFocusedWebCoreFrame(); - if (frame) - frame->selection()->setFocused(false); - return; - } - WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); - WebCore::Frame* webcore_frame = frame_impl->frame(); - webcore_frame->page()->focusController()->setFocusedFrame(webcore_frame); -} - -WebFrame* WebViewImpl::GetFrameWithName(const std::wstring& name) { - String name_str = webkit_glue::StdWStringToString(name); - Frame* frame = page_->mainFrame()->tree()->find(name_str); - return frame ? WebFrameImpl::FromFrame(frame) : NULL; -} - -WebFrame* WebViewImpl::GetPreviousFrameBefore(WebFrame* frame, bool wrap) { - WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); - WebCore::Frame* previous = - frame_impl->frame()->tree()->traversePreviousWithWrap(wrap); - return previous ? WebFrameImpl::FromFrame(previous) : NULL; -} - -WebFrame* WebViewImpl::GetNextFrameAfter(WebFrame* frame, bool wrap) { - WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); - WebCore::Frame* next = - frame_impl->frame()->tree()->traverseNextWithWrap(wrap); - return next ? WebFrameImpl::FromFrame(next) : NULL; -} - -void WebViewImpl::Resize(const WebSize& new_size) { +void WebViewImpl::resize(const WebSize& new_size) { if (size_ == new_size) return; size_ = new_size; @@ -1010,11 +959,11 @@ void WebViewImpl::Resize(const WebSize& new_size) { if (delegate_) { WebRect damaged_rect(0, 0, size_.width, size_.height); - delegate_->DidInvalidateRect(this, damaged_rect); + delegate_->didInvalidateRect(damaged_rect); } } -void WebViewImpl::Layout() { +void WebViewImpl::layout() { WebFrameImpl* webframe = main_frame(); if (webframe) { // In order for our child HWNDs (NativeWindowWidgets) to update properly, @@ -1034,7 +983,7 @@ void WebViewImpl::Layout() { } } -void WebViewImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) { +void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) { WebFrameImpl* webframe = main_frame(); if (webframe) webframe->Paint(canvas, rect); @@ -1045,7 +994,7 @@ void WebViewImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) { /* static */ const WebInputEvent* WebViewImpl::g_current_input_event = NULL; -bool WebViewImpl::HandleInputEvent(const WebInputEvent* input_event) { +bool WebViewImpl::handleInputEvent(const WebInputEvent& input_event) { // If we've started a drag and drop operation, ignore input events until // we're done. if (doing_drag_and_drop_) @@ -1060,42 +1009,42 @@ bool WebViewImpl::HandleInputEvent(const WebInputEvent* input_event) { // Safari must perform a similar hack, ours is in our WebKit glue layer // theirs is in the application. This should go when WebCore can be fixed // to pass more event information to ChromeClient::show() - g_current_input_event = input_event; + g_current_input_event = &input_event; bool handled = true; // TODO(jcampan): WebKit seems to always return false on mouse events // processing methods. For now we'll assume it has processed them (as we are // only interested in whether keyboard events are processed). - switch (input_event->type) { + switch (input_event.type) { case WebInputEvent::MouseMove: - MouseMove(*static_cast<const WebMouseEvent*>(input_event)); + MouseMove(*static_cast<const WebMouseEvent*>(&input_event)); break; case WebInputEvent::MouseLeave: - MouseLeave(*static_cast<const WebMouseEvent*>(input_event)); + MouseLeave(*static_cast<const WebMouseEvent*>(&input_event)); break; case WebInputEvent::MouseWheel: - MouseWheel(*static_cast<const WebMouseWheelEvent*>(input_event)); + MouseWheel(*static_cast<const WebMouseWheelEvent*>(&input_event)); break; case WebInputEvent::MouseDown: - MouseDown(*static_cast<const WebMouseEvent*>(input_event)); + MouseDown(*static_cast<const WebMouseEvent*>(&input_event)); break; case WebInputEvent::MouseUp: - MouseUp(*static_cast<const WebMouseEvent*>(input_event)); + MouseUp(*static_cast<const WebMouseEvent*>(&input_event)); break; case WebInputEvent::RawKeyDown: case WebInputEvent::KeyDown: case WebInputEvent::KeyUp: - handled = KeyEvent(*static_cast<const WebKeyboardEvent*>(input_event)); + handled = KeyEvent(*static_cast<const WebKeyboardEvent*>(&input_event)); break; case WebInputEvent::Char: - handled = CharEvent(*static_cast<const WebKeyboardEvent*>(input_event)); + handled = CharEvent(*static_cast<const WebKeyboardEvent*>(&input_event)); break; default: handled = false; @@ -1106,53 +1055,10 @@ bool WebViewImpl::HandleInputEvent(const WebInputEvent* input_event) { return handled; } -void WebViewImpl::MouseCaptureLost() { +void WebViewImpl::mouseCaptureLost() { } -// TODO(darin): these navigation methods should be killed - -void WebViewImpl::StopLoading() { - main_frame()->StopLoading(); -} - -void WebViewImpl::SetBackForwardListSize(int size) { - page_->backForwardList()->setCapacity(size); -} - -void WebViewImpl::ClearFocusedNode() { - if (!page_.get()) - return; - - RefPtr<Frame> frame = page_->mainFrame(); - if (!frame.get()) - return; - - RefPtr<Document> document = frame->document(); - if (!document.get()) - return; - - RefPtr<Node> old_focused_node = document->focusedNode(); - - // Clear the focused node. - document->setFocusedNode(NULL); - - if (!old_focused_node.get()) - return; - - // If a text field has focus, we need to make sure the selection controller - // knows to remove selection from it. Otherwise, the text field is still - // processing keyboard events even though focus has been moved to the page and - // keystrokes get eaten as a result. - if (old_focused_node->hasTagName(HTMLNames::textareaTag) || - (old_focused_node->hasTagName(HTMLNames::inputTag) && - static_cast<HTMLInputElement*>(old_focused_node.get())->isTextField())) { - // Clear the selection. - SelectionController* selection = frame->selection(); - selection->clear(); - } -} - -void WebViewImpl::SetFocus(bool enable) { +void WebViewImpl::setFocus(bool enable) { page_->focusController()->setFocused(enable); if (enable) { // Note that we don't call setActive() when disabled as this cause extra @@ -1181,11 +1087,11 @@ void WebViewImpl::SetFocus(bool enable) { } } -bool WebViewImpl::ImeSetComposition(int string_type, - int cursor_position, - int target_start, - int target_end, - const std::wstring& ime_string) { +bool WebViewImpl::handleCompositionEvent(WebCompositionCommand command, + int cursor_position, + int target_start, + int target_end, + const WebString& ime_string) { Frame* focused = GetFocusedWebCoreFrame(); if (!focused || !ime_accept_events_) { return false; @@ -1212,7 +1118,7 @@ bool WebViewImpl::ImeSetComposition(int string_type, return false; } - if (string_type == -1) { + if (command == WebCompositionCommandDiscard) { // A browser process sent an IPC message which does not contain a valid // string, which means an ongoing composition has been canceled. // If the ongoing composition has been canceled, replace the ongoing @@ -1225,10 +1131,12 @@ bool WebViewImpl::ImeSetComposition(int string_type, // displayed in this Editor object. // To display the given string, set the given string to the // m_compositionNode member of this Editor object and display it. - if (target_start < 0) target_start = 0; - if (target_end < 0) target_end = static_cast<int>(ime_string.length()); + if (target_start < 0) + target_start = 0; + if (target_end < 0) + target_end = static_cast<int>(ime_string.length()); WebCore::String composition_string( - webkit_glue::StdWStringToString(ime_string)); + webkit_glue::WebStringToString(ime_string)); // Create custom underlines. // To emphasize the selection, the selected region uses a solid black // for its underline while other regions uses a pale gray for theirs. @@ -1255,16 +1163,15 @@ bool WebViewImpl::ImeSetComposition(int string_type, // The given string is a result string, which means the ongoing // composition has been completed. I have to call the // Editor::confirmCompletion() and complete this composition. - if (string_type == 1) { + if (command == WebCompositionCommandConfirm) editor->confirmComposition(); - } } return editor->hasComposition(); } -bool WebViewImpl::ImeUpdateStatus(bool* enable_ime, - WebRect* caret_rect) { +bool WebViewImpl::queryCompositionStatus(bool* enable_ime, + WebRect* caret_rect) { // Store whether the selected node needs IME and the caret rectangle. // This process consists of the following four steps: // 1. Retrieve the selection controller of the focused frame; @@ -1299,7 +1206,7 @@ bool WebViewImpl::ImeUpdateStatus(bool* enable_ime, return true; } -void WebViewImpl::SetTextDirection(WebTextDirection direction) { +void WebViewImpl::setTextDirection(WebTextDirection direction) { // The Editor::setBaseWritingDirection() function checks if we can change // the text direction of the selected node and updates its DOM "dir" // attribute and its CSS "direction" property. @@ -1313,15 +1220,15 @@ void WebViewImpl::SetTextDirection(WebTextDirection direction) { return; switch (direction) { - case WEB_TEXT_DIRECTION_DEFAULT: + case WebTextDirectionDefault: editor->setBaseWritingDirection(WebCore::NaturalWritingDirection); break; - case WEB_TEXT_DIRECTION_LTR: + case WebTextDirectionLeftToRight: editor->setBaseWritingDirection(WebCore::LeftToRightWritingDirection); break; - case WEB_TEXT_DIRECTION_RTL: + case WebTextDirectionRightToLeft: editor->setBaseWritingDirection(WebCore::RightToLeftWritingDirection); break; @@ -1331,6 +1238,112 @@ void WebViewImpl::SetTextDirection(WebTextDirection direction) { } } +// WebView -------------------------------------------------------------------- + +bool WebViewImpl::ShouldClose() { + // TODO(creis): This should really cause a recursive depth-first walk of all + // frames in the tree, calling each frame's onbeforeunload. At the moment, + // we're consistent with Safari 3.1, not IE/FF. + Frame* frame = page_->focusController()->focusedOrMainFrame(); + if (!frame) + return true; + + return frame->shouldClose(); +} + +WebViewDelegate* WebViewImpl::GetDelegate() { + return delegate_; +} + +void WebViewImpl::SetDelegate(WebViewDelegate* delegate) { + delegate_ = delegate; +} + +WebFrame* WebViewImpl::GetMainFrame() { + return main_frame(); +} + +WebFrame* WebViewImpl::GetFocusedFrame() { + Frame* frame = GetFocusedWebCoreFrame(); + return frame ? WebFrameImpl::FromFrame(frame) : NULL; +} + +void WebViewImpl::SetFocusedFrame(WebFrame* frame) { + if (!frame) { + // Clears the focused frame if any. + Frame* frame = GetFocusedWebCoreFrame(); + if (frame) + frame->selection()->setFocused(false); + return; + } + WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); + WebCore::Frame* webcore_frame = frame_impl->frame(); + webcore_frame->page()->focusController()->setFocusedFrame(webcore_frame); +} + +WebFrame* WebViewImpl::GetFrameWithName(const std::wstring& name) { + String name_str = webkit_glue::StdWStringToString(name); + Frame* frame = page_->mainFrame()->tree()->find(name_str); + return frame ? WebFrameImpl::FromFrame(frame) : NULL; +} + +WebFrame* WebViewImpl::GetPreviousFrameBefore(WebFrame* frame, bool wrap) { + WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); + WebCore::Frame* previous = + frame_impl->frame()->tree()->traversePreviousWithWrap(wrap); + return previous ? WebFrameImpl::FromFrame(previous) : NULL; +} + +WebFrame* WebViewImpl::GetNextFrameAfter(WebFrame* frame, bool wrap) { + WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); + WebCore::Frame* next = + frame_impl->frame()->tree()->traverseNextWithWrap(wrap); + return next ? WebFrameImpl::FromFrame(next) : NULL; +} + +// TODO(darin): these navigation methods should be killed + +void WebViewImpl::StopLoading() { + main_frame()->StopLoading(); +} + +void WebViewImpl::SetBackForwardListSize(int size) { + page_->backForwardList()->setCapacity(size); +} + +void WebViewImpl::ClearFocusedNode() { + if (!page_.get()) + return; + + RefPtr<Frame> frame = page_->mainFrame(); + if (!frame.get()) + return; + + RefPtr<Document> document = frame->document(); + if (!document.get()) + return; + + RefPtr<Node> old_focused_node = document->focusedNode(); + + // Clear the focused node. + document->setFocusedNode(NULL); + + if (!old_focused_node.get()) + return; + + // If a text field has focus, we need to make sure the selection controller + // knows to remove selection from it. Otherwise, the text field is still + // processing keyboard events even though focus has been moved to the page and + // keystrokes get eaten as a result. + if (old_focused_node->hasTagName(HTMLNames::textareaTag) || + (old_focused_node->hasTagName(HTMLNames::inputTag) && + static_cast<HTMLInputElement*>(old_focused_node.get())->isTextField())) { + // Clear the selection. + SelectionController* selection = frame->selection(); + selection->clear(); + } +} + void WebViewImpl::SetInitialFocus(bool reverse) { if (page_.get()) { // Since we don't have a keyboard event, we'll create one. @@ -1866,10 +1879,10 @@ void WebViewImpl::RefreshAutofillPopup() { IntRect new_bounds = autocomplete_popup_->boundsRect(); // Let's resize the backing window if necessary. if (old_bounds != new_bounds) { - WebWidgetImpl* web_widget = - static_cast<WebWidgetImpl*>(autocomplete_popup_->client()); - web_widget->delegate()->SetWindowRect( - web_widget, webkit_glue::IntRectToWebRect(new_bounds)); + WebPopupMenuImpl* popup_menu = + static_cast<WebPopupMenuImpl*>(autocomplete_popup_->client()); + popup_menu->client()->setWindowRect( + webkit_glue::IntRectToWebRect(new_bounds)); } } diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index d55df1a..6c2f883 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -49,9 +49,27 @@ class WebViewDelegate; class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { public: - // WebView + // WebWidget methods: + virtual void close(); + virtual WebKit::WebSize size() { return size_; } + virtual void resize(const WebKit::WebSize& new_size); + virtual void layout(); + virtual void paint(WebKit::WebCanvas* canvas, + const WebKit::WebRect& rect); + virtual bool handleInputEvent(const WebKit::WebInputEvent& input_event); + virtual void mouseCaptureLost(); + virtual void setFocus(bool enable); + virtual bool handleCompositionEvent(WebKit::WebCompositionCommand command, + int cursor_position, + int target_start, + int target_end, + const WebKit::WebString& text); + virtual bool queryCompositionStatus(bool* enabled, + WebKit::WebRect* caret_rect); + virtual void setTextDirection(WebKit::WebTextDirection direction); + + // WebView methods: virtual bool ShouldClose(); - virtual void Close(); virtual WebViewDelegate* GetDelegate(); virtual void SetDelegate(WebViewDelegate*); virtual void SetUseEditorDelegate(bool value); @@ -62,22 +80,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { virtual WebFrame* GetFrameWithName(const std::wstring& name); virtual WebFrame* GetPreviousFrameBefore(WebFrame* frame, bool wrap); virtual WebFrame* GetNextFrameAfter(WebFrame* frame, bool wrap); - virtual void Resize(const WebKit::WebSize& new_size); - virtual WebKit::WebSize GetSize() { return size(); } - virtual void Layout(); - virtual void Paint(skia::PlatformCanvas* canvas, const WebKit::WebRect& rect); - virtual bool HandleInputEvent(const WebKit::WebInputEvent* input_event); - virtual void MouseCaptureLost(); - virtual void SetFocus(bool enable); virtual void ClearFocusedNode(); - virtual bool ImeSetComposition(int string_type, - int cursor_position, - int target_start, - int target_end, - const std::wstring& ime_string); - virtual bool ImeUpdateStatus(bool* enable_ime, - WebKit::WebRect* caret_rect); - virtual void SetTextDirection(WebTextDirection direction); virtual void StopLoading(); virtual void SetBackForwardListSize(int size); virtual void SetInitialFocus(bool reverse); @@ -130,8 +133,6 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { // WebViewImpl - const WebKit::WebSize& size() const { return size_; } - const WebKit::WebPoint& last_mouse_down_point() const { return last_mouse_down_point_; } @@ -196,11 +197,11 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { } // Set the disposition for how this webview is to be initially shown. - void set_window_open_disposition(WindowOpenDisposition disp) { - window_open_disposition_ = disp; + void set_initial_navigation_policy(WebKit::WebNavigationPolicy policy) { + initial_navigation_policy_ = policy; } - WindowOpenDisposition window_open_disposition() const { - return window_open_disposition_; + WebKit::WebNavigationPolicy initial_navigation_policy() const { + return initial_navigation_policy_; } // Start a system drag and drop operation. @@ -303,8 +304,8 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { // this behavior by setting this flag if the keyDown was handled. bool suppress_next_keypress_event_; - // The disposition for how this webview is to be initially shown. - WindowOpenDisposition window_open_disposition_; + // The policy for how this webview is to be initially shown. + WebKit::WebNavigationPolicy initial_navigation_policy_; // Represents whether or not this object should process incoming IME events. bool ime_accept_events_; diff --git a/webkit/glue/webwidget.h b/webkit/glue/webwidget.h deleted file mode 100644 index 6653e28..0000000 --- a/webkit/glue/webwidget.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_GLUE_WEBWIDGET_H__ -#define WEBKIT_GLUE_WEBWIDGET_H__ - -#include "skia/ext/platform_canvas.h" -#include "webkit/glue/webtextdirection.h" - -namespace WebKit { -class WebInputEvent; -struct WebRect; -struct WebSize; -} - -class WebWidgetDelegate; - -class WebWidget { - public: - WebWidget() {} - - // This method creates a WebWidget that is initially invisible and positioned - // according to the given bounds relative to the specified parent window. - // The caller is responsible for showing the WebWidget's view window (see - // GetViewWindow) once it is ready to have the WebWidget appear on the screen. - static WebWidget* Create(WebWidgetDelegate* delegate); - - // This method closes and deletes the WebWidget. - virtual void Close() = 0; - - // Called to resize the WebWidget. - virtual void Resize(const WebKit::WebSize& new_size) = 0; - - // Returns the current size of the WebWidget. - virtual WebKit::WebSize GetSize() = 0; - - // Called to layout the WebWidget. This MUST be called before Paint, and it - // may result in calls to WebWidgetDelegate::DidInvalidateRect. - virtual void Layout() = 0; - - // Called to paint the specified region of the WebWidget onto the given canvas. - // You MUST call Layout before calling this method. It is okay to call Paint - // multiple times once Layout has been called, assuming no other changes are - // made to the WebWidget (e.g., once events are processed, it should be assumed - // that another call to Layout is warranted before painting again). - virtual void Paint(skia::PlatformCanvas* canvas, - const WebKit::WebRect& rect) = 0; - - // Called to inform the WebWidget of an input event. - // Returns true if the event has been processed, false otherwise. - virtual bool HandleInputEvent(const WebKit::WebInputEvent* input_event) = 0; - - // Called to inform the WebWidget that mouse capture was lost. - virtual void MouseCaptureLost() = 0; - - // Called to inform the WebWidget that it has gained or lost keyboard focus. - virtual void SetFocus(bool enable) = 0; - - // Called to inform the webwidget of a composition event from IMM - // (Input Method Manager). - virtual bool ImeSetComposition(int string_type, int cursor_position, - int target_start, int target_end, - const std::wstring& ime_string) = 0; - - // Retrieve the status of this widget required by IME APIs. - virtual bool ImeUpdateStatus(bool* enable_ime, - WebKit::WebRect* caret_rect) = 0; - - // Changes the text direction of the selected input node. - virtual void SetTextDirection(WebTextDirection direction) = 0; - - protected: - virtual ~WebWidget() {} - - private: - DISALLOW_EVIL_CONSTRUCTORS(WebWidget); -}; - -#endif // #ifndef WEBKIT_GLUE_WEBWIDGET_H__ diff --git a/webkit/glue/webwidget_delegate.h b/webkit/glue/webwidget_delegate.h deleted file mode 100644 index a891cb1..0000000 --- a/webkit/glue/webwidget_delegate.h +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_GLUE_WEBWIDGET_DELEGATE_H__ -#define WEBKIT_GLUE_WEBWIDGET_DELEGATE_H__ - -#include <vector> - -#include "base/string16.h" -#include "webkit/glue/window_open_disposition.h" - -namespace WebKit { -struct WebCursorInfo; -struct WebRect; -struct WebScreenInfo; -} - -class WebWidget; -struct WebPluginGeometry; - -class WebWidgetDelegate { - public: - // Called when a region of the WebWidget needs to be re-painted. - virtual void DidInvalidateRect(WebWidget* webwidget, - const WebKit::WebRect& rect) = 0; - - // Called when a region of the WebWidget, given by clip_rect, should be - // scrolled by the specified dx and dy amounts. - virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy, - const WebKit::WebRect& clip_rect) = 0; - - // This method is called to instruct the window containing the WebWidget to - // show itself as the topmost window. This method is only used after a - // successful call to CreateWebWidget. |disposition| indicates how this new - // window should be displayed, but generally only means something for - // WebViews. - virtual void Show(WebWidget* webwidget, - WindowOpenDisposition disposition) = 0; - - // This method is called to instruct the window containing the WebWidget to - // close. Note: This method should just be the trigger that causes the - // WebWidget to eventually close. It should not actually be destroyed until - // after this call returns. - virtual void CloseWidgetSoon(WebWidget* webwidget) = 0; - - // This method is called to focus the window containing the WebWidget so - // that it receives keyboard events. - virtual void Focus(WebWidget* webwidget) = 0; - - // This method is called to unfocus the window containing the WebWidget so that - // it no longer receives keyboard events. - virtual void Blur(WebWidget* webwidget) = 0; - - virtual void SetCursor(WebWidget* webwidget, - const WebKit::WebCursorInfo& cursor) = 0; - - // Returns the rectangle of the WebWidget in screen coordinates. - virtual void GetWindowRect(WebWidget* webwidget, WebKit::WebRect* rect) = 0; - - // This method is called to re-position the WebWidget on the screen. The given - // rect is in screen coordinates. The implementation may choose to ignore - // this call or modify the given rect. This method may be called before Show - // has been called. - // TODO(darin): this is more of a request; does this need to take effect - // synchronously? - virtual void SetWindowRect(WebWidget* webwidget, - const WebKit::WebRect& rect) = 0; - - // Returns the rectangle of the window in which this WebWidget is embeded. - virtual void GetRootWindowRect(WebWidget* webwidget, - WebKit::WebRect* rect) = 0; - - // Returns the resizer rectangle of the window this WebWidget is in. This - // is used on Mac to determine if a scrollbar is over the in-window resize - // area at the bottom right corner. - virtual void GetRootWindowResizerRect(WebWidget* webwidget, - WebKit::WebRect* rect) = 0; - - // Keeps track of the necessary window move for a plugin window that resulted - // from a scroll operation. That way, all plugin windows can be moved at the - // same time as each other and the page. - virtual void DidMove(WebWidget* webwidget, const WebPluginGeometry& move) = 0; - - // Suppress input events to other windows, and do not return until the widget - // is closed. This is used to support |window.showModalDialog|. - virtual void RunModal(WebWidget* webwidget) = 0; - - // Returns true if the widget is in a background tab. - virtual bool IsHidden(WebWidget* webwidget) = 0; - - // Returns information about the screen associated with this widget. - virtual WebKit::WebScreenInfo GetScreenInfo(WebWidget* webwidget) = 0; - - WebWidgetDelegate() { } - virtual ~WebWidgetDelegate() { } - - private: - DISALLOW_COPY_AND_ASSIGN(WebWidgetDelegate); -}; - -#endif // #ifndef WEBKIT_GLUE_WEBWIDGET_DELEGATE_H__ diff --git a/webkit/glue/webworker_impl.cc b/webkit/glue/webworker_impl.cc index c706524..c20b6839 100644 --- a/webkit/glue/webworker_impl.cc +++ b/webkit/glue/webworker_impl.cc @@ -34,6 +34,9 @@ #include "webkit/glue/webworker_impl.h" using WebKit::WebCursorInfo; +using WebKit::WebNavigationPolicy; +using WebKit::WebRect; +using WebKit::WebScreenInfo; using WebKit::WebString; using WebKit::WebURL; using WebKit::WebWorker; @@ -46,39 +49,33 @@ using WebKit::WebWorkerClient; class WorkerWebViewDelegate : public WebViewDelegate { public: WorkerWebViewDelegate() {} - virtual void Blur(WebWidget *webwidget) { } - virtual void CloseWidgetSoon(WebWidget *webwidget) { } - virtual void DidInvalidateRect(WebWidget *webwidget, - const WebKit::WebRect &rect) { } - virtual void DidMove(WebWidget *webwidget, const WebPluginGeometry &move) { } - virtual void DidScrollRect(WebWidget *webwidget, int dx, int dy, - const WebKit::WebRect &clip_rect) { } - virtual void Focus(WebWidget *webwidget) { } - virtual void GetRootWindowRect(WebWidget *webwidget, - WebKit::WebRect *rect) { } - virtual void GetRootWindowResizerRect(WebWidget *webwidget, - WebKit::WebRect *rect) { } - virtual WebKit::WebScreenInfo GetScreenInfo(WebWidget *webwidget) { - WebKit::WebScreenInfo info; - return info; - } - virtual void GetWindowRect(WebWidget *webwidget, WebKit::WebRect *rect) { } - virtual bool IsHidden(WebWidget *webwidget) { return true; } - virtual void RunModal(WebWidget *webwidget) { } - virtual void SetCursor(WebWidget *webwidget, const WebCursorInfo &cursor) { } - virtual void SetWindowRect(WebWidget *webwidget, - const WebKit::WebRect &rect) { } - virtual void Show(WebWidget *webwidget, WindowOpenDisposition disposition) { } + + virtual void didInvalidateRect(const WebRect&) {} + virtual void didScrollRect(int dx, int dy, const WebRect& clipRect) {} + virtual void didFocus() {} + virtual void didBlur() {} + virtual void didChangeCursor(const WebCursorInfo&) {} + virtual void closeWidgetSoon() {} + virtual void show(WebNavigationPolicy) {} + virtual void runModal() {} + virtual WebRect windowRect() { return WebRect(); } + virtual void setWindowRect(const WebRect&) {} + virtual WebRect windowResizerRect() { return WebRect(); } + virtual WebRect rootWindowRect() { return WebRect(); } + virtual WebScreenInfo screenInfo() { return WebScreenInfo(); } + // Tell the loader to load the data into the 'shadow page' synchronously, // so we can grab the resulting Document right after load. virtual void DidCreateDataSource(WebFrame* frame, WebKit::WebDataSource* ds) { static_cast<WebDataSourceImpl*>(ds)->setDeferMainResourceDataLoad(false); } + // Lazy allocate and leak this instance. static WorkerWebViewDelegate* worker_delegate() { static WorkerWebViewDelegate* worker_delegate = new WorkerWebViewDelegate(); return worker_delegate; } + private: DISALLOW_COPY_AND_ASSIGN(WorkerWebViewDelegate); }; @@ -116,7 +113,7 @@ WebWorkerImpl::WebWorkerImpl(WebWorkerClient* client) } WebWorkerImpl::~WebWorkerImpl() { - web_view_->Close(); + web_view_->close(); } void WebWorkerImpl::PostMessageToWorkerContextTask( diff --git a/webkit/glue/window_open_disposition.cc b/webkit/glue/window_open_disposition.cc new file mode 100644 index 0000000..417ab1a --- /dev/null +++ b/webkit/glue/window_open_disposition.cc @@ -0,0 +1,43 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/glue/window_open_disposition.h" + +#include "base/logging.h" + +// The macro dance here allows us to only express the mapping once. +#define MAPPINGS(MAP) \ + MAP(WebNavigationPolicyIgnore, IGNORE_ACTION) \ + MAP(WebNavigationPolicyDownload, SAVE_TO_DISK) \ + MAP(WebNavigationPolicyCurrentTab, CURRENT_TAB) \ + MAP(WebNavigationPolicyNewBackgroundTab, NEW_BACKGROUND_TAB) \ + MAP(WebNavigationPolicyNewForegroundTab, NEW_FOREGROUND_TAB) \ + MAP(WebNavigationPolicyNewWindow, NEW_WINDOW) \ + MAP(WebNavigationPolicyNewPopup, NEW_POPUP) + +#define POLICY_TO_DISPOSITION(policy, disposition) \ + case WebKit::policy: return disposition; + +WindowOpenDisposition NavigationPolicyToDisposition( + WebKit::WebNavigationPolicy policy) { + switch (policy) { + MAPPINGS(POLICY_TO_DISPOSITION) + default: + NOTREACHED() << "Unexpected WebNavigationPolicy"; + return IGNORE_ACTION; + } +} + +#define DISPOSITION_TO_POLICY(policy, disposition) \ + case disposition: return WebKit::policy; + +WebKit::WebNavigationPolicy DispositionToNavigationPolicy( + WindowOpenDisposition disposition) { + switch (disposition) { + MAPPINGS(DISPOSITION_TO_POLICY) + default: + NOTREACHED() << "Unexpected WindowOpenDisposition"; + return WebKit::WebNavigationPolicyIgnore; + } +} diff --git a/webkit/glue/window_open_disposition.h b/webkit/glue/window_open_disposition.h index b3096c7..23b59c0 100644 --- a/webkit/glue/window_open_disposition.h +++ b/webkit/glue/window_open_disposition.h @@ -5,6 +5,8 @@ #ifndef WEBKIT_GLUE_WINDOW_OPEN_DISPOSITION_H_ #define WEBKIT_GLUE_WINDOW_OPEN_DISPOSITION_H_ +#include "webkit/api/public/WebNavigationPolicy.h" + enum WindowOpenDisposition { SUPPRESS_OPEN, CURRENT_TAB, @@ -19,4 +21,10 @@ enum WindowOpenDisposition { IGNORE_ACTION }; +// Conversion functions: +WindowOpenDisposition NavigationPolicyToDisposition( + WebKit::WebNavigationPolicy policy); +//WebKit::WebNavigationPolicy DispositionToNavigationPolicy( +// WindowOpenDisposition disposition); + #endif // WEBKIT_GLUE_WINDOW_OPEN_DISPOSITION_H_ 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); } diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 9760266..5c9c718 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -996,6 +996,7 @@ 'api/public/WebClipboard.h', 'api/public/WebColor.h', 'api/public/WebCommon.h', + 'api/public/WebCompositionCommand.h', 'api/public/WebConsoleMessage.h', 'api/public/WebCString.h', 'api/public/WebCursorInfo.h', @@ -1017,12 +1018,14 @@ 'api/public/WebNonCopyable.h', 'api/public/WebPluginListBuilder.h', 'api/public/WebPoint.h', + 'api/public/WebPopupMenu.h', 'api/public/WebPopupMenuInfo.h', 'api/public/WebRect.h', 'api/public/WebScreenInfo.h', 'api/public/WebScriptSource.h', 'api/public/WebSize.h', 'api/public/WebString.h', + 'api/public/WebTextDirection.h', 'api/public/WebURL.h', 'api/public/WebURLError.h', 'api/public/WebURLLoader.h', @@ -1030,6 +1033,8 @@ 'api/public/WebURLRequest.h', 'api/public/WebURLResponse.h', 'api/public/WebVector.h', + 'api/public/WebWidget.h', + 'api/public/WebWidgetClient.h', 'api/public/win/WebInputEventFactory.h', 'api/public/win/WebSandboxSupport.h', 'api/public/win/WebScreenInfoFactory.h', @@ -1400,6 +1405,8 @@ 'glue/webplugin_impl.cc', 'glue/webplugin_impl.h', 'glue/webplugininfo.h', + 'glue/webpopupmenu_impl.cc', + 'glue/webpopupmenu_impl.h', 'glue/webpreferences.h', 'glue/webtextinput.h', 'glue/webtextinput_impl.cc', @@ -1412,15 +1419,12 @@ 'glue/webview_delegate.h', 'glue/webview_impl.cc', 'glue/webview_impl.h', - 'glue/webwidget.h', - 'glue/webwidget_delegate.h', - 'glue/webwidget_impl.cc', - 'glue/webwidget_impl.h', 'glue/webworker_impl.cc', 'glue/webworker_impl.h', 'glue/webworkerclient_impl.cc', 'glue/webworkerclient_impl.h', 'glue/window_open_disposition.h', + 'glue/window_open_disposition.cc', ], # When glue is a dependency, it needs to be a hard dependency. # Dependents may rely on files generated by this target or one of its |