Changeset 163505 in webkit


Ignore:
Timestamp:
Feb 5, 2014 6:30:04 PM (10 years ago)
Author:
ryuan.choi@samsung.com
Message:

[EFL][GTK] Share plugin's implementation between EFL and Gtk ports.
https://bugs.webkit.org/show_bug.cgi?id=70592

Reviewed by Gyuyoung Kim.

Merge common logics of PluginViewGtk.cpp and PluginViewEfl.cpp to PluginViewX11.cpp.
So, this patch improves the windowless plugin support for the EFL port.

  • GNUmakefile.am: Add include path for gtk2xtbin.h header file.
  • GNUmakefile.list.am: Added PluginViewX11.cpp into source lists.
  • PlatformEfl.cmake: Ditto.
  • PlatformGTK.cmake: Ditto.
  • plugins/PluginView.h: Added getRootWindow and getPluginDisply which implement platform specific code.
  • plugins/efl/PluginViewEfl.cpp:

(WebCore::PluginView::getRootWindow):
(WebCore::PluginView::platformGetValueStatic): Turn on NPNVSupportsWindowless support.
(WebCore::PluginView::getPluginDisplay):
(WebCore::PluginView::platformStart):

  • plugins/gtk/PluginViewGtk.cpp:

(WebCore::PluginView::getRootWindow):
(WebCore::setXButtonEventSpecificFields):
(WebCore::setXMotionEventSpecificFields):
(WebCore::setXCrossingEventSpecificFields):
(WebCore::PluginView::getPluginDisplay):
(WebCore::PluginView::platformStart):

  • plugins/x11/PluginViewX11.cpp: Moved common logics from PluginViewGtk.cpp

(WebCore::PluginView::dispatchNPEvent):
(WebCore::PluginView::updatePluginWidget):
(WebCore::PluginView::handleFocusInEvent):
(WebCore::PluginView::invalidateRect):
(WebCore::PluginView::invalidateRegion):
(WebCore::PluginView::handleFocusOutEvent):
(WebCore::PluginView::initXEvent):
(WebCore::PluginView::paint):
(WebCore::PluginView::setParent):
(WebCore::PluginView::setNPWindowRect):
(WebCore::PluginView::setNPWindowIfNeeded):

Location:
trunk/Source/WebCore
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r163503 r163505  
     12014-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
    1412014-02-05  Anders Carlsson  <andersca@apple.com>
    242
  • trunk/Source/WebCore/GNUmakefile.am

    r163440 r163505  
    9494        -I$(srcdir)/Source/WebCore/platform/win \
    9595        -I$(srcdir)/Source/WebCore/plugins \
     96        -I$(srcdir)/Source/WebCore/plugins/gtk \
    9697        -I$(srcdir)/Source/WebCore/plugins/win \
    9798        -I$(srcdir)/Source/WebCore/rendering \
  • trunk/Source/WebCore/GNUmakefile.list.am

    r163359 r163505  
    62236223        Source/WebCore/plugins/gtk/PluginPackageGtk.cpp \
    62246224        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
    62266227platformgtk_sources += \
    62276228        Source/WebCore/platform/gtk/WidgetBackingStoreGtkX11.h \
  • trunk/Source/WebCore/PlatformEfl.cmake

    r162922 r163505  
    192192        plugins/efl/PluginPackageEfl.cpp
    193193        plugins/efl/PluginViewEfl.cpp
     194
     195        plugins/x11/PluginViewX11.cpp
    194196    )
    195197endif ()
  • trunk/Source/WebCore/PlatformGTK.cmake

    r163240 r163505  
    283283        plugins/gtk/PluginViewGtk.cpp
    284284        plugins/gtk/gtk2xtbin.c
     285
     286        plugins/x11/PluginViewX11.cpp
    285287    )
    286288else ()
  • trunk/Source/WebCore/plugins/PluginView.h

    r162451 r163505  
    5858#endif
    5959
     60#if PLATFORM(X11)
     61typedef unsigned long Window;
     62typedef struct _XDisplay Display;
     63#endif
     64
    6065namespace JSC {
    6166    namespace Bindings {
     
    6671namespace WebCore {
    6772    class Frame;
     73    class FrameView;
    6874    class Image;
    6975    class HTMLPlugInElement;
     
    235241        void keepAlive();
    236242
     243#if PLATFORM(X11)
     244        static Display* getPluginDisplay(Frame*);
     245        static Window getRootWindow(Frame* parentFrame);
     246#endif
     247
    237248    private:
    238249        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  
    44 * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
    55 * Copyright (C) 2009-2010 ProFUSION embedded systems
    6  * Copyright (C) 2009-2011 Samsung Electronics
     6 * Copyright (C) 2009-2014 Samsung Electronics
    77 *
    88 * Redistribution and use in source and binary forms, with or without
     
    3333#include "Frame.h"
    3434#include "FrameView.h"
    35 #include "GraphicsContext.h"
    3635#include "HTMLNames.h"
    3736#include "HTMLPlugInElement.h"
    38 #include "HostWindow.h"
    39 #include "JSDOMWindowBase.h"
    4037#include "MouseEvent.h"
    4138#include "NotImplemented.h"
     
    5350using namespace HTMLNames;
    5451
    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
     52Window 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}
    8258
    8359void PluginView::handleKeyboardEvent(KeyboardEvent*)
     
    11894}
    11995
    120 void PluginView::updatePluginWidget()
    121 {
    122     notImplemented();
    123 }
    124 
    12596void PluginView::setFocus(bool focused)
    12697{
     
    143114
    144115    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 {
    168116}
    169117
     
    222170
    223171    case NPNVSupportsWindowless:
    224         *static_cast<NPBool*>(value) = false;
     172        *static_cast<NPBool*>(value) = true;
    225173        *result = NPERR_NO_ERROR;
    226174        return true;
     
    313261}
    314262
    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();
     263Display* PluginView::getPluginDisplay(Frame*)
     264{
     265    return static_cast<Display*>(ecore_x_display_get());
    328266}
    329267
     
    338276    ASSERT(m_status == PluginStatusLoadedSuccessfully);
    339277
    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
    341313    return true;
    342314}
  • trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp

    r156144 r163505  
    5353#include "NotImplemented.h"
    5454#include "Page.h"
    55 #include "PlatformContextCairo.h"
    5655#include "PlatformKeyboardEvent.h"
    5756#include "PlatformMouseEvent.h"
     
    7574#include "RefPtrCairo.h"
    7675#include "gtk2xtbin.h"
    77 #define Bool int // this got undefined somewhere
     76#define Bool int // this became undefined in npruntime_internal.h
    7877#define Status int // ditto
    7978#include <X11/extensions/Xrender.h>
    80 #include <cairo-xlib.h>
    8179#include <gdk/gdkx.h>
    8280
     
    9492using namespace HTMLNames;
    9593
    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)
     94Window PluginView::getRootWindow(Frame* parentFrame)
    11495{
    11596    GtkWidget* parentWidget = parentFrame->view()->hostWindow()->platformPageClient();
    11697    GdkScreen* gscreen = gtk_widget_get_screen(parentWidget);
    11798    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 Drawable
    150     }
    151 
    152     setNPWindowIfNeeded();
    15399}
    154100
     
    171117    ASSERT(platformPluginWidget() == platformWidget());
    172118    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 our
    215             // pixmap.  If that's not possible, at least clear the window to
    216             // 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         } else
    223             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 mode
    239     exposeEvent.height = exposedRect.y() + exposedRect.height(); // flash bug? it thinks height is the bottom in transparent mode
    240 
    241     dispatchNPEvent(xevent);
    242 
    243     if (syncX)
    244         XSync(m_pluginDisplay, false); // sync changes by plugin
    245 
    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     else
    259         cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
    260     cairo_paint(cr);
    261 
    262     cairo_restore(cr);
    263119}
    264120
     
    312168}
    313169
    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 Server
    319     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't
    325     // even send these types of events to windowed plugins. In the future, it may be good to only
    326     // send them to windowless plugins.
    327     xEvent->xany.window = None;
    328 }
    329 
    330170static void setXButtonEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos, Frame* parentFrame)
    331171{
    332172    XButtonEvent& xbutton = xEvent->xbutton;
    333173    xbutton.type = event->type() == eventNames().mousedownEvent ? ButtonPress : ButtonRelease;
    334     xbutton.root = getRootWindow(parentFrame);
     174    xbutton.root = PluginView::getRootWindow(parentFrame);
    335175    xbutton.subwindow = 0;
    336176    xbutton.time = event->timeStamp();
     
    359199    XMotionEvent& xmotion = xEvent->xmotion;
    360200    xmotion.type = MotionNotify;
    361     xmotion.root = getRootWindow(parentFrame);
     201    xmotion.root = PluginView::getRootWindow(parentFrame);
    362202    xmotion.subwindow = 0;
    363203    xmotion.time = event->timeStamp();
     
    375215    XCrossingEvent& xcrossing = xEvent->xcrossing;
    376216    xcrossing.type = event->type() == eventNames().mouseoverEvent ? EnterNotify : LeaveNotify;
    377     xcrossing.root = getRootWindow(parentFrame);
     217    xcrossing.root = PluginView::getRootWindow(parentFrame);
    378218    xcrossing.subwindow = 0;
    379219    xcrossing.time = event->timeStamp();
     
    427267    if (dispatchNPEvent(xEvent))
    428268        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 somewhere
    441     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 somewhere
    457     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 setwindow
    483     if (m_status != PluginStatusLoadedSuccessfully)
    484         return;
    485 
    486     // On Unix, only call plugin's setwindow if it's full-page or windowed
    487     if (m_mode != NP_FULL && m_mode != NP_EMBED)
    488         return;
    489 
    490     // Check if the platformPluginWidget still exists
    491     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 to
    510     // setNPWindow() cause the plugin to crash in windowed mode.
    511     if (!m_plugin->quirks().contains(PluginQuirkDontCallSetWindowMoreThanOnce) || !m_isWindowed
    512         || 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();
    536269}
    537270
     
    697430}
    698431
    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: optimize
    713     invalidate();
    714 }
    715 
    716432void PluginView::forceRedraw()
    717433{
     
    722438}
    723439
    724 static Display* getPluginDisplay()
    725 {
     440Display* 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
    726447    // The plugin toolkit might have a different X connection open.  Since we're
    727448    // a gdk/gtk app, we'll (probably?) have the same X connection as any gdk-based
     
    816537    } else {
    817538        setPlatformWidget(0);
    818         m_pluginDisplay = getPluginDisplay();
     539        m_pluginDisplay = getPluginDisplay(nullptr);
    819540    }
    820541
Note: See TracChangeset for help on using the changeset viewer.