summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp')
-rw-r--r--src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp118
1 files changed, 102 insertions, 16 deletions
diff --git a/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp b/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp
index 272a540ae..c97984dda 100644
--- a/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp
+++ b/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Collabora Ltd. All rights reserved.
+ * Copyright (C) 2008-2009 Torch Mobile, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -65,6 +66,13 @@
#include <runtime/JSValue.h>
#include <wtf/ASCIICType.h>
+#if PLATFORM(WINCE)
+#undef LOG_NPERROR
+#define LOG_NPERROR(x)
+#undef LOG_PLUGIN_NET_ERROR
+#define LOG_PLUGIN_NET_ERROR()
+#endif
+
#if PLATFORM(QT)
#include <QWidget.h>
#endif
@@ -98,6 +106,7 @@ const LPCWSTR kWebPluginViewProperty = L"WebPluginViewProperty";
static const char* MozillaUserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0";
+#if !PLATFORM(WINCE)
// The code used to hook BeginPaint/EndPaint originally came from
// <http://www.fengyuan.com/article/wmprint.html>.
// Copyright (C) 2000 by Feng Yuan (www.fengyuan.com).
@@ -154,7 +163,7 @@ BOOL WINAPI PluginView::hookedEndPaint(HWND hWnd, const PAINTSTRUCT* lpPaint)
"push %3\n"
"call *%4\n"
: "=a" (result)
- : "a" (endPaintSysCall), "g" (lpPaint), "g" (hWnd), "g" (*endPaint)
+ : "a" (endPaintSysCall), "g" (lpPaint), "g" (hWnd), "m" (*endPaint)
);
return result;
#else
@@ -207,6 +216,7 @@ static void setUpOffscreenPaintingHooks(HDC (WINAPI*hookedBeginPaint)(HWND, PAIN
hook("user32.dll", "EndPaint", endPaintSysCall, endPaint, reinterpret_cast<const void *>(reinterpret_cast<ptrdiff_t>(hookedEndPaint)));
}
+#endif
static bool registerPluginView()
{
@@ -222,11 +232,18 @@ static bool registerPluginView()
ASSERT(Page::instanceHandle());
+#if PLATFORM(WINCE)
+ WNDCLASS wcex = { 0 };
+#else
WNDCLASSEX wcex;
-
wcex.cbSize = sizeof(WNDCLASSEX);
+ wcex.hIconSm = 0;
+#endif
wcex.style = CS_DBLCLKS;
+#if PLATFORM(WINCE)
+ wcex.style |= CS_PARENTDC;
+#endif
wcex.lpfnWndProc = DefWindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
@@ -236,9 +253,12 @@ static bool registerPluginView()
wcex.hbrBackground = (HBRUSH)COLOR_WINDOW;
wcex.lpszMenuName = 0;
wcex.lpszClassName = kWebPluginViewdowClassName;
- wcex.hIconSm = 0;
+#if PLATFORM(WINCE)
+ return !!RegisterClass(&wcex);
+#else
return !!RegisterClassEx(&wcex);
+#endif
}
LRESULT CALLBACK PluginView::PluginViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -310,6 +330,7 @@ PluginView::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
m_popPopupsStateTimer.startOneShot(0);
}
+#if !PLATFORM(WINCE)
if (message == WM_PRINTCLIENT) {
// Most (all?) windowed plugins don't respond to WM_PRINTCLIENT, so we
// change the message to WM_PAINT and rely on our hooked versions of
@@ -317,6 +338,7 @@ PluginView::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
message = WM_PAINT;
m_wmPrintHDC = reinterpret_cast<HDC>(wParam);
}
+#endif
// Call the plug-in's window proc.
LRESULT result = ::CallWindowProc(m_pluginWndProc, hWnd, message, wParam, lParam);
@@ -339,7 +361,11 @@ void PluginView::updatePluginWidget()
IntRect oldWindowRect = m_windowRect;
IntRect oldClipRect = m_clipRect;
+#if PLATFORM(WINCE)
+ m_windowRect = frameView->contentsToWindow(frameRect());
+#else
m_windowRect = IntRect(frameView->contentsToWindow(frameRect().location()), frameRect().size());
+#endif
m_clipRect = windowClipRect();
m_clipRect.move(-m_windowRect.x(), -m_windowRect.y());
@@ -413,7 +439,7 @@ bool PluginView::dispatchNPEvent(NPEvent& npEvent)
shouldPop = true;
}
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
setCallingPlugin(true);
bool result = m_plugin->pluginFuncs()->event(m_instance, &npEvent);
setCallingPlugin(false);
@@ -426,6 +452,7 @@ bool PluginView::dispatchNPEvent(NPEvent& npEvent)
void PluginView::paintWindowedPluginIntoContext(GraphicsContext* context, const IntRect& rect) const
{
+#if !PLATFORM(WINCE)
ASSERT(m_isWindowed);
ASSERT(context->shouldIncludeChildWindows());
@@ -450,6 +477,7 @@ void PluginView::paintWindowedPluginIntoContext(GraphicsContext* context, const
SetWorldTransform(hdc, &originalTransform);
context->releaseWindowsContext(hdc, frameRect(), false);
+#endif
}
void PluginView::paint(GraphicsContext* context, const IntRect& rect)
@@ -464,8 +492,10 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
return;
if (m_isWindowed) {
+#if !PLATFORM(WINCE)
if (context->shouldIncludeChildWindows())
paintWindowedPluginIntoContext(context, rect);
+#endif
return;
}
@@ -478,7 +508,7 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
// of the window and the plugin expects that the passed in DC has window coordinates.
// In the Qt port we always draw in an offscreen buffer and therefore need to preserve
// the translation set in getWindowsContext.
-#if !PLATFORM(QT)
+#if !PLATFORM(QT) && !PLATFORM(WINCE)
if (!context->inTransparencyLayer()) {
XFORM transform;
GetWorldTransform(hdc, &transform);
@@ -491,15 +521,24 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
m_npWindow.type = NPWindowTypeDrawable;
m_npWindow.window = hdc;
- IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(frameRect().location());
-
WINDOWPOS windowpos;
memset(&windowpos, 0, sizeof(windowpos));
+#if PLATFORM(WINCE)
+ IntRect r = static_cast<FrameView*>(parent())->contentsToWindow(frameRect());
+
+ windowpos.x = r.x();
+ windowpos.y = r.y();
+ windowpos.cx = r.width();
+ windowpos.cy = r.height();
+#else
+ IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(frameRect().location());
+
windowpos.x = p.x();
windowpos.y = p.y();
windowpos.cx = frameRect().width();
windowpos.cy = frameRect().height();
+#endif
npEvent.event = WM_WINDOWPOSCHANGED;
npEvent.lParam = reinterpret_cast<uint32>(&windowpos);
@@ -535,13 +574,15 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event)
npEvent.lParam = 0x8000;
}
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
if (!dispatchNPEvent(npEvent))
event->setDefaultHandled();
}
+#if !PLATFORM(WINCE)
extern HCURSOR lastSetCursor;
extern bool ignoreNextSetCursor;
+#endif
void PluginView::handleMouseEvent(MouseEvent* event)
{
@@ -602,11 +643,11 @@ void PluginView::handleMouseEvent(MouseEvent* event)
} else
return;
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
if (!dispatchNPEvent(npEvent))
event->setDefaultHandled();
-#if !PLATFORM(QT)
+#if !PLATFORM(QT) && !PLATFORM(WINCE)
// Currently, Widget::setCursor is always called after this function in EventHandler.cpp
// and since we don't want that we set ignoreNextSetCursor to true here to prevent that.
ignoreNextSetCursor = true;
@@ -618,6 +659,15 @@ void PluginView::setParent(ScrollView* parent)
{
Widget::setParent(parent);
+#if PLATFORM(WINCE)
+ if (parent) {
+ init();
+ if (parent->isVisible())
+ show();
+ else
+ hide();
+ }
+#else
if (parent)
init();
else {
@@ -631,7 +681,7 @@ void PluginView::setParent(ScrollView* parent)
if (platformPluginWidget() == focusedWindow || ::IsChild(platformPluginWidget(), focusedWindow))
::SetFocus(0);
}
-
+#endif
}
void PluginView::setParentVisible(bool visible)
@@ -654,6 +704,17 @@ void PluginView::setNPWindowRect(const IntRect& rect)
if (!m_isStarted)
return;
+#if PLATFORM(WINCE)
+ IntRect r = static_cast<FrameView*>(parent())->contentsToWindow(rect);
+ m_npWindow.x = r.x();
+ m_npWindow.y = r.y();
+
+ m_npWindow.width = r.width();
+ m_npWindow.height = r.height();
+
+ m_npWindow.clipRect.right = r.width();
+ m_npWindow.clipRect.bottom = r.height();
+#else
IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(rect.location());
m_npWindow.x = p.x();
m_npWindow.y = p.y();
@@ -661,13 +722,14 @@ void PluginView::setNPWindowRect(const IntRect& rect)
m_npWindow.width = rect.width();
m_npWindow.height = rect.height();
- m_npWindow.clipRect.left = 0;
- m_npWindow.clipRect.top = 0;
m_npWindow.clipRect.right = rect.width();
m_npWindow.clipRect.bottom = rect.height();
+#endif
+ m_npWindow.clipRect.left = 0;
+ m_npWindow.clipRect.top = 0;
if (m_plugin->pluginFuncs()->setwindow) {
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
setCallingPlugin(true);
m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
setCallingPlugin(false);
@@ -677,9 +739,17 @@ void PluginView::setNPWindowRect(const IntRect& rect)
ASSERT(platformPluginWidget());
+#if PLATFORM(WINCE)
+ if (!m_pluginWndProc) {
+ WNDPROC currentWndProc = (WNDPROC)GetWindowLong(platformPluginWidget(), GWL_WNDPROC);
+ if (currentWndProc != PluginViewWndProc)
+ m_pluginWndProc = (WNDPROC)SetWindowLong(platformPluginWidget(), GWL_WNDPROC, (LONG)PluginViewWndProc);
+ }
+#else
WNDPROC currentWndProc = (WNDPROC)GetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC);
if (currentWndProc != PluginViewWndProc)
m_pluginWndProc = (WNDPROC)SetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC, (LONG)PluginViewWndProc);
+#endif
}
}
@@ -701,13 +771,20 @@ void PluginView::stop()
// Unsubclass the window
if (m_isWindowed) {
+#if PLATFORM(WINCE)
+ WNDPROC currentWndProc = (WNDPROC)GetWindowLong(platformPluginWidget(), GWL_WNDPROC);
+
+ if (currentWndProc == PluginViewWndProc)
+ SetWindowLong(platformPluginWidget(), GWL_WNDPROC, (LONG)m_pluginWndProc);
+#else
WNDPROC currentWndProc = (WNDPROC)GetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC);
-
+
if (currentWndProc == PluginViewWndProc)
SetWindowLongPtr(platformPluginWidget(), GWLP_WNDPROC, (LONG)m_pluginWndProc);
+#endif
}
- JSC::JSLock::DropAllLocks dropAllLocks(false);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
// Clear the window
m_npWindow.window = 0;
@@ -785,11 +862,15 @@ NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32 len, const c
NPError PluginView::getValueStatic(NPNVariable variable, void* value)
{
+ LOG(Plugins, "PluginView::getValueStatic(%s)", prettyNameForNPNVariable(variable).data());
+
return NPERR_GENERIC_ERROR;
}
NPError PluginView::getValue(NPNVariable variable, void* value)
{
+ LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data());
+
switch (variable) {
#if ENABLE(NETSCAPE_PLUGIN_API)
case NPNVWindowNPObject: {
@@ -950,7 +1031,9 @@ void PluginView::init()
if (m_isWindowed) {
registerPluginView();
+#if !PLATFORM(WINCE)
setUpOffscreenPaintingHooks(hookedBeginPaint, hookedEndPaint);
+#endif
DWORD flags = WS_CHILD;
if (isSelfVisible())
@@ -959,6 +1042,7 @@ void PluginView::init()
HWND parentWindowHandle = windowHandleForPlatformWidget(m_parentFrame->view()->hostWindow()->platformWindow());
HWND window = ::CreateWindowEx(0, kWebPluginViewdowClassName, 0, flags,
0, 0, 0, 0, parentWindowHandle, 0, Page::instanceHandle(), 0);
+
#if PLATFORM(WIN_OS) && PLATFORM(QT)
m_window = window;
#else
@@ -969,6 +1053,8 @@ void PluginView::init()
// the Shockwave Director plug-in.
#if PLATFORM(WIN_OS) && PLATFORM(X86_64) && COMPILER(MSVC)
::SetWindowLongPtrA(platformPluginWidget(), GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
+#elif PLATFORM(WINCE)
+ ::SetWindowLong(platformPluginWidget(), GWL_WNDPROC, (LONG)DefWindowProc);
#else
::SetWindowLongPtrA(platformPluginWidget(), GWL_WNDPROC, (LONG)DefWindowProcA);
#endif