OLD | NEW |
---|---|
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file was forked off the Mac port. | 5 // This file was forked off the Mac port. |
6 | 6 |
7 #include "webkit/tools/test_shell/test_webview_delegate.h" | 7 #include "webkit/tools/test_shell/test_webview_delegate.h" |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 x += vbox->allocation.x + drawing_area->allocation.x; | 149 x += vbox->allocation.x + drawing_area->allocation.x; |
150 y += vbox->allocation.y + drawing_area->allocation.y; | 150 y += vbox->allocation.y + drawing_area->allocation.y; |
151 | 151 |
152 return WebRect(x, y, | 152 return WebRect(x, y, |
153 drawing_area->allocation.width, | 153 drawing_area->allocation.width, |
154 drawing_area->allocation.height); | 154 drawing_area->allocation.height); |
155 } | 155 } |
156 | 156 |
157 void TestWebViewDelegate::setWindowRect(const WebRect& rect) { | 157 void TestWebViewDelegate::setWindowRect(const WebRect& rect) { |
158 if (this == shell_->delegate()) { | 158 if (this == shell_->delegate()) { |
159 // ignored | 159 setFakeWindowRect(rect); |
160 } else if (this == shell_->popup_delegate()) { | 160 } else if (this == shell_->popup_delegate()) { |
161 WebWidgetHost* host = GetWidgetHost(); | 161 WebWidgetHost* host = GetWidgetHost(); |
162 GtkWidget* drawing_area = host->view_handle(); | 162 GtkWidget* drawing_area = host->view_handle(); |
163 GtkWidget* window = | 163 GtkWidget* window = |
164 gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); | 164 gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); |
165 gtk_window_resize(GTK_WINDOW(window), rect.width, rect.height); | 165 gtk_window_resize(GTK_WINDOW(window), rect.width, rect.height); |
166 gtk_window_move(GTK_WINDOW(window), rect.x, rect.y); | 166 gtk_window_move(GTK_WINDOW(window), rect.x, rect.y); |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 WebRect TestWebViewDelegate::rootWindowRect() { | 170 WebRect TestWebViewDelegate::rootWindowRect() { |
171 if (WebWidgetHost* host = GetWidgetHost()) { | 171 if (using_fake_rect_) { |
172 return getFakeWindowRect(); | |
173 } else if (WebWidgetHost* host = GetWidgetHost()) { | |
dglazkov
2009/09/23 18:17:14
Ditto on early return.
| |
172 // We are being asked for the x/y and width/height of the entire browser | 174 // We are being asked for the x/y and width/height of the entire browser |
173 // window. This means the x/y is the distance from the corner of the | 175 // window. This means the x/y is the distance from the corner of the |
174 // screen, and the width/height is the size of the entire browser window. | 176 // screen, and the width/height is the size of the entire browser window. |
175 // For example, this is used to implement window.screenX and window.screenY. | 177 // For example, this is used to implement window.screenX and window.screenY. |
176 GtkWidget* drawing_area = host->view_handle(); | 178 GtkWidget* drawing_area = host->view_handle(); |
177 GtkWidget* window = | 179 GtkWidget* window = |
178 gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); | 180 gtk_widget_get_parent(gtk_widget_get_parent(drawing_area)); |
179 gint x, y, width, height; | 181 gint x, y, width, height; |
180 gtk_window_get_position(GTK_WINDOW(window), &x, &y); | 182 gtk_window_get_position(GTK_WINDOW(window), &x, &y); |
181 gtk_window_get_size(GTK_WINDOW(window), &width, &height); | 183 gtk_window_get_size(GTK_WINDOW(window), &width, &height); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 } | 272 } |
271 | 273 |
272 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { | 274 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { |
273 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), | 275 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), |
274 ("Test Shell - " + WideToUTF8(title)).c_str()); | 276 ("Test Shell - " + WideToUTF8(title)).c_str()); |
275 } | 277 } |
276 | 278 |
277 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { | 279 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { |
278 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); | 280 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); |
279 } | 281 } |
OLD | NEW |