Changeset 46430 in webkit


Ignore:
Timestamp:
Jul 27, 2009 3:00:58 PM (15 years ago)
Author:
treat@webkit.org
Message:

2009-07-27 Yong Li <yong.li@torchmobile.com>

Reviewed by George Staikos.

WINCE PORT: Make plugin work for WINCE
https://bugs.webkit.org/show_bug.cgi?id=27713

  • plugins/win/PluginDatabaseWin.cpp: (SHGetValue): (PathRemoveFileSpec): (WebCore::addWindowsMediaPlayerPluginDirectory): (WebCore::addMacromediaPluginDirectories):
  • plugins/win/PluginPackageWin.cpp: (WebCore::PluginPackage::load):
  • plugins/win/PluginViewWin.cpp: (WebCore::registerPluginView): (WebCore::PluginView::wndProc): (WebCore::PluginView::updatePluginWidget): (WebCore::PluginView::paintWindowedPluginIntoContext): (WebCore::PluginView::paint): (WebCore::PluginView::handleMouseEvent): (WebCore::PluginView::setParent): (WebCore::PluginView::setNPWindowRect): (WebCore::PluginView::stop): (WebCore::PluginView::init):
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r46429 r46430  
     12009-07-27  Yong Li  <yong.li@torchmobile.com>
     2
     3        Reviewed by George Staikos.
     4
     5        WINCE PORT: Make plugin work for WINCE
     6        https://bugs.webkit.org/show_bug.cgi?id=27713
     7
     8        * plugins/win/PluginDatabaseWin.cpp:
     9        (SHGetValue):
     10        (PathRemoveFileSpec):
     11        (WebCore::addWindowsMediaPlayerPluginDirectory):
     12        (WebCore::addMacromediaPluginDirectories):
     13        * plugins/win/PluginPackageWin.cpp:
     14        (WebCore::PluginPackage::load):
     15        * plugins/win/PluginViewWin.cpp:
     16        (WebCore::registerPluginView):
     17        (WebCore::PluginView::wndProc):
     18        (WebCore::PluginView::updatePluginWidget):
     19        (WebCore::PluginView::paintWindowedPluginIntoContext):
     20        (WebCore::PluginView::paint):
     21        (WebCore::PluginView::handleMouseEvent):
     22        (WebCore::PluginView::setParent):
     23        (WebCore::PluginView::setNPWindowRect):
     24        (WebCore::PluginView::stop):
     25        (WebCore::PluginView::init):
     26
    1272009-07-27  Joseph Pecoraro  <joepeck02@gmail.com>
    228
  • trunk/WebCore/plugins/win/PluginDatabaseWin.cpp

    r35158 r46430  
    22 * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
    33 * Copyright (C) 2008 Collabora, Ltd.  All rights reserved.
     4 * Copyright (C) 2008-2009 Torch Mobile, Inc.  All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    3839#endif
    3940
     41#if PLATFORM(WINCE)
     42// WINCE doesn't support Registry Key Access Rights. The parameter should always be 0
     43#define KEY_ENUMERATE_SUB_KEYS 0
     44
     45DWORD SHGetValue(HKEY hkey, LPCWSTR pszSubKey, LPCWSTR pszValue, LPDWORD pdwType, LPVOID pvData, LPDWORD pcbData)
     46{
     47    HKEY key;
     48    if (RegOpenKeyEx(hkey, pszSubKey, 0, 0, &key) == ERROR_SUCCESS) {
     49        DWORD result = RegQueryValueEx(key, pszValue, 0, pdwType, (LPBYTE)pvData, pcbData);
     50        RegCloseKey(key);
     51        return result;
     52    }
     53    return ERROR_INVALID_NAME;
     54}
     55
     56BOOL PathRemoveFileSpec(LPWSTR moduleFileNameStr)
     57{
     58    if (!*moduleFileNameStr)
     59        return FALSE;
     60
     61    LPWSTR lastPos = 0;
     62    LPWSTR curPos = moduleFileNameStr;
     63    do {
     64        if (*curPos == L'/' || *curPos == L'\\')
     65            lastPos = curPos;
     66    } while (*++curPos);
     67
     68    if (lastPos == curPos - 1)
     69        return FALSE;
     70
     71    if (lastPos)
     72        *lastPos = 0;
     73    else {
     74        moduleFileNameStr[0] = L'\\';
     75        moduleFileNameStr[1] = 0;
     76    }
     77
     78    return TRUE;
     79}
     80#endif
     81
    4082namespace WebCore {
    4183
     
    211253static inline void addWindowsMediaPlayerPluginDirectory(Vector<String>& directories)
    212254{
     255#if !PLATFORM(WINCE)
    213256    // The new WMP Firefox plugin is installed in \PFiles\Plugins if it can't find any Firefox installs
    214257    WCHAR pluginDirectoryStr[_MAX_PATH + 1];
     
    217260    if (pluginDirectorySize > 0 && pluginDirectorySize <= _countof(pluginDirectoryStr))
    218261        directories.append(String(pluginDirectoryStr, pluginDirectorySize - 1));
     262#endif
    219263
    220264    DWORD type;
     
    312356static inline void addMacromediaPluginDirectories(Vector<String>& directories)
    313357{
     358#if !PLATFORM(WINCE)
    314359    WCHAR systemDirectoryStr[MAX_PATH];
    315360
     
    324369    PathCombine(macromediaDirectoryStr, systemDirectoryStr, TEXT("macromed\\Shockwave 10"));
    325370    directories.append(macromediaDirectoryStr);
     371#endif
    326372}
    327373
  • trunk/WebCore/plugins/win/PluginPackageWin.cpp

    r45721 r46430  
    22 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Collabora, Ltd.  All rights reserved.
     4 * Copyright (C) 2009 Torch Mobile, Inc.  All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    245246        return true;
    246247    } else {
     248#if !PLATFORM(WINCE)
    247249        WCHAR currentPath[MAX_PATH];
    248250
     
    254256        if (!::SetCurrentDirectoryW(path.charactersWithNullTermination()))
    255257            return false;
     258#endif
    256259
    257260        // Load the library
    258261        m_module = ::LoadLibraryExW(m_path.charactersWithNullTermination(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
    259262
     263#if !PLATFORM(WINCE)
    260264        if (!::SetCurrentDirectoryW(currentPath)) {
    261265            if (m_module)
     
    263267            return false;
    264268        }
     269#endif
    265270    }
    266271
     
    274279    NPError npErr;
    275280
    276     NP_Initialize = (NP_InitializeFuncPtr)GetProcAddress(m_module, "NP_Initialize");
    277     NP_GetEntryPoints = (NP_GetEntryPointsFuncPtr)GetProcAddress(m_module, "NP_GetEntryPoints");
    278     m_NPP_Shutdown = (NPP_ShutdownProcPtr)GetProcAddress(m_module, "NP_Shutdown");
     281    NP_Initialize = (NP_InitializeFuncPtr)GetProcAddress(m_module, _T("NP_Initialize"));
     282    NP_GetEntryPoints = (NP_GetEntryPointsFuncPtr)GetProcAddress(m_module, _T("NP_GetEntryPoints"));
     283    m_NPP_Shutdown = (NPP_ShutdownProcPtr)GetProcAddress(m_module, _T("NP_Shutdown"));
    279284
    280285    if (!NP_Initialize || !NP_GetEntryPoints || !m_NPP_Shutdown)
    281286        goto abort;
    282  
     287
    283288    memset(&m_pluginFuncs, 0, sizeof(m_pluginFuncs));
    284289    m_pluginFuncs.size = sizeof(m_pluginFuncs);
  • trunk/WebCore/plugins/win/PluginViewWin.cpp

    r46411 r46430  
    22 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Collabora Ltd. All rights reserved.
     4 * Copyright (C) 2008-2009 Torch Mobile, Inc. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    6667#include <wtf/ASCIICType.h>
    6768
     69#if PLATFORM(WINCE)
     70#undef LOG_NPERROR
     71#define LOG_NPERROR(x)
     72#undef LOG_PLUGIN_NET_ERROR
     73#define LOG_PLUGIN_NET_ERROR()
     74#endif
     75
    6876#if PLATFORM(QT)
    6977#include <QWidget.h>
     
    99107static const char* MozillaUserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0";
    100108
     109#if !PLATFORM(WINCE)
    101110// The code used to hook BeginPaint/EndPaint originally came from
    102111// <http://www.fengyuan.com/article/wmprint.html>.
     
    208217
    209218}
     219#endif
    210220
    211221static bool registerPluginView()
     
    223233    ASSERT(Page::instanceHandle());
    224234
     235#if PLATFORM(WINCE)
     236    WNDCLASS wcex = { 0 };
     237#else
    225238    WNDCLASSEX wcex;
    226 
    227239    wcex.cbSize = sizeof(WNDCLASSEX);
     240    wcex.hIconSm        = 0;
     241#endif
    228242
    229243    wcex.style          = CS_DBLCLKS;
     244#if PLATFORM(WINCE)
     245    wcex.style          |= CS_PARENTDC;
     246#endif
    230247    wcex.lpfnWndProc    = DefWindowProc;
    231248    wcex.cbClsExtra     = 0;
     
    237254    wcex.lpszMenuName   = 0;
    238255    wcex.lpszClassName  = kWebPluginViewdowClassName;
    239     wcex.hIconSm        = 0;
    240 
     256
     257#if PLATFORM(WINCE)
     258    return !!RegisterClass(&wcex);
     259#else
    241260    return !!RegisterClassEx(&wcex);
     261#endif
    242262}
    243263
     
    311331    }
    312332
     333#if !PLATFORM(WINCE)
    313334    if (message == WM_PRINTCLIENT) {
    314335        // Most (all?) windowed plugins don't respond to WM_PRINTCLIENT, so we
     
    318339        m_wmPrintHDC = reinterpret_cast<HDC>(wParam);
    319340    }
     341#endif
    320342
    321343    // Call the plug-in's window proc.
     
    340362    IntRect oldClipRect = m_clipRect;
    341363
     364#if PLATFORM(WINCE)
     365    m_windowRect = frameView->contentsToWindow(frameRect());
     366#else
    342367    m_windowRect = IntRect(frameView->contentsToWindow(frameRect().location()), frameRect().size());
     368#endif
    343369    m_clipRect = windowClipRect();
    344370    m_clipRect.move(-m_windowRect.x(), -m_windowRect.y());
     
    427453void PluginView::paintWindowedPluginIntoContext(GraphicsContext* context, const IntRect& rect) const
    428454{
     455#if !PLATFORM(WINCE)
    429456    ASSERT(m_isWindowed);
    430457    ASSERT(context->shouldIncludeChildWindows());
     
    451478
    452479    context->releaseWindowsContext(hdc, frameRect(), false);
     480#endif
    453481}
    454482
     
    465493
    466494    if (m_isWindowed) {
     495#if !PLATFORM(WINCE)
    467496        if (context->shouldIncludeChildWindows())
    468497            paintWindowedPluginIntoContext(context, rect);
     498#endif
    469499        return;
    470500    }
     
    479509    // In the Qt port we always draw in an offscreen buffer and therefore need to preserve
    480510    // the translation set in getWindowsContext.
    481 #if !PLATFORM(QT)
     511#if !PLATFORM(QT) && !PLATFORM(WINCE)
    482512    if (!context->inTransparencyLayer()) {
    483513        XFORM transform;
     
    492522    m_npWindow.window = hdc;
    493523
    494     IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(frameRect().location());
    495    
    496524    WINDOWPOS windowpos;
    497525    memset(&windowpos, 0, sizeof(windowpos));
     526
     527#if PLATFORM(WINCE)
     528    IntRect r = static_cast<FrameView*>(parent())->contentsToWindow(frameRect());
     529
     530    windowpos.x = r.x();
     531    windowpos.y = r.y();
     532    windowpos.cx = r.width();
     533    windowpos.cy = r.height();
     534#else
     535    IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(frameRect().location());
    498536
    499537    windowpos.x = p.x();
     
    501539    windowpos.cx = frameRect().width();
    502540    windowpos.cy = frameRect().height();
     541#endif
    503542
    504543    npEvent.event = WM_WINDOWPOSCHANGED;
     
    541580}
    542581
     582#if !PLATFORM(WINCE)
    543583extern HCURSOR lastSetCursor;
    544584extern bool ignoreNextSetCursor;
     585#endif
    545586
    546587void PluginView::handleMouseEvent(MouseEvent* event)
     
    607648        event->setDefaultHandled();
    608649
    609 #if !PLATFORM(QT)
     650#if !PLATFORM(QT) && !PLATFORM(WINCE)
    610651    // Currently, Widget::setCursor is always called after this function in EventHandler.cpp
    611652    // and since we don't want that we set ignoreNextSetCursor to true here to prevent that.
     
    619660    Widget::setParent(parent);
    620661
     662#if PLATFORM(WINCE)
     663    if (parent) {
     664        init();
     665        if (parent->isVisible())
     666            show();
     667        else
     668            hide();
     669    }
     670#else
    621671    if (parent)
    622672        init();
     
    632682            ::SetFocus(0);
    633683    }
    634 
     684#endif
    635685}
    636686
     
    655705        return;
    656706
     707#if PLATFORM(WINCE)
     708    IntRect r = static_cast<FrameView*>(parent())->contentsToWindow(rect);
     709    m_npWindow.x = r.x();
     710    m_npWindow.y = r.y();
     711
     712    m_npWindow.width = r.width();
     713    m_npWindow.height = r.height();
     714
     715    m_npWindow.clipRect.right = r.width();
     716    m_npWindow.clipRect.bottom = r.height();
     717#else
    657718    IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(rect.location());
    658719    m_npWindow.x = p.x();
     
    662723    m_npWindow.height = rect.height();
    663724
     725    m_npWindow.clipRect.right = rect.width();
     726    m_npWindow.clipRect.bottom = rect.height();
     727#endif
    664728    m_npWindow.clipRect.left = 0;
    665729    m_npWindow.clipRect.top = 0;
    666     m_npWindow.clipRect.right = rect.width();
    667     m_npWindow.clipRect.bottom = rect.height();
    668730
    669731    if (m_plugin->pluginFuncs()->setwindow) {
     
    678740        ASSERT(platformPluginWidget());
    679741
     742#if PLATFORM(WINCE)
     743        if (!m_pluginWndProc) {
     744            WNDPROC currentWndProc = (WNDPROC)GetWindowLong(platformPluginWidget(), GWL_WNDPROC);
     745            if (currentWndProc != PluginViewWndProc)
     746                m_pluginWndProc = (WNDPROC)SetWindowLong(platformPluginWidget(), GWL_WNDPROC, (LONG)PluginViewWndProc);
     747        }
     748#else
    680749        WNDPROC currentWndProc = (WNDPROC)GetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC);
    681750        if (currentWndProc != PluginViewWndProc)
    682751            m_pluginWndProc = (WNDPROC)SetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC, (LONG)PluginViewWndProc);
     752#endif
    683753    }
    684754}
     
    702772    // Unsubclass the window
    703773    if (m_isWindowed) {
     774#if PLATFORM(WINCE)
     775        WNDPROC currentWndProc = (WNDPROC)GetWindowLong(platformPluginWidget(), GWL_WNDPROC);
     776
     777        if (currentWndProc == PluginViewWndProc)
     778            SetWindowLong(platformPluginWidget(), GWL_WNDPROC, (LONG)m_pluginWndProc);
     779#else
    704780        WNDPROC currentWndProc = (WNDPROC)GetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC);
    705        
     781
    706782        if (currentWndProc == PluginViewWndProc)
    707783            SetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC, (LONG)m_pluginWndProc);
     784#endif
    708785    }
    709786
     
    9531030    if (m_isWindowed) {
    9541031        registerPluginView();
     1032#if !PLATFORM(WINCE)
    9551033        setUpOffscreenPaintingHooks(hookedBeginPaint, hookedEndPaint);
     1034#endif
    9561035
    9571036        DWORD flags = WS_CHILD;
     
    9621041        HWND window = ::CreateWindowEx(0, kWebPluginViewdowClassName, 0, flags,
    9631042                                       0, 0, 0, 0, parentWindowHandle, 0, Page::instanceHandle(), 0);
     1043
    9641044#if PLATFORM(WIN_OS) && PLATFORM(QT)
    9651045        m_window = window;
     
    9721052#if PLATFORM(WIN_OS) && PLATFORM(X86_64) && COMPILER(MSVC)
    9731053        ::SetWindowLongPtrA(platformPluginWidget(), GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
     1054#elif PLATFORM(WINCE)
     1055        ::SetWindowLong(platformPluginWidget(), GWL_WNDPROC, (LONG)DefWindowProc);
    9741056#else
    9751057        ::SetWindowLongPtrA(platformPluginWidget(), GWL_WNDPROC, (LONG)DefWindowProcA);
Note: See TracChangeset for help on using the changeset viewer.