summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins
diff options
context:
space:
mode:
authorojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-09 21:58:05 +0000
committerojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-09 21:58:05 +0000
commit8a2820a90f85f91c500a9d382f8e8ba870fb621c (patch)
tree8d8bd23228cd1e6455e64b0de46e961947459382 /webkit/glue/plugins
parent283f76091ad757bdc17c6d9090209eade4211075 (diff)
downloadchromium_src-8a2820a90f85f91c500a9d382f8e8ba870fb621c.zip
chromium_src-8a2820a90f85f91c500a9d382f8e8ba870fb621c.tar.gz
chromium_src-8a2820a90f85f91c500a9d382f8e8ba870fb621c.tar.bz2
Patch by Thatcher Ulrich <tulrich@google.com>.
Implement "iframe shim" behavior for windowed plugins. In FF and IE on windows, iframes are implemented as native HWNDs. This has the side effect that iframes display on top of windowed plugins. This side effect has long been known as a workaround for allowing HTML elements to appear above plugin content. BUG=1788 Review URL: http://codereview.chromium.org/7032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3137 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.cc45
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h14
2 files changed, 40 insertions, 19 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc
index 4e1c713..fa2a64f 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl.cc
@@ -6,6 +6,7 @@
#include "base/file_util.h"
#include "base/message_loop.h"
+#include "base/gfx/gdi_util.h"
#include "base/gfx/point.h"
#include "base/stats_counters.h"
#include "webkit/default_plugin/plugin_impl.h"
@@ -250,13 +251,15 @@ void WebPluginDelegateImpl::DestroyInstance() {
}
}
-void WebPluginDelegateImpl::UpdateGeometry(const gfx::Rect& window_rect,
- const gfx::Rect& clip_rect,
- bool visible) {
+void WebPluginDelegateImpl::UpdateGeometry(
+ const gfx::Rect& window_rect,
+ const gfx::Rect& clip_rect,
+ const std::vector<gfx::Rect>& cutout_rects,
+ bool visible) {
if (windowless_) {
WindowlessUpdateGeometry(window_rect, clip_rect);
} else {
- WindowedUpdateGeometry(window_rect, clip_rect, visible);
+ WindowedUpdateGeometry(window_rect, clip_rect, cutout_rects, visible);
}
// Initiate a download on the plugin url. This should be done for the
@@ -344,10 +347,12 @@ void WebPluginDelegateImpl::InstallMissingPlugin() {
instance()->NPP_HandleEvent(&evt);
}
-void WebPluginDelegateImpl::WindowedUpdateGeometry(const gfx::Rect& window_rect,
- const gfx::Rect& clip_rect,
- bool visible) {
- if (WindowedReposition(window_rect, clip_rect, visible) ||
+void WebPluginDelegateImpl::WindowedUpdateGeometry(
+ const gfx::Rect& window_rect,
+ const gfx::Rect& clip_rect,
+ const std::vector<gfx::Rect>& cutout_rects,
+ bool visible) {
+ if (WindowedReposition(window_rect, clip_rect, cutout_rects, visible) ||
!windowed_did_set_window_) {
// Let the plugin know that it has been moved
WindowedSetWindow();
@@ -584,14 +589,17 @@ bool WebPluginDelegateImpl::CreateDummyWindowForActivation() {
return true;
}
-void WebPluginDelegateImpl::MoveWindow(HWND window,
- const gfx::Rect& window_rect,
- const gfx::Rect& clip_rect,
- bool visible) {
+void WebPluginDelegateImpl::MoveWindow(
+ HWND window,
+ const gfx::Rect& window_rect,
+ const gfx::Rect& clip_rect,
+ const std::vector<gfx::Rect>& cutout_rects,
+ bool visible) {
HRGN hrgn = ::CreateRectRgn(clip_rect.x(),
clip_rect.y(),
clip_rect.right(),
clip_rect.bottom());
+ gfx::SubtractRectanglesFromRegion(hrgn, cutout_rects);
// Note: System will own the hrgn after we call SetWindowRgn,
// so we don't need to call DeleteObject(hrgn)
@@ -612,20 +620,24 @@ void WebPluginDelegateImpl::MoveWindow(HWND window,
flags);
}
-bool WebPluginDelegateImpl::WindowedReposition(const gfx::Rect& window_rect,
- const gfx::Rect& clip_rect,
- bool visible) {
+bool WebPluginDelegateImpl::WindowedReposition(
+ const gfx::Rect& window_rect,
+ const gfx::Rect& clip_rect,
+ const std::vector<gfx::Rect>& cutout_rects,
+ bool visible) {
if (!windowed_handle_) {
NOTREACHED();
return false;
}
if (window_rect_ == window_rect && clip_rect_ == clip_rect &&
+ cutout_rects == cutout_rects_ &&
initial_plugin_resize_done_)
return false;
window_rect_ = window_rect;
clip_rect_ = clip_rect;
+ cutout_rects_ = cutout_rects;
if (!initial_plugin_resize_done_) {
// We need to ensure that the plugin process continues to reposition
@@ -636,7 +648,7 @@ bool WebPluginDelegateImpl::WindowedReposition(const gfx::Rect& window_rect,
// We created the window with 0 width and height since we didn't know it
// at the time. Now that we know the geometry, we we can update its size
// since the browser only calls SetWindowPos when scrolling occurs.
- MoveWindow(windowed_handle_, window_rect, clip_rect, visible);
+ MoveWindow(windowed_handle_, window_rect, clip_rect, cutout_rects, visible);
// Ensure that the entire window gets repainted.
::InvalidateRect(windowed_handle_, NULL, FALSE);
}
@@ -791,6 +803,7 @@ void WebPluginDelegateImpl::WindowlessUpdateGeometry(
// We will inform the instance of this change when we call NPP_SetWindow.
clip_rect_ = clip_rect;
+ cutout_rects_.clear();
if (window_rect_ != window_rect) {
window_rect_ = window_rect;
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index 7ef9d80..51d0b9b 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -41,7 +41,9 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
WebPlugin* plugin,
bool load_manually);
virtual void UpdateGeometry(const gfx::Rect& window_rect,
- const gfx::Rect& clip_rect, bool visible);
+ const gfx::Rect& clip_rect,
+ const std::vector<gfx::Rect>& cutout_rects,
+ bool visible);
virtual void Paint(HDC hdc, const gfx::Rect& rect);
virtual void Print(HDC hdc);
virtual void SetFocus(); // only called when windowless
@@ -93,6 +95,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
static void MoveWindow(HWND window,
const gfx::Rect& window_rect,
const gfx::Rect& clip_rect,
+ const std::vector<gfx::Rect>& cutout_rects,
bool visible);
private:
@@ -103,7 +106,9 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
//--------------------------
// used for windowed plugins
void WindowedUpdateGeometry(const gfx::Rect& window_rect,
- const gfx::Rect& clip_rect, bool visible);
+ const gfx::Rect& clip_rect,
+ const std::vector<gfx::Rect>& cutout_rects,
+ bool visible);
// Create the native window.
// Returns true if the window is created (or already exists).
// Returns false if unable to create the window.
@@ -115,7 +120,9 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
// Reposition the native window to be in sync with the given geometry.
// Returns true if the native window has moved or been clipped differently.
bool WindowedReposition(const gfx::Rect& window_rect,
- const gfx::Rect& clip_rect, bool visible);
+ const gfx::Rect& clip_rect,
+ const std::vector<gfx::Rect>& cutout_rects,
+ bool visible);
// Tells the plugin about the current state of the window.
// See NPAPI NPP_SetWindow for more information.
@@ -187,6 +194,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
NPWindow window_;
gfx::Rect window_rect_;
gfx::Rect clip_rect_;
+ std::vector<gfx::Rect> cutout_rects_;
int quirks_;
// We only move/size the plugin window once after its creation. The