diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-08 21:58:04 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-08 21:58:04 +0000 |
commit | 02e80deede0729617aeb87128b1db3cd14b36d6b (patch) | |
tree | dfdec4f6e761c652ba8439dc36204cfa31246962 /webkit/tools | |
parent | 98aebc7fc44cc34ecfa5a33ade9a8aa511bb96a3 (diff) | |
download | chromium_src-02e80deede0729617aeb87128b1db3cd14b36d6b.zip chromium_src-02e80deede0729617aeb87128b1db3cd14b36d6b.tar.gz chromium_src-02e80deede0729617aeb87128b1db3cd14b36d6b.tar.bz2 |
Switch to using WebPoint, WebRect, and WebSize in more of the glue
layer interface. This will help when we move those interfaces into
the WebKit API.
R=dglazkov
Review URL: http://codereview.chromium.org/63126
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13381 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
-rwxr-xr-x | webkit/tools/test_shell/mac/test_webview_delegate.mm | 19 | ||||
-rw-r--r-- | webkit/tools/test_shell/mac/webwidget_host.mm | 8 | ||||
-rwxr-xr-x | webkit/tools/test_shell/test_webview_delegate.cc | 6 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 17 | ||||
-rwxr-xr-x | webkit/tools/test_shell/test_webview_delegate_gtk.cc | 27 | ||||
-rwxr-xr-x | webkit/tools/test_shell/test_webview_delegate_win.cc | 15 | ||||
-rw-r--r-- | webkit/tools/test_shell/webwidget_host_gtk.cc | 6 | ||||
-rw-r--r-- | webkit/tools/test_shell/webwidget_host_win.cc | 4 |
8 files changed, 61 insertions, 41 deletions
diff --git a/webkit/tools/test_shell/mac/test_webview_delegate.mm b/webkit/tools/test_shell/mac/test_webview_delegate.mm index 039e34f3..9ae7a80 100755 --- a/webkit/tools/test_shell/mac/test_webview_delegate.mm +++ b/webkit/tools/test_shell/mac/test_webview_delegate.mm @@ -7,12 +7,15 @@ #import <Cocoa/Cocoa.h> #include "base/sys_string_conversions.h" #include "base/string_util.h" +#include "third_party/WebKit/WebKit/chromium/public/WebRect.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/webview.h" #include "webkit/glue/plugins/plugin_list.h" #include "webkit/glue/plugins/webplugin_delegate_impl.h" #include "webkit/tools/test_shell/test_shell.h" +using WebKit::WebRect; + // MenuDelegate ---------------------------------------------------------------- // A class for determining whether an item was selected from an HTML select // control, or if the menu was dismissed without making a selection. If a menu @@ -121,7 +124,7 @@ void TestWebViewDelegate::Show(WebWidget* webview, // Display a HTML select menu. void TestWebViewDelegate::ShowWithItems( WebWidget* webview, - const gfx::Rect& bounds, + const WebRect& bounds, int item_height, int selected_index, const std::vector<MenuItem>& items) { @@ -141,9 +144,9 @@ void TestWebViewDelegate::ShowWithItems( [button selectItemAtIndex:selected_index]; NSView* web_view = shell_->webViewWnd(); NSRect view_rect = [web_view bounds]; - int y_offset = bounds.y() + bounds.height(); - NSRect position = NSMakeRect(bounds.x(), view_rect.size.height - y_offset, - bounds.width(), bounds.height()); + int y_offset = bounds.y + bounds.height; + NSRect position = NSMakeRect(bounds.x, view_rect.size.height - y_offset, + bounds.width, bounds.height); // Display the menu, and set a flag to determine if something was chosen. If // nothing was chosen (i.e., the user dismissed the popup by the "ESC" key or @@ -226,7 +229,7 @@ void TestWebViewDelegate::SetCursor(WebWidget* webwidget, } void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget, - gfx::Rect* out_rect) { + WebRect* out_rect) { DCHECK(out_rect); if (WebWidgetHost* host = GetHostForWidget(webwidget)) { NSView *view = host->view_handle(); @@ -236,7 +239,7 @@ void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget, } void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget, - const gfx::Rect& rect) { + const WebRect& rect) { // TODO: Mac window movement if (webwidget == shell_->webView()) { // ignored @@ -247,7 +250,7 @@ void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget, } void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, - gfx::Rect* out_rect) { + WebRect* out_rect) { if (WebWidgetHost* host = GetHostForWidget(webwidget)) { NSView *view = host->view_handle(); NSRect rect = [[[view window] contentView] frame]; @@ -260,7 +263,7 @@ void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, @end void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget, - gfx::Rect* out_rect) { + WebRect* out_rect) { NSRect resize_rect = NSMakeRect(0, 0, 0, 0); WebWidgetHost* host = GetHostForWidget(webwidget); // To match the WebKit screen shots, we need the resize area to overlap diff --git a/webkit/tools/test_shell/mac/webwidget_host.mm b/webkit/tools/test_shell/mac/webwidget_host.mm index bccb584..a24928a 100644 --- a/webkit/tools/test_shell/mac/webwidget_host.mm +++ b/webkit/tools/test_shell/mac/webwidget_host.mm @@ -14,6 +14,7 @@ #include "third_party/WebKit/WebKit/chromium/public/mac/WebScreenInfoFactory.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" +#include "third_party/WebKit/WebKit/chromium/public/WebSize.h" #include "webkit/glue/webwidget.h" #include "webkit/tools/test_shell/test_shell.h" @@ -24,6 +25,7 @@ using WebKit::WebMouseEvent; using WebKit::WebMouseWheelEvent; using WebKit::WebScreenInfo; using WebKit::WebScreenInfoFactory; +using WebKit::WebSize; /*static*/ WebWidgetHost* WebWidgetHost::Create(NSView* parent_view, @@ -39,8 +41,8 @@ WebWidgetHost* WebWidgetHost::Create(NSView* parent_view, // win_util::SetWindowUserData(host->hwnd_, host); host->webwidget_ = WebWidget::Create(delegate); - host->webwidget_->Resize(gfx::Size(content_rect.size.width, - content_rect.size.height)); + host->webwidget_->Resize(WebSize(content_rect.size.width, + content_rect.size.height)); return host; } @@ -225,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(gfx::Size(rect.width(), rect.height())); + webwidget_->Resize(WebSize(rect.width(), rect.height())); } void WebWidgetHost::MouseEvent(NSEvent *event) { diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index af7a662..9ba64e0 100755 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -43,7 +43,9 @@ #endif using WebKit::WebDragData; +using WebKit::WebRect; using WebKit::WebScreenInfo; +using WebKit::WebSize; using WebKit::WebString; namespace { @@ -715,13 +717,13 @@ gfx::NativeViewId TestWebViewDelegate::GetContainingView(WebWidget* webwidget) { } void TestWebViewDelegate::DidInvalidateRect(WebWidget* webwidget, - const gfx::Rect& rect) { + const WebRect& rect) { if (WebWidgetHost* host = GetHostForWidget(webwidget)) host->DidInvalidateRect(rect); } void TestWebViewDelegate::DidScrollRect(WebWidget* webwidget, int dx, int dy, - const gfx::Rect& clip_rect) { + const WebRect& clip_rect) { if (WebWidgetHost* host = GetHostForWidget(webwidget)) host->DidScrollRect(dx, dy, clip_rect); } diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 94e1f83..e1692fe 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -212,12 +212,13 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, // WebWidgetDelegate virtual gfx::NativeViewId GetContainingView(WebWidget* webwidget); - virtual void DidInvalidateRect(WebWidget* webwidget, const gfx::Rect& rect); + virtual void DidInvalidateRect(WebWidget* webwidget, + const WebKit::WebRect& rect); virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy, - const gfx::Rect& clip_rect); + const WebKit::WebRect& clip_rect); virtual void Show(WebWidget* webview, WindowOpenDisposition disposition); virtual void ShowWithItems(WebWidget* webwidget, - const gfx::Rect& bounds, + const WebKit::WebRect& bounds, int item_height, int selected_index, const std::vector<MenuItem>& items); @@ -226,10 +227,12 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, virtual void Blur(WebWidget* webwidget); virtual void SetCursor(WebWidget* webwidget, const WebCursor& cursor); - virtual void GetWindowRect(WebWidget* webwidget, gfx::Rect* rect); - virtual void SetWindowRect(WebWidget* webwidget, const gfx::Rect& rect); - virtual void GetRootWindowRect(WebWidget *, gfx::Rect *); - virtual void GetRootWindowResizerRect(WebWidget* webwidget, gfx::Rect* rect); + 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); diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc index bce7619..ef92a3b 100755 --- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc +++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc @@ -14,6 +14,7 @@ #include "base/string_util.h" #include "net/base/net_errors.h" #include "chrome/common/page_transition_types.h" +#include "third_party/WebKit/WebKit/chromium/public/WebRect.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/webdatasource.h" #include "webkit/glue/webdropdata.h" @@ -29,8 +30,9 @@ #include "webkit/tools/test_shell/test_navigation_controller.h" #include "webkit/tools/test_shell/test_shell.h" -namespace { +using WebKit::WebRect; +namespace { enum SelectionClipboardType { TEXT_HTML, @@ -114,7 +116,7 @@ void TestWebViewDelegate::Show(WebWidget* webwidget, } void TestWebViewDelegate::ShowWithItems(WebWidget* webwidget, - const gfx::Rect& bounds, + const WebRect& bounds, int item_height, int selected_index, const std::vector<MenuItem>& items) { @@ -159,7 +161,7 @@ void TestWebViewDelegate::SetCursor(WebWidget* webwidget, } void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget, - gfx::Rect* out_rect) { + WebRect* out_rect) { DCHECK(out_rect); WebWidgetHost* host = GetHostForWidget(webwidget); GtkWidget* drawing_area = host->view_handle(); @@ -171,12 +173,13 @@ void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget, x += vbox->allocation.x + drawing_area->allocation.x; y += vbox->allocation.y + drawing_area->allocation.y; - out_rect->SetRect(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(WebWidget* webwidget, - const gfx::Rect& rect) { + const WebRect& rect) { if (webwidget == shell_->webView()) { // ignored } else if (webwidget == shell_->popup()) { @@ -184,13 +187,13 @@ void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget, GtkWidget* drawing_area = host->view_handle(); GtkWidget* window = gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); - gtk_window_resize(GTK_WINDOW(window), rect.width(), rect.height()); - gtk_window_move(GTK_WINDOW(window), rect.x(), rect.y()); + gtk_window_resize(GTK_WINDOW(window), rect.width, rect.height); + gtk_window_move(GTK_WINDOW(window), rect.x, rect.y); } } void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, - gfx::Rect* out_rect) { + 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 @@ -202,14 +205,14 @@ void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, gint x, y, width, height; gtk_window_get_position(GTK_WINDOW(window), &x, &y); gtk_window_get_size(GTK_WINDOW(window), &width, &height); - out_rect->SetRect(x, y, width, height); + *out_rect = WebRect(x, y, width, height); } } void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget, - gfx::Rect* out_rect) { + WebRect* out_rect) { // Not necessary on Linux. - *out_rect = gfx::Rect(); + *out_rect = WebRect(); } void TestWebViewDelegate::DidMove(WebWidget* webwidget, diff --git a/webkit/tools/test_shell/test_webview_delegate_win.cc b/webkit/tools/test_shell/test_webview_delegate_win.cc index 28c5034..125c1b2 100755 --- a/webkit/tools/test_shell/test_webview_delegate_win.cc +++ b/webkit/tools/test_shell/test_webview_delegate_win.cc @@ -19,6 +19,7 @@ #include "base/string_util.h" #include "base/trace_event.h" #include "net/base/net_errors.h" +#include "third_party/WebKit/WebKit/chromium/public/WebRect.h" #include "webkit/glue/webdatasource.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/weberror.h" @@ -35,6 +36,8 @@ #include "webkit/tools/test_shell/test_navigation_controller.h" #include "webkit/tools/test_shell/test_shell.h" +using WebKit::WebRect; + // WebViewDelegate ----------------------------------------------------------- TestWebViewDelegate::~TestWebViewDelegate() { @@ -79,7 +82,7 @@ void TestWebViewDelegate::Show(WebWidget* webwidget, WindowOpenDisposition) { } void TestWebViewDelegate::ShowWithItems(WebWidget* webwidget, - const gfx::Rect& bounds, + const WebRect& bounds, int item_height, int selected_index, const std::vector<MenuItem>& items) { @@ -104,7 +107,7 @@ void TestWebViewDelegate::SetCursor(WebWidget* webwidget, } void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget, - gfx::Rect* out_rect) { + WebRect* out_rect) { if (WebWidgetHost* host = GetHostForWidget(webwidget)) { RECT rect; ::GetWindowRect(host->view_handle(), &rect); @@ -113,17 +116,17 @@ void TestWebViewDelegate::GetWindowRect(WebWidget* webwidget, } void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget, - const gfx::Rect& rect) { + const WebRect& rect) { if (webwidget == shell_->webView()) { // ignored } else if (webwidget == shell_->popup()) { MoveWindow(shell_->popupWnd(), - rect.x(), rect.y(), rect.width(), rect.height(), FALSE); + rect.x, rect.y, rect.width, rect.height, FALSE); } } void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, - gfx::Rect* out_rect) { + WebRect* out_rect) { if (WebWidgetHost* host = GetHostForWidget(webwidget)) { RECT rect; HWND root_window = ::GetAncestor(host->view_handle(), GA_ROOT); @@ -133,7 +136,7 @@ void TestWebViewDelegate::GetRootWindowRect(WebWidget* webwidget, } void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget, - gfx::Rect* out_rect) { + WebRect* out_rect) { // Not necessary on Windows. *out_rect = gfx::Rect(); } diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc index 08dd9bc..5645da7 100644 --- a/webkit/tools/test_shell/webwidget_host_gtk.cc +++ b/webkit/tools/test_shell/webwidget_host_gtk.cc @@ -16,6 +16,7 @@ #include "third_party/WebKit/WebKit/chromium/public/gtk/WebScreenInfoFactory.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" +#include "third_party/WebKit/WebKit/chromium/public/WebSize.h" #include "webkit/glue/webwidget.h" #include "webkit/tools/test_shell/test_shell.h" @@ -25,6 +26,7 @@ using WebKit::WebMouseEvent; using WebKit::WebMouseWheelEvent; using WebKit::WebScreenInfo; using WebKit::WebScreenInfoFactory; +using WebKit::WebSize; namespace { @@ -122,14 +124,14 @@ class WebWidgetHostGtkWidget { static void HandleSizeAllocate(GtkWidget* widget, GtkAllocation* allocation, WebWidgetHost* host) { - host->Resize(gfx::Size(allocation->width, allocation->height)); + host->Resize(WebSize(allocation->width, allocation->height)); } // Size, position, or stacking of the GdkWindow changed. static gboolean HandleConfigure(GtkWidget* widget, GdkEventConfigure* config, WebWidgetHost* host) { - host->Resize(gfx::Size(config->width, config->height)); + host->Resize(WebSize(config->width, config->height)); return FALSE; } diff --git a/webkit/tools/test_shell/webwidget_host_win.cc b/webkit/tools/test_shell/webwidget_host_win.cc index 9db06c0..c5464ef 100644 --- a/webkit/tools/test_shell/webwidget_host_win.cc +++ b/webkit/tools/test_shell/webwidget_host_win.cc @@ -11,6 +11,7 @@ #include "skia/ext/platform_canvas_win.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" +#include "third_party/WebKit/WebKit/chromium/public/WebSize.h" #include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h" #include "third_party/WebKit/WebKit/chromium/public/win/WebScreenInfoFactory.h" #include "webkit/glue/webwidget.h" @@ -23,6 +24,7 @@ using WebKit::WebMouseEvent; using WebKit::WebMouseWheelEvent; using WebKit::WebScreenInfo; using WebKit::WebScreenInfoFactory; +using WebKit::WebSize; static const wchar_t kWindowClassName[] = L"WebWidgetHost"; @@ -285,7 +287,7 @@ void WebWidgetHost::Resize(LPARAM lparam) { // Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer. DiscardBackingStore(); - webwidget_->Resize(gfx::Size(LOWORD(lparam), HIWORD(lparam))); + webwidget_->Resize(WebSize(LOWORD(lparam), HIWORD(lparam))); } void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) { |