Changeset 163505 in webkit
- Timestamp:
- Feb 5, 2014 6:30:04 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r163503 r163505 1 2014-02-05 Ryuan Choi <ryuan.choi@samsung.com> 2 3 [EFL][GTK] Share plugin's implementation between EFL and Gtk ports. 4 https://bugs.webkit.org/show_bug.cgi?id=70592 5 6 Reviewed by Gyuyoung Kim. 7 8 Merge common logics of PluginViewGtk.cpp and PluginViewEfl.cpp to PluginViewX11.cpp. 9 So, this patch improves the windowless plugin support for the EFL port. 10 11 * GNUmakefile.am: Add include path for gtk2xtbin.h header file. 12 * GNUmakefile.list.am: Added PluginViewX11.cpp into source lists. 13 * PlatformEfl.cmake: Ditto. 14 * PlatformGTK.cmake: Ditto. 15 * plugins/PluginView.h: Added getRootWindow and getPluginDisply which implement platform specific code. 16 * plugins/efl/PluginViewEfl.cpp: 17 (WebCore::PluginView::getRootWindow): 18 (WebCore::PluginView::platformGetValueStatic): Turn on NPNVSupportsWindowless support. 19 (WebCore::PluginView::getPluginDisplay): 20 (WebCore::PluginView::platformStart): 21 * plugins/gtk/PluginViewGtk.cpp: 22 (WebCore::PluginView::getRootWindow): 23 (WebCore::setXButtonEventSpecificFields): 24 (WebCore::setXMotionEventSpecificFields): 25 (WebCore::setXCrossingEventSpecificFields): 26 (WebCore::PluginView::getPluginDisplay): 27 (WebCore::PluginView::platformStart): 28 * plugins/x11/PluginViewX11.cpp: Moved common logics from PluginViewGtk.cpp 29 (WebCore::PluginView::dispatchNPEvent): 30 (WebCore::PluginView::updatePluginWidget): 31 (WebCore::PluginView::handleFocusInEvent): 32 (WebCore::PluginView::invalidateRect): 33 (WebCore::PluginView::invalidateRegion): 34 (WebCore::PluginView::handleFocusOutEvent): 35 (WebCore::PluginView::initXEvent): 36 (WebCore::PluginView::paint): 37 (WebCore::PluginView::setParent): 38 (WebCore::PluginView::setNPWindowRect): 39 (WebCore::PluginView::setNPWindowIfNeeded): 40 1 41 2014-02-05 Anders Carlsson <andersca@apple.com> 2 42 -
trunk/Source/WebCore/GNUmakefile.am
r163440 r163505 94 94 -I$(srcdir)/Source/WebCore/platform/win \ 95 95 -I$(srcdir)/Source/WebCore/plugins \ 96 -I$(srcdir)/Source/WebCore/plugins/gtk \ 96 97 -I$(srcdir)/Source/WebCore/plugins/win \ 97 98 -I$(srcdir)/Source/WebCore/rendering \ -
trunk/Source/WebCore/GNUmakefile.list.am
r163359 r163505 6223 6223 Source/WebCore/plugins/gtk/PluginPackageGtk.cpp \ 6224 6224 Source/WebCore/plugins/gtk/PluginViewGtk.cpp \ 6225 Source/WebCore/plugins/gtk/xembed.h 6225 Source/WebCore/plugins/gtk/xembed.h \ 6226 Source/WebCore/plugins/x11/PluginViewX11.cpp 6226 6227 platformgtk_sources += \ 6227 6228 Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h \ -
trunk/Source/WebCore/PlatformEfl.cmake
r162922 r163505 192 192 plugins/efl/PluginPackageEfl.cpp 193 193 plugins/efl/PluginViewEfl.cpp 194 195 plugins/x11/PluginViewX11.cpp 194 196 ) 195 197 endif () -
trunk/Source/WebCore/PlatformGTK.cmake
r163240 r163505 283 283 plugins/gtk/PluginViewGtk.cpp 284 284 plugins/gtk/gtk2xtbin.c 285 286 plugins/x11/PluginViewX11.cpp 285 287 ) 286 288 else () -
trunk/Source/WebCore/plugins/PluginView.h
r162451 r163505 58 58 #endif 59 59 60 #if PLATFORM(X11) 61 typedef unsigned long Window; 62 typedef struct _XDisplay Display; 63 #endif 64 60 65 namespace JSC { 61 66 namespace Bindings { … … 66 71 namespace WebCore { 67 72 class Frame; 73 class FrameView; 68 74 class Image; 69 75 class HTMLPlugInElement; … … 235 241 void keepAlive(); 236 242 243 #if PLATFORM(X11) 244 static Display* getPluginDisplay(Frame*); 245 static Window getRootWindow(Frame* parentFrame); 246 #endif 247 237 248 private: 238 249 PluginView(Frame* parentFrame, const IntSize&, PluginPackage*, HTMLPlugInElement*, const URL&, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually); -
trunk/Source/WebCore/plugins/efl/PluginViewEfl.cpp
r154877 r163505 4 4 * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia 5 5 * Copyright (C) 2009-2010 ProFUSION embedded systems 6 * Copyright (C) 2009-201 1Samsung Electronics6 * Copyright (C) 2009-2014 Samsung Electronics 7 7 * 8 8 * Redistribution and use in source and binary forms, with or without … … 33 33 #include "Frame.h" 34 34 #include "FrameView.h" 35 #include "GraphicsContext.h"36 35 #include "HTMLNames.h" 37 36 #include "HTMLPlugInElement.h" 38 #include "HostWindow.h"39 #include "JSDOMWindowBase.h"40 37 #include "MouseEvent.h" 41 38 #include "NotImplemented.h" … … 53 50 using namespace HTMLNames; 54 51 55 bool PluginView::dispatchNPEvent(NPEvent& event) 56 { 57 if (!m_plugin->pluginFuncs()->event) 58 return false; 59 60 PluginView::setCurrentPluginView(this); 61 JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM()); 62 setCallingPlugin(true); 63 64 bool accepted = m_plugin->pluginFuncs()->event(m_instance, &event); 65 66 setCallingPlugin(false); 67 PluginView::setCurrentPluginView(0); 68 return accepted; 69 } 70 71 #if defined(XP_UNIX) 72 void PluginView::handleFocusInEvent() 73 { 74 notImplemented(); 75 } 76 77 void PluginView::handleFocusOutEvent() 78 { 79 notImplemented(); 80 } 81 #endif 52 Window PluginView::getRootWindow(Frame* parentFrame) 53 { 54 Evas* evas = evas_object_evas_get(parentFrame->view()->evasObject()); 55 Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(evas); 56 return static_cast<Window>(ecore_evas_window_get(ecoreEvas)); 57 } 82 58 83 59 void PluginView::handleKeyboardEvent(KeyboardEvent*) … … 118 94 } 119 95 120 void PluginView::updatePluginWidget()121 {122 notImplemented();123 }124 125 96 void PluginView::setFocus(bool focused) 126 97 { … … 143 114 144 115 Widget::hide(); 145 }146 147 void PluginView::paint(GraphicsContext* context, const IntRect& rect)148 {149 if (!m_isStarted)150 paintMissingPluginIcon(context, rect);151 }152 153 void PluginView::setParent(ScrollView* parent)154 {155 Widget::setParent(parent);156 157 if (parent)158 init();159 }160 161 void PluginView::setNPWindowRect(const IntRect&)162 {163 notImplemented();164 }165 166 void PluginView::setNPWindowIfNeeded()167 {168 116 } 169 117 … … 222 170 223 171 case NPNVSupportsWindowless: 224 *static_cast<NPBool*>(value) = false;172 *static_cast<NPBool*>(value) = true; 225 173 *result = NPERR_NO_ERROR; 226 174 return true; … … 313 261 } 314 262 315 void PluginView::invalidateRect(NPRect* rect) 316 { 317 if (!rect) { 318 invalidate(); 319 return; 320 } 321 322 invalidateRect(IntRect(rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top)); 323 } 324 325 void PluginView::invalidateRegion(NPRegion) 326 { 327 notImplemented(); 263 Display* PluginView::getPluginDisplay(Frame*) 264 { 265 return static_cast<Display*>(ecore_x_display_get()); 328 266 } 329 267 … … 338 276 ASSERT(m_status == PluginStatusLoadedSuccessfully); 339 277 340 notImplemented(); 278 if (m_plugin->pluginFuncs()->getvalue) { 279 PluginView::setCurrentPluginView(this); 280 JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM()); 281 setCallingPlugin(true); 282 m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginNeedsXEmbed, &m_needsXEmbed); 283 setCallingPlugin(false); 284 PluginView::setCurrentPluginView(0); 285 } 286 287 setPlatformWidget(0); 288 m_pluginDisplay = getPluginDisplay(nullptr); 289 290 show(); 291 292 NPSetWindowCallbackStruct* ws = new NPSetWindowCallbackStruct(); 293 ws->type = 0; 294 295 m_npWindow.type = NPWindowTypeDrawable; 296 m_npWindow.window = 0; // Not used? 297 298 Screen* screen = static_cast<Screen*>(ecore_x_default_screen_get()); 299 m_visual = static_cast<Visual*>(ecore_x_default_visual_get(m_pluginDisplay, screen)); 300 m_colormap = ecore_x_default_colormap_get(m_pluginDisplay, screen); 301 302 ws->depth = ecore_x_default_depth_get(m_pluginDisplay, screen); 303 ws->display = m_pluginDisplay; 304 ws->visual = m_visual; 305 ws->colormap = m_colormap; 306 307 m_npWindow.ws_info = ws; 308 309 // FIXME: remove in favor of null events, like mac port? 310 if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))) 311 updatePluginWidget(); // was: setNPWindowIfNeeded(), but this doesn't produce 0x0 rects at first go 312 341 313 return true; 342 314 } -
trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp
r156144 r163505 53 53 #include "NotImplemented.h" 54 54 #include "Page.h" 55 #include "PlatformContextCairo.h"56 55 #include "PlatformKeyboardEvent.h" 57 56 #include "PlatformMouseEvent.h" … … 75 74 #include "RefPtrCairo.h" 76 75 #include "gtk2xtbin.h" 77 #define Bool int // this got undefined somewhere76 #define Bool int // this became undefined in npruntime_internal.h 78 77 #define Status int // ditto 79 78 #include <X11/extensions/Xrender.h> 80 #include <cairo-xlib.h>81 79 #include <gdk/gdkx.h> 82 80 … … 94 92 using namespace HTMLNames; 95 93 96 bool PluginView::dispatchNPEvent(NPEvent& event) 97 { 98 // sanity check 99 if (!m_plugin->pluginFuncs()->event) 100 return false; 101 102 PluginView::setCurrentPluginView(this); 103 JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM()); 104 setCallingPlugin(true); 105 106 bool accepted = !m_plugin->pluginFuncs()->event(m_instance, &event); 107 108 setCallingPlugin(false); 109 PluginView::setCurrentPluginView(0); 110 return accepted; 111 } 112 113 static Window getRootWindow(Frame* parentFrame) 94 Window PluginView::getRootWindow(Frame* parentFrame) 114 95 { 115 96 GtkWidget* parentWidget = parentFrame->view()->hostWindow()->platformPageClient(); 116 97 GdkScreen* gscreen = gtk_widget_get_screen(parentWidget); 117 98 return GDK_WINDOW_XWINDOW(gdk_screen_get_root_window(gscreen)); 118 }119 120 void PluginView::updatePluginWidget()121 {122 if (!parent())123 return;124 125 ASSERT(parent()->isFrameView());126 FrameView* frameView = toFrameView(parent());127 128 IntRect oldWindowRect = m_windowRect;129 IntRect oldClipRect = m_clipRect;130 131 m_windowRect = IntRect(frameView->contentsToWindow(frameRect().location()), frameRect().size());132 m_clipRect = windowClipRect();133 m_clipRect.move(-m_windowRect.x(), -m_windowRect.y());134 135 if (m_windowRect == oldWindowRect && m_clipRect == oldClipRect)136 return;137 138 if (m_status != PluginStatusLoadedSuccessfully)139 return;140 141 if (!m_isWindowed && !m_windowRect.isEmpty()) {142 Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());143 if (m_drawable)144 XFreePixmap(display, m_drawable);145 146 m_drawable = XCreatePixmap(display, getRootWindow(m_parentFrame.get()),147 m_windowRect.width(), m_windowRect.height(),148 ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth);149 XSync(display, false); // make sure that the server knows about the Drawable150 }151 152 setNPWindowIfNeeded();153 99 } 154 100 … … 171 117 ASSERT(platformPluginWidget() == platformWidget()); 172 118 Widget::hide(); 173 }174 175 void PluginView::paint(GraphicsContext* context, const IntRect& rect)176 {177 if (!m_isStarted || m_status != PluginStatusLoadedSuccessfully) {178 paintMissingPluginIcon(context, rect);179 return;180 }181 182 if (context->paintingDisabled())183 return;184 185 setNPWindowIfNeeded();186 187 if (m_isWindowed)188 return;189 190 if (!m_drawable)191 return;192 193 Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());194 const bool syncX = m_pluginDisplay && m_pluginDisplay != display;195 196 IntRect exposedRect(rect);197 exposedRect.intersect(frameRect());198 exposedRect.move(-frameRect().x(), -frameRect().y());199 200 RefPtr<cairo_surface_t> drawableSurface = adoptRef(cairo_xlib_surface_create(display,201 m_drawable,202 m_visual,203 m_windowRect.width(),204 m_windowRect.height()));205 206 if (m_isTransparent) {207 // If we have a 32 bit drawable and the plugin wants transparency,208 // we'll clear the exposed area to transparent first. Otherwise,209 // we'd end up with junk in there from the last paint, or, worse,210 // uninitialized data.211 RefPtr<cairo_t> cr = adoptRef(cairo_create(drawableSurface.get()));212 213 if (!(cairo_surface_get_content(drawableSurface.get()) & CAIRO_CONTENT_ALPHA)) {214 // Attempt to fake it when we don't have an alpha channel on our215 // pixmap. If that's not possible, at least clear the window to216 // avoid drawing artifacts.217 218 // This Would not work without double buffering, but we always use it.219 cairo_set_source_surface(cr.get(), cairo_get_group_target(context->platformContext()->cr()),220 -m_windowRect.x(), -m_windowRect.y());221 cairo_set_operator(cr.get(), CAIRO_OPERATOR_SOURCE);222 } else223 cairo_set_operator(cr.get(), CAIRO_OPERATOR_CLEAR);224 225 cairo_rectangle(cr.get(), exposedRect.x(), exposedRect.y(),226 exposedRect.width(), exposedRect.height());227 cairo_fill(cr.get());228 }229 230 XEvent xevent;231 memset(&xevent, 0, sizeof(XEvent));232 XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose;233 exposeEvent.type = GraphicsExpose;234 exposeEvent.display = display;235 exposeEvent.drawable = m_drawable;236 exposeEvent.x = exposedRect.x();237 exposeEvent.y = exposedRect.y();238 exposeEvent.width = exposedRect.x() + exposedRect.width(); // flash bug? it thinks width is the right in transparent mode239 exposeEvent.height = exposedRect.y() + exposedRect.height(); // flash bug? it thinks height is the bottom in transparent mode240 241 dispatchNPEvent(xevent);242 243 if (syncX)244 XSync(m_pluginDisplay, false); // sync changes by plugin245 246 cairo_t* cr = context->platformContext()->cr();247 cairo_save(cr);248 249 cairo_set_source_surface(cr, drawableSurface.get(), frameRect().x(), frameRect().y());250 251 cairo_rectangle(cr,252 frameRect().x() + exposedRect.x(), frameRect().y() + exposedRect.y(),253 exposedRect.width(), exposedRect.height());254 cairo_clip(cr);255 256 if (m_isTransparent)257 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);258 else259 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);260 cairo_paint(cr);261 262 cairo_restore(cr);263 119 } 264 120 … … 312 168 } 313 169 314 void PluginView::initXEvent(XEvent* xEvent)315 {316 memset(xEvent, 0, sizeof(XEvent));317 318 xEvent->xany.serial = 0; // we are unaware of the last request processed by X Server319 xEvent->xany.send_event = false;320 GtkWidget* widget = m_parentFrame->view()->hostWindow()->platformPageClient();321 xEvent->xany.display = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(widget));322 323 // Mozilla also sends None here for windowless plugins. See nsObjectFrame.cpp in the Mozilla sources.324 // This method also sets up FocusIn and FocusOut events for windows plugins, but Mozilla doesn't325 // even send these types of events to windowed plugins. In the future, it may be good to only326 // send them to windowless plugins.327 xEvent->xany.window = None;328 }329 330 170 static void setXButtonEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos, Frame* parentFrame) 331 171 { 332 172 XButtonEvent& xbutton = xEvent->xbutton; 333 173 xbutton.type = event->type() == eventNames().mousedownEvent ? ButtonPress : ButtonRelease; 334 xbutton.root = getRootWindow(parentFrame);174 xbutton.root = PluginView::getRootWindow(parentFrame); 335 175 xbutton.subwindow = 0; 336 176 xbutton.time = event->timeStamp(); … … 359 199 XMotionEvent& xmotion = xEvent->xmotion; 360 200 xmotion.type = MotionNotify; 361 xmotion.root = getRootWindow(parentFrame);201 xmotion.root = PluginView::getRootWindow(parentFrame); 362 202 xmotion.subwindow = 0; 363 203 xmotion.time = event->timeStamp(); … … 375 215 XCrossingEvent& xcrossing = xEvent->xcrossing; 376 216 xcrossing.type = event->type() == eventNames().mouseoverEvent ? EnterNotify : LeaveNotify; 377 xcrossing.root = getRootWindow(parentFrame);217 xcrossing.root = PluginView::getRootWindow(parentFrame); 378 218 xcrossing.subwindow = 0; 379 219 xcrossing.time = event->timeStamp(); … … 427 267 if (dispatchNPEvent(xEvent)) 428 268 event->setDefaultHandled(); 429 }430 431 void PluginView::handleFocusInEvent()432 {433 if (!m_isStarted || m_status != PluginStatusLoadedSuccessfully)434 return;435 436 XEvent npEvent;437 initXEvent(&npEvent);438 439 XFocusChangeEvent& event = npEvent.xfocus;440 event.type = 9; // FocusIn gets unset somewhere441 event.mode = NotifyNormal;442 event.detail = NotifyDetailNone;443 444 dispatchNPEvent(npEvent);445 }446 447 void PluginView::handleFocusOutEvent()448 {449 if (!m_isStarted || m_status != PluginStatusLoadedSuccessfully)450 return;451 452 XEvent npEvent;453 initXEvent(&npEvent);454 455 XFocusChangeEvent& event = npEvent.xfocus;456 event.type = 10; // FocusOut gets unset somewhere457 event.mode = NotifyNormal;458 event.detail = NotifyDetailNone;459 460 dispatchNPEvent(npEvent);461 }462 463 void PluginView::setParent(ScrollView* parent)464 {465 Widget::setParent(parent);466 467 if (parent)468 init();469 }470 471 void PluginView::setNPWindowRect(const IntRect&)472 {473 if (!m_isWindowed)474 setNPWindowIfNeeded();475 }476 477 void PluginView::setNPWindowIfNeeded()478 {479 if (!m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow)480 return;481 482 // If the plugin didn't load sucessfully, no point in calling setwindow483 if (m_status != PluginStatusLoadedSuccessfully)484 return;485 486 // On Unix, only call plugin's setwindow if it's full-page or windowed487 if (m_mode != NP_FULL && m_mode != NP_EMBED)488 return;489 490 // Check if the platformPluginWidget still exists491 if (m_isWindowed && !platformPluginWidget())492 return;493 494 if (m_clipRect.isEmpty()) {495 // If width or height are null, set the clipRect to null,496 // indicating that the plugin is not visible/scrolled out.497 m_npWindow.clipRect.left = 0;498 m_npWindow.clipRect.right = 0;499 m_npWindow.clipRect.top = 0;500 m_npWindow.clipRect.bottom = 0;501 } else {502 // Clipping rectangle of the plug-in; the origin is the top left corner of the drawable or window.503 m_npWindow.clipRect.left = m_npWindow.x + m_clipRect.x();504 m_npWindow.clipRect.top = m_npWindow.y + m_clipRect.y();505 m_npWindow.clipRect.right = m_npWindow.x + m_clipRect.x() + m_clipRect.width();506 m_npWindow.clipRect.bottom = m_npWindow.y + m_clipRect.y() + m_clipRect.height();507 }508 509 // FLASH WORKAROUND: Only set initially. Multiple calls to510 // setNPWindow() cause the plugin to crash in windowed mode.511 if (!m_plugin->quirks().contains(PluginQuirkDontCallSetWindowMoreThanOnce) || !m_isWindowed512 || m_npWindow.width == static_cast<uint32_t>(-1) || m_npWindow.height == static_cast<uint32_t>(-1)) {513 m_npWindow.width = m_windowRect.width();514 m_npWindow.height = m_windowRect.height();515 }516 517 PluginView::setCurrentPluginView(this);518 JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM());519 setCallingPlugin(true);520 m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);521 setCallingPlugin(false);522 PluginView::setCurrentPluginView(0);523 524 if (!m_isWindowed)525 return;526 527 // GtkXtBin will call gtk_widget_size_allocate, so we don't need to do it here.528 if (!m_needsXEmbed) {529 gtk_xtbin_set_position(GTK_XTBIN(platformPluginWidget()), m_windowRect.x(), m_windowRect.y());530 gtk_xtbin_resize(platformPluginWidget(), m_windowRect.width(), m_windowRect.height());531 return;532 }533 534 m_delayedAllocation = m_windowRect;535 updateWidgetAllocationAndClip();536 269 } 537 270 … … 697 430 } 698 431 699 void PluginView::invalidateRect(NPRect* rect)700 {701 if (!rect) {702 invalidate();703 return;704 }705 706 IntRect r(rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top);707 invalidateWindowlessPluginRect(r);708 }709 710 void PluginView::invalidateRegion(NPRegion)711 {712 // TODO: optimize713 invalidate();714 }715 716 432 void PluginView::forceRedraw() 717 433 { … … 722 438 } 723 439 724 static Display* getPluginDisplay() 725 { 440 Display* PluginView::getPluginDisplay(Frame* parentFrame) 441 { 442 if (parentFrame) { 443 GtkWidget* widget = parentFrame->view()->hostWindow()->platformPageClient(); 444 return GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(widget)); 445 } 446 726 447 // The plugin toolkit might have a different X connection open. Since we're 727 448 // a gdk/gtk app, we'll (probably?) have the same X connection as any gdk-based … … 816 537 } else { 817 538 setPlatformWidget(0); 818 m_pluginDisplay = getPluginDisplay( );539 m_pluginDisplay = getPluginDisplay(nullptr); 819 540 } 820 541
Note: See TracChangeset
for help on using the changeset viewer.