summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 05:11:05 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 05:11:05 +0000
commit05158051ea881677c03a22ddf38a3e6779cebb9e (patch)
tree95c6756227e0bbea55da3c4b19abdf99d7eb3ebe /webkit/glue
parent6c14b76fede6abc592d9d65965fbdf4626e83efe (diff)
downloadchromium_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/glue')
-rw-r--r--webkit/glue/chrome_client_impl.cc51
-rw-r--r--webkit/glue/chromium_bridge_impl.cc53
-rw-r--r--webkit/glue/context_menu_unittest.cc4
-rw-r--r--webkit/glue/inspector_client_impl.cc2
-rw-r--r--webkit/glue/webframeloaderclient_impl.cc68
-rw-r--r--webkit/glue/webframeloaderclient_impl.h19
-rw-r--r--webkit/glue/webplugin_impl.cc4
-rw-r--r--webkit/glue/webpopupmenu_impl.cc (renamed from webkit/glue/webwidget_impl.cc)135
-rw-r--r--webkit/glue/webpopupmenu_impl.h (renamed from webkit/glue/webwidget_impl.h)69
-rw-r--r--webkit/glue/webtextdirection.h22
-rw-r--r--webkit/glue/webview.h4
-rw-r--r--webkit/glue/webview_delegate.h40
-rw-r--r--webkit/glue/webview_impl.cc305
-rw-r--r--webkit/glue/webview_impl.h51
-rw-r--r--webkit/glue/webwidget.h80
-rw-r--r--webkit/glue/webwidget_delegate.h102
-rw-r--r--webkit/glue/webworker_impl.cc45
-rw-r--r--webkit/glue/window_open_disposition.cc43
-rw-r--r--webkit/glue/window_open_disposition.h8
19 files changed, 487 insertions, 618 deletions
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_