summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-15 11:46:04 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-15 11:46:04 +0000
commit3d8835ce738f3bb2f7006d3d195723a97170c856 (patch)
tree4a2d60eeed2783f52ff8283cce732c9beb46e2e4 /webkit
parentf69ae902bf6a334736a09e6ad278a6b63f4cb704 (diff)
downloadchromium_src-3d8835ce738f3bb2f7006d3d195723a97170c856.zip
chromium_src-3d8835ce738f3bb2f7006d3d195723a97170c856.tar.gz
chromium_src-3d8835ce738f3bb2f7006d3d195723a97170c856.tar.bz2
Match the Windows plugin moving/sizing behavior on Linux.
This keep the sizing operations in WebPluginDelegateImpl, and does the moving in DidMove. This more or less matches what currently happens on Windows. Add a comment explaining this situation better. Add some random comments and small code cleanup. Remove the flash useragent spoofing hack on non-Windows, we don't need to worry about this for now. Review URL: http://codereview.chromium.org/20304 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9843 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/plugin_host.cc16
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.cc10
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_gtk.cc20
-rw-r--r--webkit/glue/webplugin_impl.cc2
-rwxr-xr-xwebkit/tools/test_shell/test_webview_delegate_gtk.cc11
5 files changed, 39 insertions, 20 deletions
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc
index 087abf8..8338b2a1a 100644
--- a/webkit/glue/plugins/plugin_host.cc
+++ b/webkit/glue/plugins/plugin_host.cc
@@ -580,6 +580,7 @@ NPError NPN_DestroyStream(NPP id, NPStream* stream, NPReason reason) {
}
const char* NPN_UserAgent(NPP id) {
+#if defined(OS_WIN)
// Flash passes in a null id during the NP_initialize call. We need to
// default to the Mozilla user agent if we don't have an NPP instance or
// else Flash won't request windowless mode.
@@ -589,16 +590,12 @@ const char* NPN_UserAgent(NPP id) {
return webkit_glue::GetUserAgent(GURL()).c_str();
}
-#if defined(OS_WIN)
- static const char *UA = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061103 Firefox/2.0a1";
-#elif defined(OS_MACOSX)
- // TODO(port): this is probably wrong...
- static const char *UA = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1";
+ return "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061103 Firefox/2.0a1";
#else
- // TODO(port): set appropriately for other platforms
- static const char *UA = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061103 Firefox/2.0a1";
+ // TODO(port): For now we always use our real useragent on Mac and Linux.
+ // We might eventually need to spoof for some plugins.
+ return webkit_glue::GetUserAgent(GURL()).c_str();
#endif
- return UA;
}
void NPN_Status(NPP id, const char* message) {
@@ -842,8 +839,7 @@ NPError NPN_SetValue(NPP id, NPPVariable variable, void *value) {
// Note: the documentation at http://developer.mozilla.org/en/docs/NPN_SetValue
// is wrong. When value is NULL, the mode is set to true. This is the same
// way Mozilla works.
- bool mode = (value == 0);
- plugin->set_windowless(mode);
+ plugin->set_windowless(value == 0);
return NPERR_NO_ERROR;
}
case NPPVpluginTransparentBool:
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc
index 0ab5c02..bb3d527 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl.cc
@@ -690,7 +690,15 @@ bool WebPluginDelegateImpl::WindowedReposition(
if (window_rect_ == window_rect && clip_rect_ == clip_rect)
return false;
- // Clipping is handled by WebPlugin.
+ // There are a few parts to managing the plugin windows:
+ // - Initial geometry, show / resize / position the window.
+ // - Geometry updates, resize the window.
+ // - Geometry updates, move the window or update the clipping region.
+ // This code should handle the first two, positioning and sizing the window
+ // initially, and resizing it when the size changes. Clipping and moving are
+ // handled separately by WebPlugin, after it has called this code. This
+ // allows window moves, like scrolling, to be synchronized with painting.
+ // See WebPluginImpl::setFrameRect().
if (window_rect.size() != window_rect_.size()) {
::SetWindowPos(windowed_handle_,
NULL,
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
index 40da272b..4236c25 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
@@ -341,17 +341,23 @@ bool WebPluginDelegateImpl::WindowedReposition(
if (window_rect_ == window_rect && clip_rect_ == clip_rect)
return false;
- // Clipping is handled by WebPlugin.
- GtkAllocation allocation = { window_rect.x(), window_rect.y(),
- window_rect.width(), window_rect.height() };
- // Tell our parent GtkFixed container where to place the widget.
- gtk_fixed_move(
- GTK_FIXED(parent_), windowed_handle_, window_rect.x(), window_rect.y());
- gtk_widget_size_allocate(windowed_handle_, &allocation);
+
+ if (window_rect.size() != window_rect_.size()) {
+ // Clipping is handled by WebPlugin.
+ GtkAllocation allocation = { window_rect.x(), window_rect.y(),
+ window_rect.width(), window_rect.height() };
+ // TODO(deanm): we probably want to match Windows here, where x and y is
+ // fixed at 0, and we're just sizing the window.
+ // Tell our parent GtkFixed container where to place the widget.
+ gtk_fixed_move(
+ GTK_FIXED(parent_), windowed_handle_, window_rect.x(), window_rect.y());
+ gtk_widget_size_allocate(windowed_handle_, &allocation);
+ }
window_rect_ = window_rect;
clip_rect_ = clip_rect;
+ // TODO(deanm): Is this really needed?
// Ensure that the entire window gets repainted.
gtk_widget_queue_draw(windowed_handle_);
diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc
index 2877423..05264e1 100644
--- a/webkit/glue/webplugin_impl.cc
+++ b/webkit/glue/webplugin_impl.cc
@@ -56,9 +56,7 @@ MSVC_POP_WARNING();
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webplugin_impl.h"
#include "webkit/glue/plugins/plugin_host.h"
-#if !defined(OS_LINUX)
#include "webkit/glue/plugins/plugin_instance.h"
-#endif
#include "webkit/glue/stacking_order_iterator.h"
#include "webkit/glue/webview_impl.h"
#include "googleurl/src/gurl.h"
diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
index 2564061..c74b64f 100755
--- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc
+++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
@@ -207,11 +207,22 @@ void TestWebViewDelegate::DidMove(WebWidget* webwidget,
GtkWidget* widget = move.window;
DCHECK(!GTK_WIDGET_NO_WINDOW(widget) && GTK_WIDGET_REALIZED(widget));
+ // Update the clipping region on the GdkWindow.
GdkRectangle clip_rect = move.clip_rect.ToGdkRectangle();
GdkRegion* clip_region = gdk_region_rectangle(&clip_rect);
gfx::SubtractRectanglesFromRegion(clip_region, move.cutout_rects);
gdk_window_shape_combine_region(widget->window, clip_region, 0, 0);
gdk_region_destroy(clip_region);
+
+ // Update the window position. Resizing is handled by WebPluginDelegate.
+ // TODO(deanm): Verify that we only need to move and not resize.
+ // TODO(deanm): Can we avoid the X call if it's already at the right place,
+ // the GtkFixed knows where the child is, maybe it handles this for us?
+ WebWidgetHost* host = GetHostForWidget(webwidget);
+ gtk_fixed_move(GTK_FIXED(host->view_handle()),
+ widget,
+ move.window_rect.x(),
+ move.window_rect.y());
}
void TestWebViewDelegate::RunModal(WebWidget* webwidget) {