| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | 5 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 if (!windowless_) | 74 if (!windowless_) |
| 75 WindowedDestroyWindow(); | 75 WindowedDestroyWindow(); |
| 76 | 76 |
| 77 if (window_.ws_info) { | 77 if (window_.ws_info) { |
| 78 // We only ever use ws_info as an NPSetWindowCallbackStruct. | 78 // We only ever use ws_info as an NPSetWindowCallbackStruct. |
| 79 delete static_cast<NPSetWindowCallbackStruct*>(window_.ws_info); | 79 delete static_cast<NPSetWindowCallbackStruct*>(window_.ws_info); |
| 80 } | 80 } |
| 81 | 81 |
| 82 if (pixmap_) { | 82 if (pixmap_) { |
| 83 g_object_unref(gdk_drawable_get_colormap(pixmap_)); | |
| 84 g_object_unref(pixmap_); | 83 g_object_unref(pixmap_); |
| 85 pixmap_ = NULL; | 84 pixmap_ = NULL; |
| 86 } | 85 } |
| 87 } | 86 } |
| 88 | 87 |
| 89 void WebPluginDelegateImpl::PlatformInitialize(WebPlugin* plugin) { | 88 void WebPluginDelegateImpl::PlatformInitialize(WebPlugin* plugin) { |
| 90 gfx::PluginWindowHandle handle = | 89 gfx::PluginWindowHandle handle = |
| 91 windowless_ ? 0 : gtk_plug_get_id(GTK_PLUG(plug_)); | 90 windowless_ ? 0 : gtk_plug_get_id(GTK_PLUG(plug_)); |
| 92 plugin->SetWindow(handle); | 91 plugin->SetWindow(handle); |
| 93 } | 92 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 242 } |
| 244 | 243 |
| 245 void WebPluginDelegateImpl::EnsurePixmapAtLeastSize(int width, int height) { | 244 void WebPluginDelegateImpl::EnsurePixmapAtLeastSize(int width, int height) { |
| 246 if (pixmap_) { | 245 if (pixmap_) { |
| 247 gint cur_width, cur_height; | 246 gint cur_width, cur_height; |
| 248 gdk_drawable_get_size(pixmap_, &cur_width, &cur_height); | 247 gdk_drawable_get_size(pixmap_, &cur_width, &cur_height); |
| 249 if (cur_width >= width && cur_height >= height) | 248 if (cur_width >= width && cur_height >= height) |
| 250 return; // We are already the appropriate size. | 249 return; // We are already the appropriate size. |
| 251 | 250 |
| 252 // Otherwise, we need to recreate ourselves. | 251 // Otherwise, we need to recreate ourselves. |
| 253 g_object_unref(gdk_drawable_get_colormap(pixmap_)); | |
| 254 g_object_unref(pixmap_); | 252 g_object_unref(pixmap_); |
| 255 pixmap_ = NULL; | 253 pixmap_ = NULL; |
| 256 } | 254 } |
| 257 | 255 |
| 258 // |sys_visual| is owned by gdk; we shouldn't free it. | 256 // |sys_visual| is owned by gdk; we shouldn't free it. |
| 259 GdkVisual* sys_visual = gdk_visual_get_system(); | 257 GdkVisual* sys_visual = gdk_visual_get_system(); |
| 260 pixmap_ = gdk_pixmap_new(NULL, // use width/height/depth params | 258 pixmap_ = gdk_pixmap_new(NULL, // use width/height/depth params |
| 261 std::max(1, width), std::max(1, height), | 259 std::max(1, width), std::max(1, height), |
| 262 sys_visual->depth); | 260 sys_visual->depth); |
| 263 GdkColormap* colormap = gdk_colormap_new(gdk_visual_get_system(), | 261 GdkColormap* colormap = gdk_colormap_new(gdk_visual_get_system(), |
| 264 FALSE); | 262 FALSE); |
| 265 gdk_drawable_set_colormap(GDK_DRAWABLE(pixmap_), colormap); | 263 gdk_drawable_set_colormap(GDK_DRAWABLE(pixmap_), colormap); |
| 264 // The GdkDrawable now owns the GdkColormap. |
| 265 g_object_unref(colormap); |
| 266 } | 266 } |
| 267 | 267 |
| 268 #ifdef DEBUG_RECTANGLES | 268 #ifdef DEBUG_RECTANGLES |
| 269 namespace { | 269 namespace { |
| 270 | 270 |
| 271 // Draw a rectangle on a Cairo context. | 271 // Draw a rectangle on a Cairo context. |
| 272 // Useful for debugging various rectangles involved in drawing plugins. | 272 // Useful for debugging various rectangles involved in drawing plugins. |
| 273 void DrawDebugRectangle(cairo_t* cairo, | 273 void DrawDebugRectangle(cairo_t* cairo, |
| 274 const gfx::Rect& rect, | 274 const gfx::Rect& rect, |
| 275 float r, float g, float b) { | 275 float r, float g, float b) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 window_.width = window_rect_.width(); | 472 window_.width = window_rect_.width(); |
| 473 window_.x = window_rect_.x(); | 473 window_.x = window_rect_.x(); |
| 474 window_.y = window_rect_.y(); | 474 window_.y = window_rect_.y(); |
| 475 window_.type = NPWindowTypeDrawable; | 475 window_.type = NPWindowTypeDrawable; |
| 476 | 476 |
| 477 if (!window_.ws_info) | 477 if (!window_.ws_info) |
| 478 window_.ws_info = new NPSetWindowCallbackStruct; | 478 window_.ws_info = new NPSetWindowCallbackStruct; |
| 479 NPSetWindowCallbackStruct* extra = | 479 NPSetWindowCallbackStruct* extra = |
| 480 static_cast<NPSetWindowCallbackStruct*>(window_.ws_info); | 480 static_cast<NPSetWindowCallbackStruct*>(window_.ws_info); |
| 481 extra->display = GDK_DISPLAY(); | 481 extra->display = GDK_DISPLAY(); |
| 482 GdkVisual* visual = gdk_visual_get_system(); | 482 extra->visual = DefaultVisual(GDK_DISPLAY(), 0); |
| 483 extra->visual = GDK_VISUAL_XVISUAL(visual); | 483 extra->depth = DefaultDepth(GDK_DISPLAY(), 0); |
| 484 extra->depth = visual->depth; | 484 extra->colormap = DefaultColormap(GDK_DISPLAY(), 0); |
| 485 GdkColormap* colormap = gdk_colormap_new(gdk_visual_get_system(), FALSE); | |
| 486 extra->colormap = GDK_COLORMAP_XCOLORMAP(colormap); | |
| 487 | 485 |
| 488 if (!force_set_window) | 486 if (!force_set_window) |
| 489 windowless_needs_set_window_ = false; | 487 windowless_needs_set_window_ = false; |
| 490 | 488 |
| 491 NPError err = instance()->NPP_SetWindow(&window_); | 489 NPError err = instance()->NPP_SetWindow(&window_); |
| 492 DCHECK(err == NPERR_NO_ERROR); | 490 DCHECK(err == NPERR_NO_ERROR); |
| 493 if (quirks_ & PLUGIN_QUIRK_WINDOWLESS_INVALIDATE_AFTER_SET_WINDOW) { | 491 if (quirks_ & PLUGIN_QUIRK_WINDOWLESS_INVALIDATE_AFTER_SET_WINDOW) { |
| 494 // After a NPP_SetWindow, Flash cancels its timer that generates the | 492 // After a NPP_SetWindow, Flash cancels its timer that generates the |
| 495 // invalidates until it gets a paint event, but doesn't explicitly call | 493 // invalidates until it gets a paint event, but doesn't explicitly call |
| 496 // NPP_InvalidateRect. | 494 // NPP_InvalidateRect. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 if (event->event == WM_MOUSEMOVE) { | 699 if (event->event == WM_MOUSEMOVE) { |
| 702 // Snag a reference to the current cursor ASAP in case the plugin modified | 700 // Snag a reference to the current cursor ASAP in case the plugin modified |
| 703 // it. There is a nasty race condition here with the multiprocess browser | 701 // it. There is a nasty race condition here with the multiprocess browser |
| 704 // as someone might be setting the cursor in the main process as well. | 702 // as someone might be setting the cursor in the main process as well. |
| 705 *cursor = current_windowless_cursor_; | 703 *cursor = current_windowless_cursor_; |
| 706 } | 704 } |
| 707 #endif | 705 #endif |
| 708 | 706 |
| 709 return ret; | 707 return ret; |
| 710 } | 708 } |
| OLD | NEW |