Changeset 51143 in webkit


Ignore:
Timestamp:
Nov 18, 2009 3:18:33 PM (14 years ago)
Author:
kevino@webkit.org
Message:

Reviewed by Kevin Ollivier.

Enable wx plugin support using the Windows implementation as a base.

https://bugs.webkit.org/show_bug.cgi?id=31636

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51140 r51143  
     12009-11-18  Kevin Watters  <kevinwatters@gmail.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        Enable wx plugin support using the Windows implementation as a base.
     6       
     7        https://bugs.webkit.org/show_bug.cgi?id=31636
     8
     9        * platform/graphics/GraphicsContext.h:
     10        (WebCore::GraphicsContext::inTransparencyLayer):
     11        * platform/graphics/wx/GraphicsContextWx.cpp:
     12        (WebCore::GraphicsContext::getWindowsContext):
     13        (WebCore::GraphicsContext::releaseWindowsContext):
     14        * platform/wx/FileSystemWx.cpp:
     15        (WebCore::unloadModule):
     16        (WebCore::listDirectory):
     17        * plugins/PluginDatabase.cpp:
     18        * plugins/PluginView.cpp:
     19        (WebCore::PluginView::stop):
     20        (WebCore::PluginView::PluginView):
     21        * plugins/PluginView.h:
     22        * plugins/win/PluginViewWin.cpp:
     23        (windowHandleForPageClient):
     24        (WebCore::PluginView::handleMouseEvent):
     25        (WebCore::PluginView::platformStart):
     26        (WebCore::PluginView::snapshot):
     27        * wscript:
     28
    1292009-11-18  Andrei Popescu  <andreip@google.com>
    230
  • trunk/WebCore/platform/graphics/GraphicsContext.h

    r51124 r51143  
    362362#endif
    363363
    364 #if PLATFORM(QT) && defined(Q_WS_WIN)
     364#if (PLATFORM(QT) && defined(Q_WS_WIN)) || (PLATFORM(WX) && PLATFORM(WIN_OS))
    365365        HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);
    366366        void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);
    367367        bool shouldIncludeChildWindows() const { return false; }
     368#endif
     369
     370#if PLATFORM(WX)
     371        bool inTransparencyLayer() const { return false; }
    368372#endif
    369373
  • trunk/WebCore/platform/graphics/wx/GraphicsContextWx.cpp

    r50852 r51143  
    567567}
    568568
    569 }
     569#if PLATFORM(WIN_OS)
     570HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
     571{
     572    if (dstRect.isEmpty())
     573        return 0;
     574
     575    // Create a bitmap DC in which to draw.
     576    BITMAPINFO bitmapInfo;
     577    bitmapInfo.bmiHeader.biSize          = sizeof(BITMAPINFOHEADER);
     578    bitmapInfo.bmiHeader.biWidth         = dstRect.width();
     579    bitmapInfo.bmiHeader.biHeight        = dstRect.height();
     580    bitmapInfo.bmiHeader.biPlanes        = 1;
     581    bitmapInfo.bmiHeader.biBitCount      = 32;
     582    bitmapInfo.bmiHeader.biCompression   = BI_RGB;
     583    bitmapInfo.bmiHeader.biSizeImage     = 0;
     584    bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
     585    bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
     586    bitmapInfo.bmiHeader.biClrUsed       = 0;
     587    bitmapInfo.bmiHeader.biClrImportant  = 0;
     588
     589    void* pixels = 0;
     590    HBITMAP bitmap = ::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0);
     591    if (!bitmap)
     592        return 0;
     593
     594    HDC displayDC = ::GetDC(0);
     595    HDC bitmapDC = ::CreateCompatibleDC(displayDC);
     596    ::ReleaseDC(0, displayDC);
     597
     598    ::SelectObject(bitmapDC, bitmap);
     599
     600    // Fill our buffer with clear if we're going to alpha blend.
     601    if (supportAlphaBlend) {
     602        BITMAP bmpInfo;
     603        GetObject(bitmap, sizeof(bmpInfo), &bmpInfo);
     604        int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
     605        memset(bmpInfo.bmBits, 0, bufferSize);
     606    }
     607    return bitmapDC;
     608}
     609
     610void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
     611{
     612    if (hdc) {
     613
     614        if (!dstRect.isEmpty()) {
     615
     616            HBITMAP bitmap = static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP));
     617            BITMAP info;
     618            GetObject(bitmap, sizeof(info), &info);
     619            ASSERT(info.bmBitsPixel == 32);
     620
     621            wxBitmap bmp;
     622            bmp.SetHBITMAP(bitmap);
     623#if !wxCHECK_VERSION(2,9,0)
     624            if (supportAlphaBlend)
     625                bmp.UseAlpha();
     626#endif
     627            m_data->context->DrawBitmap(bmp, dstRect.x(), dstRect.y(), supportAlphaBlend);
     628
     629            ::DeleteObject(bitmap);
     630        }
     631
     632        ::DeleteDC(hdc);
     633    }
     634}
     635#endif
     636
     637}
  • trunk/WebCore/platform/wx/FileSystemWx.cpp

    r48344 r51143  
    22 * Copyright (C) 2007 Kevin Ollivier
    33 * Copyright (C) 2008 Collabora, Ltd.
     4 * Copyright (C) 2009 Peter Laufenberg @ Inhance Digital Corp
    45 *
    56 * All rights reserved.
     
    3637#include <wx/wx.h>
    3738#include <wx/filename.h>
     39#include <wx/dir.h>
     40#include <wx/file.h>
     41#include <wx/datetime.h>
     42#include <wx/filefn.h>
    3843
    3944namespace WebCore {
     
    115120}
    116121
    117 bool unloadModule(PlatformModule)
     122bool unloadModule(PlatformModule mod)
    118123{
     124#if PLATFORM(WIN_OS)
     125    return ::FreeLibrary(mod);
     126#else
    119127    notImplemented();
    120128    return false;
     129#endif
    121130}
    122131
    123132Vector<String> listDirectory(const String& path, const String& filter)
    124133{
     134    wxArrayString   file_paths;
     135   
     136    int n_files = wxDir::GetAllFiles(path, &file_paths, _T(""), wxDIR_FILES);
     137
    125138    Vector<String> entries;
    126     notImplemented();
     139   
     140    for (int i = 0; i < n_files; i++)
     141    {
     142        entries.append(file_paths[i]);
     143    }   
     144   
    127145    return entries;
    128146}
  • trunk/WebCore/plugins/PluginDatabase.cpp

    r50452 r51143  
    321321}
    322322
    323 #if (!PLATFORM(WINCE)) && (!PLATFORM(SYMBIAN)) && (!PLATFORM(WIN_OS) || PLATFORM(WX) || !ENABLE(NETSCAPE_PLUGIN_API))
     323#if (!PLATFORM(WINCE)) && (!PLATFORM(SYMBIAN)) && (!PLATFORM(WIN_OS) || !ENABLE(NETSCAPE_PLUGIN_API))
    324324// For Safari/Win the following three methods are implemented
    325325// in PluginDatabaseWin.cpp, but if we can use WebCore constructs
  • trunk/WebCore/plugins/PluginView.cpp

    r50804 r51143  
    4747#include "FocusController.h"
    4848#include "PlatformMouseEvent.h"
    49 #if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API)
     49#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API)
    5050#include "PluginMessageThrottlerWin.h"
    5151#endif
     
    307307
    308308#if ENABLE(NETSCAPE_PLUGIN_API)
    309 #if !PLATFORM(WX) // FIXME: Revisit this when implementing plugins for wx
    310309#ifdef XP_WIN
    311310    // Unsubclass the window
     
    324323    }
    325324#endif // XP_WIN
    326 #endif // !PLATFORM(WX)
    327325#endif // ENABLE(NETSCAPE_PLUGIN_API)
    328326
     
    805803    , m_needsXEmbed(false)
    806804#endif
    807 #if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API)
     805#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API)
    808806    , m_pluginWndProc(0)
    809807    , m_lastMessage(0)
  • trunk/WebCore/plugins/PluginView.h

    r51105 r51143  
    4646#include <wtf/Vector.h>
    4747
    48 #if PLATFORM(WIN_OS) && PLATFORM(QT)
     48#if PLATFORM(WIN_OS) && (PLATFORM(QT) || PLATFORM(WX))
    4949typedef struct HWND__* HWND;
    5050typedef HWND PlatformPluginWidget;
     
    6666    class MouseEvent;
    6767    class KURL;
    68 #if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API)
     68#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API)
    6969    class PluginMessageThrottlerWin;
    7070#endif
     
    184184        const KURL& url() const { return m_url; }
    185185
    186 #if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API)
     186#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API)
    187187        static LRESULT CALLBACK PluginViewWndProc(HWND, UINT, WPARAM, LPARAM);
    188188        LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
     
    227227        void invalidateWindowlessPluginRect(const IntRect&);
    228228
    229 #if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API)
     229#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API)
    230230        void paintWindowedPluginIntoContext(GraphicsContext*, const IntRect&);
    231231        static HDC WINAPI hookedBeginPaint(HWND, PAINTSTRUCT*);
     
    297297#endif
    298298
    299 #if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API)
     299#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API)
    300300        OwnPtr<PluginMessageThrottlerWin> m_messageThrottler;
    301301        WNDPROC m_pluginWndProc;
     
    306306#endif
    307307
    308 #if (PLATFORM(QT) && PLATFORM(WIN_OS)) || defined(XP_MACOSX)
     308#if ((PLATFORM(QT) || PLATFORM(WX)) && PLATFORM(WIN_OS)) || defined(XP_MACOSX)
    309309        // On Mac OSX and Qt/Windows the plugin does not have its own native widget,
    310310        // but is using the containing window as its reference for positioning/painting.
  • trunk/WebCore/plugins/win/PluginViewWin.cpp

    r49933 r51143  
    3131
    3232#include "BitmapImage.h"
     33#if !PLATFORM(WX)
    3334#include "BitmapInfo.h"
     35#endif
    3436#include "Document.h"
    3537#include "DocumentLoader.h"
     
    8284#endif
    8385
     86#if PLATFORM(WX)
     87#include <wx/defs.h>
     88#include <wx/window.h>
     89#endif
     90
    8491static inline HWND windowHandleForPageClient(PlatformPageClient client)
    8592{
     
    8895        return 0;
    8996    return client->ownerWidget()->winId();
     97#elif PLATFORM(WX)
     98    if (!client)
     99        return 0;
     100    return (HWND)client->GetHandle();
    90101#else
    91102    return client;
     
    703714        event->setDefaultHandled();
    704715
    705 #if !PLATFORM(QT) && !PLATFORM(WINCE)
     716#if !PLATFORM(QT) && !PLATFORM(WX) && !PLATFORM(WINCE)
    706717    // Currently, Widget::setCursor is always called after this function in EventHandler.cpp
    707718    // and since we don't want that we set ignoreNextSetCursor to true here to prevent that.
     
    988999                                       0, 0, 0, 0, parentWindowHandle, 0, Page::instanceHandle(), 0);
    9891000
    990 #if PLATFORM(WIN_OS) && PLATFORM(QT)
     1001#if PLATFORM(WIN_OS) && (PLATFORM(QT) || PLATFORM(WX))
    9911002        m_window = window;
    9921003#else
     
    10311042PassRefPtr<Image> PluginView::snapshot()
    10321043{
     1044#if !PLATFORM(WX)
    10331045    OwnPtr<HDC> hdc(CreateCompatibleDC(0));
    10341046
     
    10601072
    10611073    return BitmapImage::create(hbmp.get());
     1074#else
     1075    return 0;
     1076#endif
    10621077}
    10631078
  • trunk/WebCore/wscript

    r49907 r51143  
    3131
    3232if build_port == "wx":
    33     webcore_sources['plugins'] = [  'plugins/PluginDataNone.cpp',
    34                                     'plugins/PluginViewNone.cpp'
    35                                   ]
     33    no_plugins = [      'plugins/PluginDataNone.cpp',
     34                        'plugins/PluginViewNone.cpp',
     35                        'plugins/PluginPackageNone.cpp'
     36                 ]
    3637   
    3738    if building_on_win32:
    38         webcore_dirs.append('platform/wx/wxcode/win')
     39        webcore_dirs.extend(['platform/wx/wxcode/win', 'plugins/win'])
    3940        webcore_sources['wx-win'] = [
    4041               # wxTimer on Windows has a bug that causes it to eat crashes in callbacks
     
    4243               # widely available (it was fixed in 2.8.10).
    4344               'platform/win/SharedTimerWin.cpp',
     45               # Use the Windows plugin architecture
    4446               'page/win/PageWin.cpp',
     47               'plugins/win/PluginDataWin.cpp',
     48               'plugins/win/PluginDatabaseWin.cpp',
     49               'plugins/win/PluginMessageThrottlerWin.cpp',
    4550               'plugins/win/PluginPackageWin.cpp',
     51               'plugins/win/PluginViewWin.cpp',
    4652        ]
    4753    elif sys.platform.startswith('darwin'):
     
    5056               'platform/mac/PurgeableBufferMac.cpp',
    5157        ]
    52         webcore_sources['plugins'].append('plugins/PluginPackageNone.cpp')
     58        webcore_sources['plugins'] = no_plugins
    5359    else:
    5460        webcore_dirs.append('platform/wx/wxcode/gtk')
    55         webcore_sources['plugins'].append('plugins/PluginPackageNone.cpp')
     61        webcore_sources['plugins'] = no_plugins
    5662       
    5763from TaskGen import taskgen, feature, after
  • trunk/WebKit/wx/ChangeLog

    r50984 r51143  
     12009-11-18  Kevin Watters  <kevinwatters@gmail.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        Enable wx plugin support using the Windows implementation as a base.
     6       
     7        https://bugs.webkit.org/show_bug.cgi?id=31636
     8
     9        * WebKitSupport/FrameLoaderClientWx.cpp:
     10        (WebCore::FrameLoaderClientWx::FrameLoaderClientWx):
     11        (WebCore::FrameLoaderClientWx::finishedLoading):
     12        (WebCore::FrameLoaderClientWx::committedLoad):
     13        (WebCore::FrameLoaderClientWx::createPlugin):
     14        (WebCore::FrameLoaderClientWx::redirectDataToPlugin):
     15        (WebCore::FrameLoaderClientWx::shouldUsePluginDocument):
     16        * WebKitSupport/FrameLoaderClientWx.h:
     17        * WebView.cpp:
     18        (wxWebView::Create):
     19
    1202009-11-13  Kevin Ollivier  <kevino@theolliviers.com>
    221
  • trunk/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp

    r50973 r51143  
    4040#include "HTMLFormElement.h"
    4141#include "HTMLFrameOwnerElement.h"
     42#include "HTMLPluginElement.h"
    4243#include "NotImplemented.h"
    4344#include "Page.h"
    4445#include "PlatformString.h"
     46#include "PluginView.h"
    4547#include "ProgressTracker.h"
    4648#include "RenderPart.h"
     
    8183
    8284FrameLoaderClientWx::FrameLoaderClientWx()
    83     : m_webFrame(0)
     85    : m_frame(0)
     86    , m_pluginView(0)
     87    , m_hasSentResponseToPlugin(false)
     88    , m_webFrame(0)
    8489{
    8590}
     
    409414void FrameLoaderClientWx::finishedLoading(DocumentLoader*)
    410415{
    411     notImplemented();
     416    if (m_pluginView) {
     417        m_pluginView->didFinishLoading();
     418        m_pluginView = 0;
     419        m_hasSentResponseToPlugin = false;
     420    }
    412421}
    413422
     
    568577    if (!m_webFrame)
    569578        return;
    570     FrameLoader* fl = loader->frameLoader();
    571     fl->setEncoding(m_response.textEncodingName(), false);
    572     fl->addData(data, length);
     579    if (!m_pluginView) {
     580        FrameLoader* fl = loader->frameLoader();
     581        fl->setEncoding(m_response.textEncodingName(), false);
     582        fl->addData(data, length);
     583    }
     584   
     585    // We re-check here as the plugin can have been created
     586    if (m_pluginView) {
     587        if (!m_hasSentResponseToPlugin) {
     588            m_pluginView->didReceiveResponse(loader->response());
     589            // didReceiveResponse sets up a new stream to the plug-in. on a full-page plug-in, a failure in
     590            // setting up this stream can cause the main document load to be cancelled, setting m_pluginView
     591            // to null
     592            if (!m_pluginView)
     593                return;
     594            m_hasSentResponseToPlugin = true;
     595        }
     596        m_pluginView->didReceiveData(data, length);
     597    }
    573598}
    574599
     
    801826}
    802827
    803 PassRefPtr<Widget> FrameLoaderClientWx::createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually)
    804 {
    805     notImplemented();
     828PassRefPtr<Widget> FrameLoaderClientWx::createPlugin(const IntSize& size, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
     829{
     830#if PLATFORM(WIN_OS)
     831    RefPtr<PluginView> pv = PluginView::create(m_frame, size, element, url, paramNames, paramValues, mimeType, loadManually);
     832    if (pv->status() == PluginStatusLoadedSuccessfully)
     833        return pv;
     834#endif
    806835    return 0;
    807836}
     
    809838void FrameLoaderClientWx::redirectDataToPlugin(Widget* pluginWidget)
    810839{
    811     notImplemented();
    812     return;
     840     ASSERT(!m_pluginView);
     841     m_pluginView = static_cast<PluginView*>(pluginWidget);
     842     m_hasSentResponseToPlugin = false;
    813843}
    814844
     
    889919}
    890920
    891 }
     921bool FrameLoaderClientWx::shouldUsePluginDocument(const String &mimeType) const
     922{
     923    // NOTE: Plugin Documents are used for viewing PDFs, etc. inline, and should
     924    // not be used for pages with plugins in them.
     925    return false;
     926}
     927
     928}
  • trunk/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h

    r50973 r51143  
    3232#include "FrameLoader.h"
    3333#include "KURL.h"
     34#include "PluginView.h"
    3435#include "ResourceResponse.h"
     36#include "HTMLPlugInElement.h"
    3537
    3638class wxWebFrame;
     
    209211       
    210212        virtual void registerForIconNotification(bool listen = true);
     213       
     214        virtual bool shouldUsePluginDocument(const String &mimeType) const;
    211215
    212216    private:
     
    214218        Frame* m_frame;
    215219        wxWebView *m_webView;
     220        PluginView* m_pluginView;
     221        bool m_hasSentResponseToPlugin;
    216222        ResourceResponse m_response;
    217223        bool m_firstData;
  • trunk/WebKit/wx/WebView.cpp

    r50522 r51143  
    337337#if ENABLE(DATABASE)
    338338    settings->setDatabasesEnabled(true);
     339#endif
     340
     341#if __WXMSW__
     342    settings->setPluginsEnabled(true);
    339343#endif
    340344
  • trunk/WebKitTools/ChangeLog

    r51114 r51143  
     12009-11-18  Kevin Watters  <kevinwatters@gmail.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        Enable wx plugin support using the Windows implementation as a base.
     6       
     7        https://bugs.webkit.org/show_bug.cgi?id=31636
     8
     9        * wx/build/settings.py:
     10
    1112009-11-18  Kenneth Rohde Christiansen  <kenneth@webkit.org>
    212
  • trunk/WebKitTools/wx/build/settings.py

    r50135 r51143  
    338338        conf.env.append_value('LIB', [
    339339            'kernel32', 'user32','gdi32','comdlg32','winspool','winmm',
    340             'shell32', 'comctl32', 'ole32', 'oleaut32', 'uuid', 'advapi32',
     340            'shell32', 'shlwapi', 'comctl32', 'ole32', 'oleaut32', 'uuid', 'advapi32',
    341341            'wsock32', 'gdiplus', 'version'])
    342342
Note: See TracChangeset for help on using the changeset viewer.