Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Unified Diff: webkit/glue/plugins/webplugin_delegate_impl_gtk.cc

Issue 39105: Windowless plugins: basic drawing works. (Closed)
Patch Set: retry Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
index cde9502ec38ec2b7782be38e85b6a541a3f87b6d..f6f7da6c0bb89e39d26517b71583461a010829b9 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
@@ -108,8 +108,6 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url,
// a valid window handle causes subtle bugs with plugins which retreive
// the window handle and validate the same. The window handle can be
// retreived via NPN_GetValue of NPNVnetscapeWindow.
- NOTIMPLEMENTED() << "windowless not implemented";
- return false;
// instance_->set_window_handle(parent_);
// CreateDummyWindowForActivation();
// handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL);
@@ -161,8 +159,7 @@ void WebPluginDelegateImpl::UpdateGeometry(
void WebPluginDelegateImpl::Paint(void* dc, const gfx::Rect& rect) {
if (windowless_) {
- // TODO(port): windowless painting.
- // WindowlessPaint(dc, rect);
+ WindowlessPaint(dc, rect);
}
}
@@ -411,7 +408,7 @@ void WebPluginDelegateImpl::WindowlessUpdateGeometry(
// Only resend to the instance if the geometry has changed.
if (window_rect == window_rect_ && clip_rect == clip_rect_)
return;
- /*
+
// Set this flag before entering the instance in case of side-effects.
windowless_needs_set_window_ = true;
@@ -423,40 +420,22 @@ void WebPluginDelegateImpl::WindowlessUpdateGeometry(
window_rect_ = window_rect;
WindowlessSetWindow(true);
-
- WINDOWPOS win_pos = {0};
- win_pos.x = window_rect_.x();
- win_pos.y = window_rect_.y();
- win_pos.cx = window_rect_.width();
- win_pos.cy = window_rect_.height();
-
- NPEvent pos_changed_event;
- pos_changed_event.event = WM_WINDOWPOSCHANGED;
- pos_changed_event.wParam = 0;
- pos_changed_event.lParam = PtrToUlong(&win_pos);
-
- instance()->NPP_HandleEvent(&pos_changed_event);
}
- */
}
-#if 0
-void WebPluginDelegateImpl::WindowlessPaint(HDC hdc,
+void WebPluginDelegateImpl::WindowlessPaint(void* context,
const gfx::Rect& damage_rect) {
- DCHECK(hdc);
+ // Compare to:
+ // http://mxr.mozilla.org/firefox/source/layout/generic/nsObjectFrame.cpp#4222
- RECT damage_rect_win;
- damage_rect_win.left = damage_rect.x(); // + window_rect_.x();
- damage_rect_win.top = damage_rect.y(); // + window_rect_.y();
- damage_rect_win.right = damage_rect_win.left + damage_rect.width();
- damage_rect_win.bottom = damage_rect_win.top + damage_rect.height();
+ DCHECK(context);
- // We need to pass the HDC to the plugin via NPP_SetWindow in the
+ // We need to pass the DC to the plugin via NPP_SetWindow in the
// first paint to ensure that it initiates rect invalidations.
- if (window_.window == NULL)
+ // TODO(evanm): for now, it appears we always need to do this.
+ if (true)
windowless_needs_set_window_ = true;
- window_.window = hdc;
// TODO(darin): we should avoid calling NPP_SetWindow here since it may
// cause page layout to be invalidated.
@@ -465,16 +444,20 @@ void WebPluginDelegateImpl::WindowlessPaint(HDC hdc,
if (windowless_needs_set_window_)
WindowlessSetWindow(false);
- NPEvent paint_event;
- paint_event.event = WM_PAINT;
- // NOTE: NPAPI is not 64bit safe. It puts pointers into 32bit values.
- paint_event.wParam = PtrToUlong(hdc);
- paint_event.lParam = PtrToUlong(&damage_rect_win);
+ XGraphicsExposeEvent event = {0};
+ event.type = GraphicsExpose;
+ event.display = GDK_DISPLAY();
+ event.drawable = (Drawable)context;
+ event.x = damage_rect.x();
+ event.y = damage_rect.y();
+ event.width = damage_rect.width();
+ event.height = damage_rect.height();
+
static StatsRate plugin_paint("Plugin.Paint");
StatsScope<StatsRate> scope(plugin_paint);
- instance()->NPP_HandleEvent(&paint_event);
+ NPError err = instance()->NPP_HandleEvent(reinterpret_cast<XEvent*>(&event));
+ DCHECK(err == NPERR_NO_ERROR);
}
-#endif
void WebPluginDelegateImpl::WindowlessSetWindow(bool force_set_window) {
if (!instance())
@@ -484,6 +467,9 @@ void WebPluginDelegateImpl::WindowlessSetWindow(bool force_set_window) {
return;
DCHECK(instance()->windowless());
+ // Mozilla docs say that this window param is not used for windowless
+ // plugins; rather, the window is passed during the GraphicsExpose event.
+ DCHECK(window_.window == 0);
window_.clipRect.top = clip_rect_.y();
window_.clipRect.left = clip_rect_.x();
@@ -495,6 +481,19 @@ void WebPluginDelegateImpl::WindowlessSetWindow(bool force_set_window) {
window_.y = window_rect_.y();
window_.type = NPWindowTypeDrawable;
+ NPSetWindowCallbackStruct* extra = new NPSetWindowCallbackStruct;
+ extra->display = GDK_DISPLAY();
+ GdkVisual* visual = gdk_visual_get_system();
+ extra->visual = GDK_VISUAL_XVISUAL(visual);
+ extra->depth = visual->depth;
+ // XXX we leak the colormap.
+ GdkColormap* colormap = gdk_colormap_new(gdk_visual_get_system(), FALSE);
+ extra->colormap = GDK_COLORMAP_XCOLORMAP(colormap);
+ window_.ws_info = extra;
+
+ if (!force_set_window)
+ windowless_needs_set_window_ = false;
+
NPError err = instance()->NPP_SetWindow(&window_);
DCHECK(err == NPERR_NO_ERROR);
}

Powered by Google App Engine
This is Rietveld 408576698