2008-01-07 Jon Honeycutt <jhoneycutt@apple.com>
authorjhoneycutt@apple.com <jhoneycutt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jan 2008 01:37:21 +0000 (01:37 +0000)
committerjhoneycutt@apple.com <jhoneycutt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jan 2008 01:37:21 +0000 (01:37 +0000)
        Reviewed by Hyatt.

        <rdar://problem/5673489> Safari does not render windowless plugins in an
        iframe when opacity < 1.0

        Plugins in transparency layers handle their own world transforms, so
        only apply the horizontal/vertical transform if we are not in a
        transparency layer.

        * platform/graphics/GraphicsContext.h: Add a Windows-platform-only
        inTransparencyLayer() function
        * platform/win/GraphicsContextWin.cpp:
        (WebCore::GraphicsContext::getWindowsContext): Use inTransparencyLayer()
        (WebCore::GraphicsContext::inTransparencyLayer):
        (WebCore::GraphicsContext::releaseWindowsContext): Use
        inTransparencyLayer()
        * plugins/win/PluginViewWin.cpp:
        (WebCore::PluginViewWin::paint): When retrieving the HDC, use the rect
        relative to the window. Pass m_isTransparent to
        get/releaseWindowsContext(). Only set the world transform if we are not
        in a transparency layer.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29270 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/GraphicsContext.h
WebCore/platform/win/GraphicsContextWin.cpp
WebCore/plugins/win/PluginViewWin.cpp

index f6bc68c18f8c2a23f5c39a2f5622afae0606750a..36a34020c25819f8fc07f2307d224016227e29d1 100644 (file)
@@ -1,3 +1,27 @@
+2008-01-07  Jon Honeycutt  <jhoneycutt@apple.com>
+
+        Reviewed by Hyatt.
+
+        <rdar://problem/5673489> Safari does not render windowless plugins in an
+        iframe when opacity < 1.0
+
+        Plugins in transparency layers handle their own world transforms, so
+        only apply the horizontal/vertical transform if we are not in a
+        transparency layer.
+
+        * platform/graphics/GraphicsContext.h: Add a Windows-platform-only
+        inTransparencyLayer() function
+        * platform/win/GraphicsContextWin.cpp:
+        (WebCore::GraphicsContext::getWindowsContext): Use inTransparencyLayer()
+        (WebCore::GraphicsContext::inTransparencyLayer):
+        (WebCore::GraphicsContext::releaseWindowsContext): Use
+        inTransparencyLayer()
+        * plugins/win/PluginViewWin.cpp:
+        (WebCore::PluginViewWin::paint): When retrieving the HDC, use the rect
+        relative to the window. Pass m_isTransparent to
+        get/releaseWindowsContext(). Only set the world transform if we are not
+        in a transparency layer.
+
 2008-01-07  Adele Peterson  <adele@apple.com>
 
         Build fix.  Need to wrap these classes in #if ENABLE(VIDEO)
index 06d63f6d0cfe3475900298cfa59fa9c7b020f3df..25a6efc087ab2598ca5c8557b1782ebddd9e5858 100644 (file)
@@ -221,6 +221,7 @@ namespace WebCore {
 
 #if PLATFORM(WIN)
         GraphicsContext(HDC); // FIXME: To be removed.
+        bool inTransparencyLayer() const;
         HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = true); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
         void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true);    // The passed in HDC should be the one handed back by getWindowsContext.
 #endif
index 57eb7ea969980a14adba0e5ae26b9db70cf4fb01..478fb7e281e02a0419c0cc2a5611ec2470e1d5cb 100644 (file)
@@ -79,7 +79,7 @@ GraphicsContext::GraphicsContext(HDC hdc)
 
 HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend)
 {
-    if (m_data->m_transparencyCount) {
+    if (inTransparencyLayer()) {
         if (dstRect.isEmpty())
             return 0;
 
@@ -134,9 +134,11 @@ HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlpha
     return m_data->m_hdc;
 }
 
+bool GraphicsContext::inTransparencyLayer() const { return m_data->m_transparencyCount; }
+
 void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend)
 {
-    if (hdc && m_data->m_transparencyCount) {
+    if (hdc && inTransparencyLayer()) {
         if (dstRect.isEmpty())
             return;
 
index 81272289fe77954e2e1b96780a95ede85569e541..9eecc130338a66aa0326a34f233ddc65a272a38f 100644 (file)
@@ -472,24 +472,23 @@ void PluginViewWin::paint(GraphicsContext* context, const IntRect& rect)
     if (m_isWindowed || context->paintingDisabled())
         return;
 
-    HDC hdc = context->getWindowsContext(frameGeometry());
-
-    // FIXME: This is completely wrong and will break in the presence of opacity, SVG transforms
-    // and CSS transforms.
-    // The plugin expects that the passed in DC has window coordinates.
-    // (This probably breaks funky SVG transform stuff)
-    XFORM transform;
-    GetWorldTransform(hdc, &transform);
-    transform.eDx = 0;
-    transform.eDy = 0;
-    SetWorldTransform(hdc, &transform);
-
+    ASSERT(parent()->isFrameView());
+    IntRect rectInWindow = static_cast<FrameView*>(parent())->contentsToWindow(frameGeometry());
+    HDC hdc = context->getWindowsContext(rectInWindow, m_isTransparent);
     NPEvent npEvent;
 
+    if (!context->inTransparencyLayer()) {
+        // The plugin expects that the passed in DC has window coordinates.
+        XFORM transform;
+        GetWorldTransform(hdc, &transform);
+        transform.eDx = 0;
+        transform.eDy = 0;
+        SetWorldTransform(hdc, &transform);
+    }
+
     m_npWindow.type = NPWindowTypeDrawable;
     m_npWindow.window = hdc;
 
-    ASSERT(parent()->isFrameView());
     IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(frameGeometry().location());
     
     WINDOWPOS windowpos;
@@ -517,7 +516,7 @@ void PluginViewWin::paint(GraphicsContext* context, const IntRect& rect)
 
     dispatchNPEvent(npEvent);
 
-    context->releaseWindowsContext(hdc, frameGeometry());
+    context->releaseWindowsContext(hdc, frameGeometry(), m_isTransparent);
 }
 
 void PluginViewWin::handleKeyboardEvent(KeyboardEvent* event)