Changeset 62973 in webkit


Ignore:
Timestamp:
Jul 9, 2010 11:43:17 AM (14 years ago)
Author:
andersca@apple.com
Message:

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.

Location:
trunk/WebKit2
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r62964 r62973  
     12010-07-09  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Pass a clip rect to the plugin and call NPP_SetWindow
     6        https://bugs.webkit.org/show_bug.cgi?id=41969
     7
     8        * WebProcess/Plugins/DummyPlugin.cpp:
     9        (WebKit::DummyPlugin::geometryDidChange):
     10        * WebProcess/Plugins/DummyPlugin.h:
     11        Add clip rect parameter.
     12
     13        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
     14        (WebKit::NetscapePlugin::NetscapePlugin):
     15        Initialize m_npWindow.
     16
     17        (WebKit::NetscapePlugin::callSetWindow):
     18        Call NPP_SetWindow.
     19
     20        (WebKit::NetscapePlugin::initialize):
     21        Set the window type to NPWindowTypeDrawable for now.
     22
     23        (WebKit::NetscapePlugin::geometryDidChange):
     24        Update the frame and clip rects and call NPP_SetWindow.
     25
     26        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
     27        Add an NPWindow member variable.
     28
     29        * WebProcess/Plugins/Plugin.h:
     30        Add a clipRect parameter to geometryDidChange.
     31
     32        * WebProcess/Plugins/PluginView.cpp:
     33        (WebKit::PluginView::PluginView):
     34        Add the plug-in element to the constructor.
     35       
     36        (WebKit::PluginView::viewGeometryDidChange):
     37        Compute the clip rect and pass it to the plug-in.
     38
     39        * WebProcess/Plugins/PluginView.h:
     40        (WebKit::PluginView::create):
     41        Pass the plug-in element to the constructor.
     42
     43        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     44        (WebKit::WebFrameLoaderClient::createPlugin):
     45        Pass the plug-in element to PluginView::create.
     46
    1472010-07-09  Anders Carlsson  <andersca@apple.com>
    248
  • trunk/WebKit2/WebProcess/Plugins/DummyPlugin.cpp

    r62823 r62973  
    5858}
    5959   
    60 void DummyPlugin::geometryDidChange(const IntRect& frameRect)
     60void DummyPlugin::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect)
    6161{
    6262}
  • trunk/WebKit2/WebProcess/Plugins/DummyPlugin.h

    r62823 r62973  
    4646    virtual void destroy();
    4747    virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect);
    48     virtual void geometryDidChange(const WebCore::IntRect& frameRect);
     48    virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect);
    4949};
    5050
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

    r62964 r62973  
    3434NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
    3535    : m_pluginModule(pluginModule)
     36    , m_npWindow()
    3637{
    3738    m_npp.ndata = this;
     
    4142NetscapePlugin::~NetscapePlugin()
    4243{
     44}
     45
     46void NetscapePlugin::callSetWindow()
     47{
     48    m_npWindow.x = m_frameRect.x();
     49    m_npWindow.y = m_frameRect.y();
     50    m_npWindow.width = m_frameRect.width();
     51    m_npWindow.height = m_frameRect.height();
     52    m_npWindow.clipRect.top = m_clipRect.y();
     53    m_npWindow.clipRect.left = m_clipRect.x();
     54    m_npWindow.clipRect.bottom = m_clipRect.bottom();
     55    m_npWindow.clipRect.right = m_clipRect.right();
     56
     57    m_pluginModule->pluginFuncs().setwindow(&m_npp, &m_npWindow);
    4358}
    4459
     
    5166    if (error != NPERR_NO_ERROR)
    5267        return false;
     68
     69    // FIXME: This is not correct in all cases.
     70    m_npWindow.type = NPWindowTypeDrawable;
    5371
    5472    return true;
     
    6381}
    6482
    65 void NetscapePlugin::geometryDidChange(const IntRect& frameRect)
     83void NetscapePlugin::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect)
    6684{
     85    if (m_frameRect == frameRect && m_clipRect == clipRect) {
     86        // Nothing to do.
     87        return;
     88    }
     89
     90    m_frameRect = frameRect;
     91    m_clipRect = clipRect;
     92
     93    callSetWindow();
    6794}
    6895
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r62964 r62973  
    2929#include "NetscapePluginModule.h"
    3030#include "Plugin.h"
     31#include <WebCore/IntRect.h>
    3132
    3233namespace WebKit {
     
    4344    NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule);
    4445
     46    void callSetWindow();
     47
    4548    // Plugin
    4649    virtual bool initialize(const WebCore::KURL&, const Vector<WebCore::String>& paramNames, const Vector<WebCore::String>& paramValues, const WebCore::String& mimeType, bool loadManually);
    4750    virtual void destroy();
    4851    virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect);
    49     virtual void geometryDidChange(const WebCore::IntRect& frameRect);
     52    virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect);
    5053   
    5154    RefPtr<NetscapePluginModule> m_pluginModule;
    5255    NPP_t m_npp;
     56    NPWindow m_npWindow;
     57   
     58    WebCore::IntRect m_frameRect;
     59    WebCore::IntRect m_clipRect;
    5360};
    5461
  • trunk/WebKit2/WebProcess/Plugins/Plugin.h

    r62823 r62973  
    4646    virtual void destroy() = 0;
    4747    virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect) = 0;
    48     virtual void geometryDidChange(const WebCore::IntRect& frameRect) = 0;
     48    virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect) = 0;
    4949
    5050protected:
  • trunk/WebKit2/WebProcess/Plugins/PluginView.cpp

    r62964 r62973  
    2727
    2828#include "Plugin.h"
     29#include <WebCore/FrameView.h>
    2930#include <WebCore/GraphicsContext.h>
     31#include <WebCore/HTMLPlugInElement.h>
     32#include <WebCore/RenderLayer.h>
    3033#include <WebCore/ScrollView.h>
    3134
     
    3437namespace WebKit {
    3538
    36 PluginView::PluginView(PassRefPtr<Plugin> plugin)
     39PluginView::PluginView(PassRefPtr<Plugin> plugin, HTMLPlugInElement* pluginElement)
    3740    : m_plugin(plugin)
     41    , m_pluginElement(pluginElement)
    3842{
    3943}
     
    6266}
    6367
    64 
    6568void PluginView::frameRectsChanged()
    6669{
     
    8083        return;
    8184
     85    // Get the frame rect in window coordinates.
    8286    IntRect frameRectInWindowCoordinates = parent()->contentsToWindow(frameRect());
    83    
    84     m_plugin->geometryDidChange(frameRectInWindowCoordinates);
     87
     88    // Get the window clip rect for the enclosing layer (in window coordinates).
     89    RenderLayer* layer = m_pluginElement->renderer()->enclosingLayer();
     90    FrameView* parentView = m_pluginElement->document()->frame()->view();
     91    IntRect windowClipRect = parentView->windowClipRectForLayer(layer, true);
     92
     93    // Intersect the two rects to get the view clip rect in window coordinates.
     94    IntRect clipRectInWindowCoordinates = intersection(frameRectInWindowCoordinates, windowClipRect);
     95
     96    m_plugin->geometryDidChange(frameRectInWindowCoordinates, clipRectInWindowCoordinates);
    8597}
    8698
  • trunk/WebKit2/WebProcess/Plugins/PluginView.h

    r62964 r62973  
    3232// FIXME: Eventually this should move to WebCore.
    3333
     34namespace WebCore {
     35    class HTMLPlugInElement;
     36}
     37
    3438namespace WebKit {
    3539
    3640class PluginView : public WebCore::Widget {
    3741public:
    38     static PassRefPtr<PluginView> create(PassRefPtr<Plugin> plugin)
     42    static PassRefPtr<PluginView> create(PassRefPtr<Plugin> plugin, WebCore::HTMLPlugInElement* pluginElement)
    3943    {
    40         return adoptRef(new PluginView(plugin));
     44        return adoptRef(new PluginView(plugin, pluginElement));
    4145    }
    4246
    4347private:
    44     PluginView(PassRefPtr<Plugin>);
     48    PluginView(PassRefPtr<Plugin>, WebCore::HTMLPlugInElement*);
    4549    virtual ~PluginView();
    4650
     
    5559
    5660    RefPtr<Plugin> m_plugin;
     61    WebCore::HTMLPlugInElement* m_pluginElement;
    5762};
    5863
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r62878 r62973  
    771771}   
    772772
    773 PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement*, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
     773PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement* pluginElement, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
    774774{
    775775    String pluginPath;
     
    796796        return 0;
    797797
    798     return PluginView::create(plugin.release());
     798    return PluginView::create(plugin.release(), pluginElement);
    799799#else
    800800    return 0;
Note: See TracChangeset for help on using the changeset viewer.