Skip to content
Permalink
Browse files
Don't call NPP_SetWindow until the plugin's HWND has been sized/posit…
…ioned

Test: platform/win/plugins/window-geometry-initialized-before-set-window.html

Reviewed by Anders Carlsson.

Fixes <http://webkit.org/b/46716> <rdar://problem/8482014> Full-page
Adobe Reader does not paint until window is resized

WebKit2:

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::geometryDidChange): Call NPP_SetWindow after
updating the platform (HWND) geometry.

WebKitTools:

Test that a plugin's HWND is sized/positioned before NPP_SetWindow is called

Reviewed by Anders Carlsson.

* DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp:
(PluginTest::NPP_SetWindow): Added. Just returns NPERR_NO_ERROR at
this level.

* DumpRenderTree/TestNetscapePlugIn/PluginTest.h: Declared
NPP_SetWindow.

* DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp: Added.
(WindowGeometryInitializedBeforeSetWindow::NPP_SetWindow): Checks that
the plugin's HWND has a non-zero size and that its size/position
matches that specified in the NPWindow.

* DumpRenderTree/TestNetscapePlugIn/main.cpp:
(NPP_SetWindow): Call through to the PluginTest.

* DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
Added WindowGeometryInitializedBeforeSetWindow.cpp, and let VS reorder
the files as it saw fit.

LayoutTests:

Test that a plugin's HWND is sized/positioned before NPP_SetWindow is called

* platform/win/plugins/window-geometry-initialized-before-set-window-expected.txt: Added.
* platform/win/plugins/window-geometry-initialized-before-set-window.html: Added.

Canonical link: https://commits.webkit.org/59207@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@68520 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aroben committed Sep 28, 2010
1 parent 93ac100 commit f8c43731c01adb82491cd6d0d63a9278254892ec
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 22 deletions.
@@ -1,3 +1,16 @@
2010-09-28 Adam Roben <aroben@apple.com>

Test that a plugin's HWND is sized/positioned before NPP_SetWindow is
called

Reviewed by Anders Carlsson.

Test for <http://webkit.org/b/46716> <rdar://problem/8482014>
Full-page Adobe Reader does not paint until window is resized

* platform/win/plugins/window-geometry-initialized-before-set-window-expected.txt: Added.
* platform/win/plugins/window-geometry-initialized-before-set-window.html: Added.

2010-09-28 Adam Roben <aroben@apple.com>

Start running plugins tests in WebKit2 on Windows
@@ -0,0 +1,3 @@
CONSOLE MESSAGE: line 0: PLUGIN: Plugin's HWND has been sized and positioned before NPP_SetWindow was called

This tests that a plugin's HWND is already sized and positioned before NPP_SetWindow is called.
@@ -0,0 +1,19 @@
<html>
<head>
<body>
<embed id="testPlugin"
type="application/x-webkit-test-netscape"
src="data:text/plain,"
test="window-geometry-initialized-before-set-window">
</embed>

<div>
This tests that a plugin's HWND is already sized and positioned before NPP_SetWindow is called.
</div>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
</script>
</body>
</html>

@@ -1,3 +1,19 @@
2010-09-28 Adam Roben <aroben@apple.com>

Don't call NPP_SetWindow until the plugin's HWND has been
sized/positioned

Test: platform/win/plugins/window-geometry-initialized-before-set-window.html

Reviewed by Anders Carlsson.

Fixes <http://webkit.org/b/46716> <rdar://problem/8482014> Full-page
Adobe Reader does not paint until window is resized

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::geometryDidChange): Call NPP_SetWindow after
updating the platform (HWND) geometry.

2010-09-28 Anders Carlsson <andersca@apple.com>

Out of process plug-ins shouldn't be turned on just yet...
@@ -397,8 +397,8 @@ void NetscapePlugin::geometryDidChange(const IntRect& frameRect, const IntRect&
m_frameRect = frameRect;
m_clipRect = clipRect;

callSetWindow();
platformGeometryDidChange();
callSetWindow();
}

void NetscapePlugin::frameDidFinishLoading(uint64_t requestID)
@@ -1,3 +1,32 @@
2010-09-28 Adam Roben <aroben@apple.com>

Test that a plugin's HWND is sized/positioned before NPP_SetWindow is
called

Reviewed by Anders Carlsson.

Test for <http://webkit.org/b/46716> <rdar://problem/8482014>
Full-page Adobe Reader does not paint until window is resized

* DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp:
(PluginTest::NPP_SetWindow): Added. Just returns NPERR_NO_ERROR at
this level.

* DumpRenderTree/TestNetscapePlugIn/PluginTest.h: Declared
NPP_SetWindow.

* DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp: Added.
(WindowGeometryInitializedBeforeSetWindow::NPP_SetWindow): Checks that
the plugin's HWND has a non-zero size and that its size/position
matches that specified in the NPWindow.

* DumpRenderTree/TestNetscapePlugIn/main.cpp:
(NPP_SetWindow): Call through to the PluginTest.

* DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
Added WindowGeometryInitializedBeforeSetWindow.cpp, and let VS reorder
the files as it saw fit.

2010-09-28 Benjamin Poulain <benjamin.poulain@nokia.com>

Reviewed by Andreas Kling.
@@ -60,6 +60,11 @@ NPError PluginTest::NPP_GetValue(NPPVariable variable, void *value)
return NPERR_GENERIC_ERROR;
}

NPError PluginTest::NPP_SetWindow(NPP, NPWindow*)
{
return NPERR_NO_ERROR;
}

NPIdentifier PluginTest::NPN_GetStringIdentifier(const NPUTF8 *name)
{
return browser->getstringidentifier(name);
@@ -57,6 +57,7 @@ class PluginTest {
// NPP functions.
virtual NPError NPP_DestroyStream(NPStream* stream, NPReason reason);
virtual NPError NPP_GetValue(NPPVariable, void* value);
virtual NPError NPP_SetWindow(NPP, NPWindow*);

// NPN functions.
NPIdentifier NPN_GetStringIdentifier(const NPUTF8* name);
@@ -0,0 +1,83 @@
/*
* 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;

// Plugin's HWND should be sized/positioned before NPP_SetWindow is called.

class WindowGeometryInitializedBeforeSetWindow : public PluginTest {
public:
WindowGeometryInitializedBeforeSetWindow(NPP npp, const string& identifier)
: PluginTest(npp, identifier)
{
}

private:
virtual NPError NPP_SetWindow(NPP instance, NPWindow* window)
{
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 rect;
if (!::GetClientRect(hwnd, &rect)) {
pluginLog(instance, "::GetClientRect failed");
return NPERR_GENERIC_ERROR;
}

if (::IsRectEmpty(&rect)) {
pluginLog(instance, "Plugin's HWND has not been sized when NPP_SetWindow is called");
return NPERR_GENERIC_ERROR;
}

HWND parent = ::GetParent(hwnd);
if (!parent) {
pluginLog(instance, "::GetParent failed");
return NPERR_GENERIC_ERROR;
}

// MSDN says that calling ::MapWindowPoints this way will tell it we're passing a RECT rather than two POINTs.
if (!::MapWindowPoints(hwnd, parent, reinterpret_cast<POINT*>(&rect), 2)) {
pluginLog(instance, "::MapWindowPoints failed");
return NPERR_GENERIC_ERROR;
}

if (rect.left != window->x || rect.top != window->y || (rect.right - rect.left) != window->width || (rect.bottom - rect.top) != window->height) {
pluginLog(instance, "HWND's rect and NPWindow's rect are not equal");
return NPERR_GENERIC_ERROR;
}

pluginLog(instance, "Plugin's HWND has been sized and positioned before NPP_SetWindow was called");
return NPERR_NO_ERROR;
}
};

static PluginTest::Register<WindowGeometryInitializedBeforeSetWindow> windowGeometryInitializedBeforeSetWindow("window-geometry-initialized-before-set-window");
@@ -300,7 +300,7 @@ NPError NPP_SetWindow(NPP instance, NPWindow *window)
}
}

return NPERR_NO_ERROR;
return obj->pluginTest->NPP_SetWindow(instance, window);
}

static void executeScript(const PluginObject* obj, const char* script)
@@ -367,6 +367,34 @@
<References>
</References>
<Files>
<Filter
Name="Tests"
>
<File
RelativePath="..\Tests\DocumentOpenInDestroyStream.cpp"
>
</File>
<File
RelativePath="..\Tests\NPRuntimeObjectFromDestroyedPlugin.cpp"
>
</File>
<File
RelativePath="..\Tests\NPRuntimeRemoveProperty.cpp"
>
</File>
<File
RelativePath="..\Tests\PluginScriptableNPObjectInvokeDefault.cpp"
>
</File>
<Filter
Name="win"
>
<File
RelativePath="..\Tests\win\WindowGeometryInitializedBeforeSetWindow.cpp"
>
</File>
</Filter>
</Filter>
<File
RelativePath="..\main.cpp"
>
@@ -456,26 +484,6 @@
RelativePath="..\TestObject.h"
>
</File>
<Filter
Name="Tests"
>
<File
RelativePath="..\Tests\DocumentOpenInDestroyStream.cpp"
>
</File>
<File
RelativePath="..\Tests\NPRuntimeObjectFromDestroyedPlugin.cpp"
>
</File>
<File
RelativePath="..\Tests\NPRuntimeRemoveProperty.cpp"
>
</File>
<File
RelativePath="..\Tests\PluginScriptableNPObjectInvokeDefault.cpp"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>

0 comments on commit f8c4373

Please sign in to comment.