Changeset 116403 in webkit


Ignore:
Timestamp:
May 8, 2012 1:42:37 AM (12 years ago)
Author:
kbalazs@webkit.org
Message:

[Qt] X11 plugins need to be reworked for Qt5+WK1
https://bugs.webkit.org/show_bug.cgi?id=80691

Reviewed by Simon Hausmann.

.:

Implement basic windowless plugin support with Qt5.

  • Source/api.pri: Need private API's to be able

to use QApplicationPrivate::windowForWidget.

Source/WebCore:

Implement basic windowless plugin support with Qt5.
The solution is the same that has been chosen for
WebKit2. We get the content drawed by the plugin
from the X server as an image, create a QImage
from it and paint it to the window surface with QPainter.
Performance is sufficient for basic video playback.

No new tests, covered by existing plugin tests.

  • Target.pri:
  • WebCore.pri:
  • platform/qt/QWebPageClient.h:

(QWebPageClient):

  • plugins/PluginView.h:

(PluginView):

  • plugins/qt/PluginPackageQt.cpp:

(WebCore::PluginPackage::isPluginBlacklisted):
Blacklist plugins that are incompatible with Qt5.
The only one I know about currently is skypebuttons
but the list can be extended in the future.
(WebCore):
(WebCore::PluginPackage::load):

  • plugins/qt/PluginViewQt.cpp:

(X11Environment):
(WebCore):
(WebCore::x11Display):
(WebCore::x11Screen):
(WebCore::rootWindowID):
(WebCore::displayDepth):
(WebCore::syncX):
(WebCore::PluginView::platformPageClient): Added a safe
convenience getter for the QWebpageClient.
(WebCore::PluginView::updatePluginWidget):
(WebCore::PluginView::setFocus):
(WebCore::setupGraphicsExposeEvent):
(WebCore::PluginView::paintUsingXPixmap):
(WebCore::setSharedXEventFields):
(WebCore::PluginView::initXEvent):
(WebCore::PluginView::setXKeyEventSpecificFields):
(WebCore::setXButtonEventSpecificFields):
(WebCore::setXMotionEventSpecificFields):
(WebCore::setXCrossingEventSpecificFields):
(WebCore::PluginView::setNPWindowIfNeeded):
(WebCore::PluginView::setParentVisible):
(WebCore::PluginView::platformGetValue):
(WebCore::PluginView::invalidateRect):
(WebCore::getVisualAndColormap):
Refactored this function to make it more clear
what does it actually do.
(WebCore::PluginView::platformStart):
(WebCore::PluginView::platformDestroy):

Source/WebKit/qt:

  • Api/qwebsettings.cpp:

(QWebSettings::enablePersistentStorage):
Build fix for Qt5.

  • WebCoreSupport/FrameLoaderClientQt.cpp:

(WebCore::FrameLoaderClientQt::createPlugin):
Inject the wmode parameter for flash so it will
work in windowless, non-transparent mode which
is the only one we support currently.

  • WebCoreSupport/PageClientQt.cpp:

(WebCore):
(WebCore::QWebPageClient::ownerWindow):
Added a getter for the top level window so the PluginView
can get it without calling into QtWidgets code.

Tools:

Implement basic windowless plugin support with Qt5.

  • qmake/mkspecs/features/features.prf:

Enable NPAPI plugins if X11 libraries are available.

  • qmake/mkspecs/features/functions.prf:

Added a convenience function to determine availability
of X11 libraries.

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r116396 r116403  
     12012-05-08  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        [Qt] X11 plugins need to be reworked for Qt5+WK1
     4        https://bugs.webkit.org/show_bug.cgi?id=80691
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Implement basic windowless plugin support with Qt5.
     9
     10        * Source/api.pri: Need private API's to be able
     11        to use QApplicationPrivate::windowForWidget.
     12
    1132012-05-07  Dave Tu  <dtu@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r116402 r116403  
     12012-05-08  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        [Qt] X11 plugins need to be reworked for Qt5+WK1
     4        https://bugs.webkit.org/show_bug.cgi?id=80691
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Implement basic windowless plugin support with Qt5.
     9        The solution is the same that has been chosen for
     10        WebKit2. We get the content drawed by the plugin
     11        from the X server as an image, create a QImage
     12        from it and paint it to the window surface with QPainter.
     13        Performance is sufficient for basic video playback.
     14
     15        No new tests, covered by existing plugin tests.
     16
     17        * Target.pri:
     18        * WebCore.pri:
     19        * platform/qt/QWebPageClient.h:
     20        (QWebPageClient):
     21        * plugins/PluginView.h:
     22        (PluginView):
     23        * plugins/qt/PluginPackageQt.cpp:
     24        (WebCore::PluginPackage::isPluginBlacklisted):
     25        Blacklist plugins that are incompatible with Qt5.
     26        The only one I know about currently is skypebuttons
     27        but the list can be extended in the future.
     28        (WebCore):
     29        (WebCore::PluginPackage::load):
     30        * plugins/qt/PluginViewQt.cpp:
     31        (X11Environment):
     32        (WebCore):
     33        (WebCore::x11Display):
     34        (WebCore::x11Screen):
     35        (WebCore::rootWindowID):
     36        (WebCore::displayDepth):
     37        (WebCore::syncX):
     38        (WebCore::PluginView::platformPageClient): Added a safe
     39        convenience getter for the QWebpageClient.
     40        (WebCore::PluginView::updatePluginWidget):
     41        (WebCore::PluginView::setFocus):
     42        (WebCore::setupGraphicsExposeEvent):
     43        (WebCore::PluginView::paintUsingXPixmap):
     44        (WebCore::setSharedXEventFields):
     45        (WebCore::PluginView::initXEvent):
     46        (WebCore::PluginView::setXKeyEventSpecificFields):
     47        (WebCore::setXButtonEventSpecificFields):
     48        (WebCore::setXMotionEventSpecificFields):
     49        (WebCore::setXCrossingEventSpecificFields):
     50        (WebCore::PluginView::setNPWindowIfNeeded):
     51        (WebCore::PluginView::setParentVisible):
     52        (WebCore::PluginView::platformGetValue):
     53        (WebCore::PluginView::invalidateRect):
     54        (WebCore::getVisualAndColormap):
     55        Refactored this function to make it more clear
     56        what does it actually do.
     57        (WebCore::PluginView::platformStart):
     58        (WebCore::PluginView::platformDestroy):
     59
    1602012-05-07  Antti Koivisto  <antti@apple.com>
    261
  • trunk/Source/WebCore/Target.pri

    r116277 r116403  
    29712971        } else {
    29722972            SOURCES += \
    2973                 plugins/qt/PluginContainerQt.cpp \
    29742973                plugins/qt/PluginPackageQt.cpp \
    29752974                plugins/qt/PluginViewQt.cpp
    2976             HEADERS += \
    2977                 plugins/qt/PluginContainerQt.h
     2975
     2976            haveQt(4) {
     2977                SOURCES += plugins/qt/PluginContainerQt.cpp
     2978                HEADERS += plugins/qt/PluginContainerQt.h
     2979            }
    29782980        }
    29792981    }
  • trunk/Source/WebCore/WebCore.pri

    r116105 r116403  
    135135            # Note: XP_MACOSX is defined in npapi.h
    136136        } else {
    137             !embedded {
     137            xlibAvailable() {
    138138                CONFIG += x11
    139139                LIBS += -lXrender
  • trunk/Source/WebCore/platform/qt/QWebPageClient.h

    r107815 r116403  
    4444QT_BEGIN_NAMESPACE
    4545class QStyle;
     46class QWindow;
    4647QT_END_NAMESPACE
    4748
     
    110111                                                 PlatformGraphicsSurface3D*) = 0;
    111112#endif
     113#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
     114    virtual QWindow* ownerWindow() const;
     115#endif
    112116
    113117protected:
  • trunk/Source/WebCore/plugins/PluginView.h

    r116371 r116403  
    427427        static void setXKeyEventSpecificFields(XEvent*, KeyboardEvent*);
    428428        void paintUsingXPixmap(QPainter* painter, const QRect &exposedRect);
     429        QWebPageClient* platformPageClient() const;
    429430#endif
    430431#if USE(ACCELERATED_COMPOSITING_PLUGIN_LAYER)
  • trunk/Source/WebCore/plugins/qt/PluginPackageQt.cpp

    r108281 r116403  
    3232#include "PluginDatabase.h"
    3333#include "PluginDebug.h"
     34#include <QFileInfo>
    3435#include <wtf/text/CString.h>
    3536
     
    130131}
    131132
     133bool PluginPackage::isPluginBlacklisted()
     134{
     135#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
     136    // TODO: enumerate all plugins that are incompatible with Qt5.
     137    const QLatin1String pluginBlacklist[] = {
     138        QLatin1String("skypebuttons")
     139    };
     140
     141    QString baseName = QFileInfo(static_cast<QString>(m_path)).baseName();
     142    for (unsigned i = 0; i < sizeof(pluginBlacklist) / sizeof(QLatin1String); ++i) {
     143        if (baseName == pluginBlacklist[i])
     144            return true;
     145    }
     146#endif
     147    return false;
     148}
     149
    132150bool PluginPackage::load()
    133151{
     
    136154        return true;
    137155    }
     156
     157    if (isPluginBlacklisted())
     158        return false;
    138159
    139160    m_module = new QLibrary((QString)m_path);
  • trunk/Source/WebCore/plugins/qt/PluginViewQt.cpp

    r113990 r116403  
    5959#include "PlatformMouseEvent.h"
    6060#include "PlatformKeyboardEvent.h"
    61 #include "PluginContainerQt.h"
    6261#include "PluginDebug.h"
    6362#include "PluginPackage.h"
     
    7069#include "runtime_root.h"
    7170#endif
    72 
    73 #include <QApplication>
    74 #include <QDesktopWidget>
    75 #include <QGraphicsWidget>
    7671#include <QKeyEvent>
    7772#include <QPainter>
    78 #include <QStyleOptionGraphicsItem>
    79 #include <QWidget>
    80 #include <QX11Info>
    8173#include <X11/X.h>
    8274#ifndef QT_NO_XRENDER
     
    8880#include <runtime/JSValue.h>
    8981
     82#define HAVE_QT5 (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
     83
     84#if HAVE(QT5)
     85#include "QtX11ImageConversion.h"
     86#include <QGuiApplication>
     87#include <QPlatformNativeInterface>
     88#include <QWindow>
     89#else
     90#include "PluginContainerQt.h"
     91#include <QApplication>
     92#include <QDesktopWidget>
     93#include <QGraphicsWidget>
     94#include <QStyleOptionGraphicsItem>
     95#include <QWidget>
     96#include <QX11Info>
     97#endif
     98
    9099using JSC::ExecState;
    91100#if USE(JSC)
     
    106115using namespace HTMLNames;
    107116
    108 #if USE(ACCELERATED_COMPOSITING)
     117struct X11Environment {
     118    Display* display;
     119    int screenID;
     120    unsigned long rootWindowID;
     121    int displayDepth;
     122};
     123
     124static X11Environment x11Environment = { 0, 0, 0, 0 };
     125
     126static inline Display* x11Display() { return x11Environment.display; }
     127static inline int x11Screen() { return x11Environment.screenID; }
     128static inline unsigned long rootWindowID() { return x11Environment.rootWindowID; }
     129static inline int displayDepth() { return x11Environment.displayDepth; }
     130
     131static inline void syncX()
     132{
     133    XSync(x11Display(), false);
     134}
     135
     136QWebPageClient* PluginView::platformPageClient() const
     137{
     138    FrameView* view = m_parentFrame->view();
     139    if (!view)
     140        return 0;
     141    HostWindow* hostWindow = view->hostWindow();
     142    if (!hostWindow)
     143        return 0;
     144    return hostWindow->platformPageClient();
     145}
     146
     147#if !HAVE(QT5) && USE(ACCELERATED_COMPOSITING)
    109148// Qt's GraphicsLayer (GraphicsLayerQt) requires layers to be QGraphicsWidgets
    110149class PluginGraphicsLayerQt : public QGraphicsWidget {
     
    155194    if (!m_isWindowed && m_windowRect.size() != oldWindowRect.size()) {
    156195        if (m_drawable)
    157             XFreePixmap(QX11Info::display(), m_drawable);
    158 
    159         m_drawable = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), m_windowRect.width(), m_windowRect.height(),
     196            XFreePixmap(x11Display(), m_drawable);
     197
     198        m_drawable = XCreatePixmap(x11Display(), rootWindowID(), m_windowRect.width(), m_windowRect.height(),
    160199                                   ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth);
    161         QApplication::syncX(); // make sure that the server knows about the Drawable
     200        syncX(); // make sure that the server knows about the Drawable
    162201    }
    163202
     
    188227void PluginView::setFocus(bool focused)
    189228{
     229#if !HAVE(QT5) // Windowed mode is not supported with Qt5 yet (so platformPluginWidget() is always null).
    190230    if (platformPluginWidget()) {
    191231        if (focused)
    192232            static_cast<QWidget*>(platformPluginWidget())->setFocus(Qt::OtherFocusReason);
    193     } else {
     233    } else
     234#endif
    194235        Widget::setFocus(focused);
    195     }
    196236}
    197237
     
    208248}
    209249
     250static void setupGraphicsExposeEvent(Pixmap drawable, const QRect& exposedRect, XEvent& xevent)
     251{
     252    memset(&xevent, 0, sizeof(XEvent));
     253    XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose;
     254    exposeEvent.type = GraphicsExpose;
     255    exposeEvent.display = x11Display();
     256    exposeEvent.drawable = drawable;
     257    exposeEvent.x = exposedRect.x();
     258    exposeEvent.y = exposedRect.y();
     259    exposeEvent.width = exposedRect.x() + exposedRect.width(); // flash bug? it thinks width is the right in transparent mode
     260    exposeEvent.height = exposedRect.y() + exposedRect.height(); // flash bug? it thinks height is the bottom in transparent mode
     261}
     262
    210263void PluginView::paintUsingXPixmap(QPainter* painter, const QRect &exposedRect)
    211264{
     265    bool shouldSyncX = m_pluginDisplay && m_pluginDisplay != x11Display();
     266    XEvent xevent;
     267
     268#if HAVE(QT5)
     269    setupGraphicsExposeEvent(m_drawable, exposedRect, xevent);
     270#else
    212271    QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared);
    213272    const int drawableDepth = ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth;
    214273    ASSERT(drawableDepth == qtDrawable.depth());
    215     const bool syncX = m_pluginDisplay && m_pluginDisplay != QX11Info::display();
    216274
    217275    // When printing, Qt uses a QPicture to capture the output in preview mode. The
     
    233291        // (because backing store contents are already transformed). What we really mean to do
    234292        // here is to check if we are painting on QWebView, but let's be a little permissive :)
    235         QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
     293        QWebPageClient* client = platformPageClient();
    236294        const bool backingStoreHasUntransformedContents = client && qobject_cast<QWidget*>(client->pluginParent());
    237295
     
    247305        }
    248306
    249         if (syncX)
    250             QApplication::syncX();
    251     }
    252 
    253     XEvent xevent;
    254     memset(&xevent, 0, sizeof(XEvent));
    255     XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose;
    256     exposeEvent.type = GraphicsExpose;
    257     exposeEvent.display = QX11Info::display();
    258     exposeEvent.drawable = qtDrawable.handle();
    259     exposeEvent.x = exposedRect.x();
    260     exposeEvent.y = exposedRect.y();
    261     exposeEvent.width = exposedRect.x() + exposedRect.width(); // flash bug? it thinks width is the right in transparent mode
    262     exposeEvent.height = exposedRect.y() + exposedRect.height(); // flash bug? it thinks height is the bottom in transparent mode
     307        if (shouldSyncX)
     308            syncX();
     309    }
     310
     311    setupGraphicsExposeEvent(qtDrawable.handle(), exposedRect, xevent);
     312#endif
    263313
    264314    dispatchNPEvent(xevent);
    265315
    266     if (syncX)
     316    if (shouldSyncX)
    267317        XSync(m_pluginDisplay, false); // sync changes by plugin
    268318
     319#if HAVE(QT5)
     320    XImage* xImage = XGetImage(x11Display(), m_drawable, exposedRect.x(), exposedRect.y(),
     321                               exposedRect.width(), exposedRect.height(), ULONG_MAX, ZPixmap);
     322    painter->drawImage(QPoint(exposedRect.x(), exposedRect.y()), qimageFromXImage(xImage), exposedRect);
     323    XDestroyImage(xImage);
     324#else
    269325    painter->drawPixmap(QPoint(exposedRect.x(), exposedRect.y()), qtDrawable, exposedRect);
     326#endif
    270327}
    271328
     
    332389}
    333390
    334 void setSharedXEventFields(XEvent* xEvent, QWidget* ownerWidget)
     391void setSharedXEventFields(XEvent* xEvent, QWebPageClient* pageClient)
    335392{
    336393    xEvent->xany.serial = 0; // we are unaware of the last request processed by X Server
    337394    xEvent->xany.send_event = false;
    338     xEvent->xany.display = QX11Info::display();
     395    xEvent->xany.display = x11Display();
    339396    // NOTE: event->xany.window doesn't always respond to the .window property of other XEvent's
    340397    // but does in the case of KeyPress, KeyRelease, ButtonPress, ButtonRelease, and MotionNotify
    341398    // events; thus, this is right:
    342     xEvent->xany.window = ownerWidget ? ownerWidget->window()->handle() : 0;
     399#if HAVE(QT5)
     400    QWindow* window = pageClient ? pageClient->ownerWindow() : 0;
     401    xEvent->xany.window = window ? window->winId() : 0;
     402#else
     403    QWidget* ownerWidget = pageClient ? pageClient->ownerWidget() : 0;
     404    xEvent->xany.window = ownerWidget ? ownerWidget->window()->winId() : 0;
     405#endif
    343406}
    344407
     
    347410    memset(xEvent, 0, sizeof(XEvent));
    348411
    349     QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
    350     QWidget* ownerWidget = client ? client->ownerWidget() : 0;
    351     setSharedXEventFields(xEvent, ownerWidget);
     412    QWebPageClient* client = platformPageClient();
     413    setSharedXEventFields(xEvent, client);
    352414}
    353415
     
    357419
    358420    xEvent->type = (event->type() == eventNames().keydownEvent) ? 2 : 3; // ints as Qt unsets KeyPress and KeyRelease
    359     xEvent->xkey.root = QX11Info::appRootWindow();
     421    xEvent->xkey.root = rootWindowID();
    360422    xEvent->xkey.subwindow = 0; // we have no child window
    361423    xEvent->xkey.time = event->timeStamp();
     
    371433        ASSERT(qKeyEvent);
    372434        QString keyText = qKeyEvent->text().left(1);
    373         xEvent->xkey.keycode = XKeysymToKeycode(QX11Info::display(), XStringToKeysym(keyText.toUtf8().constData()));
     435        xEvent->xkey.keycode = XKeysymToKeycode(x11Display(), XStringToKeysym(keyText.toUtf8().constData()));
    374436    }
    375437
     
    420482    XButtonEvent& xbutton = xEvent->xbutton;
    421483    xbutton.type = event->type() == eventNames().mousedownEvent ? ButtonPress : ButtonRelease;
    422     xbutton.root = QX11Info::appRootWindow();
     484    xbutton.root = rootWindowID();
    423485    xbutton.subwindow = 0;
    424486    xbutton.time = event->timeStamp();
     
    447509    XMotionEvent& xmotion = xEvent->xmotion;
    448510    xmotion.type = MotionNotify;
    449     xmotion.root = QX11Info::appRootWindow();
     511    xmotion.root = rootWindowID();
    450512    xmotion.subwindow = 0;
    451513    xmotion.time = event->timeStamp();
     
    463525    XCrossingEvent& xcrossing = xEvent->xcrossing;
    464526    xcrossing.type = event->type() == eventNames().mouseoverEvent ? EnterNotify : LeaveNotify;
    465     xcrossing.root = QX11Info::appRootWindow();
     527    xcrossing.root = rootWindowID();
    466528    xcrossing.subwindow = 0;
    467529    xcrossing.time = event->timeStamp();
     
    572634    m_hasPendingGeometryChange = false;
    573635
     636#if !HAVE(QT5) // Windowed mode is not supported with Qt5 yet
    574637    if (m_isWindowed) {
    575638        QWidget* widget = static_cast<QWidget*>(platformPluginWidget());
     
    591654        m_npWindow.x = m_windowRect.x();
    592655        m_npWindow.y = m_windowRect.y();
    593     } else {
     656    } else
     657#endif
     658    {
    594659        m_npWindow.x = 0;
    595660        m_npWindow.y = 0;
     
    640705    Widget::setParentVisible(visible);
    641706
     707#if !HAVE(QT5) // Windowed mode is not supported with Qt5 yet.
    642708    if (isSelfVisible() && platformPluginWidget())
    643709        static_cast<QWidget*>(platformPluginWidget())->setVisible(visible);
     710#endif
    644711}
    645712
     
    702769    switch (variable) {
    703770    case NPNVxDisplay:
    704         *(void **)value = QX11Info::display();
     771        *reinterpret_cast<void**>(value) = x11Display();
    705772        *result = NPERR_NO_ERROR;
    706773        return true;
     
    711778
    712779    case NPNVnetscapeWindow: {
    713         void* w = reinterpret_cast<void*>(value);
    714         QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
    715         *((XID *)w) = client ? client->ownerWidget()->window()->winId() : 0;
     780        QWebPageClient* client = platformPageClient();
     781#if HAVE(QT5)
     782        QWindow* window = client ? client->ownerWindow() : 0;
     783        *reinterpret_cast<XID*>(value) = window ? window->winId() : 0;
     784#else
     785        *reinterpret_cast<XID*>(value) = client ? client->ownerWidget()->window()->winId() : 0;
     786#endif
    716787        *result = NPERR_NO_ERROR;
    717788        return true;
     
    740811#endif
    741812
     813#if !HAVE(QT5) // Windowed mode is not supported with Qt5 yet.
    742814    if (m_isWindowed) {
    743815        if (platformWidget()) {
     
    750822        return;
    751823    }
     824#endif
    752825
    753826    invalidateWindowlessPluginRect(rect);
     
    804877}
    805878
    806 static void getVisualAndColormap(int depth, Visual **visual, Colormap *colormap)
    807 {
    808     *visual = 0;
    809     *colormap = 0;
    810 
    811 #ifndef QT_NO_XRENDER
     879static bool getVisualAndColormap(int depth, Visual*& visual, Colormap& colormap, bool forceARGB32)
     880{
     881    ASSERT(depth == 32 || !forceARGB32);
     882
     883    visual = 0;
     884    colormap = 0;
     885
     886#if !HAVE(QT5) && !defined(QT_NO_XRENDER)
    812887    static const bool useXRender = qgetenv("QT_X11_NO_XRENDER").isNull(); // Should also check for XRender >= 0.5
    813888#else
    814889    static const bool useXRender = false;
    815890#endif
    816 
    817     if (!useXRender && depth == 32)
    818         return;
     891    if (!useXRender && forceARGB32)
     892        return false;
    819893
    820894    int nvi;
    821895    XVisualInfo templ;
    822     templ.screen  = QX11Info::appScreen();
     896    templ.screen  = x11Screen();
    823897    templ.depth   = depth;
    824898    templ.c_class = TrueColor;
    825     XVisualInfo* xvi = XGetVisualInfo(QX11Info::display(), VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi);
    826 
     899    XVisualInfo* xvi = XGetVisualInfo(x11Display(), VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi);
     900    ASSERT(xvi || forceARGB32);
    827901    if (!xvi)
    828         return;
    829 
    830 #ifndef QT_NO_XRENDER
    831     if (depth == 32) {
     902        return false;
     903
     904#if !HAVE(QT5) && !defined(QT_NO_XRENDER)
     905    if (forceARGB32) {
    832906        for (int idx = 0; idx < nvi; ++idx) {
    833             XRenderPictFormat* format = XRenderFindVisualFormat(QX11Info::display(), xvi[idx].visual);
     907            XRenderPictFormat* format = XRenderFindVisualFormat(x11Display(), xvi[idx].visual);
    834908            if (format->type == PictTypeDirect && format->direct.alphaMask) {
    835                  *visual = xvi[idx].visual;
     909                 visual = xvi[idx].visual;
    836910                 break;
    837911            }
    838          }
     912        }
     913        if (!visual)
     914            return false;
    839915    } else
    840 #endif // QT_NO_XRENDER
    841         *visual = xvi[0].visual;
     916#endif
     917    {
     918        visual = xvi[0].visual;
     919    }
     920    ASSERT(visual);
    842921
    843922    XFree(xvi);
    844923
    845     if (*visual)
    846         *colormap = XCreateColormap(QX11Info::display(), QX11Info::appRootWindow(), *visual, AllocNone);
     924    colormap = XCreateColormap(x11Display(), rootWindowID(), visual, AllocNone);
     925    return true;
    847926}
    848927
     
    852931    ASSERT(m_status == PluginStatusLoadedSuccessfully);
    853932
     933    if (!x11Environment.display) {
     934        Display* display;
     935#if HAVE(QT5)
     936        display = static_cast<Display*>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("display", 0));
     937#else
     938        display = QX11Info::display();
     939#endif
     940        x11Environment.display = display;
     941        x11Environment.screenID = XDefaultScreen(display);
     942        x11Environment.displayDepth = XDefaultDepth(display, x11Environment.screenID);
     943        x11Environment.rootWindowID = XDefaultRootWindow(display);
     944    }
     945
     946#if HAVE(QT5)
     947    // Windowed mode is not supported with Qt5 yet.
     948    if (m_isWindowed)
     949        return false;
     950#else
    854951    if (m_plugin->pluginFuncs()->getvalue) {
    855952        PluginView::setCurrentPluginView(this);
     
    864961
    865962    if (m_isWindowed) {
    866         QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
     963        QWebPageClient* client = platformPageClient();
    867964        if (m_needsXEmbed && client) {
    868965            setPlatformWidget(new PluginContainerQt(this, client->ownerWidget()));
     
    874971            return false;
    875972        }
    876     } else {
     973    } else
     974#endif // HAVE(QT5)
     975    {
    877976        setPlatformWidget(0);
    878977        m_pluginDisplay = getPluginDisplay();
     
    894993    wsi->type = 0;
    895994
     995#if !HAVE(QT5)
    896996    if (m_isWindowed) {
    897997        const QX11Info* x11Info = &static_cast<QWidget*>(platformPluginWidget())->x11Info();
     
    9061006        m_npWindow.width = -1;
    9071007        m_npWindow.height = -1;
    908     } else {
     1008    } else
     1009#endif
     1010    {
     1011#if !HAVE(QT5)
    9091012        const QX11Info* x11Info = &QApplication::desktop()->x11Info();
    910 
    911         if (x11Info->depth() == 32 || !m_plugin->quirks().contains(PluginQuirkRequiresDefaultScreenDepth)) {
    912             getVisualAndColormap(32, &m_visual, &m_colormap);
     1013        if ((x11Info->depth() == 32 || !m_plugin->quirks().contains(PluginQuirkRequiresDefaultScreenDepth))
     1014             && getVisualAndColormap(32, m_visual, m_colormap, /* forceARGB32 = */ true))
    9131015            wsi->depth = 32;
     1016        else
     1017#endif
     1018        {
     1019            int depth = displayDepth();
     1020            bool found = getVisualAndColormap(depth, m_visual, m_colormap, /* forceARGB32 = */ false);
     1021            ASSERT_UNUSED(found, found);
     1022            wsi->depth = depth;
    9141023        }
    9151024
    916         if (!m_visual) {
    917             getVisualAndColormap(x11Info->depth(), &m_visual, &m_colormap);
    918             wsi->depth = x11Info->depth();
    919         }
    920 
    921         wsi->display = x11Info->display();
     1025        wsi->display = x11Display();
    9221026        wsi->visual = m_visual;
    9231027        wsi->colormap = m_colormap;
     
    9471051
    9481052    if (m_drawable)
    949         XFreePixmap(QX11Info::display(), m_drawable);
     1053        XFreePixmap(x11Display(), m_drawable);
    9501054
    9511055    if (m_colormap)
    952         XFreeColormap(QX11Info::display(), m_colormap);
     1056        XFreeColormap(x11Display(), m_colormap);
    9531057}
    9541058
  • trunk/Source/WebKit/qt/Api/qwebsettings.cpp

    r111002 r116403  
    11751175    // All applications can share the common QtWebkit cache file(s).
    11761176    // Path is not configurable and uses QDesktopServices::CacheLocation by default.
     1177#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
     1178    QString cachePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
     1179#else
    11771180    QString cachePath = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
     1181#endif
    11781182    WebCore::makeAllDirectories(cachePath);
    11791183
  • trunk/Source/WebKit/qt/ChangeLog

    r116246 r116403  
     12012-05-08  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        [Qt] X11 plugins need to be reworked for Qt5+WK1
     4        https://bugs.webkit.org/show_bug.cgi?id=80691
     5
     6        Reviewed by Simon Hausmann.
     7
     8        * Api/qwebsettings.cpp:
     9        (QWebSettings::enablePersistentStorage):
     10        Build fix for Qt5.
     11        * WebCoreSupport/FrameLoaderClientQt.cpp:
     12        (WebCore::FrameLoaderClientQt::createPlugin):
     13        Inject the wmode parameter for flash so it will
     14        work in windowless, non-transparent mode which
     15        is the only one we support currently.
     16        * WebCoreSupport/PageClientQt.cpp:
     17        (WebCore):
     18        (WebCore::QWebPageClient::ownerWindow):
     19        Added a getter for the top level window so the PluginView
     20        can get it without calling into QtWidgets code.
     21
    1222012-05-06  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    223
  • trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp

    r116121 r116403  
    16041604        Vector<String> values = paramValues;
    16051605        if (mimeType == "application/x-shockwave-flash") {
     1606#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
     1607            const bool shouldInjectWmode = true;
     1608#else
     1609            // Inject wmode=opaque when there is no client or the client is not a QWebView.
    16061610            QWebPageClient* client = m_webFrame->page()->d->client.get();
    1607             const bool isQWebView = client && qobject_cast<QWidget*>(client->pluginParent());
    1608             if (!isQWebView) {
     1611            const bool shouldInjectWmode = !(client && qobject_cast<QWidget*>(client->pluginParent()));
     1612#endif
     1613            if (shouldInjectWmode) {
    16091614                // Inject wmode=opaque when there is no client or the client is not a QWebView.
    16101615                size_t wmodeIndex = params.find("wmode");
  • trunk/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp

    r107819 r116403  
    7070#endif
    7171
     72#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
     73QWindow* QWebPageClient::ownerWindow() const
     74{
     75    QWidget* widget = ownerWidget();
     76    if (!widget)
     77        return 0;
     78    if (QWindow *window = widget->windowHandle())
     79        return window;
     80    if (const QWidget *nativeParent = widget->nativeParentWidget())
     81        return nativeParent->windowHandle();
     82    return 0;
     83}
     84#endif
     85
    7286namespace WebCore {
    7387
  • trunk/Tools/ChangeLog

    r116387 r116403  
     12012-05-08  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        [Qt] X11 plugins need to be reworked for Qt5+WK1
     4        https://bugs.webkit.org/show_bug.cgi?id=80691
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Implement basic windowless plugin support with Qt5.
     9
     10        * qmake/mkspecs/features/features.prf:
     11        Enable NPAPI plugins if X11 libraries are available.
     12        * qmake/mkspecs/features/functions.prf:
     13        Added a convenience function to determine availability
     14        of X11 libraries.
     15
    1162012-05-07  Raphael Kubo da Costa  <rakuco@webkit.org>
    217
  • trunk/Tools/qmake/mkspecs/features/features.prf

    r116215 r116403  
    8181# Nescape plugins support (NPAPI)
    8282!contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=.) {
    83     unix:haveQt(4)|win32-*:!embedded:!wince*: {
     83    haveQt(5):xlibAvailable() {
     84        DEFINES += ENABLE_NETSCAPE_PLUGIN_API=1
     85        CONFIG += plugin_backend_xlib
     86    } else: unix|win32-*:!embedded:!wince* {
    8487        DEFINES += ENABLE_NETSCAPE_PLUGIN_API=1
    8588    }
  • trunk/Tools/qmake/mkspecs/features/functions.prf

    r115293 r116403  
    324324    return(true)
    325325}
     326
     327defineTest(xlibAvailable) {
     328    haveQt(5) {
     329        contains(QT_CONFIG, xcb-xlib) {
     330            return(true)
     331        } else {
     332            return(false)
     333        }
     334    } else {
     335        unix:!mac:!embedded {
     336            return(true)
     337        } else {
     338            return(false)
     339        }
     340    }
     341}
Note: See TracChangeset for help on using the changeset viewer.