[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

aroben at apple.com aroben at apple.com
Wed Dec 22 15:31:02 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 4c058a46ea34446c4609dc4d5d4098a01137174f
Author: aroben at apple.com <aroben at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Nov 5 14:46:05 2010 +0000

    Use a window region to clip windowed plugins
    
    Fixes <http://webkit.org/b/49024> <rdar://problem/8487847> Windowed
    plugins aren't clipped in WebKit2 on Windows
    
    Reviewed by Jon Honeycutt.
    
    WebKit2:
    
    * WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp:
    (WebKit::registerPluginView): Removed the CS_PARENTDC style. This style
    makes Windows ignore the window region and always clip to the parent
    window. Also pass WebKit.dll's HINSTANCE as part of the WNDCLASSW
    struct so that the window class will be specific to WebKit.dll rather
    than to WebKit2WebProcess.exe. This is useful for testing, but also
    more pedantically correct.
    (WebKit::setWindowRegion): Helper function to set a window region and
    deal with ownership of the HRGN correctly.
    (WebKit::NetscapePlugin::platformGeometryDidChange): Make an HRGN that
    corresponds to m_clipRect and set it on the plugin's window.
    
    WebKitTools:
    
    Add a plugin test to show that windowed plugins are clipped correctly
    
    * DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp: Added.
    (WindowRegionIsSetToClipRect::WindowRegionIsSetToClipRect): Initialize members.
    (WindowRegionIsSetToClipRect::NPP_SetWindow): Check that our window
    region matches the clip rect we know we should have based on
    window-region-is-set-to-clip-rect.html, and check that our window class
    doesn't have the CS_PARENTDC style.
    
    * DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
    Added WindowRegionIsSetToClipRect.
    
    LayoutTests:
    
    Add a test to show that windowed plugins are clipped correctly
    
    * platform/win/plugins/window-region-is-set-to-clip-rect-expected.txt: Added.
    * platform/win/plugins/window-region-is-set-to-clip-rect.html: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71416 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index b2b3a54..45e3d13 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-11-04  Adam Roben  <aroben at apple.com>
+
+        Add a test to show that windowed plugins are clipped correctly
+
+        Fixes <http://webkit.org/b/49024> <rdar://problem/8487847> Windowed
+        plugins aren't clipped in WebKit2 on Windows
+
+        Reviewed by Jon Honeycutt.
+
+        * platform/win/plugins/window-region-is-set-to-clip-rect-expected.txt: Added.
+        * platform/win/plugins/window-region-is-set-to-clip-rect.html: Added.
+
 2010-11-05  Csaba Osztrogonác  <ossy at webkit.org>
 
         Unreviewed.
diff --git a/LayoutTests/platform/win/plugins/window-region-is-set-to-clip-rect-expected.txt b/LayoutTests/platform/win/plugins/window-region-is-set-to-clip-rect-expected.txt
new file mode 100644
index 0000000..136566b
--- /dev/null
+++ b/LayoutTests/platform/win/plugins/window-region-is-set-to-clip-rect-expected.txt
@@ -0,0 +1,4 @@
+CONSOLE MESSAGE: line 0: PLUGIN: PASS: Plugin's window's window region has been set as expected
+CONSOLE MESSAGE: line 0: PLUGIN: PASS: Plugin's window's class does not have the CS_PARENTDC style
+
+This tests that a plugin's window's window region is set to its clip rect.
diff --git a/LayoutTests/platform/win/plugins/window-region-is-set-to-clip-rect.html b/LayoutTests/platform/win/plugins/window-region-is-set-to-clip-rect.html
new file mode 100644
index 0000000..ead7d9e
--- /dev/null
+++ b/LayoutTests/platform/win/plugins/window-region-is-set-to-clip-rect.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script>
+        if (window.layoutTestController)
+            layoutTestController.dumpAsText();
+    </script>
+    <style>
+        #container {
+            width: 50px;
+            height: 50px;
+            overflow: hidden;
+        }
+
+        embed {
+            position: relative;
+            top: -50px;
+            left: -50px;
+        }
+    </style>
+</head>
+<body>
+    <div id=container>
+        <embed type="application/x-webkit-test-netscape" test="window-region-is-set-to-clip-rect"></embed>
+    </div>
+    <p>This tests that a plugin's window's window region is set to its clip rect.</p>
+</body>
+</html>
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 2ded1fb..5a5d75a 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,24 @@
+2010-11-04  Adam Roben  <aroben at apple.com>
+
+        Use a window region to clip windowed plugins
+
+        Fixes <http://webkit.org/b/49024> <rdar://problem/8487847> Windowed
+        plugins aren't clipped in WebKit2 on Windows
+
+        Reviewed by Jon Honeycutt.
+
+        * WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp:
+        (WebKit::registerPluginView): Removed the CS_PARENTDC style. This style
+        makes Windows ignore the window region and always clip to the parent
+        window. Also pass WebKit.dll's HINSTANCE as part of the WNDCLASSW
+        struct so that the window class will be specific to WebKit.dll rather
+        than to WebKit2WebProcess.exe. This is useful for testing, but also
+        more pedantically correct.
+        (WebKit::setWindowRegion): Helper function to set a window region and
+        deal with ownership of the HRGN correctly.
+        (WebKit::NetscapePlugin::platformGeometryDidChange): Make an HRGN that
+        corresponds to m_clipRect and set it on the plugin's window.
+
 2010-11-05  Balazs Kelemen  <kbalazs at webkit.org>
 
         Reviewed by Andreas Kling.
diff --git a/WebKit2/WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp b/WebKit2/WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp
index 35ee6e0..930f87b 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp
@@ -33,6 +33,8 @@
 
 using namespace WebCore;
 
+extern "C" HINSTANCE gInstance;
+
 namespace WebKit {
 
 static LPCWSTR windowClassName = L"org.webkit.NetscapePluginWindow";
@@ -45,8 +47,9 @@ static void registerPluginView()
     didRegister = true;
 
     WNDCLASSW windowClass = {0};
-    windowClass.style = CS_DBLCLKS | CS_PARENTDC;
+    windowClass.style = CS_DBLCLKS;
     windowClass.lpfnWndProc = ::DefWindowProcW;
+    windowClass.hInstance = gInstance;
     windowClass.hCursor = ::LoadCursorW(0, IDC_ARROW);
     windowClass.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
     windowClass.lpszClassName = windowClassName;
@@ -103,15 +106,31 @@ bool NetscapePlugin::platformInvalidate(const IntRect& invalidRect)
     return true;
 }
 
+enum RedrawOrNot { DoNotRedraw, Redraw };
+static void setWindowRegion(HWND window, PassOwnPtr<HRGN> popRegion, RedrawOrNot redrawOrNot)
+{
+    OwnPtr<HRGN> region = popRegion;
+
+    if (!::SetWindowRgn(window, region.get(), redrawOrNot == Redraw))
+        return;
+
+    // Windows owns the region now.
+    region.leakPtr();
+}
+
 void NetscapePlugin::platformGeometryDidChange()
 {
     if (!m_isWindowed)
         return;
 
+    IntRect clipRectInPluginWindowCoordinates = m_clipRect;
+    clipRectInPluginWindowCoordinates.move(-m_frameRect.x(), -m_frameRect.y());
+
+    OwnPtr<HRGN> clipRegion = adoptPtr(::CreateRectRgn(clipRectInPluginWindowCoordinates.x(), clipRectInPluginWindowCoordinates.y(), clipRectInPluginWindowCoordinates.right(), clipRectInPluginWindowCoordinates.bottom()));
+    setWindowRegion(m_window, clipRegion.release(), Redraw);
+
     // FIXME: We should only update the size here and let the UI process update our position so
     // that we can keep our position in sync when scrolling, etc.
-    // FIXME: We should also set a window region based on m_clipRect. Perhaps that should happen in
-    // the UI process, too.
     ::MoveWindow(m_window, m_frameRect.x(), m_frameRect.y(), m_frameRect.width(), m_frameRect.height(), TRUE);
 }
 
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 44fb229..6394ab0 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,22 @@
+2010-11-04  Adam Roben  <aroben at apple.com>
+
+        Add a plugin test to show that windowed plugins are clipped correctly
+
+        Fixes <http://webkit.org/b/49024> <rdar://problem/8487847> Windowed
+        plugins aren't clipped in WebKit2 on Windows
+
+        Reviewed by Jon Honeycutt.
+
+        * DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp: Added.
+        (WindowRegionIsSetToClipRect::WindowRegionIsSetToClipRect): Initialize members.
+        (WindowRegionIsSetToClipRect::NPP_SetWindow): Check that our window
+        region matches the clip rect we know we should have based on
+        window-region-is-set-to-clip-rect.html, and check that our window class
+        doesn't have the CS_PARENTDC style.
+
+        * DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
+        Added WindowRegionIsSetToClipRect.
+
 2010-11-05  Alejandro G. Castro  <alex at igalia.com>
 
         Reviewed by Martin Robinson.
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp
new file mode 100644
index 0000000..975a598
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2010 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 "PluginTest.h"
+
+#include "PluginObject.h"
+
+using namespace std;
+
+// The plugin's window's window region should be set to the plugin's clip rect.
+
+class WindowRegionIsSetToClipRect : public PluginTest {
+public:
+    WindowRegionIsSetToClipRect(NPP, const string& identifier);
+
+private:
+    virtual NPError NPP_SetWindow(NPP, NPWindow*);
+
+    bool m_didReceiveInitialSetWindowCall;
+};
+
+static PluginTest::Register<WindowRegionIsSetToClipRect> registrar("window-region-is-set-to-clip-rect");
+
+WindowRegionIsSetToClipRect::WindowRegionIsSetToClipRect(NPP npp, const string& identifier)
+    : PluginTest(npp, identifier)
+    , m_didReceiveInitialSetWindowCall(false)
+{
+}
+
+NPError WindowRegionIsSetToClipRect::NPP_SetWindow(NPP instance, NPWindow* window)
+{
+    if (m_didReceiveInitialSetWindowCall)
+        return NPERR_NO_ERROR;
+    m_didReceiveInitialSetWindowCall = true;
+
+    if (window->type != NPWindowTypeWindow) {
+        pluginLog(instance, "window->type should be NPWindowTypeWindow but was %d", window->type);
+        return NPERR_GENERIC_ERROR;
+    }
+
+    HWND hwnd = reinterpret_cast<HWND>(window->window);
+
+    RECT regionRect;
+    if (::GetWindowRgnBox(hwnd, &regionRect) == ERROR) {
+        pluginLog(instance, "::GetWindowRgnBox failed with error %u", ::GetLastError());
+        return NPERR_GENERIC_ERROR;
+    }
+
+    // This expected rect is based on the layout of window-region-is-set-to-clip-rect.html.
+    RECT expectedRect = { 50, 50, 100, 100 };
+    if (!::EqualRect(&regionRect, &expectedRect)) {
+        pluginLog(instance, "Expected region rect {left=%u, top=%u, right=%u, bottom=%u}, but got {left=%d, top=%d, right=%d, bottom=%d}", expectedRect.left, expectedRect.top, expectedRect.right, expectedRect.bottom, regionRect.left, regionRect.top, regionRect.right, regionRect.bottom);
+        return NPERR_GENERIC_ERROR;
+    }
+
+    pluginLog(instance, "PASS: Plugin's window's window region has been set as expected");
+
+    // While we're here, check that our window class doesn't have the CS_PARENTDC style, which
+    // defeats clipping by ignoring the window region and always clipping to the parent window.
+    // FIXME: It would be nice to have a pixel test that shows that we're
+    // getting clipped correctly, but unfortunately window regions are ignored
+    // during WM_PRINT (see <http://webkit.org/b/49034>).
+    wchar_t className[512];
+    if (!::GetClassNameW(hwnd, className, _countof(className))) {
+        pluginLog(instance, "::GetClassName failed with error %u", ::GetLastError());
+        return NPERR_GENERIC_ERROR;
+    }
+
+#ifdef DEBUG_ALL
+    const wchar_t webKitDLLName[] = L"WebKit_debug.dll";
+#else
+    const wchar_t webKitDLLName[] = L"WebKit.dll";
+#endif
+    HMODULE webKitModule = ::GetModuleHandleW(webKitDLLName);
+    if (!webKitModule) {
+        pluginLog(instance, "::GetModuleHandleW failed with error %u", ::GetLastError());
+        return NPERR_GENERIC_ERROR;
+    }
+
+    WNDCLASSW wndClass;
+    if (!::GetClassInfoW(webKitModule, className, &wndClass)) {
+        pluginLog(instance, "::GetClassInfoW failed with error %u", ::GetLastError());
+        return NPERR_GENERIC_ERROR;
+    }
+
+    if (wndClass.style & CS_PARENTDC)
+        pluginLog(instance, "FAIL: Plugin's window's class has the CS_PARENTDC style, which will defeat clipping");
+    else
+        pluginLog(instance, "PASS: Plugin's window's class does not have the CS_PARENTDC style");
+
+    return NPERR_NO_ERROR;
+}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
index 6b943a0..a451d60 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
@@ -413,6 +413,10 @@
 					RelativePath="..\Tests\win\WindowGeometryInitializedBeforeSetWindow.cpp"
 					>
 				</File>
+				<File
+					RelativePath="..\Tests\win\WindowRegionIsSetToClipRect.cpp"
+					>
+				</File>
 			</Filter>
 		</Filter>
 		<File

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list