summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-09 01:43:49 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-09 01:43:49 +0000
commit525f9f6d6eab948d11f8a55422ee0e7a352a768d (patch)
tree8535abe850265913281f1de74ebd145d342b8bd4 /webkit/glue
parent2181ea006830c226a8a3c21aa17030a01ec62a5e (diff)
downloadchromium_src-525f9f6d6eab948d11f8a55422ee0e7a352a768d.zip
chromium_src-525f9f6d6eab948d11f8a55422ee0e7a352a768d.tar.gz
chromium_src-525f9f6d6eab948d11f8a55422ee0e7a352a768d.tar.bz2
Don't call NPP_SetWindow before we have the plugin geometry.
Note: the full fix to the bug also needs Ananta's change at http://codereview.chromium.org/119200 Bug=12993 Review URL: http://codereview.chromium.org/118359 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.cc8
-rw-r--r--webkit/glue/webplugin.h1
-rw-r--r--webkit/glue/webplugin_impl.cc57
-rw-r--r--webkit/glue/webplugin_impl.h4
4 files changed, 36 insertions, 34 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc
index 325c294..5cf00a5 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl.cc
@@ -740,10 +740,10 @@ void WebPluginDelegateImpl::WindowedSetWindow() {
DCHECK(!instance()->windowless());
- window_.clipRect.top = clip_rect_.y();
- window_.clipRect.left = clip_rect_.x();
- window_.clipRect.bottom = clip_rect_.y() + clip_rect_.height();
- window_.clipRect.right = clip_rect_.x() + clip_rect_.width();
+ window_.clipRect.top = std::max(0, clip_rect_.y());
+ window_.clipRect.left = std::max(0, clip_rect_.x());
+ window_.clipRect.bottom = std::max(0, clip_rect_.y() + clip_rect_.height());
+ window_.clipRect.right = std::max(0, clip_rect_.x() + clip_rect_.width());
window_.height = window_rect_.height();
window_.width = window_rect_.width();
window_.x = 0;
diff --git a/webkit/glue/webplugin.h b/webkit/glue/webplugin.h
index 00e60e7..d6a5b75 100644
--- a/webkit/glue/webplugin.h
+++ b/webkit/glue/webplugin.h
@@ -31,6 +31,7 @@ struct WebPluginGeometry {
// window_rect origin.
gfx::Rect clip_rect;
std::vector<gfx::Rect> cutout_rects;
+ bool rects_valid;
bool visible;
};
diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc
index 04d8c79..9ea7d52 100644
--- a/webkit/glue/webplugin_impl.cc
+++ b/webkit/glue/webplugin_impl.cc
@@ -172,28 +172,15 @@ void WebPluginContainer::setFocus() {
}
void WebPluginContainer::show() {
- bool old_visible = isVisible();
setSelfVisible(true);
- // We don't want to force a geometry update when the plugin widget is
- // already visible as this involves a geometry update which may lead
- // to unnecessary window moves in the plugin process.
- if (old_visible != isVisible()) {
- // This is to force an updategeometry call to the plugin process
- // where the plugin window can be hidden or shown.
- frameRectsChanged();
- }
+ impl_->UpdateVisibility();
WebCore::Widget::show();
}
void WebPluginContainer::hide() {
- bool old_visible = isVisible();
setSelfVisible(false);
- if (old_visible != isVisible()) {
- // This is to force an updategeometry call to the plugin process
- // where the plugin window can be hidden or shown.
- frameRectsChanged();
- }
+ impl_->UpdateVisibility();
WebCore::Widget::hide();
}
@@ -222,20 +209,7 @@ void WebPluginContainer::setParentVisible(bool visible) {
if (!isSelfVisible())
return; // This widget has explicitely been marked as not visible.
- // This is to force an updategeometry call to the plugin process
- // where the plugin window can be hidden or shown.
- frameRectsChanged();
-}
-
-// We override this function so that if the plugin is windowed, we can call
-// NPP_SetWindow at the first possible moment. This ensures that NPP_SetWindow
-// is called before the manual load data is sent to a plugin. If this order is
-// reversed, Flash won't load videos.
-void WebPluginContainer::setParent(WebCore::ScrollView* view) {
- WebCore::Widget::setParent(view);
- if (view) {
- impl_->setFrameRect(frameRect());
- }
+ impl_->UpdateVisibility();
}
void WebPluginContainer::windowCutoutRects(const WebCore::IntRect& bounds,
@@ -248,6 +222,10 @@ void WebPluginContainer::didReceiveResponse(
const WebCore::ResourceResponse& response) {
set_ignore_response_error(false);
+ // Manual loading, so make sure that the plugin receives window geometry
+ // before data, or else plugins misbehave.
+ frameRectsChanged();
+
HttpResponseInfo http_response_info;
ReadHttpResponseInfo(response, &http_response_info);
@@ -671,6 +649,7 @@ void WebPluginImpl::setFrameRect(const WebCore::IntRect& rect) {
move.window_rect = webkit_glue::FromIntRect(window_rect);
move.clip_rect = webkit_glue::FromIntRect(clip_rect);
move.cutout_rects = cutout_rects;
+ move.rects_valid = true;
move.visible = widget_->isVisible();
webview->delegate()->DidMove(webview, move);
@@ -1351,3 +1330,23 @@ void WebPluginImpl::TearDownPluginInstance(
webframe_->set_plugin_delegate(NULL);
webframe_ = NULL;
}
+
+void WebPluginImpl::UpdateVisibility() {
+ if (!window_)
+ return;
+
+ WebCore::Frame* frame = element_->document()->frame();
+ WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame);
+ WebViewImpl* webview = webframe->GetWebViewImpl();
+ if (!webview->delegate())
+ return;
+
+ WebPluginGeometry move;
+ move.window = window_;
+ move.window_rect = gfx::Rect();
+ move.clip_rect = gfx::Rect();
+ move.rects_valid = false;
+ move.visible = widget_->isVisible();
+
+ webview->delegate()->DidMove(webview, move);
+}
diff --git a/webkit/glue/webplugin_impl.h b/webkit/glue/webplugin_impl.h
index f4464ac..396c94c 100644
--- a/webkit/glue/webplugin_impl.h
+++ b/webkit/glue/webplugin_impl.h
@@ -66,7 +66,6 @@ class WebPluginContainer : public WebCore::Widget {
virtual void handleEvent(WebCore::Event* event);
virtual void frameRectsChanged();
virtual void setParentVisible(bool visible);
- virtual void setParent(WebCore::ScrollView* view);
#if USE(JSC)
virtual bool isPluginView() const;
@@ -313,6 +312,9 @@ class WebPluginImpl : public WebPlugin,
// to handle the response identified by the response_handle parameter.
bool ReinitializePluginForResponse(WebCore::ResourceHandle* response_handle);
+ // Notifies us that the visibility of the plugin has changed.
+ void UpdateVisibility();
+
// Helper functions to convert an array of names/values to a vector.
static void ArrayToVector(int total_values, char** values,
std::vector<std::string>* value_vector);