summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 05: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/glue
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/glue')
-rw-r--r--webkit/glue/chrome_client_impl.cc51
-rw-r--r--webkit/glue/chromium_bridge_impl.cc53
-rw-r--r--webkit/glue/context_menu_unittest.cc4
-rw-r--r--webkit/glue/inspector_client_impl.cc2
-rw-r--r--webkit/glue/webframeloaderclient_impl.cc68
-rw-r--r--webkit/glue/webframeloaderclient_impl.h19
-rw-r--r--webkit/glue/webplugin_impl.cc4
-rw-r--r--webkit/glue/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
19 files changed, 618 insertions, 487 deletions
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_