Changeset 196053 in webkit
- Timestamp:
- Feb 3, 2016 12:18:23 AM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r196046 r196053 1 2016-02-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [UNIX] Add support for windowless NPAPI plugins with no UI in non X11 platforms 4 https://bugs.webkit.org/show_bug.cgi?id=151992 5 6 Reviewed by Darin Adler. 7 8 We are currently disabling all plugins when running under wayland, 9 for example. There are some plugins, like the one used by 10 extensions.gnome.org, that don't do any rendering, so there's not 11 reason not to support those plugins under wayland or any other 12 unix non-x11 platform. 13 X11 specific code has been moved to a new class NetscapePluginX11, 14 only used under X11. The common code is in NetscapePluginUnix.cpp 15 that will use the X11 implementatin only when needed and 16 available. For windowed plugins we will fail the initialization 17 under non-X11 plaforms, while for windowless plugins we will just 18 return early from paint method. 19 20 * PlatformEfl.cmake: Add new files to compilation. 21 * PlatformGTK.cmake: Ditto. 22 * UIProcess/API/gtk/WebKitSettings.cpp: 23 (webkit_settings_set_enable_plugins): Do not disable plugins in wayland. 24 * UIProcess/gtk/WebPreferencesGtk.cpp: 25 (WebKit::WebPreferences::platformInitializeStore): Ditto. 26 * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp: 27 (WebKit::NPN_GetValue): Use PlatformDisplay instead of 28 NetscapePlugin::x11HostDisplay() and don't claim to support X11 29 specific features under non-x11 platforms. 30 * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: 31 (WebKit::NetscapePlugin::NetscapePlugin): Remove X11 and GTK 32 specific memebers that are now moved to a dedicated class NetscapePluginX11. 33 * WebProcess/Plugins/Netscape/NetscapePlugin.h: 34 (WebKit::NetscapePlugin::frameRectInWindowCoordinates): Make this public. 35 (WebKit::NetscapePlugin::clipRect): Add getter. 36 (WebKit::NetscapePlugin::size): Ditto. 37 (WebKit::NetscapePlugin::isWindowed): Ditto. 38 (WebKit::NetscapePlugin::isVisible): Ditto. 39 * WebProcess/Plugins/Netscape/unix/NetscapePluginUnix.cpp: Added. 40 (WebKit::NetscapePlugin::platformPreInitialize): 41 (WebKit::NetscapePlugin::platformPostInitialize): 42 (WebKit::NetscapePlugin::platformDestroy): 43 (WebKit::NetscapePlugin::platformInvalidate): 44 (WebKit::NetscapePlugin::platformGeometryDidChange): 45 (WebKit::NetscapePlugin::platformVisibilityDidChange): 46 (WebKit::NetscapePlugin::platformPaint): 47 (WebKit::NetscapePlugin::platformHandleMouseEvent): 48 (WebKit::NetscapePlugin::platformHandleWheelEvent): 49 (WebKit::NetscapePlugin::platformSetFocus): 50 (WebKit::NetscapePlugin::wantsPluginRelativeNPWindowCoordinates): 51 (WebKit::NetscapePlugin::platformHandleMouseEnterEvent): 52 (WebKit::NetscapePlugin::platformHandleMouseLeaveEvent): 53 (WebKit::NetscapePlugin::platformHandleKeyboardEvent): 54 * WebProcess/Plugins/Netscape/unix/NetscapePluginUnix.h: Added. 55 (WebKit::NetscapePluginUnix::~NetscapePluginUnix): 56 * WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp: 57 (WebKit::getPluginDisplay): 58 (WebKit::displayDepth): 59 (WebKit::x11HostDisplay): 60 (WebKit::NetscapePluginX11::create): 61 (WebKit::NetscapePluginX11::NetscapePluginX11): 62 (WebKit::NetscapePluginX11::~NetscapePluginX11): 63 (WebKit::NetscapePluginX11::windowType): 64 (WebKit::NetscapePluginX11::window): 65 (WebKit::NetscapePluginX11::geometryDidChange): 66 (WebKit::NetscapePluginX11::visibilityDidChange): 67 (WebKit::NetscapePluginX11::paint): 68 (WebKit::initializeXEvent): 69 (WebKit::NetscapePluginX11::handleMouseEvent): 70 (WebKit::NetscapePluginX11::handleWheelEvent): 71 (WebKit::NetscapePluginX11::setFocus): 72 (WebKit::NetscapePluginX11::handleMouseEnterEvent): 73 (WebKit::NetscapePluginX11::handleMouseLeaveEvent): 74 (WebKit::NetscapePluginX11::handleKeyboardEvent): 75 (WebKit::setCommonMouseEventFields): Deleted. 76 (WebKit::setXKeyEventFields): Deleted. 77 * WebProcess/Plugins/Netscape/x11/NetscapePluginX11.h: Added. 78 1 79 2016-02-02 Gyuyoung Kim <gyuyoung.kim@webkit.org> 2 80 -
trunk/Source/WebKit2/PlatformEfl.cmake
r194637 r196053 201 201 WebProcess/MediaCache/WebMediaKeyStorageManager.cpp 202 202 203 WebProcess/Plugins/Netscape/unix/NetscapePluginUnix.cpp 203 204 WebProcess/Plugins/Netscape/unix/PluginProxyUnix.cpp 204 205 … … 274 275 "${WEBKIT2_DIR}/WebProcess/unix" 275 276 "${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/efl" 277 "${WEBKIT2_DIR}/WebProcess/Plugins/Netscape/unix" 278 "${WEBKIT2_DIR}/WebProcess/Plugins/Netscape/x11" 276 279 "${WEBKIT2_DIR}/WebProcess/WebCoreSupport/efl" 277 280 "${WEBKIT2_DIR}/WebProcess/WebCoreSupport/soup" -
trunk/Source/WebKit2/PlatformGTK.cmake
r195902 r196053 339 339 WebProcess/MediaCache/WebMediaKeyStorageManager.cpp 340 340 341 WebProcess/Plugins/Netscape/unix/NetscapePluginUnix.cpp 341 342 WebProcess/Plugins/Netscape/unix/PluginProxyUnix.cpp 342 343 … … 525 526 "${WEBKIT2_DIR}/UIProcess/soup" 526 527 "${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/gtk" 528 "${WEBKIT2_DIR}/WebProcess/Plugins/Netscape/unix" 529 "${WEBKIT2_DIR}/WebProcess/Plugins/Netscape/x11" 527 530 "${WEBKIT2_DIR}/WebProcess/gtk" 528 531 "${WEBKIT2_DIR}/WebProcess/soup" … … 794 797 WebProcess/Plugins/Netscape/NetscapePluginStream.cpp 795 798 799 WebProcess/Plugins/Netscape/unix/NetscapePluginUnix.cpp 796 800 WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp 797 801 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
r187641 r196053 1595 1595 g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); 1596 1596 1597 #if PLATFORM(WAYLAND)1598 // Do not allow to change this setting in Wayland, since plugins are not supported.1599 if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::Wayland)1600 return;1601 #endif1602 1603 1597 WebKitSettingsPrivate* priv = settings->priv; 1604 1598 bool currentValue = priv->preferences->pluginsEnabled(); -
trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp
r193626 r196053 40 40 // https://bugs.webkit.org/show_bug.cgi?id=115803 41 41 setAcceleratedCompositingEnabled(false); 42 43 setPluginsEnabled(false);44 42 } 45 43 #endif -
trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
r194496 r196053 46 46 #endif 47 47 48 #if PLUGIN_ARCHITECTURE(X11) 49 #include <WebCore/PlatformDisplayX11.h> 50 #endif 51 48 52 using namespace WebCore; 49 53 … … 525 529 #endif 526 530 #elif PLUGIN_ARCHITECTURE(X11) 527 case NPNVxDisplay: { 528 if (!npp) 529 return NPERR_GENERIC_ERROR; 530 *reinterpret_cast<Display**>(value) = NetscapePlugin::x11HostDisplay(); 531 break; 532 } 533 case NPNVSupportsXEmbedBool: 534 *static_cast<NPBool*>(value) = true; 535 break; 536 case NPNVSupportsWindowless: 537 *static_cast<NPBool*>(value) = true; 538 break; 531 case NPNVxDisplay: { 532 if (!npp) 533 return NPERR_GENERIC_ERROR; 534 auto& display = PlatformDisplay::sharedDisplay(); 535 if (display.type() != PlatformDisplay::Type::X11) 536 return NPERR_GENERIC_ERROR; 537 *reinterpret_cast<Display**>(value) = downcast<PlatformDisplayX11>(display).native(); 538 break; 539 } 540 case NPNVSupportsXEmbedBool: 541 *static_cast<NPBool*>(value) = PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11; 542 break; 543 case NPNVSupportsWindowless: 544 *static_cast<NPBool*>(value) = true; 545 break; 539 546 540 547 case NPNVToolkit: { -
trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
r195452 r196053 43 43 #include <wtf/text/CString.h> 44 44 45 #if PLUGIN_ARCHITECTURE(X11) 46 #include "NetscapePluginUnix.h" 47 #endif 48 45 49 using namespace WebCore; 46 50 … … 91 95 , m_npCGContext() 92 96 #endif 93 #elif PLUGIN_ARCHITECTURE(X11)94 , m_drawable(0)95 , m_pluginDisplay(0)96 #if PLATFORM(GTK)97 , m_platformPluginWidget(0)98 #endif99 97 #endif 100 98 { -
trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
r191922 r196053 39 39 #include <wtf/text/StringHash.h> 40 40 41 #if PLUGIN_ARCHITECTURE(X11)42 #include <WebCore/XUniqueResource.h>43 #endif44 45 41 namespace WebCore { 46 42 class MachSendRight; … … 55 51 56 52 class NetscapePluginStream; 57 53 class NetscapePluginUnix; 54 58 55 class NetscapePlugin : public Plugin { 59 56 public: … … 95 92 96 93 #endif 94 95 #if PLUGIN_ARCHITECTURE(X11) 96 const WebCore::IntRect& frameRectInWindowCoordinates() const { return m_frameRectInWindowCoordinates; } 97 #endif 98 const WebCore::IntRect& clipRect() const { return m_clipRect; } 99 const WebCore::IntSize& size() const { return m_pluginSize; } 97 100 98 101 PluginQuirks quirks() const { return m_pluginModule->pluginQuirks(); } … … 110 113 bool isPrivateBrowsingEnabled(); 111 114 bool isMuted() const; 115 bool isWindowed() const { return m_isWindowed; } 116 bool isVisible() const { return m_isVisible; } 112 117 113 118 static void setSetExceptionFunction(void (*)(const String&)); … … 155 160 NPError NPP_GetValue(NPPVariable, void *value); 156 161 NPError NPP_SetValue(NPNVariable, void *value); 162 163 // Convert the given point from plug-in coordinates to root view coordinates. 164 virtual WebCore::IntPoint convertToRootView(const WebCore::IntPoint&) const override; 157 165 158 166 private: … … 259 267 virtual bool supportsSnapshotting() const override; 260 268 261 // Convert the given point from plug-in coordinates to root view coordinates.262 virtual WebCore::IntPoint convertToRootView(const WebCore::IntPoint&) const override;263 264 269 // Convert the given point from root view coordinates to plug-in coordinates. Returns false if the point can't be 265 270 // converted (if the transformation matrix isn't invertible). … … 277 282 278 283 void updateNPNPrivateMode(); 279 280 #if PLUGIN_ARCHITECTURE(X11)281 bool platformPostInitializeWindowed(bool needsXEmbed, uint64_t windowID);282 bool platformPostInitializeWindowless();283 #endif284 284 285 285 uint64_t m_nextRequestID; … … 395 395 #endif 396 396 #elif PLUGIN_ARCHITECTURE(X11) 397 WebCore::XUniquePixmap m_drawable; 398 Display* m_pluginDisplay; 399 #if PLATFORM(GTK) 400 GtkWidget* m_platformPluginWidget; 401 #endif 402 403 public: // Need to call it in the NPN_GetValue browser callback. 404 static Display* x11HostDisplay(); 397 std::unique_ptr<NetscapePluginUnix> m_impl; 405 398 #endif 406 399 }; -
trunk/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
r192311 r196053 26 26 27 27 #include "config.h" 28 #include "NetscapePluginX11.h" 29 28 30 #if PLUGIN_ARCHITECTURE(X11) && ENABLE(NETSCAPE_PLUGIN_API) 29 31 30 32 #include "NetscapePlugin.h" 31 32 33 #include "PluginController.h" 33 34 #include "WebEvent.h" … … 58 59 namespace WebKit { 59 60 61 static inline Display* x11HostDisplay() 62 { 63 return downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native(); 64 } 65 60 66 static Display* getPluginDisplay() 61 67 { … … 67 73 return static_cast<Display*>(ecore_x_display_get()); 68 74 #else 69 return 0;75 return nullptr; 70 76 #endif 71 77 } … … 87 93 return gdk_visual_get_depth(gdk_screen_get_system_visual(gdk_screen_get_default())); 88 94 #elif PLATFORM(EFL) && defined(HAVE_ECORE_X) 89 return ecore_x_default_depth_get( NetscapePlugin::x11HostDisplay(), ecore_x_default_screen_get());95 return ecore_x_default_depth_get(x11HostDisplay(), ecore_x_default_screen_get()); 90 96 #else 91 97 return 0; … … 102 108 return 0; 103 109 #endif 104 }105 106 Display* NetscapePlugin::x11HostDisplay()107 {108 return downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();109 110 } 110 111 … … 120 121 #endif 121 122 122 bool NetscapePlugin::platformPostInitializeWindowed(bool needsXEmbed, uint64_t windowID) 123 { 124 m_npWindow.type = NPWindowTypeWindow; 125 if (!needsXEmbed) { 123 std::unique_ptr<NetscapePluginX11> NetscapePluginX11::create(NetscapePlugin& plugin) 124 { 125 #if PLATFORM(GTK) 126 uint64_t windowID = 0; 127 #endif 128 if (plugin.isWindowed()) { 129 #if PLATFORM(GTK) 130 // NPPVplugiNeedsXEmbed is a boolean value, but at least the 131 // Flash player plugin is using an 'int' instead. 132 int needsXEmbed = 0; 133 plugin.NPP_GetValue(NPPVpluginNeedsXEmbed, &needsXEmbed); 134 if (needsXEmbed) { 135 windowID = plugin.controller()->createPluginContainer(); 136 if (!windowID) 137 return nullptr; 138 } else { 139 notImplemented(); 140 return nullptr; 141 } 142 #else 126 143 notImplemented(); 127 return false; 144 return nullptr; 145 #endif 128 146 } 129 147 130 Display* display = x11HostDisplay(); 131 132 #if PLATFORM(GTK) 148 Display* display = getPluginDisplay(); 149 if (!display) 150 return nullptr; 151 152 #if PLATFORM(GTK) 153 if (plugin.isWindowed()) 154 return std::make_unique<NetscapePluginX11>(plugin, display, windowID); 155 #endif 156 157 return std::make_unique<NetscapePluginX11>(plugin, display); 158 } 159 160 NetscapePluginX11::NetscapePluginX11(NetscapePlugin& plugin, Display* display) 161 : m_plugin(plugin) 162 , m_pluginDisplay(display) 163 { 164 Display* hostDisplay = x11HostDisplay(); 165 int depth = displayDepth(); 166 m_setWindowCallbackStruct.display = hostDisplay; 167 m_setWindowCallbackStruct.depth = depth; 168 169 XVisualInfo visualTemplate; 170 visualTemplate.screen = x11Screen(); 171 visualTemplate.depth = depth; 172 visualTemplate.c_class = TrueColor; 173 int numMatching; 174 XUniquePtr<XVisualInfo> visualInfo(XGetVisualInfo(hostDisplay, VisualScreenMask | VisualDepthMask | VisualClassMask, &visualTemplate, &numMatching)); 175 ASSERT(visualInfo); 176 Visual* visual = visualInfo.get()[0].visual; 177 ASSERT(visual); 178 179 m_setWindowCallbackStruct.visual = visual; 180 m_setWindowCallbackStruct.colormap = XCreateColormap(hostDisplay, rootWindowID(), visual, AllocNone); 181 } 182 183 #if PLATFORM(GTK) 184 NetscapePluginX11::NetscapePluginX11(NetscapePlugin& plugin, Display* display, uint64_t windowID) 185 : m_plugin(plugin) 186 , m_pluginDisplay(display) 187 , m_windowID(windowID) 188 { 133 189 // It seems flash needs the socket to be in the same process, 134 190 // I guess it uses gdk_window_lookup(), so we create a new socket here … … 147 203 gtk_widget_show(socket); 148 204 149 m_npWindow.window = GINT_TO_POINTER(gtk_socket_get_id(GTK_SOCKET(socket))); 205 Display* hostDisplay = x11HostDisplay(); 206 m_npWindowID = gtk_socket_get_id(GTK_SOCKET(socket)); 150 207 GdkWindow* window = gtk_widget_get_window(socket); 151 NPSetWindowCallbackStruct* callbackStruct = static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info); 152 callbackStruct->display = GDK_WINDOW_XDISPLAY(window); 153 callbackStruct->visual = GDK_VISUAL_XVISUAL(gdk_window_get_visual(window)); 154 callbackStruct->depth = gdk_visual_get_depth(gdk_window_get_visual(window)); 155 callbackStruct->colormap = XCreateColormap(display, GDK_ROOT_WINDOW(), callbackStruct->visual, AllocNone); 156 #else 157 UNUSED_PARAM(windowID); 158 #endif 159 160 XFlush(display); 161 162 callSetWindow(); 163 164 return true; 165 } 166 167 bool NetscapePlugin::platformPostInitializeWindowless() 168 { 169 Display* display = x11HostDisplay(); 170 m_npWindow.type = NPWindowTypeDrawable; 171 m_npWindow.window = 0; 172 173 int depth = displayDepth(); 174 175 NPSetWindowCallbackStruct* callbackStruct = static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info); 176 callbackStruct->display = display; 177 callbackStruct->depth = depth; 178 179 XVisualInfo visualTemplate; 180 visualTemplate.screen = x11Screen(); 181 visualTemplate.depth = depth; 182 visualTemplate.c_class = TrueColor; 183 int numMatching; 184 XUniquePtr<XVisualInfo> visualInfo(XGetVisualInfo(display, VisualScreenMask | VisualDepthMask | VisualClassMask, &visualTemplate, &numMatching)); 185 ASSERT(visualInfo); 186 Visual* visual = visualInfo.get()[0].visual; 187 ASSERT(visual); 188 189 callbackStruct->visual = visual; 190 callbackStruct->colormap = XCreateColormap(display, rootWindowID(), visual, AllocNone); 191 192 callSetWindow(); 193 194 return true; 195 } 196 197 void NetscapePlugin::platformPreInitialize() 198 { 199 } 200 201 bool NetscapePlugin::platformPostInitialize() 202 { 203 uint64_t windowID = 0; 204 // NPPVpluginNeedsXEmbed is a boolean value, but at least the 205 // Flash player plugin is using an 'int' instead. 206 int needsXEmbed = 0; 207 if (m_isWindowed) { 208 NPP_GetValue(NPPVpluginNeedsXEmbed, &needsXEmbed); 209 if (needsXEmbed) { 210 windowID = controller()->createPluginContainer(); 211 if (!windowID) 212 return false; 213 } else { 214 notImplemented(); 215 return false; 216 } 217 } 218 219 if (!(m_pluginDisplay = getPluginDisplay())) 220 return false; 221 222 NPSetWindowCallbackStruct* callbackStruct = new NPSetWindowCallbackStruct; 223 callbackStruct->type = 0; 224 m_npWindow.ws_info = callbackStruct; 225 226 if (m_isWindowed) 227 return platformPostInitializeWindowed(needsXEmbed, windowID); 228 229 return platformPostInitializeWindowless(); 230 } 231 232 void NetscapePlugin::platformDestroy() 233 { 234 NPSetWindowCallbackStruct* callbackStruct = static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info); 235 Display* hostDisplay = x11HostDisplay(); 236 XFreeColormap(hostDisplay, callbackStruct->colormap); 237 delete callbackStruct; 208 m_setWindowCallbackStruct.display = GDK_WINDOW_XDISPLAY(window); 209 m_setWindowCallbackStruct.visual = GDK_VISUAL_XVISUAL(gdk_window_get_visual(window)); 210 m_setWindowCallbackStruct.depth = gdk_visual_get_depth(gdk_window_get_visual(window)); 211 m_setWindowCallbackStruct.colormap = XCreateColormap(hostDisplay, GDK_ROOT_WINDOW(), m_setWindowCallbackStruct.visual, AllocNone); 212 213 XFlush(hostDisplay); 214 } 215 #endif 216 217 NetscapePluginX11::~NetscapePluginX11() 218 { 219 XFreeColormap(x11HostDisplay(), m_setWindowCallbackStruct.colormap); 238 220 239 221 m_drawable.reset(); 240 222 241 223 #if PLATFORM(GTK) 242 if (m_platformPluginWidget) {224 if (m_platformPluginWidget) 243 225 gtk_widget_destroy(m_platformPluginWidget); 244 m_platformPluginWidget = 0; 245 } 246 #endif 247 } 248 249 bool NetscapePlugin::platformInvalidate(const IntRect&) 250 { 251 notImplemented(); 252 return false; 253 } 254 255 void NetscapePlugin::platformGeometryDidChange() 256 { 257 if (m_isWindowed) { 226 #endif 227 } 228 229 NPWindowType NetscapePluginX11::windowType() const 230 { 231 return m_plugin.isWindowed() ? NPWindowTypeWindow : NPWindowTypeDrawable; 232 } 233 234 void* NetscapePluginX11::window() const 235 { 236 #if PLATFORM(GTK) 237 return m_plugin.isWindowed() ? GINT_TO_POINTER(m_npWindowID) : nullptr; 238 #else 239 return nullptr; 240 #endif 241 } 242 243 void NetscapePluginX11::geometryDidChange() 244 { 245 if (m_plugin.isWindowed()) { 258 246 uint64_t windowID = 0; 259 247 #if PLATFORM(GTK) 260 248 windowID = static_cast<uint64_t>(GDK_WINDOW_XID(gtk_plug_get_socket_window(GTK_PLUG(m_platformPluginWidget)))); 261 249 #endif 262 controller()->windowedPluginGeometryDidChange(m_frameRectInWindowCoordinates, m_clipRect, windowID);250 m_plugin.controller()->windowedPluginGeometryDidChange(m_plugin.frameRectInWindowCoordinates(), m_plugin.clipRect(), windowID); 263 251 return; 264 252 } 265 253 266 254 m_drawable.reset(); 267 if (m_plugin Size.isEmpty())255 if (m_plugin.size().isEmpty()) 268 256 return; 269 257 270 m_drawable = XCreatePixmap(x11HostDisplay(), rootWindowID(), m_plugin Size.width(), m_pluginSize.height(), displayDepth());258 m_drawable = XCreatePixmap(x11HostDisplay(), rootWindowID(), m_plugin.size().width(), m_plugin.size().height(), displayDepth()); 271 259 XSync(x11HostDisplay(), false); // Make sure that the server knows about the Drawable. 272 260 } 273 261 274 void NetscapePlugin::platformVisibilityDidChange() 275 { 276 if (!m_isWindowed) 277 return; 278 262 void NetscapePluginX11::visibilityDidChange() 263 { 264 ASSERT(m_plugin.isWindowed()); 279 265 uint64_t windowID = 0; 280 266 #if PLATFORM(GTK) 281 267 windowID = static_cast<uint64_t>(GDK_WINDOW_XID(gtk_plug_get_socket_window(GTK_PLUG(m_platformPluginWidget)))); 282 268 #endif 283 controller()->windowedPluginVisibilityDidChange(m_isVisible, windowID); 284 controller()->windowedPluginGeometryDidChange(m_frameRectInWindowCoordinates, m_clipRect, windowID); 285 } 286 287 void NetscapePlugin::platformPaint(GraphicsContext& context, const IntRect& dirtyRect, bool /*isSnapshot*/) 288 { 289 if (m_isWindowed) 290 return; 291 292 if (!m_isStarted) { 293 // FIXME: we should paint a missing plugin icon. 294 return; 295 } 269 m_plugin.controller()->windowedPluginVisibilityDidChange(m_plugin.isVisible(), windowID); 270 m_plugin.controller()->windowedPluginGeometryDidChange(m_plugin.frameRectInWindowCoordinates(), m_plugin.clipRect(), windowID); 271 } 272 273 void NetscapePluginX11::paint(GraphicsContext& context, const IntRect& dirtyRect) 274 { 275 ASSERT(m_plugin.isWindowed()); 296 276 297 277 if (context.paintingDisabled() || !m_drawable) … … 314 294 exposeEvent.height = exposedRect.height(); 315 295 316 NPP_HandleEvent(&xevent);296 m_plugin.NPP_HandleEvent(&xevent); 317 297 318 298 if (m_pluginDisplay != x11HostDisplay()) … … 321 301 #if PLATFORM(GTK) || (PLATFORM(EFL) && USE(CAIRO)) 322 302 RefPtr<cairo_surface_t> drawableSurface = adoptRef(cairo_xlib_surface_create(m_pluginDisplay, m_drawable.get(), 323 static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info)->visual, m_pluginSize.width(), m_pluginSize.height()));303 m_setWindowCallbackStruct.visual, m_plugin.size().width(), m_plugin.size().height())); 324 304 cairo_t* cr = context.platformContext()->cr(); 325 305 cairo_save(cr); … … 343 323 event.xany.serial = 0; 344 324 event.xany.send_event = false; 345 event.xany.display = NetscapePlugin::x11HostDisplay();325 event.xany.display = x11HostDisplay(); 346 326 event.xany.window = 0; 347 327 } … … 441 421 } 442 422 443 bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& event) 444 { 445 if (m_isWindowed) 446 return false; 447 448 if ((event.type() == WebEvent::MouseDown || event.type() == WebEvent::MouseUp) 449 && event.button() == WebMouseEvent::RightButton 450 && quirks().contains(PluginQuirks::IgnoreRightClickInWindowlessMode)) 451 return false; 423 bool NetscapePluginX11::handleMouseEvent(const WebMouseEvent& event) 424 { 425 ASSERT(m_plugin.isWindowed()); 452 426 453 427 XEvent xEvent; … … 457 431 case WebEvent::MouseDown: 458 432 case WebEvent::MouseUp: 459 setXButtonEventFields(xEvent, event, convertToRootView(IntPoint()));433 setXButtonEventFields(xEvent, event, m_plugin.convertToRootView(IntPoint())); 460 434 break; 461 435 case WebEvent::MouseMove: 462 setXMotionEventFields(xEvent, event, convertToRootView(IntPoint()));436 setXMotionEventFields(xEvent, event, m_plugin.convertToRootView(IntPoint())); 463 437 break; 464 438 case WebEvent::MouseForceChanged: … … 480 454 } 481 455 482 return ! NPP_HandleEvent(&xEvent);456 return !m_plugin.NPP_HandleEvent(&xEvent); 483 457 } 484 458 … … 490 464 const int kFocusOutType = 10; 491 465 492 bool NetscapePlugin::platformHandleWheelEvent(const WebWheelEvent& event) 493 { 494 if (m_isWindowed) 495 return false; 466 bool NetscapePluginX11::handleWheelEvent(const WebWheelEvent& event) 467 { 468 ASSERT(m_plugin.isWindowed()); 496 469 497 470 XEvent xEvent; 498 471 initializeXEvent(xEvent); 499 setXButtonEventFieldsByWebWheelEvent(xEvent, event, convertToRootView(IntPoint())); 500 501 return !NPP_HandleEvent(&xEvent); 502 } 503 504 void NetscapePlugin::platformSetFocus(bool focusIn) 505 { 506 if (m_isWindowed) 507 return; 472 setXButtonEventFieldsByWebWheelEvent(xEvent, event, m_plugin.convertToRootView(IntPoint())); 473 474 return !m_plugin.NPP_HandleEvent(&xEvent); 475 } 476 477 void NetscapePluginX11::setFocus(bool focusIn) 478 { 479 ASSERT(m_plugin.isWindowed()); 508 480 509 481 XEvent xEvent; … … 514 486 focusEvent.detail = NotifyDetailNone; 515 487 516 NPP_HandleEvent(&xEvent); 517 } 518 519 bool NetscapePlugin::wantsPluginRelativeNPWindowCoordinates() 520 { 521 return true; 522 } 523 524 bool NetscapePlugin::platformHandleMouseEnterEvent(const WebMouseEvent& event) 525 { 526 if (m_isWindowed) 527 return false; 488 m_plugin.NPP_HandleEvent(&xEvent); 489 } 490 491 bool NetscapePluginX11::handleMouseEnterEvent(const WebMouseEvent& event) 492 { 493 ASSERT(m_plugin.isWindowed()); 528 494 529 495 XEvent xEvent; 530 496 initializeXEvent(xEvent); 531 setXCrossingEventFields(xEvent, event, convertToRootView(IntPoint()), EnterNotify); 532 533 return !NPP_HandleEvent(&xEvent); 534 } 535 536 bool NetscapePlugin::platformHandleMouseLeaveEvent(const WebMouseEvent& event) 537 { 538 if (m_isWindowed) 539 return false; 497 setXCrossingEventFields(xEvent, event, m_plugin.convertToRootView(IntPoint()), EnterNotify); 498 499 return !m_plugin.NPP_HandleEvent(&xEvent); 500 } 501 502 bool NetscapePluginX11::handleMouseLeaveEvent(const WebMouseEvent& event) 503 { 504 ASSERT(m_plugin.isWindowed()); 540 505 541 506 XEvent xEvent; 542 507 initializeXEvent(xEvent); 543 setXCrossingEventFields(xEvent, event, convertToRootView(IntPoint()), LeaveNotify);544 545 return ! NPP_HandleEvent(&xEvent);508 setXCrossingEventFields(xEvent, event, m_plugin.convertToRootView(IntPoint()), LeaveNotify); 509 510 return !m_plugin.NPP_HandleEvent(&xEvent); 546 511 } 547 512 … … 566 531 } 567 532 568 bool NetscapePlugin::platformHandleKeyboardEvent(const WebKeyboardEvent& event) 569 { 533 bool NetscapePluginX11::handleKeyboardEvent(const WebKeyboardEvent& event) 534 { 535 ASSERT(m_plugin.isWindowed()); 570 536 // We don't generate other types of keyboard events via WebEventFactory. 571 537 ASSERT(event.type() == WebEvent::KeyDown || event.type() == WebEvent::KeyUp); … … 575 541 setXKeyEventFields(xEvent, event); 576 542 577 return ! NPP_HandleEvent(&xEvent);543 return !m_plugin.NPP_HandleEvent(&xEvent); 578 544 } 579 545
Note: See TracChangeset
for help on using the changeset viewer.