Commit 54f85263 authored by andersca@apple.com's avatar andersca@apple.com
Browse files

Pass a clip rect to the plugin and call NPP_SetWindow

https://bugs.webkit.org/show_bug.cgi?id=41969

Reviewed by Sam Weinig.

* WebProcess/Plugins/DummyPlugin.cpp:
(WebKit::DummyPlugin::geometryDidChange):
* WebProcess/Plugins/DummyPlugin.h:
Add clip rect parameter.

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::NetscapePlugin):
Initialize m_npWindow.

(WebKit::NetscapePlugin::callSetWindow):
Call NPP_SetWindow.

(WebKit::NetscapePlugin::initialize):
Set the window type to NPWindowTypeDrawable for now.

(WebKit::NetscapePlugin::geometryDidChange):
Update the frame and clip rects and call NPP_SetWindow.

* WebProcess/Plugins/Netscape/NetscapePlugin.h:
Add an NPWindow member variable.

* WebProcess/Plugins/Plugin.h:
Add a clipRect parameter to geometryDidChange.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::PluginView):
Add the plug-in element to the constructor.

(WebKit::PluginView::viewGeometryDidChange):
Compute the clip rect and pass it to the plug-in.

* WebProcess/Plugins/PluginView.h:
(WebKit::PluginView::create):
Pass the plug-in element to the constructor.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::createPlugin):
Pass the plug-in element to PluginView::create.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@62973 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ef878554
2010-07-09 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
Pass a clip rect to the plugin and call NPP_SetWindow
https://bugs.webkit.org/show_bug.cgi?id=41969
* WebProcess/Plugins/DummyPlugin.cpp:
(WebKit::DummyPlugin::geometryDidChange):
* WebProcess/Plugins/DummyPlugin.h:
Add clip rect parameter.
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::NetscapePlugin):
Initialize m_npWindow.
(WebKit::NetscapePlugin::callSetWindow):
Call NPP_SetWindow.
(WebKit::NetscapePlugin::initialize):
Set the window type to NPWindowTypeDrawable for now.
(WebKit::NetscapePlugin::geometryDidChange):
Update the frame and clip rects and call NPP_SetWindow.
* WebProcess/Plugins/Netscape/NetscapePlugin.h:
Add an NPWindow member variable.
* WebProcess/Plugins/Plugin.h:
Add a clipRect parameter to geometryDidChange.
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::PluginView):
Add the plug-in element to the constructor.
(WebKit::PluginView::viewGeometryDidChange):
Compute the clip rect and pass it to the plug-in.
* WebProcess/Plugins/PluginView.h:
(WebKit::PluginView::create):
Pass the plug-in element to the constructor.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::createPlugin):
Pass the plug-in element to PluginView::create.
2010-07-09 Anders Carlsson <andersca@apple.com>
Reviewed by Simon Fraser.
......
......@@ -57,7 +57,7 @@ void DummyPlugin::paint(GraphicsContext* context, const IntRect& dirtyRect)
#endif
}
void DummyPlugin::geometryDidChange(const IntRect& frameRect)
void DummyPlugin::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect)
{
}
......
......@@ -45,7 +45,7 @@ private:
virtual bool initialize(const WebCore::KURL&, const Vector<WebCore::String>& paramNames, const Vector<WebCore::String>& paramValues, const WebCore::String& mimeType, bool loadManually);
virtual void destroy();
virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect);
virtual void geometryDidChange(const WebCore::IntRect& frameRect);
virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect);
};
} // namespace WebKit
......
......@@ -33,6 +33,7 @@ namespace WebKit {
NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
: m_pluginModule(pluginModule)
, m_npWindow()
{
m_npp.ndata = this;
m_npp.pdata = 0;
......@@ -42,6 +43,20 @@ NetscapePlugin::~NetscapePlugin()
{
}
void NetscapePlugin::callSetWindow()
{
m_npWindow.x = m_frameRect.x();
m_npWindow.y = m_frameRect.y();
m_npWindow.width = m_frameRect.width();
m_npWindow.height = m_frameRect.height();
m_npWindow.clipRect.top = m_clipRect.y();
m_npWindow.clipRect.left = m_clipRect.x();
m_npWindow.clipRect.bottom = m_clipRect.bottom();
m_npWindow.clipRect.right = m_clipRect.right();
m_pluginModule->pluginFuncs().setwindow(&m_npp, &m_npWindow);
}
bool NetscapePlugin::initialize(const KURL&, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
{
uint16_t mode = loadManually ? NP_FULL : NP_EMBED;
......@@ -51,6 +66,9 @@ bool NetscapePlugin::initialize(const KURL&, const Vector<String>& paramNames, c
if (error != NPERR_NO_ERROR)
return false;
// FIXME: This is not correct in all cases.
m_npWindow.type = NPWindowTypeDrawable;
return true;
}
......@@ -62,8 +80,17 @@ void NetscapePlugin::paint(GraphicsContext* context, const IntRect& dirtyRect)
{
}
void NetscapePlugin::geometryDidChange(const IntRect& frameRect)
void NetscapePlugin::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect)
{
if (m_frameRect == frameRect && m_clipRect == clipRect) {
// Nothing to do.
return;
}
m_frameRect = frameRect;
m_clipRect = clipRect;
callSetWindow();
}
} // namespace WebKit
......@@ -28,6 +28,7 @@
#include "NetscapePluginModule.h"
#include "Plugin.h"
#include <WebCore/IntRect.h>
namespace WebKit {
......@@ -42,14 +43,20 @@ public:
private:
NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule);
void callSetWindow();
// Plugin
virtual bool initialize(const WebCore::KURL&, const Vector<WebCore::String>& paramNames, const Vector<WebCore::String>& paramValues, const WebCore::String& mimeType, bool loadManually);
virtual void destroy();
virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect);
virtual void geometryDidChange(const WebCore::IntRect& frameRect);
virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect);
RefPtr<NetscapePluginModule> m_pluginModule;
NPP_t m_npp;
NPWindow m_npWindow;
WebCore::IntRect m_frameRect;
WebCore::IntRect m_clipRect;
};
} // namespace WebKit
......
......@@ -45,7 +45,7 @@ public:
virtual bool initialize(const WebCore::KURL&, const Vector<WebCore::String>& paramNames, const Vector<WebCore::String>& paramValues, const WebCore::String& mimeType, bool loadManually) = 0;
virtual void destroy() = 0;
virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect) = 0;
virtual void geometryDidChange(const WebCore::IntRect& frameRect) = 0;
virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect) = 0;
protected:
Plugin();
......
......@@ -26,15 +26,19 @@
#include "PluginView.h"
#include "Plugin.h"
#include <WebCore/FrameView.h>
#include <WebCore/GraphicsContext.h>
#include <WebCore/HTMLPlugInElement.h>
#include <WebCore/RenderLayer.h>
#include <WebCore/ScrollView.h>
using namespace WebCore;
namespace WebKit {
PluginView::PluginView(PassRefPtr<Plugin> plugin)
PluginView::PluginView(PassRefPtr<Plugin> plugin, HTMLPlugInElement* pluginElement)
: m_plugin(plugin)
, m_pluginElement(pluginElement)
{
}
......@@ -61,7 +65,6 @@ void PluginView::paint(GraphicsContext* context, const IntRect& dirtyRect)
m_plugin->paint(context, paintRect);
}
void PluginView::frameRectsChanged()
{
Widget::frameRectsChanged();
......@@ -79,9 +82,18 @@ void PluginView::viewGeometryDidChange()
if (!parent())
return;
// Get the frame rect in window coordinates.
IntRect frameRectInWindowCoordinates = parent()->contentsToWindow(frameRect());
m_plugin->geometryDidChange(frameRectInWindowCoordinates);
// Get the window clip rect for the enclosing layer (in window coordinates).
RenderLayer* layer = m_pluginElement->renderer()->enclosingLayer();
FrameView* parentView = m_pluginElement->document()->frame()->view();
IntRect windowClipRect = parentView->windowClipRectForLayer(layer, true);
// Intersect the two rects to get the view clip rect in window coordinates.
IntRect clipRectInWindowCoordinates = intersection(frameRectInWindowCoordinates, windowClipRect);
m_plugin->geometryDidChange(frameRectInWindowCoordinates, clipRectInWindowCoordinates);
}
void PluginView::invalidateRect(const IntRect&)
......
......@@ -31,17 +31,21 @@
// FIXME: Eventually this should move to WebCore.
namespace WebCore {
class HTMLPlugInElement;
}
namespace WebKit {
class PluginView : public WebCore::Widget {
public:
static PassRefPtr<PluginView> create(PassRefPtr<Plugin> plugin)
static PassRefPtr<PluginView> create(PassRefPtr<Plugin> plugin, WebCore::HTMLPlugInElement* pluginElement)
{
return adoptRef(new PluginView(plugin));
return adoptRef(new PluginView(plugin, pluginElement));
}
private:
PluginView(PassRefPtr<Plugin>);
PluginView(PassRefPtr<Plugin>, WebCore::HTMLPlugInElement*);
virtual ~PluginView();
void viewGeometryDidChange();
......@@ -54,6 +58,7 @@ private:
virtual void setParent(WebCore::ScrollView*);
RefPtr<Plugin> m_plugin;
WebCore::HTMLPlugInElement* m_pluginElement;
};
} // namespace WebKit
......
......@@ -770,7 +770,7 @@ void WebFrameLoaderClient::didTransferChildFrameToNewDocument()
notImplemented();
}
PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement*, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement* pluginElement, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
{
String pluginPath;
......@@ -795,7 +795,7 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugIn
if (!plugin->initialize(url, paramNames, paramValues, mimeType, loadManually))
return 0;
return PluginView::create(plugin.release());
return PluginView::create(plugin.release(), pluginElement);
#else
return 0;
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment