Changeset 99872 in webkit


Ignore:
Timestamp:
Nov 10, 2011 9:32:31 AM (12 years ago)
Author:
kbalazs@webkit.org
Message:

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

Reviewed by Simon Hausmann.

.:

Rework our basic plugin support in a way that does
not need a bridge between Qt and X. The solution is
based on getting the content drawed by the plugin
from the server as an image and creating a QImage
from it.

  • Source/api.pri: Link to xlib if necessary.

Source/WebCore:

Rework our basic plugin support in a way that does
not need a bridge between Qt and X. The solution is
based on getting the content drawed by the plugin
from the server as an image and creating a QImage
from it.

No new tests. Existing plugin test are sufficient.

  • Target.pri:
  • bridge/npruntime_internal.h: Added yet another undef

to fix build with Qt5 + X11 headers.

  • plugins/qt/QtX11ImageConversion.cpp: Added.

(WebCore::qimageFromXImage):

  • plugins/qt/QtX11ImageConversion.h: Added.

Added a helper function to create a QImage from an XImage.
Put it in a new file into WebCore to avoid copyright issues - as
the code has been taken directly from Qt - and to be able to resuse
it for the WK1 plugin support in the future.

Source/WebKit2:

  • Target.pri:
  • UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp:

(WebKit::PluginInfoStore::pluginsDirectories):
Kill the last dependency from the WebKit1 plugin system.
This is necessary because currently we don't build the WebKit1
plugin code. The function is equivalent with the XP_UNIX part of
PluginDatabase::defaultPluginDirectories.

  • WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:

(WebKit::NPN_GetValue):

  • WebProcess/Plugins/Netscape/NetscapePlugin.h:
  • WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp:

(WebKit::getPluginDisplay):
(WebKit::x11Screen):
(WebKit::displayDepth):
(WebKit::rootWindowID):
(WebKit::NetscapePlugin::x11HostDisplay):
(WebKit::NetscapePlugin::platformPostInitialize):
(WebKit::NetscapePlugin::platformDestroy):
(WebKit::NetscapePlugin::platformGeometryDidChange):
(WebKit::NetscapePlugin::platformPaint):
(WebKit::initializeXEvent):
Rework plugin initialization and drawing model.

Tools:

Rework our basic plugin support in a way that does
not need a bridge between Qt and X. The solution is
based on getting the content drawed by the plugin
from the server as an image and creating a QImage
from it.

  • qmake/mkspecs/features/features.prf: Enable X11

plugins if Qt is built with the xcb-xlib backend.

Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r99846 r99872  
     12011-11-10  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        [Qt] X11 plugins need to be reworked for Qt5
     4        https://bugs.webkit.org/show_bug.cgi?id=70023
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Rework our basic plugin support in a way that does
     9        not need a bridge between Qt and X. The solution is
     10        based on getting the content drawed by the plugin
     11        from the server as an image and creating a QImage
     12        from it.
     13
     14        * Source/api.pri: Link to xlib if necessary.
     15
    1162011-11-10  Simon Hausmann  <simon.hausmann@nokia.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r99869 r99872  
     12011-11-10  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        [Qt] X11 plugins need to be reworked for Qt5
     4        https://bugs.webkit.org/show_bug.cgi?id=70023
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Rework our basic plugin support in a way that does
     9        not need a bridge between Qt and X. The solution is
     10        based on getting the content drawed by the plugin
     11        from the server as an image and creating a QImage
     12        from it.
     13
     14        No new tests. Existing plugin test are sufficient.
     15
     16        * Target.pri:
     17        * bridge/npruntime_internal.h: Added yet another undef
     18        to fix build with Qt5 + X11 headers.
     19        * plugins/qt/QtX11ImageConversion.cpp: Added.
     20        (WebCore::qimageFromXImage):
     21        * plugins/qt/QtX11ImageConversion.h: Added.
     22        Added a helper function to create a QImage from an XImage.
     23        Put it in a new file into WebCore to avoid copyright issues - as
     24        the code has been taken directly from Qt - and to be able to resuse
     25        it for the WK1 plugin support in the future.
     26
    1272011-11-10  Andreas Kling  <kling@webkit.org>
    228
  • trunk/Source/WebCore/Target.pri

    r99833 r99872  
    28652865}
    28662866
     2867plugin_backend_xlib {
     2868    SOURCES += plugins/qt/QtX11ImageConversion.cpp
     2869    HEADERS += plugins/qt/QtX11ImageConversion.h
     2870}
     2871
    28672872contains(DEFINES, ENABLE_SQL_DATABASE=1) {
    28682873    SOURCES += \
  • trunk/Source/WebCore/bridge/npruntime_internal.h

    r79210 r99872  
    5252    #undef False
    5353    #undef Success
     54    #undef Expose
    5455#endif
  • trunk/Source/WebKit2/ChangeLog

    r99863 r99872  
     12011-11-10  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        [Qt] X11 plugins need to be reworked for Qt5
     4        https://bugs.webkit.org/show_bug.cgi?id=70023
     5
     6        Reviewed by Simon Hausmann.
     7
     8        * Target.pri:
     9        * UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp:
     10        (WebKit::PluginInfoStore::pluginsDirectories):
     11        Kill the last dependency from the WebKit1 plugin system.
     12        This is necessary because currently we don't build the WebKit1
     13        plugin code. The function is equivalent with the XP_UNIX part of
     14        PluginDatabase::defaultPluginDirectories.
     15
     16        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
     17        (WebKit::NPN_GetValue):
     18        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
     19        * WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp:
     20        (WebKit::getPluginDisplay):
     21        (WebKit::x11Screen):
     22        (WebKit::displayDepth):
     23        (WebKit::rootWindowID):
     24        (WebKit::NetscapePlugin::x11HostDisplay):
     25        (WebKit::NetscapePlugin::platformPostInitialize):
     26        (WebKit::NetscapePlugin::platformDestroy):
     27        (WebKit::NetscapePlugin::platformGeometryDidChange):
     28        (WebKit::NetscapePlugin::platformPaint):
     29        (WebKit::initializeXEvent):
     30        Rework plugin initialization and drawing model.
     31
    1322011-11-10  Martin Robinson  <mrobinson@igalia.com>
    233
  • trunk/Source/WebKit2/Target.pri

    r99846 r99872  
    745745    $$WEBKIT2_GENERATED_SOURCES
    746746
    747 contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=0) {
    748     DEFINES += PLUGIN_ARCHITECTURE_UNSUPPORTED
    749 }
    750 
    751747contains(DEFINES, ENABLE_TOUCH_EVENTS=1) {
    752748    HEADERS += \
     
    757753
    758754contains(DEFINES, ENABLE_GEOLOCATION=1): QT += location
     755
     756plugin_backend_xlib {
     757    DEFINES += XP_UNIX
     758}
  • trunk/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp

    r95901 r99872  
    3131#include "NetscapePluginModule.h"
    3232#include "PluginDatabase.h"
     33#include <WebCore/FileSystem.h>
    3334
    3435using namespace WebCore;
     
    3839Vector<String> PluginInfoStore::pluginsDirectories()
    3940{
    40     return PluginDatabase::defaultPluginDirectories();
     41    Vector<String> result;
     42
     43    result.append(homeDirectoryPath() + "/.mozilla/plugins");
     44    result.append(homeDirectoryPath() + "/.netscape/plugins");
     45    result.append("/usr/lib/browser/plugins");
     46    result.append("/usr/local/lib/mozilla/plugins");
     47    result.append("/usr/lib/firefox/plugins");
     48    result.append("/usr/lib64/browser-plugins");
     49    result.append("/usr/lib/browser-plugins");
     50    result.append("/usr/lib/mozilla/plugins");
     51    result.append("/usr/local/netscape/plugins");
     52    result.append("/opt/mozilla/plugins");
     53    result.append("/opt/mozilla/lib/plugins");
     54    result.append("/opt/netscape/plugins");
     55    result.append("/opt/netscape/communicator/plugins");
     56    result.append("/usr/lib/netscape/plugins");
     57    result.append("/usr/lib/netscape/plugins-libc5");
     58    result.append("/usr/lib/netscape/plugins-libc6");
     59    result.append("/usr/lib64/netscape/plugins");
     60    result.append("/usr/lib64/mozilla/plugins");
     61    result.append("/usr/lib/nsbrowser/plugins");
     62    result.append("/usr/lib64/nsbrowser/plugins");
     63
     64    String mozillaHome(getenv("MOZILLA_HOME"));
     65    if (!mozillaHome.isEmpty())
     66        result.append(mozillaHome + "/plugins");
     67
     68    String mozillaPaths(getenv("MOZ_PLUGIN_PATH"));
     69    if (!mozillaPaths.isEmpty()) {
     70        Vector<String> paths;
     71        mozillaPaths.split(UChar(':'), /* allowEmptyEntries */ false, paths);
     72        result.append(paths);
     73    }
     74
     75    return result;
    4176}
    4277
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp

    r99146 r99872  
    3737#include <utility>
    3838
    39 #if PLUGIN_ARCHITECTURE(X11)
    40 #if PLATFORM(QT)
    41 #include <QX11Info>
    42 #elif PLATFORM(GTK)
    43 #include <gdk/gdkx.h>
    44 #endif
    45 #endif
    46 
    4739using namespace WebCore;
    4840using namespace std;
     
    528520           if (!npp)
    529521               return NPERR_GENERIC_ERROR;
    530 #if PLATFORM(QT)
    531            *reinterpret_cast<Display**>(value) = QX11Info::display();
     522           *reinterpret_cast<Display**>(value) = NetscapePlugin::x11HostDisplay();
    532523           break;
    533 #elif PLATFORM(GTK)
    534            *reinterpret_cast<Display**>(value) = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
    535            break;
    536 #else
    537            goto default;
    538 #endif
    539524       }
    540525       case NPNVSupportsXEmbedBool:
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r99449 r99872  
    342342    Pixmap m_drawable;
    343343    Display* m_pluginDisplay;
     344
     345public: // Need to call it in the NPN_GetValue browser callback.
     346    static Display* x11HostDisplay();
    344347#endif
    345348};
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp

    r99449 r99872  
    3535
    3636#if PLATFORM(QT)
    37 #include <QApplication>
    38 #include <QDesktopWidget>
    39 #include <QPixmap>
    40 #include <QX11Info>
     37#include <WebCore/QtX11ImageConversion.h>
    4138#elif PLATFORM(GTK)
    4239#include "PlatformContextCairo.h"
     
    5148namespace WebKit {
    5249
    53 static Display *getPluginDisplay()
     50static Display* getPluginDisplay()
    5451{
    5552#if PLATFORM(QT)
     
    8885}
    8986
    90 static inline Display* x11Display()
    91 {
    92 #if PLATFORM(QT)
    93     return QX11Info::display();
    94 #elif PLATFORM(GTK)
    95     return GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
     87static inline int x11Screen()
     88{
     89#if PLATFORM(QT)
     90    return XDefaultScreen(NetscapePlugin::x11HostDisplay());
     91#elif PLATFORM(GTK)
     92    return gdk_screen_get_number(gdk_screen_get_default());
    9693#else
    9794    return 0;
     
    10299{
    103100#if PLATFORM(QT)
    104     return QApplication::desktop()->x11Info().depth();
     101    return XDefaultDepth(NetscapePlugin::x11HostDisplay(), x11Screen());
    105102#elif PLATFORM(GTK)
    106103    return gdk_visual_get_depth(gdk_screen_get_system_visual(gdk_screen_get_default()));
     
    113110{
    114111#if PLATFORM(QT)
    115     return QX11Info::appRootWindow();
     112    return XDefaultRootWindow(NetscapePlugin::x11HostDisplay());
    116113#elif PLATFORM(GTK)
    117114    return GDK_ROOT_WINDOW();
    118 #else
    119     return 0;
    120 #endif
    121 }
    122 
    123 static inline int x11Screen()
    124 {
    125 #if PLATFORM(QT)
    126     return QX11Info::appScreen();
    127 #elif PLATFORM(GTK)
    128     return gdk_screen_get_number(gdk_screen_get_default());
    129115#else
    130116    return 0;
     
    143129#endif
    144130
     131Display* NetscapePlugin::x11HostDisplay()
     132{
     133#if PLATFORM(QT)
     134    static Display* dedicatedDisplay = 0;
     135    if (!dedicatedDisplay)
     136        dedicatedDisplay = XOpenDisplay(0);
     137
     138    ASSERT(dedicatedDisplay);
     139    return dedicatedDisplay;
     140#elif PLATFORM(GTK)
     141    return GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
     142#else
     143    return 0;
     144#endif
     145}
     146
    145147bool NetscapePlugin::platformPostInitialize()
    146148{
     
    158160    NPSetWindowCallbackStruct* callbackStruct = new NPSetWindowCallbackStruct;
    159161    callbackStruct->type = 0;
    160     Display* display = x11Display();
     162    Display* display = x11HostDisplay();
    161163    int depth = displayDepth();
     164#if PLATFORM(QT)
     165    ASSERT(depth == 16 || depth == 24 || depth == 32);
     166#endif
    162167    callbackStruct->display = display;
    163168    callbackStruct->depth = depth;
     
    192197
    193198    if (m_drawable) {
    194         XFreePixmap(x11Display(), m_drawable);
     199        XFreePixmap(x11HostDisplay(), m_drawable);
    195200        m_drawable = 0;
    196201    }
     
    210215    }
    211216
    212     Display* display = x11Display();
     217    Display* display = x11HostDisplay();
    213218    if (m_drawable)
    214219        XFreePixmap(display, m_drawable);
     
    243248    if (context->paintingDisabled() || !m_drawable)
    244249        return;
    245 
    246 #if PLATFORM(QT)
    247 #elif !PLATFORM(GTK)
    248     notImplemented();
    249     return;
    250 #endif
    251250
    252251    XEvent xevent;
     
    254253    XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose;
    255254    exposeEvent.type = GraphicsExpose;
    256     exposeEvent.display = x11Display();
     255    exposeEvent.display = x11HostDisplay();
    257256    exposeEvent.drawable = m_drawable;
    258257
     
    268267    NPP_HandleEvent(&xevent);
    269268
    270     if (m_pluginDisplay != x11Display())
     269    if (m_pluginDisplay != x11HostDisplay())
    271270        XSync(m_pluginDisplay, false);
    272271
    273272#if PLATFORM(QT)
    274     QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared);
    275     ASSERT(qtDrawable.depth() == static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info)->depth);
     273    XImage* xImage = XGetImage(NetscapePlugin::x11HostDisplay(), m_drawable, exposedRect.x(), exposedRect.y(),
     274                               exposedRect.width(), exposedRect.height(), ULONG_MAX, ZPixmap);
    276275    QPainter* painter = context->platformContext();
    277     painter->drawPixmap(QPoint(exposedRect.x(), exposedRect.y()), qtDrawable, exposedRect);
     276    painter->drawImage(QPoint(exposedRect.x(), exposedRect.y()), qimageFromXImage(xImage), exposedRect);
     277
     278    XDestroyImage(xImage);
    278279#elif PLATFORM(GTK)
    279280    RefPtr<cairo_surface_t> drawableSurface = adoptRef(cairo_xlib_surface_create(m_pluginDisplay,
     
    293294
    294295    cairo_restore(cr);
     296#else
     297    notImplemented();
    295298#endif
    296299}
     
    301304    event.xany.serial = 0;
    302305    event.xany.send_event = false;
    303     event.xany.display = x11Display();
     306    event.xany.display = NetscapePlugin::x11HostDisplay();
    304307    event.xany.window = 0;
    305308}
  • trunk/Source/api.pri

    r99846 r99872  
    223223}
    224224
     225plugin_backend_xlib {
     226    CONFIG *= link_pkgconfig
     227    PKGCONFIG += x11
     228}
  • trunk/Tools/ChangeLog

    r99853 r99872  
     12011-11-10  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        [Qt] X11 plugins need to be reworked for Qt5
     4        https://bugs.webkit.org/show_bug.cgi?id=70023
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Rework our basic plugin support in a way that does
     9        not need a bridge between Qt and X. The solution is
     10        based on getting the content drawed by the plugin
     11        from the server as an image and creating a QImage
     12        from it.
     13
     14        * qmake/mkspecs/features/features.prf: Enable X11
     15        plugins if Qt is built with the xcb-xlib backend.
     16
    1172011-11-10  Simon Hausmann  <simon.hausmann@nokia.com>
    218
  • trunk/Tools/qmake/mkspecs/features/features.prf

    r99843 r99872  
    9494    } else {
    9595        DEFINES += ENABLE_NETSCAPE_PLUGIN_API=0
     96    }
     97}
     98
     99# Netscape plugins support for WebKit2
     100!no_webkit2:!contains(DEFINES, PLUGIN_ARCHITECTURE_UNSUPPORTED): {
     101    contains(QT_CONFIG, xcb-xlib) {
     102        CONFIG += plugin_backend_xlib
     103        DEFINES += PLUGIN_ARCHITECTURE_X11=1 \
     104                   PLUGIN_ARCHITECTURE_UNSUPPORTED=0
     105    } else {
     106        DEFINES += PLUGIN_ARCHITECTURE_UNSUPPORTED=1
    96107    }
    97108}
Note: See TracChangeset for help on using the changeset viewer.