Diff
Modified: branches/safari-534-branch/Source/WebKit2/ChangeLog (89084 => 89085)
--- branches/safari-534-branch/Source/WebKit2/ChangeLog 2011-06-16 23:40:06 UTC (rev 89084)
+++ branches/safari-534-branch/Source/WebKit2/ChangeLog 2011-06-16 23:44:38 UTC (rev 89085)
@@ -1,5 +1,64 @@
2011-06-14 Lucas Forschler <[email protected]>
+ Merged 88978.
+
+ 2011-06-14 Jon Honeycutt <[email protected]>
+
+ REGRESSION(78201): Windowless Flash plug-ins are transparent on some sites
+ https://bugs.webkit.org/show_bug.cgi?id=62690
+ <rdar://problem/9512026>
+
+ Reviewed by Ada Chan.
+
+ The bug arises when mixing CoreGraphics and GDI. When we create a Windows
+ bitmap for a windowless plug-in to draw into, we first fill it with "clear",
+ or all 0s. If the plug-in uses GDI to draw, the GDI calls will ignore the
+ alpha channel, and if we then use CG to blend this bitmap onto the
+ GraphicsContext for the rest of the page, CG will treat the 0-filled
+ alpha channel as being transparent.
+
+ To fix this, on Windows, use a GDI-backed GraphicsContext to paint the
+ page in the WebProcess, and use GDI to blit from the UpdateInfo to the
+ backing store in the UI process.
+
+ * Platform/SharedMemory.h:
+ (WebKit::SharedMemory::handle):
+ Return the handle for the memory.
+
+ * Shared/ShareableBitmap.h:
+ Declared windowsContext() to return a HDC with the bitmap selected into it.
+ Added members to store the HDC and the HBITMAP.
+
+ * Shared/win/ShareableBitmapWin.cpp: Added.
+ (WebKit::ShareableBitmap::windowsContext):
+ Get the screen DC, and create a compatible DC from it. Create a DIB
+ section backed by the shared memory, select it into the context, and
+ return it.
+
+ * UIProcess/win/BackingStoreWin.cpp:
+ (WebKit::BackingStore::incorporateUpdate):
+ Use GDI to blit from the update info's bitmap into the backing store bitmap.
+
+ * WebProcess/WebPage/DrawingAreaImpl.cpp:
+ (WebKit::DrawingAreaImpl::createGraphicsContext):
+ Return a GraphicsContext from the ShareableBitmap.
+ (WebKit::DrawingAreaImpl::display):
+ Call createGraphicsContext(), and pass the ShareableBitmap.
+
+ * WebProcess/WebPage/DrawingAreaImpl.h:
+ Declare createGraphicsContext(), which on Windows will create a GDI-backed
+ GraphicsContext.
+
+ * WebProcess/WebPage/win/DrawingAreaImplWin.cpp: Added.
+ (WebKit::DrawingAreaImpl::createGraphicsContext):
+ Get a Windows context for the bitmap, and create and return a new
+ GraphicsContext using the DC.
+
+ * win/WebKit2.vcproj:
+ Added new files.
+
+2011-06-14 Lucas Forschler <[email protected]>
+
Merged 88956.
2011-06-14 Lucas Forschler <[email protected]>
Modified: branches/safari-534-branch/Source/WebKit2/Platform/SharedMemory.h (89084 => 89085)
--- branches/safari-534-branch/Source/WebKit2/Platform/SharedMemory.h 2011-06-16 23:40:06 UTC (rev 89084)
+++ branches/safari-534-branch/Source/WebKit2/Platform/SharedMemory.h 2011-06-16 23:44:38 UTC (rev 89085)
@@ -94,6 +94,9 @@
size_t size() const { return m_size; }
void* data() const { return m_data; }
+#if PLATFORM(WIN)
+ HANDLE handle() const { return m_handle; }
+#endif
// Creates a copy-on-write copy of the first |size| bytes.
PassRefPtr<SharedMemory> createCopyOnWriteCopy(size_t) const;
Modified: branches/safari-534-branch/Source/WebKit2/Shared/ShareableBitmap.h (89084 => 89085)
--- branches/safari-534-branch/Source/WebKit2/Shared/ShareableBitmap.h 2011-06-16 23:40:06 UTC (rev 89084)
+++ branches/safari-534-branch/Source/WebKit2/Shared/ShareableBitmap.h 2011-06-16 23:44:38 UTC (rev 89085)
@@ -102,6 +102,9 @@
bool isBackedBySharedMemory() const { return m_sharedMemory; }
+#if PLATFORM(WIN)
+ HDC windowsContext() const;
+#endif
#if USE(CG)
// This creates a copied CGImageRef (most likely a copy-on-write) of the shareable bitmap.
RetainPtr<CGImageRef> makeCGImageCopy();
@@ -142,6 +145,10 @@
// If the shareable bitmap is backed by fastMalloced memory, this points to the data.
void* m_data;
+#if PLATFORM(WIN)
+ mutable OwnPtr<HDC> m_windowsContext;
+ mutable OwnPtr<HBITMAP> m_windowsBitmap;
+#endif
};
} // namespace WebKit
Copied: branches/safari-534-branch/Source/WebKit2/Shared/win/ShareableBitmapWin.cpp (from rev 88978, trunk/Source/WebKit2/Shared/win/ShareableBitmapWin.cpp) (0 => 89085)
--- branches/safari-534-branch/Source/WebKit2/Shared/win/ShareableBitmapWin.cpp (rev 0)
+++ branches/safari-534-branch/Source/WebKit2/Shared/win/ShareableBitmapWin.cpp 2011-06-16 23:44:38 UTC (rev 89085)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ShareableBitmap.h"
+
+#include <WebCore/BitmapInfo.h>
+#include <WebCore/GraphicsContext.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+HDC ShareableBitmap::windowsContext() const
+{
+ ASSERT(isBackedBySharedMemory());
+ if (m_windowsContext)
+ return m_windowsContext.get();
+
+ OwnPtr<HDC> screenDC = adoptPtr(::GetDC(0));
+ BitmapInfo bmInfo = BitmapInfo::createBottomUp(m_size);
+
+ m_windowsContext = adoptPtr(::CreateCompatibleDC(screenDC.get()));
+ m_windowsBitmap = adoptPtr(CreateDIBSection(m_windowsContext.get(), &bmInfo, DIB_RGB_COLORS, 0, m_sharedMemory->handle(), 0));
+ ::SelectObject(m_windowsContext.get(), m_windowsBitmap.get());
+
+ return m_windowsContext.get();
+}
+
+} // namespace WebKit
Modified: branches/safari-534-branch/Source/WebKit2/UIProcess/win/BackingStoreWin.cpp (89084 => 89085)
--- branches/safari-534-branch/Source/WebKit2/UIProcess/win/BackingStoreWin.cpp 2011-06-16 23:40:06 UTC (rev 89084)
+++ branches/safari-534-branch/Source/WebKit2/UIProcess/win/BackingStoreWin.cpp 2011-06-16 23:44:38 UTC (rev 89085)
@@ -84,8 +84,8 @@
IntPoint updateRectLocation = updateInfo.updateRectBounds.location();
- BitmapDC dc(m_bitmap.get(), 0);
- GraphicsContext graphicsContext(dc);
+ BitmapDC backingStoreDC(m_bitmap.get(), 0);
+ HDC bitmapDC = bitmap->windowsContext();
// Paint all update rects.
for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) {
@@ -93,7 +93,8 @@
IntRect srcRect = updateRect;
srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
- bitmap->paint(graphicsContext, updateRect.location(), srcRect);
+ ::BitBlt(backingStoreDC, updateRect.location().x(), updateRect.location().y(), updateRect.size().width(), updateRect.size().height(),
+ bitmapDC, srcRect.x(), srcRect.y(), SRCCOPY);
}
}
Modified: branches/safari-534-branch/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp (89084 => 89085)
--- branches/safari-534-branch/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp 2011-06-16 23:40:06 UTC (rev 89084)
+++ branches/safari-534-branch/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp 2011-06-16 23:44:38 UTC (rev 89085)
@@ -620,6 +620,13 @@
return wastedSpace <= wastedSpaceThreshold;
}
+#if !PLATFORM(WIN)
+PassOwnPtr<GraphicsContext> DrawingAreaImpl::createGraphicsContext(ShareableBitmap* bitmap)
+{
+ return bitmap->createGraphicsContext();
+}
+#endif
+
void DrawingAreaImpl::display(UpdateInfo& updateInfo)
{
ASSERT(!m_isPaintingSuspended);
@@ -669,7 +676,7 @@
m_scrollRect = IntRect();
m_scrollOffset = IntSize();
- OwnPtr<GraphicsContext> graphicsContext = bitmap->createGraphicsContext();
+ OwnPtr<GraphicsContext> graphicsContext = createGraphicsContext(bitmap.get());
updateInfo.updateRectBounds = bounds;
Modified: branches/safari-534-branch/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h (89084 => 89085)
--- branches/safari-534-branch/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h 2011-06-16 23:40:06 UTC (rev 89084)
+++ branches/safari-534-branch/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h 2011-06-16 23:44:38 UTC (rev 89085)
@@ -31,8 +31,13 @@
#include "Region.h"
#include "RunLoop.h"
+namespace WebCore {
+ class GraphicsContext;
+}
+
namespace WebKit {
+class ShareableBitmap;
class UpdateInfo;
class DrawingAreaImpl : public DrawingArea {
@@ -85,6 +90,7 @@
void displayTimerFired();
void display();
void display(UpdateInfo&);
+ PassOwnPtr<WebCore::GraphicsContext> createGraphicsContext(ShareableBitmap*);
uint64_t m_backingStoreStateID;
Modified: branches/safari-534-branch/Source/WebKit2/WebProcess/WebPage/win/DrawingAreaImplWin.cpp (89084 => 89085)
--- branches/safari-534-branch/Source/WebKit2/WebProcess/WebPage/win/DrawingAreaImplWin.cpp 2011-06-16 23:40:06 UTC (rev 89084)
+++ branches/safari-534-branch/Source/WebKit2/WebProcess/WebPage/win/DrawingAreaImplWin.cpp 2011-06-16 23:44:38 UTC (rev 89085)
@@ -26,10 +26,15 @@
#include "config.h"
#include "DrawingAreaImpl.h"
+#include "ShareableBitmap.h"
+#include "UpdateInfo.h"
#include "WebPage.h"
#include "WebPageProxyMessages.h"
#include "WindowGeometry.h"
+#include <WebCore/GraphicsContext.h>
+using namespace WebCore;
+
namespace WebKit {
void DrawingAreaImpl::scheduleChildWindowGeometryUpdate(const WindowGeometry& geometry)
@@ -46,4 +51,11 @@
m_webPage->send(Messages::WebPageProxy::ScheduleChildWindowGeometryUpdate(geometry));
}
+PassOwnPtr<GraphicsContext> DrawingAreaImpl::createGraphicsContext(ShareableBitmap* bitmap)
+{
+ HDC bitmapDC = bitmap->windowsContext();
+ return adoptPtr(new GraphicsContext(bitmapDC, true));
+}
+
} // namespace WebKit
+
Modified: branches/safari-534-branch/Source/WebKit2/win/WebKit2.vcproj (89084 => 89085)
--- branches/safari-534-branch/Source/WebKit2/win/WebKit2.vcproj 2011-06-16 23:40:06 UTC (rev 89084)
+++ branches/safari-534-branch/Source/WebKit2/win/WebKit2.vcproj 2011-06-16 23:44:38 UTC (rev 89085)
@@ -1230,6 +1230,9 @@
>
</File>
<File
+ RelativePath="..\Shared\win\ShareableBitmapWin.cpp"
+ >
+ </File><File
RelativePath="..\Shared\win\WebCoreArgumentCodersWin.cpp"
>
</File>