[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

jhoneycutt at apple.com jhoneycutt at apple.com
Thu Oct 29 20:49:53 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit fd895bd035a083dc02e4f22b46b2e81ecc01b4e0
Author: jhoneycutt at apple.com <jhoneycutt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 22 07:15:28 2009 +0000

    <rdar://problem/7270320> Screenshots of off-screen plug-ins are blank
    <rdar://problem/7270314> After halting a transparent PluginView on
    Windows, the transparency is applied twice
    
    JavaScriptCore:
    
    Reviewed by Dan Bernstein.
    
    * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
    Export WTF::deleteOwnedPtr(HDC).
    
    * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def:
    Ditto.
    
    WebCore:
    
    Replace use of Frame::nodeImage() with a function that takes a snapshot
    of a PluginView.
    
    Reviewed by Dan Bernstein.
    
    * plugins/PluginView.h:
    Made paintWindowedPluginIntoContext() non-const, as it now calls
    paintIntoTransformedContext(). Declare paintIntoTransformedContext()
    and snapshot() for Windows platforms.
    
    * plugins/win/PluginViewWin.cpp:
    (WebCore::PluginView::paintIntoTransformedContext):
    Paints into the passed HDC without applying any coordinate translations.
    Code moved from paintWindowedPluginIntoContext() and paint(). Removed
    the memset() of windowpos in lieu of assignment.
    (WebCore::PluginView::paintWindowedPluginIntoContext):
    Code moved to paintIntoTransformedContext().
    (WebCore::PluginView::paint):
    Ditto.
    (WebCore::PluginView::snapshot):
    Create a context, and if the plug-in is windowless, translate it so the
    plug-in will draw at the correct location. Create a bitmap, and select
    it into the context. Paint the plug-in, and create a BitmapImage from
    the bitmap.
    (WebCore::PluginView::halt):
    Use snapshot().
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49933 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 9252307..52bcdef 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,17 @@
+2009-10-21  Jon Honeycutt  <jhoneycutt at apple.com>
+
+        <rdar://problem/7270320> Screenshots of off-screen plug-ins are blank
+        <rdar://problem/7270314> After halting a transparent PluginView on
+        Windows, the transparency is applied twice
+
+        Reviewed by Dan Bernstein.
+
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+        Export WTF::deleteOwnedPtr(HDC).
+
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def:
+        Ditto.
+
 2009-10-20  Geoffrey Garen  <ggaren at apple.com>
 
         Windows build fix: updated variable name.
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
index 320af81..01f84f1 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
+++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
@@ -96,6 +96,7 @@ EXPORTS
     ?defineSetter at JSGlobalObject@JSC@@UAEXPAVExecState at 2@ABVIdentifier at 2@PAVJSObject at 2@I at Z
     ?defineSetter at JSObject@JSC@@UAEXPAVExecState at 2@ABVIdentifier at 2@PAV12 at I@Z
     ?deleteOwnedPtr at WTF@@YAXPAUHBITMAP__@@@Z
+    ?deleteOwnedPtr at WTF@@YAXPAUHDC__@@@Z
     ?deleteOwnedPtr at WTF@@YAXPAUHRGN__@@@Z
     ?deleteProperty at JSCell@JSC@@UAE_NPAVExecState at 2@ABVIdentifier at 2@@Z
     ?deleteProperty at JSCell@JSC@@UAE_NPAVExecState at 2@I at Z
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def
index 6779eaf..8301fc9 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def
+++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def
@@ -96,6 +96,7 @@ EXPORTS
     ?defineSetter at JSGlobalObject@JSC@@UAEXPAVExecState at 2@ABVIdentifier at 2@PAVJSObject at 2@I at Z
     ?defineSetter at JSObject@JSC@@UAEXPAVExecState at 2@ABVIdentifier at 2@PAV12 at I@Z
     ?deleteOwnedPtr at WTF@@YAXPAUHBITMAP__@@@Z
+    ?deleteOwnedPtr at WTF@@YAXPAUHDC__@@@Z
     ?deleteOwnedPtr at WTF@@YAXPAUHRGN__@@@Z
     ?deleteProperty at JSCell@JSC@@UAE_NPAVExecState at 2@ABVIdentifier at 2@@Z
     ?deleteProperty at JSCell@JSC@@UAE_NPAVExecState at 2@I at Z
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1a886a2..8df8cf7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,36 @@
+2009-10-21  Jon Honeycutt  <jhoneycutt at apple.com>
+
+        <rdar://problem/7270320> Screenshots of off-screen plug-ins are blank
+        <rdar://problem/7270314> After halting a transparent PluginView on
+        Windows, the transparency is applied twice
+
+        Replace use of Frame::nodeImage() with a function that takes a snapshot
+        of a PluginView.
+
+        Reviewed by Dan Bernstein.
+
+        * plugins/PluginView.h:
+        Made paintWindowedPluginIntoContext() non-const, as it now calls
+        paintIntoTransformedContext(). Declare paintIntoTransformedContext()
+        and snapshot() for Windows platforms.
+
+        * plugins/win/PluginViewWin.cpp:
+        (WebCore::PluginView::paintIntoTransformedContext):
+        Paints into the passed HDC without applying any coordinate translations.
+        Code moved from paintWindowedPluginIntoContext() and paint(). Removed
+        the memset() of windowpos in lieu of assignment.
+        (WebCore::PluginView::paintWindowedPluginIntoContext):
+        Code moved to paintIntoTransformedContext().
+        (WebCore::PluginView::paint):
+        Ditto.
+        (WebCore::PluginView::snapshot):
+        Create a context, and if the plug-in is windowless, translate it so the
+        plug-in will draw at the correct location. Create a bitmap, and select
+        it into the context. Paint the plug-in, and create a BitmapImage from
+        the bitmap.
+        (WebCore::PluginView::halt):
+        Use snapshot().
+
 2009-10-22  Fumitoshi Ukai  <ukai at chromium.org>
 
         Reviewed by Alexey Proskuryakov.
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index 1477561..0a57fa6 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -61,6 +61,7 @@ namespace JSC {
 namespace WebCore {
     class Element;
     class Frame;
+    class Image;
     class KeyboardEvent;
     class MouseEvent;
     class KURL;
@@ -226,7 +227,7 @@ namespace WebCore {
         void invalidateWindowlessPluginRect(const IntRect&);
 
 #if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API)
-        void paintWindowedPluginIntoContext(GraphicsContext*, const IntRect&) const;
+        void paintWindowedPluginIntoContext(GraphicsContext*, const IntRect&);
         static HDC WINAPI hookedBeginPaint(HWND, PAINTSTRUCT*);
         static BOOL WINAPI hookedEndPaint(HWND, const PAINTSTRUCT*);
 #endif
@@ -263,6 +264,11 @@ namespace WebCore {
         void handleFocusOutEvent();
 #endif
 
+#if PLATFORM(WIN_OS)
+        void paintIntoTransformedContext(HDC);
+        PassRefPtr<Image> snapshot();
+#endif
+
         int m_mode;
         int m_paramCount;
         char** m_paramNames;
diff --git a/WebCore/plugins/win/PluginViewWin.cpp b/WebCore/plugins/win/PluginViewWin.cpp
index e1bf8d6..5ccce0e 100644
--- a/WebCore/plugins/win/PluginViewWin.cpp
+++ b/WebCore/plugins/win/PluginViewWin.cpp
@@ -30,6 +30,7 @@
 #include "PluginView.h"
 
 #include "BitmapImage.h"
+#include "BitmapInfo.h"
 #include "Document.h"
 #include "DocumentLoader.h"
 #include "Element.h"
@@ -495,7 +496,54 @@ bool PluginView::dispatchNPEvent(NPEvent& npEvent)
     return result;
 }
 
-void PluginView::paintWindowedPluginIntoContext(GraphicsContext* context, const IntRect& rect) const
+void PluginView::paintIntoTransformedContext(HDC hdc)
+{
+    if (m_isWindowed) {
+        SendMessage(platformPluginWidget(), WM_PRINTCLIENT, reinterpret_cast<WPARAM>(hdc), PRF_CLIENT | PRF_CHILDREN | PRF_OWNED);
+        return;
+    }
+
+    m_npWindow.type = NPWindowTypeDrawable;
+    m_npWindow.window = hdc;
+
+    WINDOWPOS windowpos = { 0 };
+
+#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 npEvent;
+    npEvent.event = WM_WINDOWPOSCHANGED;
+    npEvent.lParam = reinterpret_cast<uint32>(&windowpos);
+    npEvent.wParam = 0;
+
+    dispatchNPEvent(npEvent);
+
+    setNPWindowRect(frameRect());
+
+    npEvent.event = WM_PAINT;
+    npEvent.wParam = reinterpret_cast<uint32>(hdc);
+
+    // This is supposed to be a pointer to the dirty rect, but it seems that the Flash plugin
+    // ignores it so we just pass null.
+    npEvent.lParam = 0;
+
+    dispatchNPEvent(npEvent);
+}
+
+void PluginView::paintWindowedPluginIntoContext(GraphicsContext* context, const IntRect& rect)
 {
 #if !PLATFORM(WINCE)
     ASSERT(m_isWindowed);
@@ -517,7 +565,7 @@ void PluginView::paintWindowedPluginIntoContext(GraphicsContext* context, const
 
     SetWorldTransform(hdc, &transform);
 
-    SendMessage(platformPluginWidget(), WM_PRINTCLIENT, reinterpret_cast<WPARAM>(hdc), PRF_CLIENT | PRF_CHILDREN | PRF_OWNED);
+    paintIntoTransformedContext(hdc);
 
     SetWorldTransform(hdc, &originalTransform);
 
@@ -547,7 +595,6 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
     ASSERT(parent()->isFrameView());
     IntRect rectInWindow = static_cast<FrameView*>(parent())->contentsToWindow(frameRect());
     HDC hdc = context->getWindowsContext(rectInWindow, m_isTransparent);
-    NPEvent npEvent;
 
     // On Safari/Windows without transparency layers the GraphicsContext returns the HDC
     // of the window and the plugin expects that the passed in DC has window coordinates.
@@ -563,44 +610,7 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
     }
 #endif
 
-    m_npWindow.type = NPWindowTypeDrawable;
-    m_npWindow.window = hdc;
-
-    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);
-    npEvent.wParam = 0;
-
-    dispatchNPEvent(npEvent);
-
-    setNPWindowRect(frameRect());
-
-    npEvent.event = WM_PAINT;
-    npEvent.wParam = reinterpret_cast<uint32>(hdc);
-
-    // This is supposed to be a pointer to the dirty rect, but it seems that the Flash plugin
-    // ignores it so we just pass null.
-    npEvent.lParam = 0;
-
-    dispatchNPEvent(npEvent);
+    paintIntoTransformedContext(hdc);
 
     context->releaseWindowsContext(hdc, frameRect(), m_isTransparent);
 }
@@ -1018,6 +1028,39 @@ void PluginView::platformDestroy()
     setPlatformPluginWidget(0);
 }
 
+PassRefPtr<Image> PluginView::snapshot()
+{
+    OwnPtr<HDC> hdc(CreateCompatibleDC(0));
+
+    if (!m_isWindowed) {
+        // Enable world transforms.
+        SetGraphicsMode(hdc.get(), GM_ADVANCED);
+
+        XFORM transform;
+        GetWorldTransform(hdc.get(), &transform);
+
+        // Windowless plug-ins assume that they're drawing onto the view's DC.
+        // Translate the context so that the plug-in draws at (0, 0).
+        ASSERT(parent()->isFrameView());
+        IntPoint position = static_cast<FrameView*>(parent())->contentsToWindow(frameRect()).location();
+        transform.eDx = -position.x();
+        transform.eDy = -position.y();
+        SetWorldTransform(hdc.get(), &transform);
+    }
+
+    void* bits;
+    BitmapInfo bmp = BitmapInfo::createBottomUp(frameRect().size());
+    OwnPtr<HBITMAP> hbmp(CreateDIBSection(0, &bmp, DIB_RGB_COLORS, &bits, 0, 0));
+
+    HBITMAP hbmpOld = static_cast<HBITMAP>(SelectObject(hdc.get(), hbmp.get()));
+
+    paintIntoTransformedContext(hdc.get());
+
+    SelectObject(hdc.get(), hbmpOld);
+
+    return BitmapImage::create(hbmp.get());
+}
+
 void PluginView::halt()
 {
     ASSERT(!m_isHalted);
@@ -1025,8 +1068,7 @@ void PluginView::halt()
 
 #if !PLATFORM(QT)
     // Show a screenshot of the plug-in.
-    OwnPtr<HBITMAP> nodeImage(m_parentFrame->nodeImage(m_element));
-    toRenderWidget(m_element->renderer())->showSubstituteImage(BitmapImage::create(nodeImage.get()));
+    toRenderWidget(m_element->renderer())->showSubstituteImage(snapshot());
 #endif
 
     m_isHalted = true;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list