summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 05:33:47 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 05:33:47 +0000
commitcf13bb696f6a50b06930ed8fabb0984cd6af7be9 (patch)
treea883217d4a1eee49750954f851188c5ca6fa6308 /webkit
parent05158051ea881677c03a22ddf38a3e6779cebb9e (diff)
downloadchromium_src-cf13bb696f6a50b06930ed8fabb0984cd6af7be9.zip
chromium_src-cf13bb696f6a50b06930ed8fabb0984cd6af7be9.tar.gz
chromium_src-cf13bb696f6a50b06930ed8fabb0984cd6af7be9.tar.bz2
Reverting 20854.
Review URL: http://codereview.chromium.org/155621 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/api/public/WebCompositionCommand.h8
-rw-r--r--webkit/api/public/WebNavigationPolicy.h12
-rw-r--r--webkit/api/public/WebPopupMenu.h11
-rw-r--r--webkit/api/public/WebTextDirection.h10
-rw-r--r--webkit/api/public/WebWidget.h16
-rw-r--r--webkit/api/public/WebWidgetClient.h39
-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/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/webwidget_impl.cc (renamed from webkit/glue/webpopupmenu_impl.cc)135
-rw-r--r--webkit/glue/webwidget_impl.h (renamed from webkit/glue/webpopupmenu_impl.h)69
-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
-rw-r--r--webkit/tools/test_shell/event_sending_controller.cc33
-rw-r--r--webkit/tools/test_shell/mac/test_webview_delegate.mm60
-rw-r--r--webkit/tools/test_shell/mac/webview_host.mm2
-rw-r--r--webkit/tools/test_shell/mac/webwidget_host.mm31
-rw-r--r--webkit/tools/test_shell/plugin_tests.cc2
-rw-r--r--webkit/tools/test_shell/test_shell.cc19
-rw-r--r--webkit/tools/test_shell/test_shell.h10
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc4
-rw-r--r--webkit/tools/test_shell/test_shell_mac.mm5
-rw-r--r--webkit/tools/test_shell/test_shell_main.cc2
-rw-r--r--webkit/tools/test_shell/test_shell_test.cc2
-rw-r--r--webkit/tools/test_shell/test_shell_win.cc4
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc56
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h50
-rw-r--r--webkit/tools/test_shell/test_webview_delegate_gtk.cc56
-rw-r--r--webkit/tools/test_shell/test_webview_delegate_win.cc109
-rw-r--r--webkit/tools/test_shell/webview_host_gtk.cc2
-rw-r--r--webkit/tools/test_shell/webwidget_host.h11
-rw-r--r--webkit/tools/test_shell/webwidget_host_gtk.cc38
-rw-r--r--webkit/tools/test_shell/webwidget_host_win.cc27
-rw-r--r--webkit/webkit.gyp12
46 files changed, 939 insertions, 797 deletions
diff --git a/webkit/api/public/WebCompositionCommand.h b/webkit/api/public/WebCompositionCommand.h
index a7be66c..d7acbfd 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,6 +31,8 @@
#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 14f72da..707f56d 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,6 +31,8 @@
#ifndef WebNavigationPolicy_h
#define WebNavigationPolicy_h
+#error "This header file is still a work in progress; do not include!"
+
namespace WebKit {
enum WebNavigationPolicy {
@@ -39,8 +41,8 @@ namespace WebKit {
WebNavigationPolicyCurrentTab,
WebNavigationPolicyNewBackgroundTab,
WebNavigationPolicyNewForegroundTab,
- WebNavigationPolicyNewWindow,
- WebNavigationPolicyNewPopup,
+ WebNavigationPolicyNewForegroundTabInNewWindow,
+ WebNavigationPolicyNewPopupWindow,
};
} // namespace WebKit
diff --git a/webkit/api/public/WebPopupMenu.h b/webkit/api/public/WebPopupMenu.h
index 65f2cc4..521ecec 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,11 +31,12 @@
#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:
@@ -43,5 +44,3 @@ namespace WebKit {
};
} // namespace WebKit
-
-#endif
diff --git a/webkit/api/public/WebTextDirection.h b/webkit/api/public/WebTextDirection.h
index 901a700..8136402 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,11 +31,13 @@
#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, // Natural writing direction ("inherit")
+ WebTextDirectionDefault,
WebTextDirectionLeftToRight,
WebTextDirectionRightToLeft,
};
diff --git a/webkit/api/public/WebWidget.h b/webkit/api/public/WebWidget.h
index 262ac79..30f0601 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,16 +31,12 @@
#ifndef WebWidget_h
#define WebWidget_h
-#include "WebCanvas.h"
+#error "This header file is still a work in progress; do not include!"
+
#include "WebCommon.h"
-#include "WebCompositionCommand.h"
#include "WebTextDirection.h"
namespace WebKit {
- class WebInputEvent;
- class WebString;
- struct WebRect;
- struct WebSize;
class WebWidget {
public:
@@ -67,7 +63,7 @@ namespace WebKit {
// Called to inform the WebWidget of an input event. Returns true if
// the event has been processed, false otherwise.
- virtual bool handleInputEvent(const WebInputEvent&) = 0;
+ virtual void 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 7ac0a6a..02815e7 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,56 +31,63 @@
#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(const WebRect&) = 0;
+ virtual void didInvalidateRect(WebWidget*, 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(int dx, int dy, const WebRect& clipRect) = 0;
+ 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;
// Called when the widget acquires or loses focus, respectively.
- virtual void didFocus() = 0;
- virtual void didBlur() = 0;
+ virtual void didFocus(WebWidget*) = 0;
+ virtual void didBlur(WebWidget*) = 0;
// Called when the cursor for the widget changes.
- virtual void didChangeCursor(const WebCursorInfo&) = 0;
+ virtual void didChangeCursor(WebWidget*, 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() = 0;
+ virtual void closeWidgetSoon(WebWidget*) = 0;
// Called to show the widget according to the given policy.
- virtual void show(WebNavigationPolicy) = 0;
+ virtual void show(WebWidget*, WebNavigationPolicy) = 0;
// Called to block execution of the current thread until the widget is
// closed.
- virtual void runModal() = 0;
+ virtual void runModal(WebWidget*) = 0;
// Called to get/set the position of the widget in screen coordinates.
- virtual WebRect windowRect() = 0;
- virtual void setWindowRect(const WebRect&) = 0;
+ virtual WebRect windowRect(WebWidget*) = 0;
+ virtual void setWindowRect(WebWidget*, const WebRect&) = 0;
// Called to get the position of the resizer rect in window coordinates.
- virtual WebRect windowResizerRect() = 0;
+ virtual WebRect windowResizerRect(WebWidget*) = 0;
// Called to get the position of the root window containing the widget
// in screen coordinates.
- virtual WebRect rootWindowRect() = 0;
+ virtual WebRect rootWindowRect(WebWidget*) = 0;
// Called to query information about the screen where this widget is
// displayed.
- virtual WebScreenInfo screenInfo() = 0;
+ virtual WebScreenInfo screenInfo(WebWidget*) = 0;
};
} // namespace WebKit
diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc
index d6f4fda..4c233f2 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,12 +56,10 @@ 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
@@ -112,15 +110,16 @@ void ChromeClientImpl::chromeDestroyed() {
void ChromeClientImpl::setWindowRect(const WebCore::FloatRect& r) {
WebViewDelegate* delegate = webview_->delegate();
if (delegate) {
- delegate->setWindowRect(
- webkit_glue::IntRectToWebRect(WebCore::IntRect(r)));
+ WebCore::IntRect ir(r);
+ delegate->SetWindowRect(webview_,
+ gfx::Rect(ir.x(), ir.y(), ir.width(), ir.height()));
}
}
WebCore::FloatRect ChromeClientImpl::windowRect() {
WebRect rect;
if (webview_->delegate()) {
- rect = webview_->delegate()->rootWindowRect();
+ webview_->delegate()->GetRootWindowRect(webview_, &rect);
} 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
@@ -128,7 +127,10 @@ WebCore::FloatRect ChromeClientImpl::windowRect() {
rect.width = webview_->size().width;
rect.height = webview_->size().height;
}
- return WebCore::FloatRect(webkit_glue::WebRectToIntRect(rect));
+ return WebCore::FloatRect(static_cast<float>(rect.x),
+ static_cast<float>(rect.y),
+ static_cast<float>(rect.width),
+ static_cast<float>(rect.height));
}
WebCore::FloatRect ChromeClientImpl::pageRect() {
@@ -152,7 +154,7 @@ float ChromeClientImpl::scaleFactor() {
void ChromeClientImpl::focus() {
WebViewDelegate* delegate = webview_->delegate();
if (delegate)
- delegate->didFocus();
+ delegate->Focus(webview_);
// If accessibility is enabled, we should notify assistive technology that the
// active AccessibilityObject changed.
@@ -180,7 +182,7 @@ void ChromeClientImpl::focus() {
void ChromeClientImpl::unfocus() {
WebViewDelegate* delegate = webview_->delegate();
if (delegate)
- delegate->didBlur();
+ delegate->Blur(webview_);
}
bool ChromeClientImpl::canTakeFocus(WebCore::FocusDirection) {
@@ -255,13 +257,13 @@ void ChromeClientImpl::show() {
!resizable_ ||
!delegate->WasOpenedByUserGesture();
- WebNavigationPolicy policy = WebKit::WebNavigationPolicyNewForegroundTab;
+ WindowOpenDisposition disposition = NEW_FOREGROUND_TAB;
if (as_popup)
- policy = WebKit::WebNavigationPolicyNewPopup;
+ disposition = NEW_POPUP;
if (CurrentEventShouldCauseBackgroundTab(WebViewImpl::current_input_event()))
- policy = WebKit::WebNavigationPolicyNewBackgroundTab;
+ disposition = NEW_BACKGROUND_TAB;
- delegate->show(policy);
+ delegate->Show(webview_, disposition);
}
}
@@ -272,7 +274,7 @@ bool ChromeClientImpl::canRunModal() {
void ChromeClientImpl::runModal() {
WebViewDelegate* delegate = webview_->delegate();
if (delegate)
- delegate->runModal();
+ delegate->RunModal(webview_);
}
void ChromeClientImpl::setToolbarsVisible(bool value) {
@@ -355,7 +357,7 @@ void ChromeClientImpl::closeWindowSoon() {
WebViewDelegate* delegate = webview_->delegate();
if (delegate)
- delegate->closeWidgetSoon();
+ delegate->CloseWidgetSoon(webview_);
}
// Although a WebCore::Frame is passed in, we don't actually use it, since we
@@ -432,8 +434,9 @@ bool ChromeClientImpl::tabsToLinks() const {
WebCore::IntRect ChromeClientImpl::windowResizerRect() const {
WebCore::IntRect result;
if (webview_->delegate()) {
- result = webkit_glue::WebRectToIntRect(
- webview_->delegate()->windowResizerRect());
+ WebRect resizer_rect;
+ webview_->delegate()->GetRootWindowResizerRect(webview_, &resizer_rect);
+ result = webkit_glue::WebRectToIntRect(resizer_rect);
}
return result;
}
@@ -446,7 +449,8 @@ void ChromeClientImpl::repaint(
return;
WebViewDelegate* delegate = webview_->delegate();
if (delegate)
- delegate->didInvalidateRect(webkit_glue::IntRectToWebRect(paint_rect));
+ delegate->DidInvalidateRect(webview_,
+ webkit_glue::IntRectToWebRect(paint_rect));
}
void ChromeClientImpl::scroll(
@@ -456,8 +460,8 @@ void ChromeClientImpl::scroll(
if (delegate) {
int dx = scroll_delta.width();
int dy = scroll_delta.height();
- delegate->didScrollRect(
- dx, dy, webkit_glue::IntRectToWebRect(clip_rect));
+ delegate->DidScrollRect(webview_, dx, dy,
+ webkit_glue::IntRectToWebRect(clip_rect));
}
}
@@ -473,7 +477,8 @@ WebCore::IntRect ChromeClientImpl::windowToScreen(
WebViewDelegate* delegate = webview_->delegate();
if (delegate) {
- WebRect window_rect = delegate->windowRect();
+ WebRect window_rect;
+ delegate->GetWindowRect(webview_, &window_rect);
screen_rect.move(window_rect.x, window_rect.y);
}
@@ -562,7 +567,7 @@ void ChromeClientImpl::popupOpened(PopupContainer* popup_container,
webwidget = delegate->CreatePopupWidget(webview_, activatable);
}
- static_cast<WebPopupMenuImpl*>(webwidget)->Init(
+ static_cast<WebWidgetImpl*>(webwidget)->Init(
popup_container, webkit_glue::IntRectToWebRect(bounds));
}
@@ -574,7 +579,7 @@ void ChromeClientImpl::SetCursor(const WebCursorInfo& cursor) {
WebViewDelegate* delegate = webview_->delegate();
if (delegate)
- delegate->didChangeCursor(cursor);
+ delegate->SetCursor(webview_, cursor);
}
void ChromeClientImpl::SetCursorForPlugin(const WebCursorInfo& cursor) {
diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc
index 04acbd8..e033fcb 100644
--- a/webkit/glue/chromium_bridge_impl.cc
+++ b/webkit/glue/chromium_bridge_impl.cc
@@ -47,7 +47,6 @@
#endif
using WebKit::WebCursorInfo;
-using WebKit::WebWidgetClient;
namespace {
@@ -74,11 +73,11 @@ ChromeClientImpl* ToChromeClient(WebCore::Widget* widget) {
return static_cast<ChromeClientImpl*>(page->chrome()->client());
}
-WebWidgetClient* ToWebWidgetClient(WebCore::Widget* widget) {
+WebViewImpl* ToWebView(WebCore::Widget* widget) {
ChromeClientImpl* chrome_client = ToChromeClient(widget);
- if (!chrome_client || !chrome_client->webview())
+ if (!chrome_client)
return NULL;
- return chrome_client->webview()->delegate();
+ return chrome_client->webview();
}
WebCore::IntRect ToIntRect(const WebKit::WebRect& input) {
@@ -96,10 +95,14 @@ void ChromiumBridge::notifyJSOutOfMemory(Frame* frame) {
return;
// Dispatch to the delegate of the view that owns the frame.
- WebViewImpl* webview = WebFrameImpl::FromFrame(frame)->GetWebViewImpl();
- if (!webview || !webview->delegate())
+ WebFrame* webframe = WebFrameImpl::FromFrame(frame);
+ WebView* webview = webframe->GetView();
+ if (!webview)
return;
- webview->delegate()->JSOutOfMemory();
+ WebViewDelegate* delegate = webview->GetDelegate();
+ if (!delegate)
+ return;
+ delegate->JSOutOfMemory();
}
// Plugin ---------------------------------------------------------------------
@@ -135,38 +138,38 @@ String ChromiumBridge::uiResourceProtocol() {
// Screen ---------------------------------------------------------------------
int ChromiumBridge::screenDepth(Widget* widget) {
- WebWidgetClient* client = ToWebWidgetClient(widget);
- if (!client)
- return 0;
- return client->screenInfo().depth;
+ WebViewImpl* view = ToWebView(widget);
+ if (!view || !view->delegate())
+ return NULL;
+ return view->delegate()->GetScreenInfo(view).depth;
}
int ChromiumBridge::screenDepthPerComponent(Widget* widget) {
- WebWidgetClient* client = ToWebWidgetClient(widget);
- if (!client)
- return 0;
- return client->screenInfo().depthPerComponent;
+ WebViewImpl* view = ToWebView(widget);
+ if (!view || !view->delegate())
+ return NULL;
+ return view->delegate()->GetScreenInfo(view).depthPerComponent;
}
bool ChromiumBridge::screenIsMonochrome(Widget* widget) {
- WebWidgetClient* client = ToWebWidgetClient(widget);
- if (!client)
- return false;
- return client->screenInfo().isMonochrome;
+ WebViewImpl* view = ToWebView(widget);
+ if (!view || !view->delegate())
+ return NULL;
+ return view->delegate()->GetScreenInfo(view).isMonochrome;
}
IntRect ChromiumBridge::screenRect(Widget* widget) {
- WebWidgetClient* client = ToWebWidgetClient(widget);
- if (!client)
+ WebViewImpl* view = ToWebView(widget);
+ if (!view || !view->delegate())
return IntRect();
- return ToIntRect(client->screenInfo().rect);
+ return ToIntRect(view->delegate()->GetScreenInfo(view).rect);
}
IntRect ChromiumBridge::screenAvailableRect(Widget* widget) {
- WebWidgetClient* client = ToWebWidgetClient(widget);
- if (!client)
+ WebViewImpl* view = ToWebView(widget);
+ if (!view || !view->delegate())
return IntRect();
- return ToIntRect(client->screenInfo().availableRect);
+ return ToIntRect(view->delegate()->GetScreenInfo(view).availableRect);
}
// Widget ---------------------------------------------------------------------
diff --git a/webkit/glue/context_menu_unittest.cc b/webkit/glue/context_menu_unittest.cc
index 0905a97..8e62c2c 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 493a646..1e9873a 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(damaged_rect);
+ web_view->GetDelegate()->DidInvalidateRect(web_view, damaged_rect);
}
void WebInspectorClient::highlight(Node* node) {
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc
index ffafec3..19f1096 100644
--- a/webkit/glue/webframeloaderclient_impl.cc
+++ b/webkit/glue/webframeloaderclient_impl.cc
@@ -73,7 +73,6 @@ using base::TimeDelta;
using WebKit::WebData;
using WebKit::WebNavigationType;
-using WebKit::WebNavigationPolicy;
using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebVector;
@@ -96,7 +95,7 @@ WebFrameLoaderClient::WebFrameLoaderClient(WebFrameImpl* frame) :
postpone_loading_data_(false),
has_representation_(false),
sent_initial_response_to_plugin_(false),
- next_navigation_policy_(WebKit::WebNavigationPolicyIgnore) {
+ next_window_open_disposition_(IGNORE_ACTION) {
}
WebFrameLoaderClient::~WebFrameLoaderClient() {
@@ -811,15 +810,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_navigation_policy_ != WebKit::WebNavigationPolicyIgnore);
- WebNavigationPolicy policy = next_navigation_policy_;
- next_navigation_policy_ = WebKit::WebNavigationPolicyIgnore;
+ DCHECK(next_window_open_disposition_ != IGNORE_ACTION);
+ WindowOpenDisposition disp = next_window_open_disposition_;
+ next_window_open_disposition_ = IGNORE_ACTION;
// createWindow can return NULL (e.g., popup blocker denies the window).
if (!new_page)
return NULL;
- WebViewImpl::FromPage(new_page)->set_initial_navigation_policy(policy);
+ WebViewImpl::FromPage(new_page)->set_window_open_disposition(disp);
return new_page->mainFrame();
}
@@ -827,7 +826,7 @@ void WebFrameLoaderClient::dispatchShow() {
WebViewImpl* webview = webframe_->GetWebViewImpl();
WebViewDelegate* d = webview->delegate();
if (d)
- d->show(webview->initial_navigation_policy());
+ d->Show(webview, webview->window_open_disposition());
}
static bool TreatAsAttachment(const ResourceResponse& response) {
@@ -897,12 +896,12 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(
const WebCore::ResourceRequest& request,
PassRefPtr<WebCore::FormState> form_state,
const WebCore::String& frame_name) {
- WebNavigationPolicy navigation_policy;
- if (!ActionSpecifiesNavigationPolicy(action, &navigation_policy))
- navigation_policy = WebKit::WebNavigationPolicyNewForegroundTab;
+ WindowOpenDisposition disposition;
+ if (!ActionSpecifiesDisposition(action, &disposition))
+ disposition = NEW_FOREGROUND_TAB;
PolicyAction policy_action;
- if (navigation_policy == WebKit::WebNavigationPolicyDownload) {
+ if (disposition == SAVE_TO_DISK) {
policy_action = PolicyDownload;
} else {
policy_action = PolicyUse;
@@ -911,7 +910,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_navigation_policy_ = navigation_policy;
+ next_window_open_disposition_ = disposition;
}
(webframe_->frame()->loader()->*function)(policy_action);
}
@@ -930,42 +929,40 @@ 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()) {
- WebNavigationPolicy navigation_policy =
- WebKit::WebNavigationPolicyCurrentTab;
- ActionSpecifiesNavigationPolicy(action, &navigation_policy);
+ WindowOpenDisposition disposition = CURRENT_TAB;
+ ActionSpecifiesDisposition(action, &disposition);
- // Give the delegate a chance to change the navigation policy.
+ // Give the delegate a chance to change the disposition.
const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl();
if (ds) {
GURL url = ds->request().url();
if (url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)) {
HandleBackForwardNavigation(url);
- navigation_policy = WebKit::WebNavigationPolicyIgnore;
+ disposition = IGNORE_ACTION;
} else {
bool is_redirect = ds->HasRedirectChain();
WebNavigationType webnav_type =
WebDataSourceImpl::NavigationTypeToWebNavigationType(action.type());
- navigation_policy = d->PolicyForNavigationAction(
- wv, webframe_, ds->request(), webnav_type, navigation_policy,
- is_redirect);
+ disposition = d->DispositionForNavigationAction(
+ wv, webframe_, ds->request(), webnav_type, disposition, is_redirect);
}
}
- if (navigation_policy == WebKit::WebNavigationPolicyCurrentTab) {
+ if (disposition == CURRENT_TAB) {
policy_action = PolicyUse;
- } else if (navigation_policy == WebKit::WebNavigationPolicyDownload) {
+ } else if (disposition == SAVE_TO_DISK) {
policy_action = PolicyDownload;
} else {
- if (navigation_policy != WebKit::WebNavigationPolicyIgnore) {
+ if (disposition != IGNORE_ACTION) {
GURL referrer = webkit_glue::StringToGURL(
request.httpHeaderField("Referer"));
d->OpenURL(webframe_->GetWebViewImpl(),
webkit_glue::KURLToGURL(request.url()),
referrer,
- navigation_policy);
+ disposition);
}
policy_action = PolicyIgnore;
}
@@ -1478,9 +1475,9 @@ String WebFrameLoaderClient::overrideMediaType() const {
return rv;
}
-bool WebFrameLoaderClient::ActionSpecifiesNavigationPolicy(
+bool WebFrameLoaderClient::ActionSpecifiesDisposition(
const WebCore::NavigationAction& action,
- WebNavigationPolicy* policy) {
+ WindowOpenDisposition* disposition) {
if ((action.type() != NavigationTypeLinkClicked) ||
!action.event()->isMouseEvent())
return false;
@@ -1496,20 +1493,11 @@ bool WebFrameLoaderClient::ActionSpecifiesNavigationPolicy(
if (!new_tab_modifier && !shift && !alt)
return false;
- 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;
- }
- }
+ DCHECK(disposition);
+ if (new_tab_modifier)
+ *disposition = shift ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB;
+ else
+ *disposition = shift ? NEW_WINDOW : SAVE_TO_DISK;
return true;
}
diff --git a/webkit/glue/webframeloaderclient_impl.h b/webkit/glue/webframeloaderclient_impl.h
index e031fae..80e5d3b 100644
--- a/webkit/glue/webframeloaderclient_impl.h
+++ b/webkit/glue/webframeloaderclient_impl.h
@@ -5,13 +5,18 @@
#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;
@@ -212,11 +217,11 @@ class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
private:
void makeDocumentView();
- // Given a NavigationAction, determine the associated WebNavigationPolicy.
- // For example, a middle click means "open in background tab".
- static bool ActionSpecifiesNavigationPolicy(
+ // Given a NavigationAction, determine the associated window opening
+ // disposition. For example, a middle click means "open in background tab".
+ static bool ActionSpecifiesDisposition(
const WebCore::NavigationAction& action,
- WebKit::WebNavigationPolicy* policy);
+ WindowOpenDisposition* disposition);
// Returns a valid GURL if we have an alt 404 server URL.
GURL GetAlt404PageUrl(WebCore::DocumentLoader* loader);
@@ -259,8 +264,8 @@ class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
// which specifies that the plugin should be ready to accept data.
bool sent_initial_response_to_plugin_;
- // The navigation policy to use for the next call to dispatchCreatePage.
- WebKit::WebNavigationPolicy next_navigation_policy_;
+ // The disposition to use for the next call to dispatchCreatePage.
+ WindowOpenDisposition next_window_open_disposition_;
};
#endif // #ifndef WEBKIT_GLUE_WEBFRAMELOADERCLIENT_IMPL_H__
diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc
index 826bfb9..83ee2bc 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()->DidMovePlugin(move);
+ webview->delegate()->DidMove(webview, 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()->DidMovePlugin(move);
+ webview->delegate()->DidMove(webview, move);
}
diff --git a/webkit/glue/webtextdirection.h b/webkit/glue/webtextdirection.h
new file mode 100644
index 0000000..822eb34
--- /dev/null
+++ b/webkit/glue/webtextdirection.h
@@ -0,0 +1,22 @@
+// 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 81d0094..7468e0a 100644
--- a/webkit/glue/webview.h
+++ b/webkit/glue/webview.h
@@ -9,7 +9,7 @@
#include <vector>
#include "base/basictypes.h"
-#include "webkit/api/public/WebWidget.h"
+#include "webkit/glue/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 WebKit::WebWidget {
+class WebView : public WebWidget {
public:
WebView() {}
virtual ~WebView() {}
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index e41a7bf..1ccc761 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -29,10 +29,9 @@
#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;
@@ -52,13 +51,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;
@@ -66,8 +65,7 @@ class WebFrame;
class WebMediaPlayerDelegate;
class WebPluginDelegate;
class WebView;
-struct WebPluginGeometry;
-struct WebPreferences;
+class WebWidget;
enum NavigationGesture {
NavigationGestureUser, // User initiated navigation/load. This is not
@@ -98,8 +96,8 @@ class WebFileChooserCallback {
// Inheritance here is somewhat weird, but since a WebView is a WebWidget,
-// it makes sense that a WebViewDelegate is a WebWidgetClient.
-class WebViewDelegate : virtual public WebKit::WebWidgetClient {
+// it makes sense that a WebViewDelegate is a WebWidgetDelegate.
+class WebViewDelegate : virtual public WebWidgetDelegate {
public:
// WebView additions -------------------------------------------------------
@@ -118,15 +116,13 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient {
// This method is called to create a new WebWidget to act as a popup
// (like a drop-down menu).
- virtual WebKit::WebWidget* CreatePopupWidget(
- WebView* webview,
- bool activatable) {
+ virtual WebWidget* CreatePopupWidget(WebView* webview, bool activatable) {
return NULL;
}
// Like CreatePopupWidget, except the actual widget is rendered by the
// embedder using the supplied info.
- virtual WebKit::WebWidget* CreatePopupWidgetWithInfo(
+ virtual WebWidget* CreatePopupWidgetWithInfo(
WebView* webview,
const WebKit::WebPopupMenuInfo& info) {
return NULL;
@@ -168,7 +164,7 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient {
// This method is called to open a URL in the specified manner.
virtual void OpenURL(WebView* webview, const GURL& url,
const GURL& referrer,
- WebKit::WebNavigationPolicy policy) {
+ WindowOpenDisposition disposition) {
}
// Notifies how many matches have been found so far, for a given request_id.
@@ -201,12 +197,6 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient {
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 {
@@ -258,20 +248,20 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient {
// proposed navigation. It will be called before loading starts, and
// on every redirect.
//
- // default_policy specifies what should normally happen for this
+ // disposition 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 policy, and
+ // window, etc). This method can return an altered disposition, and
// take any additional separate action it wants to.
//
// is_redirect is true if this is a redirect rather than user action.
- virtual WebKit::WebNavigationPolicy PolicyForNavigationAction(
+ virtual WindowOpenDisposition DispositionForNavigationAction(
WebView* webview,
WebFrame* frame,
const WebKit::WebURLRequest& request,
WebKit::WebNavigationType type,
- WebKit::WebNavigationPolicy default_policy,
+ WindowOpenDisposition disposition,
bool is_redirect) {
- return default_policy;
+ return disposition;
}
// FrameLoadDelegate -------------------------------------------------------
@@ -535,8 +525,8 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient {
const std::wstring& value) {
}
- virtual void DidContentsSizeChange(WebKit::WebWidget* webwidget,
- int new_width, int new_height) {
+ virtual void DidContentsSizeChange(WebWidget* webwidget, int new_width,
+ int new_height) {
}
// UIDelegate --------------------------------------------------------------
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 29152bd..a29836d 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -91,7 +91,6 @@ 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"
@@ -106,12 +105,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
@@ -119,10 +118,6 @@ 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;
@@ -131,11 +126,6 @@ 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;
@@ -384,7 +374,7 @@ WebViewImpl::WebViewImpl()
doing_drag_and_drop_(false),
ignore_input_events_(false),
suppress_next_keypress_event_(false),
- initial_navigation_policy_(WebKit::WebNavigationPolicyIgnore),
+ window_open_disposition_(IGNORE_ACTION),
ime_accept_events_(true),
drag_target_dispatch_(false),
drag_identity_(0),
@@ -542,7 +532,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));
@@ -925,9 +915,20 @@ WebViewImpl* WebViewImpl::FromPage(WebCore::Page* page) {
return WebFrameImpl::FromFrame(page->mainFrame())->GetWebViewImpl();
}
-// WebWidget ------------------------------------------------------------------
+// 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;
-void WebViewImpl::close() {
+ return frame->shouldClose();
+}
+
+void WebViewImpl::Close() {
if (page_.get()) {
// Initiate shutdown for the entire frameset. This will cause a lot of
// notifications to be sent.
@@ -947,7 +948,57 @@ void WebViewImpl::close() {
Release(); // Balances AddRef from WebView::Create
}
-void WebViewImpl::resize(const WebSize& new_size) {
+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) {
if (size_ == new_size)
return;
size_ = new_size;
@@ -959,11 +1010,11 @@ void WebViewImpl::resize(const WebSize& new_size) {
if (delegate_) {
WebRect damaged_rect(0, 0, size_.width, size_.height);
- delegate_->didInvalidateRect(damaged_rect);
+ delegate_->DidInvalidateRect(this, damaged_rect);
}
}
-void WebViewImpl::layout() {
+void WebViewImpl::Layout() {
WebFrameImpl* webframe = main_frame();
if (webframe) {
// In order for our child HWNDs (NativeWindowWidgets) to update properly,
@@ -983,7 +1034,7 @@ void WebViewImpl::layout() {
}
}
-void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) {
+void WebViewImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) {
WebFrameImpl* webframe = main_frame();
if (webframe)
webframe->Paint(canvas, rect);
@@ -994,7 +1045,7 @@ void WebViewImpl::paint(WebCanvas* 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_)
@@ -1009,42 +1060,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;
@@ -1055,10 +1106,53 @@ bool WebViewImpl::handleInputEvent(const WebInputEvent& input_event) {
return handled;
}
-void WebViewImpl::mouseCaptureLost() {
+void WebViewImpl::MouseCaptureLost() {
}
-void WebViewImpl::setFocus(bool enable) {
+// 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) {
page_->focusController()->setFocused(enable);
if (enable) {
// Note that we don't call setActive() when disabled as this cause extra
@@ -1087,11 +1181,11 @@ void WebViewImpl::setFocus(bool enable) {
}
}
-bool WebViewImpl::handleCompositionEvent(WebCompositionCommand command,
- int cursor_position,
- int target_start,
- int target_end,
- const WebString& ime_string) {
+bool WebViewImpl::ImeSetComposition(int string_type,
+ int cursor_position,
+ int target_start,
+ int target_end,
+ const std::wstring& ime_string) {
Frame* focused = GetFocusedWebCoreFrame();
if (!focused || !ime_accept_events_) {
return false;
@@ -1118,7 +1212,7 @@ bool WebViewImpl::handleCompositionEvent(WebCompositionCommand command,
return false;
}
- if (command == WebCompositionCommandDiscard) {
+ if (string_type == -1) {
// 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
@@ -1131,12 +1225,10 @@ bool WebViewImpl::handleCompositionEvent(WebCompositionCommand command,
// 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::WebStringToString(ime_string));
+ webkit_glue::StdWStringToString(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.
@@ -1163,15 +1255,16 @@ bool WebViewImpl::handleCompositionEvent(WebCompositionCommand command,
// 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 (command == WebCompositionCommandConfirm)
+ if (string_type == 1) {
editor->confirmComposition();
+ }
}
return editor->hasComposition();
}
-bool WebViewImpl::queryCompositionStatus(bool* enable_ime,
- WebRect* caret_rect) {
+bool WebViewImpl::ImeUpdateStatus(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;
@@ -1206,7 +1299,7 @@ bool WebViewImpl::queryCompositionStatus(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.
@@ -1220,15 +1313,15 @@ void WebViewImpl::setTextDirection(WebTextDirection direction) {
return;
switch (direction) {
- case WebTextDirectionDefault:
+ case WEB_TEXT_DIRECTION_DEFAULT:
editor->setBaseWritingDirection(WebCore::NaturalWritingDirection);
break;
- case WebTextDirectionLeftToRight:
+ case WEB_TEXT_DIRECTION_LTR:
editor->setBaseWritingDirection(WebCore::LeftToRightWritingDirection);
break;
- case WebTextDirectionRightToLeft:
+ case WEB_TEXT_DIRECTION_RTL:
editor->setBaseWritingDirection(WebCore::RightToLeftWritingDirection);
break;
@@ -1238,112 +1331,6 @@ 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.
@@ -1879,10 +1866,10 @@ void WebViewImpl::RefreshAutofillPopup() {
IntRect new_bounds = autocomplete_popup_->boundsRect();
// Let's resize the backing window if necessary.
if (old_bounds != new_bounds) {
- WebPopupMenuImpl* popup_menu =
- static_cast<WebPopupMenuImpl*>(autocomplete_popup_->client());
- popup_menu->client()->setWindowRect(
- webkit_glue::IntRectToWebRect(new_bounds));
+ WebWidgetImpl* web_widget =
+ static_cast<WebWidgetImpl*>(autocomplete_popup_->client());
+ web_widget->delegate()->SetWindowRect(
+ web_widget, webkit_glue::IntRectToWebRect(new_bounds));
}
}
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index 6c2f883..d55df1a 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -49,27 +49,9 @@ class WebViewDelegate;
class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
public:
- // 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:
+ // WebView
virtual bool ShouldClose();
+ virtual void Close();
virtual WebViewDelegate* GetDelegate();
virtual void SetDelegate(WebViewDelegate*);
virtual void SetUseEditorDelegate(bool value);
@@ -80,7 +62,22 @@ 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);
@@ -133,6 +130,8 @@ 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_;
}
@@ -197,11 +196,11 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
}
// Set the disposition for how this webview is to be initially shown.
- void set_initial_navigation_policy(WebKit::WebNavigationPolicy policy) {
- initial_navigation_policy_ = policy;
+ void set_window_open_disposition(WindowOpenDisposition disp) {
+ window_open_disposition_ = disp;
}
- WebKit::WebNavigationPolicy initial_navigation_policy() const {
- return initial_navigation_policy_;
+ WindowOpenDisposition window_open_disposition() const {
+ return window_open_disposition_;
}
// Start a system drag and drop operation.
@@ -304,8 +303,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 policy for how this webview is to be initially shown.
- WebKit::WebNavigationPolicy initial_navigation_policy_;
+ // The disposition for how this webview is to be initially shown.
+ WindowOpenDisposition window_open_disposition_;
// 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
new file mode 100644
index 0000000..6653e28
--- /dev/null
+++ b/webkit/glue/webwidget.h
@@ -0,0 +1,80 @@
+// 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
new file mode 100644
index 0000000..a891cb1
--- /dev/null
+++ b/webkit/glue/webwidget_delegate.h
@@ -0,0 +1,102 @@
+// 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/webpopupmenu_impl.cc b/webkit/glue/webwidget_impl.cc
index 74b40ab..618a9bf 100644
--- a/webkit/glue/webpopupmenu_impl.cc
+++ b/webkit/glue/webwidget_impl.cc
@@ -4,6 +4,9 @@
#include "config.h"
+#include "base/compiler_specific.h"
+
+MSVC_PUSH_WARNING_LEVEL(0);
#include "Cursor.h"
#include "FramelessScrollView.h"
#include "FrameView.h"
@@ -13,70 +16,61 @@
#include "PlatformMouseEvent.h"
#include "PlatformWheelEvent.h"
#include "SkiaUtils.h"
-#undef LOG
+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/webpopupmenu_impl.h"
+#include "webkit/glue/webwidget_delegate.h"
+#include "webkit/glue/webwidget_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;
-// WebPopupMenu ---------------------------------------------------------------
+// WebWidget ----------------------------------------------------------------
-// static
-WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client) {
- WebPopupMenuImpl* instance = new WebPopupMenuImpl(client);
+/*static*/
+WebWidget* WebWidget::Create(WebWidgetDelegate* delegate) {
+ WebWidgetImpl* instance = new WebWidgetImpl(delegate);
instance->AddRef();
return instance;
}
-// WebWidget ------------------------------------------------------------------
-
-WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client)
- : client_(client),
+WebWidgetImpl::WebWidgetImpl(WebWidgetDelegate* delegate)
+ : delegate_(delegate),
widget_(NULL) {
// set to impossible point so we always get the first mouse pos
last_mouse_position_ = WebPoint(-1, -1);
}
-WebPopupMenuImpl::~WebPopupMenuImpl() {
+WebWidgetImpl::~WebWidgetImpl() {
if (widget_)
widget_->setClient(NULL);
}
-void WebPopupMenuImpl::Init(WebCore::FramelessScrollView* widget,
- const WebRect& bounds) {
+void WebWidgetImpl::Init(WebCore::FramelessScrollView* widget,
+ const WebRect& bounds) {
widget_ = widget;
widget_->setClient(this);
- if (client_) {
- client_->setWindowRect(bounds);
- client_->show(WebNavigationPolicy()); // Policy is ignored
+ if (delegate_) {
+ delegate_->SetWindowRect(this, bounds);
+ delegate_->Show(this, WindowOpenDisposition());
}
}
-void WebPopupMenuImpl::MouseMove(const WebMouseEvent& event) {
+void WebWidgetImpl::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) {
@@ -85,39 +79,39 @@ void WebPopupMenuImpl::MouseMove(const WebMouseEvent& event) {
}
}
-void WebPopupMenuImpl::MouseLeave(const WebMouseEvent& event) {
+void WebWidgetImpl::MouseLeave(const WebMouseEvent& event) {
widget_->handleMouseMoveEvent(MakePlatformMouseEvent(widget_, event));
}
-void WebPopupMenuImpl::MouseDown(const WebMouseEvent& event) {
+void WebWidgetImpl::MouseDown(const WebMouseEvent& event) {
widget_->handleMouseDownEvent(MakePlatformMouseEvent(widget_, event));
}
-void WebPopupMenuImpl::MouseUp(const WebMouseEvent& event) {
- mouseCaptureLost();
+void WebWidgetImpl::MouseUp(const WebMouseEvent& event) {
+ MouseCaptureLost();
widget_->handleMouseReleaseEvent(MakePlatformMouseEvent(widget_, event));
}
-void WebPopupMenuImpl::MouseWheel(const WebMouseWheelEvent& event) {
+void WebWidgetImpl::MouseWheel(const WebMouseWheelEvent& event) {
widget_->handleWheelEvent(MakePlatformWheelEvent(widget_, event));
}
-bool WebPopupMenuImpl::KeyEvent(const WebKeyboardEvent& event) {
+bool WebWidgetImpl::KeyEvent(const WebKeyboardEvent& event) {
return widget_->handleKeyEvent(MakePlatformKeyboardEvent(event));
}
// WebWidget -------------------------------------------------------------------
-void WebPopupMenuImpl::close() {
+void WebWidgetImpl::Close() {
if (widget_)
widget_->hide();
- client_ = NULL;
+ delegate_ = NULL;
Release(); // Balances AddRef from WebWidget::Create
}
-void WebPopupMenuImpl::resize(const WebSize& new_size) {
+void WebWidgetImpl::Resize(const WebSize& new_size) {
if (size_ == new_size)
return;
size_ = new_size;
@@ -127,16 +121,16 @@ void WebPopupMenuImpl::resize(const WebSize& new_size) {
widget_->setFrameRect(new_geometry);
}
- if (client_) {
+ if (delegate_) {
WebRect damaged_rect(0, 0, size_.width, size_.height);
- client_->didInvalidateRect(damaged_rect);
+ delegate_->DidInvalidateRect(this, damaged_rect);
}
}
-void WebPopupMenuImpl::layout() {
+void WebWidgetImpl::Layout() {
}
-void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect) {
+void WebWidgetImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) {
if (!widget_)
return;
@@ -154,32 +148,32 @@ void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect) {
}
}
-bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& input_event) {
+bool WebWidgetImpl::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
@@ -194,7 +188,7 @@ bool WebPopupMenuImpl::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;
@@ -202,70 +196,71 @@ bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& input_event) {
return false;
}
-void WebPopupMenuImpl::mouseCaptureLost() {
+void WebWidgetImpl::MouseCaptureLost() {
}
-void WebPopupMenuImpl::setFocus(bool enable) {
+void WebWidgetImpl::SetFocus(bool enable) {
}
-bool WebPopupMenuImpl::handleCompositionEvent(
- WebCompositionCommand command,
- int cursor_position,
- int target_start,
- int target_end,
- const WebString& ime_string) {
+bool WebWidgetImpl::ImeSetComposition(int string_type,
+ int cursor_position,
+ int target_start,
+ int target_end,
+ const std::wstring& ime_string) {
return false;
}
-bool WebPopupMenuImpl::queryCompositionStatus(bool* enabled,
- WebRect* caret_rect) {
+bool WebWidgetImpl::ImeUpdateStatus(bool* enable_ime,
+ WebRect* caret_rect) {
return false;
}
-void WebPopupMenuImpl::setTextDirection(WebTextDirection direction) {
+void WebWidgetImpl::SetTextDirection(WebTextDirection direction) {
}
//-----------------------------------------------------------------------------
// WebCore::HostWindow
-void WebPopupMenuImpl::repaint(const WebCore::IntRect& paint_rect,
+void WebWidgetImpl::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 (client_)
- client_->didInvalidateRect(webkit_glue::IntRectToWebRect(paint_rect));
+ if (delegate_)
+ delegate_->DidInvalidateRect(this,
+ webkit_glue::IntRectToWebRect(paint_rect));
}
-void WebPopupMenuImpl::scroll(const WebCore::IntSize& scroll_delta,
+void WebWidgetImpl::scroll(const WebCore::IntSize& scroll_delta,
const WebCore::IntRect& scroll_rect,
const WebCore::IntRect& clip_rect) {
- if (client_) {
+ if (delegate_) {
int dx = scroll_delta.width();
int dy = scroll_delta.height();
- client_->didScrollRect(dx, dy, webkit_glue::IntRectToWebRect(clip_rect));
+ delegate_->DidScrollRect(this, dx, dy,
+ webkit_glue::IntRectToWebRect(clip_rect));
}
}
-WebCore::IntPoint WebPopupMenuImpl::screenToWindow(
+WebCore::IntPoint WebWidgetImpl::screenToWindow(
const WebCore::IntPoint& point) const {
NOTIMPLEMENTED();
return WebCore::IntPoint();
}
-WebCore::IntRect WebPopupMenuImpl::windowToScreen(
+WebCore::IntRect WebWidgetImpl::windowToScreen(
const WebCore::IntRect& rect) const {
NOTIMPLEMENTED();
return WebCore::IntRect();
}
-PlatformWidget WebPopupMenuImpl::platformWindow() const {
+PlatformWidget WebWidgetImpl::platformWindow() const {
return NULL;
}
-void WebPopupMenuImpl::scrollRectIntoView(
+void WebWidgetImpl::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.
@@ -274,11 +269,11 @@ void WebPopupMenuImpl::scrollRectIntoView(
//-----------------------------------------------------------------------------
// WebCore::FramelessScrollViewClient
-void WebPopupMenuImpl::popupClosed(WebCore::FramelessScrollView* widget) {
+void WebWidgetImpl::popupClosed(WebCore::FramelessScrollView* widget) {
DCHECK(widget == widget_);
if (widget_) {
widget_->setClient(NULL);
widget_ = NULL;
}
- client_->closeWidgetSoon();
+ delegate_->CloseWidgetSoon(this);
}
diff --git a/webkit/glue/webpopupmenu_impl.h b/webkit/glue/webwidget_impl.h
index b6ef6ed..a1a1b18 100644
--- a/webkit/glue/webpopupmenu_impl.h
+++ b/webkit/glue/webwidget_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_WEBPOPUPMENU_IMPL_H_
-#define WEBKIT_GLUE_WEBPOPUPMENU_IMPL_H_
+#ifndef WEBKIT_GLUE_WEBWIDGET_IMPL_H__
+#define WEBKIT_GLUE_WEBWIDGET_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,36 +31,39 @@ struct WebRect;
}
struct MenuItem;
+class WebWidgetDelegate;
-class WebPopupMenuImpl : public WebKit::WebPopupMenu,
- public WebCore::FramelessScrollViewClient,
- public base::RefCounted<WebPopupMenuImpl> {
+class WebWidgetImpl : public WebWidget,
+ public WebCore::FramelessScrollViewClient,
+ public base::RefCounted<WebWidgetImpl> {
public:
// WebWidget
- 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,
+ 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,
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);
-
- // WebPopupMenuImpl
+ 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
void Init(WebCore::FramelessScrollView* widget,
const WebKit::WebRect& bounds);
- WebKit::WebWidgetClient* client() {
- return client_;
+ const WebKit::WebSize& size() const { return size_; }
+
+ WebWidgetDelegate* delegate() {
+ return delegate_;
}
void MouseMove(const WebKit::WebMouseEvent& mouse_event);
@@ -72,11 +75,11 @@ class WebPopupMenuImpl : public WebKit::WebPopupMenu,
bool KeyEvent(const WebKit::WebKeyboardEvent& key_event);
protected:
- friend class WebKit::WebPopupMenu; // For WebPopupMenu::create
- friend class base::RefCounted<WebPopupMenuImpl>;
+ friend class WebWidget; // So WebWidget::Create can call our constructor
+ friend class base::RefCounted<WebWidgetImpl>;
- WebPopupMenuImpl(WebKit::WebWidgetClient* client);
- ~WebPopupMenuImpl();
+ WebWidgetImpl(WebWidgetDelegate* delegate);
+ ~WebWidgetImpl();
// WebCore::HostWindow methods:
virtual void repaint(const WebCore::IntRect&,
@@ -95,7 +98,7 @@ class WebPopupMenuImpl : public WebKit::WebPopupMenu,
// WebCore::FramelessScrollViewClient methods:
virtual void popupClosed(WebCore::FramelessScrollView* popup_view);
- WebKit::WebWidgetClient* client_;
+ WebWidgetDelegate* delegate_;
WebKit::WebSize size_;
WebKit::WebPoint last_mouse_position_;
@@ -105,7 +108,7 @@ class WebPopupMenuImpl : public WebKit::WebPopupMenu,
WebCore::FramelessScrollView* widget_;
private:
- DISALLOW_COPY_AND_ASSIGN(WebPopupMenuImpl);
+ DISALLOW_COPY_AND_ASSIGN(WebWidgetImpl);
};
-#endif // WEBKIT_GLUE_WEBPOPUPMENU_IMPL_H_
+#endif // WEBKIT_GLUE_WEBWIDGET_IMPL_H__
diff --git a/webkit/glue/webworker_impl.cc b/webkit/glue/webworker_impl.cc
index c20b6839..c706524 100644
--- a/webkit/glue/webworker_impl.cc
+++ b/webkit/glue/webworker_impl.cc
@@ -34,9 +34,6 @@
#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;
@@ -49,33 +46,39 @@ using WebKit::WebWorkerClient;
class WorkerWebViewDelegate : public WebViewDelegate {
public:
WorkerWebViewDelegate() {}
-
- 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(); }
-
+ 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) { }
// 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);
};
@@ -113,7 +116,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
deleted file mode 100644
index 417ab1a..0000000
--- a/webkit/glue/window_open_disposition.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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 23b59c0..b3096c7 100644
--- a/webkit/glue/window_open_disposition.h
+++ b/webkit/glue/window_open_disposition.h
@@ -5,8 +5,6 @@
#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,
@@ -21,10 +19,4 @@ 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 a29978f..79e3d85 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,11 +460,12 @@ 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());
- webview()->handleInputEvent(WebInputEventFactory::keyboardEvent(
- NULL, msg, args[1].ToInt32(), lparam));
+ const WebKeyboardEvent& key_event = WebInputEventFactory::keyboardEvent(
+ NULL, msg, args[1].ToInt32(), lparam);
+ webview()->HandleInputEvent(&key_event);
} else {
NOTREACHED() << L"Wrong number of arguments";
}
@@ -542,7 +543,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;
@@ -556,11 +557,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 7724532..9939c68 100644
--- a/webkit/tools/test_shell/mac/test_webview_delegate.mm
+++ b/webkit/tools/test_shell/mac/test_webview_delegate.mm
@@ -16,10 +16,8 @@
#include "webkit/tools/test_shell/test_shell.h"
using WebKit::WebCursorInfo;
-using WebKit::WebNavigationPolicy;
using WebKit::WebPopupMenuInfo;
using WebKit::WebRect;
-using WebKit::WebWidget;
// WebViewDelegate -----------------------------------------------------------
@@ -40,7 +38,7 @@ WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
const std::string& mime_type,
const std::string& clsid,
std::string* actual_mime_type) {
- WebWidgetHost *host = GetWidgetHost();
+ WebWidgetHost *host = GetHostForWidget(webview);
if (!host)
return NULL;
gfx::NativeView view = host->view_handle();
@@ -58,10 +56,6 @@ WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
return WebPluginDelegateImpl::Create(info.path, mime_type, view);
}
-void TestWebViewDelegate::DidMovePlugin(const WebPluginGeometry& move) {
- // TODO(port): add me once plugins work.
-}
-
void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) {
NSString *text =
[NSString stringWithUTF8String:WideToUTF8(message).c_str()];
@@ -76,10 +70,11 @@ void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) {
// WebWidgetDelegate ---------------------------------------------------------
-void TestWebViewDelegate::show(WebNavigationPolicy policy) {
+void TestWebViewDelegate::Show(WebWidget* webwidget,
+ WindowOpenDisposition disposition) {
if (!popup_menu_info_.get())
return;
- if (this != shell_->popup_delegate())
+ if (webwidget != shell_->popup())
return;
// Display a HTML select menu.
@@ -130,8 +125,8 @@ void TestWebViewDelegate::show(WebNavigationPolicy policy) {
}
}
-void TestWebViewDelegate::closeWidgetSoon() {
- if (this == shell_->delegate()) {
+void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) {
+ if (webwidget == shell_->webView()) {
NSWindow *win = shell_->mainWnd();
// Tell Cocoa to close the window, which will let the window's delegate
// handle getting rid of the shell. |shell_| will still be alive for a short
@@ -139,50 +134,54 @@ void TestWebViewDelegate::closeWidgetSoon() {
// to the event loop), so we should make sure we don't leave it dangling.
[win performClose:nil];
shell_ = NULL;
- } else if (this == shell_->popup_delegate()) {
+ } else if (webwidget == shell_->popup()) {
shell_->ClosePopup();
}
}
-void TestWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
+void TestWebViewDelegate::SetCursor(WebWidget* webwidget,
+ const WebCursorInfo& cursor_info) {
NSCursor* ns_cursor = WebCursor(cursor_info).GetCursor();
[ns_cursor set];
}
-WebRect TestWebViewDelegate::windowRect() {
- if (WebWidgetHost* host = GetWidgetHost()) {
+void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget,
+ WebRect* out_rect) {
+ DCHECK(out_rect);
+ if (WebWidgetHost* host = GetHostForWidget(webwidget)) {
NSView *view = host->view_handle();
NSRect rect = [view frame];
- return gfx::Rect(NSRectToCGRect(rect));
+ *out_rect = gfx::Rect(NSRectToCGRect(rect));
}
- return WebRect();
}
-void TestWebViewDelegate::setWindowRect(const WebRect& rect) {
+void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget,
+ const WebRect& rect) {
// TODO: Mac window movement
- if (this == shell_->delegate()) {
+ if (webwidget == shell_->webView()) {
// ignored
- } else if (this == shell_->popup_delegate()) {
+ } else if (webwidget == shell_->popup()) {
popup_bounds_ = rect; // The initial position of the popup.
}
}
-WebRect TestWebViewDelegate::rootWindowRect() {
- if (WebWidgetHost* host = GetWidgetHost()) {
+void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget,
+ WebRect* out_rect) {
+ if (WebWidgetHost* host = GetHostForWidget(webwidget)) {
NSView *view = host->view_handle();
NSRect rect = [[[view window] contentView] frame];
- return gfx::Rect(NSRectToCGRect(rect));
+ *out_rect = gfx::Rect(NSRectToCGRect(rect));
}
- return WebRect();
}
@interface NSWindow(OSInternals)
- (NSRect)_growBoxRect;
@end
-WebRect TestWebViewDelegate::windowResizerRect() {
+void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget,
+ WebRect* out_rect) {
NSRect resize_rect = NSMakeRect(0, 0, 0, 0);
- WebWidgetHost* host = GetWidgetHost();
+ WebWidgetHost* host = GetHostForWidget(webwidget);
// To match the WebKit screen shots, we need the resize area to overlap
// the scroll arrows, so in layout test mode, we don't return a real rect.
if (!(shell_->layout_test_mode()) && host) {
@@ -200,10 +199,15 @@ WebRect TestWebViewDelegate::windowResizerRect() {
[view frame].size.height - resize_rect.origin.y -
resize_rect.size.height;
}
- return gfx::Rect(NSRectToCGRect(resize_rect));
+ *out_rect = gfx::Rect(NSRectToCGRect(resize_rect));
+}
+
+void TestWebViewDelegate::DidMove(WebWidget* webwidget,
+ const WebPluginGeometry& move) {
+ // TODO(port): add me once plugins work.
}
-void TestWebViewDelegate::runModal() {
+void TestWebViewDelegate::RunModal(WebWidget* webwidget) {
NOTIMPLEMENTED();
}
diff --git a/webkit/tools/test_shell/mac/webview_host.mm b/webkit/tools/test_shell/mac/webview_host.mm
index 3349546..96b2a75 100644
--- a/webkit/tools/test_shell/mac/webview_host.mm
+++ b/webkit/tools/test_shell/mac/webview_host.mm
@@ -34,7 +34,7 @@ WebViewHost* WebViewHost::Create(NSView* parent_view,
[host->view_ release];
host->webwidget_ = WebView::Create(delegate, prefs);
- host->webwidget_->resize(WebSize(content_rect.size.width,
+ host->webwidget_->Resize(WebSize(content_rect.size.width,
content_rect.size.height));
return host;
diff --git a/webkit/tools/test_shell/mac/webwidget_host.mm b/webkit/tools/test_shell/mac/webwidget_host.mm
index acb98b6..eb23bc1 100644
--- a/webkit/tools/test_shell/mac/webwidget_host.mm
+++ b/webkit/tools/test_shell/mac/webwidget_host.mm
@@ -13,9 +13,9 @@
#include "webkit/api/public/mac/WebInputEventFactory.h"
#include "webkit/api/public/mac/WebScreenInfoFactory.h"
#include "webkit/api/public/WebInputEvent.h"
-#include "webkit/api/public/WebPopupMenu.h"
#include "webkit/api/public/WebScreenInfo.h"
#include "webkit/api/public/WebSize.h"
+#include "webkit/glue/webwidget.h"
#include "webkit/tools/test_shell/test_shell.h"
using WebKit::WebInputEvent;
@@ -23,15 +23,13 @@ using WebKit::WebInputEventFactory;
using WebKit::WebKeyboardEvent;
using WebKit::WebMouseEvent;
using WebKit::WebMouseWheelEvent;
-using WebKit::WebPopupMenu;
using WebKit::WebScreenInfo;
using WebKit::WebScreenInfoFactory;
using WebKit::WebSize;
-using WebKit::WebWidgetClient;
/*static*/
WebWidgetHost* WebWidgetHost::Create(NSView* parent_view,
- WebWidgetClient* client) {
+ WebWidgetDelegate* delegate) {
WebWidgetHost* host = new WebWidgetHost();
NSRect content_rect = [parent_view frame];
@@ -42,8 +40,8 @@ WebWidgetHost* WebWidgetHost::Create(NSView* parent_view,
// win_util::SetWindowUserData(host->hwnd_, host);
- host->webwidget_ = WebPopupMenu::create(client);
- host->webwidget_->resize(WebSize(content_rect.size.width,
+ host->webwidget_ = WebWidget::Create(delegate);
+ host->webwidget_->Resize(WebSize(content_rect.size.width,
content_rect.size.height));
return host;
}
@@ -151,7 +149,7 @@ WebWidgetHost::~WebWidgetHost() {
TrackMouseLeave(false);
- webwidget_->close();
+ webwidget_->Close();
}
void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) {
@@ -180,7 +178,7 @@ void WebWidgetHost::Paint() {
flipped:NO]];
// This may result in more invalidation
- webwidget_->layout();
+ webwidget_->Layout();
// Scroll the canvas if necessary
scroll_rect_ = client_rect.Intersect(scroll_rect_);
@@ -229,7 +227,7 @@ WebScreenInfo WebWidgetHost::GetScreenInfo() {
void WebWidgetHost::Resize(const gfx::Rect& rect) {
// Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer.
DiscardBackingStore();
- webwidget_->resize(WebSize(rect.width(), rect.height()));
+ webwidget_->Resize(WebSize(rect.width(), rect.height()));
}
void WebWidgetHost::MouseEvent(NSEvent *event) {
@@ -245,23 +243,26 @@ void WebWidgetHost::MouseEvent(NSEvent *event) {
default:
break;
}
- webwidget_->handleInputEvent(web_event);
+ webwidget_->HandleInputEvent(&web_event);
}
void WebWidgetHost::WheelEvent(NSEvent *event) {
- webwidget_->handleInputEvent(
- WebInputEventFactory::mouseWheelEvent(event, view_));
+ const WebMouseWheelEvent& web_event = WebInputEventFactory::mouseWheelEvent(
+ event, view_);
+ webwidget_->HandleInputEvent(&web_event);
}
void WebWidgetHost::KeyEvent(NSEvent *event) {
- webwidget_->handleInputEvent(WebInputEventFactory::keyboardEvent(event));
+ const WebKeyboardEvent& web_event = WebInputEventFactory::keyboardEvent(
+ event);
+ webwidget_->HandleInputEvent(&web_event);
}
void WebWidgetHost::SetFocus(bool enable) {
// Ignore focus calls in layout test mode so that tests don't mess with each
// other's focus when running in parallel.
if (!TestShell::layout_test_mode())
- webwidget_->setFocus(enable);
+ webwidget_->SetFocus(enable);
}
void WebWidgetHost::TrackMouseLeave(bool track) {
@@ -280,6 +281,6 @@ void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
DCHECK(canvas_.get());
set_painting(true);
- webwidget_->paint(canvas_.get(), rect);
+ webwidget_->Paint(canvas_.get(), rect);
set_painting(false);
}
diff --git a/webkit/tools/test_shell/plugin_tests.cc b/webkit/tools/test_shell/plugin_tests.cc
index 0d8d8d0..a0951c9 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 cf63470..50aea1f 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,7 +112,6 @@ 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));
@@ -248,13 +247,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->size();
+ view->Layout();
+ const WebSize& size = view->GetSize();
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());
@@ -435,8 +434,8 @@ bool TestShell::RemoveWindowFromList(gfx::NativeWindow window) {
return false;
}
-void TestShell::Show(WebNavigationPolicy policy) {
- delegate_->show(policy);
+void TestShell::Show(WebView* webview, WindowOpenDisposition disposition) {
+ delegate_->Show(webview, disposition);
}
void TestShell::BindJSObjectsToWindow(WebFrame* frame) {
@@ -591,13 +590,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 8c92ca3..5b20e9d 100644
--- a/webkit/tools/test_shell/test_shell.h
+++ b/webkit/tools/test_shell/test_shell.h
@@ -93,9 +93,7 @@ public:
return m_webViewHost.get() ? m_webViewHost->webview() : NULL;
}
WebViewHost* webViewHost() { return m_webViewHost.get(); }
- WebKit::WebWidget* popup() {
- return m_popupHost ? m_popupHost->webwidget() : NULL;
- }
+ WebWidget* popup() { return m_popupHost ? m_popupHost->webwidget() : NULL; }
WebWidgetHost* popupHost() { return m_popupHost; }
// Called by the LayoutTestController to signal test completion.
@@ -104,7 +102,7 @@ public:
// Called to block the calling thread until TestFinished is called.
void WaitTestFinished();
- void Show(WebKit::WebNavigationPolicy policy);
+ void Show(WebView* webview, WindowOpenDisposition disposition);
// We use this to avoid relying on Windows focus during layout test mode.
void SetFocus(WebWidgetHost* host, bool enable);
@@ -113,7 +111,6 @@ 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();
}
@@ -178,7 +175,7 @@ public:
// Implements CreateWebView for TestWebViewDelegate, which in turn
// is called as a WebViewDelegate.
WebView* CreateWebView(WebView* webview);
- WebKit::WebWidget* CreatePopupWidget(WebView* webview);
+ WebWidget* CreatePopupWidget(WebView* webview);
void ClosePopup();
#if defined(OS_WIN)
@@ -325,7 +322,6 @@ 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 7d904d66..86a9ac9 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -32,8 +32,6 @@
#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).
@@ -469,7 +467,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, popup_delegate_);
+ WebWidgetHost* host = WebWidgetHost::Create(vbox, 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 aa34720..c2640cc 100644
--- a/webkit/tools/test_shell/test_shell_mac.mm
+++ b/webkit/tools/test_shell/test_shell_mac.mm
@@ -33,6 +33,7 @@
#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"
@@ -43,8 +44,6 @@
#import "mac/DumpRenderTreePasteboard.h"
-using WebKit::WebWidget;
-
#define MAX_LOADSTRING 100
// Sizes for URL bar layout
@@ -459,7 +458,7 @@ void TestShell::DestroyWindow(gfx::NativeWindow windowHandle) {
WebWidget* TestShell::CreatePopupWidget(WebView* webview) {
DCHECK(!m_popupHost);
- m_popupHost = WebWidgetHost::Create(webViewWnd(), popup_delegate_.get());
+ m_popupHost = WebWidgetHost::Create(webViewWnd(), 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 06c9d13..05d7bbe 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(WebKit::WebNavigationPolicyNewWindow);
+ shell->Show(shell->webView(), NEW_WINDOW);
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 87b5347..c6e7ac4 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(WebKit::WebNavigationPolicyNewWindow);
+ test_shell_->Show(test_shell_->webView(), NEW_WINDOW);
// 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 c0dc1e6..9d6cefc 100644
--- a/webkit/tools/test_shell/test_shell_win.cc
+++ b/webkit/tools/test_shell/test_shell_win.cc
@@ -36,8 +36,6 @@
#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
@@ -459,7 +457,7 @@ void TestShell::InteractiveSetFocus(WebWidgetHost* host, bool enable) {
WebWidget* TestShell::CreatePopupWidget(WebView* webview) {
DCHECK(!m_popupHost);
- m_popupHost = WebWidgetHost::Create(NULL, popup_delegate_.get());
+ m_popupHost = WebWidgetHost::Create(NULL, 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 2fdf392..d78971b 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -56,7 +56,6 @@ using WebKit::WebDataSource;
using WebKit::WebDragData;
using WebKit::WebHistoryItem;
using WebKit::WebNavigationType;
-using WebKit::WebNavigationPolicy;
using WebKit::WebRect;
using WebKit::WebScreenInfo;
using WebKit::WebSize;
@@ -64,7 +63,6 @@ using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebURLError;
using WebKit::WebURLRequest;
-using WebKit::WebWidget;
using WebKit::WebWorker;
using WebKit::WebWorkerClient;
@@ -163,11 +161,13 @@ WebWorker* TestWebViewDelegate::CreateWebWorker(WebWorkerClient* client) {
void TestWebViewDelegate::OpenURL(WebView* webview, const GURL& url,
const GURL& referrer,
- WebNavigationPolicy policy) {
- DCHECK_NE(policy, WebKit::WebNavigationPolicyCurrentTab);
+ WindowOpenDisposition disposition) {
+ DCHECK_NE(disposition, CURRENT_TAB); // No code for this
+ if (disposition == SUPPRESS_OPEN)
+ return;
TestShell* shell = NULL;
if (TestShell::CreateNewWindow(UTF8ToWide(url.spec()), &shell))
- shell->Show(policy);
+ shell->Show(shell->webView(), disposition);
}
void TestWebViewDelegate::DidStartLoading(WebView* webview) {
@@ -182,14 +182,14 @@ void TestWebViewDelegate::WindowObjectCleared(WebFrame* webframe) {
shell_->BindJSObjectsToWindow(webframe);
}
-WebNavigationPolicy TestWebViewDelegate::PolicyForNavigationAction(
+WindowOpenDisposition TestWebViewDelegate::DispositionForNavigationAction(
WebView* webview,
WebFrame* frame,
const WebURLRequest& request,
WebNavigationType type,
- WebNavigationPolicy default_policy,
+ WindowOpenDisposition disposition,
bool is_redirect) {
- WebNavigationPolicy result;
+ WindowOpenDisposition result;
if (policy_delegate_enabled_) {
std::wstring frame_name = frame->GetName();
std::string url_description;
@@ -201,15 +201,12 @@ WebNavigationPolicy TestWebViewDelegate::PolicyForNavigationAction(
}
printf("Policy delegate: attempt to load %s with navigation type '%s'\n",
url_description.c_str(), WebNavigationTypeToString(type));
- if (policy_delegate_is_permissive_) {
- result = WebKit::WebNavigationPolicyCurrentTab;
- } else {
- result = WebKit::WebNavigationPolicyIgnore;
- }
+ result = policy_delegate_is_permissive_ ? CURRENT_TAB : IGNORE_ACTION;
if (policy_delegate_should_notify_done_)
shell_->layout_test_controller()->PolicyDelegateDone();
} else {
- result = default_policy;
+ result = WebViewDelegate::DispositionForNavigationAction(
+ webview, frame, request, type, disposition, is_redirect);
}
return result;
}
@@ -747,29 +744,34 @@ void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) {
// WebWidgetDelegate ---------------------------------------------------------
-void TestWebViewDelegate::didInvalidateRect(const WebRect& rect) {
- if (WebWidgetHost* host = GetWidgetHost())
+void TestWebViewDelegate::DidInvalidateRect(WebWidget* webwidget,
+ const WebRect& rect) {
+ if (WebWidgetHost* host = GetHostForWidget(webwidget))
host->DidInvalidateRect(rect);
}
-void TestWebViewDelegate::didScrollRect(int dx, int dy,
+void TestWebViewDelegate::DidScrollRect(WebWidget* webwidget, int dx, int dy,
const WebRect& clip_rect) {
- if (WebWidgetHost* host = GetWidgetHost())
+ if (WebWidgetHost* host = GetHostForWidget(webwidget))
host->DidScrollRect(dx, dy, clip_rect);
}
-void TestWebViewDelegate::didFocus() {
- if (WebWidgetHost* host = GetWidgetHost())
+void TestWebViewDelegate::Focus(WebWidget* webwidget) {
+ if (WebWidgetHost* host = GetHostForWidget(webwidget))
shell_->SetFocus(host, true);
}
-void TestWebViewDelegate::didBlur() {
- if (WebWidgetHost* host = GetWidgetHost())
+void TestWebViewDelegate::Blur(WebWidget* webwidget) {
+ if (WebWidgetHost* host = GetHostForWidget(webwidget))
shell_->SetFocus(host, false);
}
-WebScreenInfo TestWebViewDelegate::screenInfo() {
- if (WebWidgetHost* host = GetWidgetHost())
+bool TestWebViewDelegate::IsHidden(WebWidget* webwidget) {
+ return false;
+}
+
+WebScreenInfo TestWebViewDelegate::GetScreenInfo(WebWidget* webwidget) {
+ if (WebWidgetHost* host = GetHostForWidget(webwidget))
return host->GetScreenInfo();
return WebScreenInfo();
@@ -833,10 +835,10 @@ void TestWebViewDelegate::LocationChangeDone(WebFrame* frame) {
}
}
-WebWidgetHost* TestWebViewDelegate::GetWidgetHost() {
- if (this == shell_->delegate())
+WebWidgetHost* TestWebViewDelegate::GetHostForWidget(WebWidget* webwidget) {
+ if (webwidget == shell_->webView())
return shell_->webViewHost();
- if (this == shell_->popup_delegate())
+ if (webwidget == shell_->popup())
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 e70ede9..208c8e6a 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -29,6 +29,7 @@
#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"
@@ -84,11 +85,9 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
virtual WebView* CreateWebView(WebView* webview,
bool user_gesture,
const GURL& creator_url);
- virtual WebKit::WebWidget* CreatePopupWidget(
- WebView* webview,
- bool activatable);
+ virtual WebWidget* CreatePopupWidget(WebView* webview, bool activatable);
#if defined(OS_MACOSX)
- virtual WebKit::WebWidget* CreatePopupWidgetWithInfo(
+ virtual WebWidget* CreatePopupWidgetWithInfo(
WebView* webview,
const WebKit::WebPopupMenuInfo& info);
#endif
@@ -108,8 +107,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
virtual void OpenURL(WebView* webview,
const GURL& url,
const GURL& referrer,
- WebKit::WebNavigationPolicy policy);
- virtual void DidMovePlugin(const WebPluginGeometry& move);
+ WindowOpenDisposition disposition);
virtual void RunJavaScriptAlert(WebFrame* webframe,
const std::wstring& message);
virtual bool RunJavaScriptConfirm(WebFrame* webframe,
@@ -221,32 +219,38 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
virtual void DidStopLoading(WebView* webview);
virtual void WindowObjectCleared(WebFrame* webframe);
- virtual WebKit::WebNavigationPolicy PolicyForNavigationAction(
+ virtual WindowOpenDisposition DispositionForNavigationAction(
WebView* webview,
WebFrame* frame,
const WebKit::WebURLRequest& request,
WebKit::WebNavigationType type,
- WebKit::WebNavigationPolicy default_policy,
+ WindowOpenDisposition disposition,
bool is_redirect);
virtual void NavigateBackForwardSoon(int offset);
virtual int GetHistoryBackListCount();
virtual int GetHistoryForwardListCount();
- // WebWidgetClient
- virtual void didInvalidateRect(const WebKit::WebRect& rect);
- virtual void didScrollRect(int dx, int dy,
+ // WebWidgetDelegate
+ virtual void DidInvalidateRect(WebWidget* webwidget,
+ const WebKit::WebRect& rect);
+ virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy,
const WebKit::WebRect& clip_rect);
- 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();
+ 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);
void SetSmartInsertDeleteEnabled(bool enabled);
void SetSelectTrailingWhitespaceEnabled(bool enabled);
@@ -301,7 +305,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
// test.
void LocationChangeDone(WebFrame*);
- WebWidgetHost* GetWidgetHost();
+ WebWidgetHost* GetHostForWidget(WebWidget* webwidget);
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 28d2956..1257145 100644
--- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc
+++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
@@ -32,7 +32,6 @@
#include "webkit/tools/test_shell/test_shell.h"
using WebKit::WebCursorInfo;
-using WebKit::WebNavigationPolicy;
using WebKit::WebRect;
namespace {
@@ -120,24 +119,26 @@ void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) {
gtk_widget_destroy(dialog);
}
-void TestWebViewDelegate::show(WebNavigationPolicy policy) {
- WebWidgetHost* host = GetWidgetHost();
+void TestWebViewDelegate::Show(WebWidget* webwidget,
+ WindowOpenDisposition disposition) {
+ WebWidgetHost* host = GetHostForWidget(webwidget);
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() {
- if (this == shell_->delegate()) {
+void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) {
+ if (webwidget == shell_->webView()) {
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
&gtk_widget_destroy, GTK_WIDGET(shell_->mainWnd())));
- } else if (this == shell_->popup_delegate()) {
+ } else if (webwidget == shell_->popup()) {
shell_->ClosePopup();
}
}
-void TestWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
+void TestWebViewDelegate::SetCursor(WebWidget* webwidget,
+ const WebCursorInfo& cursor_info) {
current_cursor_.InitFromCursorInfo(cursor_info);
GdkCursorType cursor_type = current_cursor_.GetCursorType();
GdkCursor* gdk_cursor;
@@ -164,8 +165,10 @@ void TestWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
gdk_cursor_unref(gdk_cursor);
}
-WebRect TestWebViewDelegate::windowRect() {
- WebWidgetHost* host = GetWidgetHost();
+void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget,
+ WebRect* out_rect) {
+ DCHECK(out_rect);
+ WebWidgetHost* host = GetHostForWidget(webwidget);
GtkWidget* drawing_area = host->view_handle();
GtkWidget* vbox = gtk_widget_get_parent(drawing_area);
GtkWidget* window = gtk_widget_get_parent(vbox);
@@ -175,16 +178,17 @@ WebRect TestWebViewDelegate::windowRect() {
x += vbox->allocation.x + drawing_area->allocation.x;
y += vbox->allocation.y + drawing_area->allocation.y;
- return WebRect(x, y,
- drawing_area->allocation.width,
- drawing_area->allocation.height);
+ *out_rect = WebRect(x, y,
+ drawing_area->allocation.width,
+ drawing_area->allocation.height);
}
-void TestWebViewDelegate::setWindowRect(const WebRect& rect) {
- if (this == shell_->delegate()) {
+void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget,
+ const WebRect& rect) {
+ if (webwidget == shell_->webView()) {
// ignored
- } else if (this == shell_->popup_delegate()) {
- WebWidgetHost* host = GetWidgetHost();
+ } else if (webwidget == shell_->popup()) {
+ WebWidgetHost* host = GetHostForWidget(webwidget);
GtkWidget* drawing_area = host->view_handle();
GtkWidget* window =
gtk_widget_get_parent(gtk_widget_get_parent(drawing_area));
@@ -193,8 +197,9 @@ void TestWebViewDelegate::setWindowRect(const WebRect& rect) {
}
}
-WebRect TestWebViewDelegate::rootWindowRect() {
- if (WebWidgetHost* host = GetWidgetHost()) {
+void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget,
+ WebRect* out_rect) {
+ if (WebWidgetHost* host = GetHostForWidget(webwidget)) {
// 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.
@@ -205,24 +210,25 @@ WebRect TestWebViewDelegate::rootWindowRect() {
gint x, y, width, height;
gtk_window_get_position(GTK_WINDOW(window), &x, &y);
gtk_window_get_size(GTK_WINDOW(window), &width, &height);
- return WebRect(x, y, width, height);
+ *out_rect = WebRect(x, y, width, height);
}
- return WebRect();
}
-WebRect TestWebViewDelegate::windowResizerRect() {
+void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget,
+ WebRect* out_rect) {
// Not necessary on Linux.
- return WebRect();
+ *out_rect = WebRect();
}
-void TestWebViewDelegate::DidMovePlugin(const WebPluginGeometry& move) {
- WebWidgetHost* host = GetWidgetHost();
+void TestWebViewDelegate::DidMove(WebWidget* webwidget,
+ const WebPluginGeometry& move) {
+ WebWidgetHost* host = GetHostForWidget(webwidget);
GtkPluginContainerManager* plugin_container_manager =
static_cast<WebViewHost*>(host)->plugin_container_manager();
plugin_container_manager->MovePluginContainer(move);
}
-void TestWebViewDelegate::runModal() {
+void TestWebViewDelegate::RunModal(WebWidget* webwidget) {
NOTIMPLEMENTED();
}
diff --git a/webkit/tools/test_shell/test_webview_delegate_win.cc b/webkit/tools/test_shell/test_webview_delegate_win.cc
index 592802b..f33c95f 100644
--- a/webkit/tools/test_shell/test_webview_delegate_win.cc
+++ b/webkit/tools/test_shell/test_webview_delegate_win.cc
@@ -36,7 +36,6 @@
#include "webkit/tools/test_shell/test_shell.h"
using WebKit::WebCursorInfo;
-using WebKit::WebNavigationPolicy;
using WebKit::WebRect;
// WebViewDelegate -----------------------------------------------------------
@@ -68,98 +67,100 @@ 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(WebNavigationPolicy) {
- if (WebWidgetHost* host = GetWidgetHost()) {
- HWND root = GetAncestor(host->view_handle(), GA_ROOT);
- ShowWindow(root, SW_SHOW);
- UpdateWindow(root);
+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::closeWidgetSoon() {
- if (this == shell_->delegate()) {
+void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) {
+ if (webwidget == shell_->webView()) {
PostMessage(shell_->mainWnd(), WM_CLOSE, 0, 0);
- } else if (this == shell_->popup_delegate()) {
+ } else if (webwidget == shell_->popup()) {
shell_->ClosePopup();
}
}
-void TestWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
- if (WebWidgetHost* host = GetWidgetHost()) {
+void TestWebViewDelegate::SetCursor(WebWidget* webwidget,
+ const WebCursorInfo& cursor_info) {
+ if (WebWidgetHost* host = GetHostForWidget(webwidget)) {
current_cursor_.InitFromCursorInfo(cursor_info);
HINSTANCE mod_handle = GetModuleHandle(NULL);
host->SetCursor(current_cursor_.GetCursor(mod_handle));
}
}
-WebRect TestWebViewDelegate::windowRect() {
- if (WebWidgetHost* host = GetWidgetHost()) {
+void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget,
+ WebRect* out_rect) {
+ if (WebWidgetHost* host = GetHostForWidget(webwidget)) {
RECT rect;
::GetWindowRect(host->view_handle(), &rect);
- return gfx::Rect(rect);
+ *out_rect = gfx::Rect(rect);
}
- return WebRect();
}
-void TestWebViewDelegate::setWindowRect(const WebRect& rect) {
- if (this == shell_->delegate()) {
+void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget,
+ const WebRect& rect) {
+ if (webwidget == shell_->webView()) {
// ignored
- } else if (this == shell_->popup_delegate()) {
+ } else if (webwidget == shell_->popup()) {
MoveWindow(shell_->popupWnd(),
rect.x, rect.y, rect.width, rect.height, FALSE);
}
}
-WebRect TestWebViewDelegate::rootWindowRect() {
- if (WebWidgetHost* host = GetWidgetHost()) {
+void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget,
+ WebRect* out_rect) {
+ if (WebWidgetHost* host = GetHostForWidget(webwidget)) {
RECT rect;
HWND root_window = ::GetAncestor(host->view_handle(), GA_ROOT);
::GetWindowRect(root_window, &rect);
- return gfx::Rect(rect);
+ *out_rect = gfx::Rect(rect);
}
- return WebRect();
}
-WebRect TestWebViewDelegate::windowResizerRect() {
+void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget,
+ WebRect* out_rect) {
// Not necessary on Windows.
- return WebRect();
+ *out_rect = gfx::Rect();
}
-void TestWebViewDelegate::runModal() {
- WebWidgetHost* host = GetWidgetHost();
- if (!host)
- return;
+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);
+}
- show(WebNavigationPolicy() /*XXX NEW_WINDOW*/);
+void TestWebViewDelegate::RunModal(WebWidget* webwidget) {
+ Show(webwidget, 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 71d6d4b..53c42d9 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 2fc2a10..e74638e 100644
--- a/webkit/tools/test_shell/webwidget_host.h
+++ b/webkit/tools/test_shell/webwidget_host.h
@@ -11,13 +11,14 @@
#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;
}
@@ -36,14 +37,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,
- WebKit::WebWidgetClient* client);
+ WebWidgetDelegate* delegate);
#if defined(OS_MACOSX)
static void HandleEvent(gfx::NativeView view, NSEvent* event);
#endif
gfx::NativeView view_handle() const { return view_; }
- WebKit::WebWidget* webwidget() const { return webwidget_; }
+ WebWidget* webwidget() const { return webwidget_; }
void DidInvalidateRect(const gfx::Rect& rect);
void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect);
@@ -114,7 +115,7 @@ class WebWidgetHost {
}
gfx::NativeView view_;
- WebKit::WebWidget* webwidget_;
+ 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 432f661..dd5b311 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,11 +25,9 @@ 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 {
@@ -161,8 +159,9 @@ class WebWidgetHostGtkWidget {
static gboolean HandleKeyPress(GtkWidget* widget,
GdkEventKey* event,
WebWidgetHost* host) {
- host->webwidget()->handleInputEvent(
- WebInputEventFactory::keyboardEvent(event));
+ const WebKeyboardEvent& wke = WebInputEventFactory::keyboardEvent(event);
+ host->webwidget()->HandleInputEvent(&wke);
+
return FALSE;
}
@@ -190,7 +189,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;
}
@@ -201,7 +200,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;
}
@@ -209,8 +208,8 @@ class WebWidgetHostGtkWidget {
static gboolean HandleButtonPress(GtkWidget* widget,
GdkEventButton* event,
WebWidgetHost* host) {
- host->webwidget()->handleInputEvent(
- WebInputEventFactory::mouseEvent(event));
+ const WebMouseEvent& wme = WebInputEventFactory::mouseEvent(event);
+ host->webwidget()->HandleInputEvent(&wme);
return FALSE;
}
@@ -225,8 +224,8 @@ class WebWidgetHostGtkWidget {
static gboolean HandleMotionNotify(GtkWidget* widget,
GdkEventMotion* event,
WebWidgetHost* host) {
- host->webwidget()->handleInputEvent(
- WebInputEventFactory::mouseEvent(event));
+ const WebMouseEvent& wme = WebInputEventFactory::mouseEvent(event);
+ host->webwidget()->HandleInputEvent(&wme);
return FALSE;
}
@@ -234,8 +233,9 @@ class WebWidgetHostGtkWidget {
static gboolean HandleScroll(GtkWidget* widget,
GdkEventScroll* event,
WebWidgetHost* host) {
- host->webwidget()->handleInputEvent(
- WebInputEventFactory::mouseWheelEvent(event));
+ const WebMouseWheelEvent& wmwe =
+ WebInputEventFactory::mouseWheelEvent(event);
+ host->webwidget()->HandleInputEvent(&wmwe);
return FALSE;
}
@@ -253,10 +253,10 @@ gfx::NativeView WebWidgetHost::CreateWidget(
// static
WebWidgetHost* WebWidgetHost::Create(GtkWidget* parent_view,
- WebWidgetClient* client) {
+ WebWidgetDelegate* delegate) {
WebWidgetHost* host = new WebWidgetHost();
host->view_ = CreateWidget(parent_view, host);
- host->webwidget_ = WebPopupMenu::create(client);
+ host->webwidget_ = WebWidget::Create(delegate);
// 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(newsize);
+ webwidget_->Resize(gfx::Size(newsize.width(), newsize.height()));
}
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 66b283e..164a051 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,18 +21,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::WebWidget;
-using WebKit::WebWidgetClient;
static const wchar_t kWindowClassName[] = L"WebWidgetHost";
/*static*/
WebWidgetHost* WebWidgetHost::Create(HWND parent_view,
- WebWidgetClient* client) {
+ WebWidgetDelegate* delegate) {
WebWidgetHost* host = new WebWidgetHost();
static bool registered_class = false;
@@ -54,7 +51,7 @@ WebWidgetHost* WebWidgetHost::Create(HWND parent_view,
parent_view, NULL, GetModuleHandle(NULL), NULL);
win_util::SetWindowUserData(host->view_, host);
- host->webwidget_ = WebPopupMenu::create(client);
+ host->webwidget_ = WebWidget::Create(delegate);
return host;
}
@@ -201,7 +198,7 @@ WebWidgetHost::~WebWidgetHost() {
TrackMouseLeave(false);
- webwidget_->close();
+ webwidget_->Close();
}
bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
@@ -235,7 +232,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_);
@@ -285,7 +282,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) {
@@ -311,30 +308,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) {
@@ -367,6 +364,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 5c9c718..9760266 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -996,7 +996,6 @@
'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',
@@ -1018,14 +1017,12 @@
'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',
@@ -1033,8 +1030,6 @@
'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',
@@ -1405,8 +1400,6 @@
'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',
@@ -1419,12 +1412,15 @@
'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