Changeset 62993 in webkit


Ignore:
Timestamp:
Jul 9, 2010 2:18:14 PM (14 years ago)
Author:
andersca@apple.com
Message:

Verify drawing coordinates, add crude painting support
https://bugs.webkit.org/show_bug.cgi?id=41984

Reviewed by Sam Weinig.

  • WebKit2.xcodeproj/project.pbxproj:

Add NetscapePluginMac.cpp.

  • WebProcess/Plugins/Netscape/NetscapePlugin.cpp:

(WebKit::NetscapePlugin::NetscapePlugin):
Initialize drawing and event models.

(WebKit::NetscapePlugin::initialize):
Call platformPostInitialize.

(WebKit::NetscapePlugin::destroy):
Call NPP_Destroy.

(WebKit::NetscapePlugin::paint):
Call platformPaint.

  • WebProcess/Plugins/Netscape/NetscapePlugin.h:

Add member functions.

  • WebProcess/Plugins/Netscape/mac/NetscapePluginMac.cpp: Added.

(WebKit::NetscapePlugin::platformPostInitialize):
Set default event and drawing models and verify that they are compatible.

(WebKit::NetscapePlugin::platformPaint):
Send a paint event (assuming the Cocoa event model currently).

  • WebProcess/Plugins/PluginView.cpp:

(WebKit::PluginView::paint):
Change the paint rect to be in window coordinates.

(WebKit::PluginView::viewGeometryDidChange):
(WebKit::PluginView::clipRectInWindowCoordinates):

  • WebProcess/Plugins/PluginView.h:
Location:
trunk/WebKit2
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r62973 r62993  
     12010-07-09  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Verify drawing coordinates, add crude painting support
     6        https://bugs.webkit.org/show_bug.cgi?id=41984
     7   
     8        * WebKit2.xcodeproj/project.pbxproj:
     9        Add NetscapePluginMac.cpp.
     10
     11        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
     12        (WebKit::NetscapePlugin::NetscapePlugin):
     13        Initialize drawing and event models.
     14
     15        (WebKit::NetscapePlugin::initialize):
     16        Call platformPostInitialize.
     17
     18        (WebKit::NetscapePlugin::destroy):
     19        Call NPP_Destroy.
     20
     21        (WebKit::NetscapePlugin::paint):
     22        Call platformPaint.
     23
     24        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
     25        Add member functions.
     26
     27        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.cpp: Added.
     28        (WebKit::NetscapePlugin::platformPostInitialize):
     29        Set default event and drawing models and verify that they are compatible.
     30       
     31        (WebKit::NetscapePlugin::platformPaint):
     32        Send a paint event (assuming the Cocoa event model currently).
     33
     34        * WebProcess/Plugins/PluginView.cpp:
     35        (WebKit::PluginView::paint):
     36        Change the paint rect to be in window coordinates.
     37
     38        (WebKit::PluginView::viewGeometryDidChange):
     39        (WebKit::PluginView::clipRectInWindowCoordinates):
     40        * WebProcess/Plugins/PluginView.h:
     41
    1422010-07-09  Anders Carlsson  <andersca@apple.com>
    243
  • trunk/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r62869 r62993  
    6464                1AADE6FF10D855FC00D3D63D /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AADE6FE10D855FC00D3D63D /* ApplicationServices.framework */; };
    6565                1AE117F611DBB30900981615 /* ProcessLauncher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE117F511DBB30900981615 /* ProcessLauncher.cpp */; };
     66                1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.cpp */; };
    6667                1AEFCC1211D01F96008219D3 /* PluginInfoStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEFCC1011D01F96008219D3 /* PluginInfoStore.h */; };
    6768                1AEFCC1311D01F96008219D3 /* PluginInfoStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AEFCC1111D01F96008219D3 /* PluginInfoStore.cpp */; };
     
    333334                1AADE6FE10D855FC00D3D63D /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
    334335                1AE117F511DBB30900981615 /* ProcessLauncher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessLauncher.cpp; sourceTree = "<group>"; };
     336                1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePluginMac.cpp; sourceTree = "<group>"; };
    335337                1AEFCC1011D01F96008219D3 /* PluginInfoStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginInfoStore.h; sourceTree = "<group>"; };
    336338                1AEFCC1111D01F96008219D3 /* PluginInfoStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginInfoStore.cpp; sourceTree = "<group>"; };
     
    670672                        isa = PBXGroup;
    671673                        children = (
     674                                1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.cpp */,
    672675                                1A6FBA0211E6813E00DB1371 /* NetscapePluginModuleMac.cpp */,
    673676                        );
     
    14131416                                1A6FBA2B11E6862700DB1371 /* NetscapeBrowserFuncs.cpp in Sources */,
    14141417                                1A6FBD2911E69BC200DB1371 /* NetscapePlugin.cpp in Sources */,
     1418                                1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.cpp in Sources */,
    14151419                        );
    14161420                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

    r62973 r62993  
    2626#include "NetscapePlugin.h"
    2727
     28#include <WebCore/GraphicsContext.h>
    2829#include <WebCore/IntRect.h>
    2930
     
    3536    : m_pluginModule(pluginModule)
    3637    , m_npWindow()
     38    , m_isStarted(false)
     39#if PLATFORM(MAC)
     40    , m_drawingModel(static_cast<NPDrawingModel>(-1))
     41    , m_eventModel(static_cast<NPEventModel>(-1))
     42#endif
    3743{
    3844    m_npp.ndata = this;
     
    6773        return false;
    6874
     75    m_isStarted = true;
     76
    6977    // FIXME: This is not correct in all cases.
    7078    m_npWindow.type = NPWindowTypeDrawable;
     79
     80    if (!platformPostInitialize()) {
     81        destroy();
     82        return false;
     83    }
    7184
    7285    return true;
     
    7588void NetscapePlugin::destroy()
    7689{
     90    ASSERT(m_isStarted);
     91
     92    m_pluginModule->pluginFuncs().destroy(&m_npp, 0);
     93    m_isStarted = false;
    7794}
    7895   
    7996void NetscapePlugin::paint(GraphicsContext* context, const IntRect& dirtyRect)
    8097{
     98    platformPaint(context, dirtyRect);
    8199}
    82100
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r62973 r62993  
    4646    void callSetWindow();
    4747
     48    bool platformPostInitialize();
     49    void platformPaint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect);
     50
    4851    // Plugin
    4952    virtual bool initialize(const WebCore::KURL&, const Vector<WebCore::String>& paramNames, const Vector<WebCore::String>& paramValues, const WebCore::String& mimeType, bool loadManually);
     
    5558    NPP_t m_npp;
    5659    NPWindow m_npWindow;
    57    
     60
    5861    WebCore::IntRect m_frameRect;
    5962    WebCore::IntRect m_clipRect;
     63   
     64    bool m_isStarted;
     65
     66#if PLATFORM(MAC)
     67    NPDrawingModel m_drawingModel;
     68    NPEventModel m_eventModel;
     69#endif
    6070};
     71
     72// Move these functions to NetscapePluginWin.cpp
     73#if !PLATFORM(MAC)
     74inline bool NetscapePlugin::platformPostInitialize()
     75{
     76    return true;
     77}
     78
     79inline void NetscapePlugin::platformPaint(WebCore::GraphicsContext*, const WebCore::IntRect&)
     80{
     81}
     82#endif
    6183
    6284} // namespace WebKit
  • trunk/WebKit2/WebProcess/Plugins/PluginView.cpp

    r62973 r62993  
    5959        return;
    6060   
    61     IntRect paintRect = intersection(dirtyRect, frameRect());
    62     if (paintRect.isEmpty())
     61    IntRect dirtyRectInWindowCoordinates = parent()->contentsToWindow(dirtyRect);
     62   
     63    IntRect paintRectInWindowCoordinates = intersection(dirtyRectInWindowCoordinates, clipRectInWindowCoordinates());
     64    if (paintRectInWindowCoordinates.isEmpty())
    6365        return;
    6466
    65     m_plugin->paint(context, paintRect);
     67    context->save();
     68
     69    // Translate the context so that the origin is at the top left corner of the plug-in view.
     70    context->translate(frameRect().x(), frameRect().y());
     71
     72    m_plugin->paint(context, paintRectInWindowCoordinates);
     73    context->restore();
    6674}
    6775
     
    8694    IntRect frameRectInWindowCoordinates = parent()->contentsToWindow(frameRect());
    8795
     96    m_plugin->geometryDidChange(frameRectInWindowCoordinates, clipRectInWindowCoordinates());
     97}
     98
     99IntRect PluginView::clipRectInWindowCoordinates() const
     100{
     101    ASSERT(parent());
     102
     103    // Get the frame rect in window coordinates.
     104    IntRect frameRectInWindowCoordinates = parent()->contentsToWindow(frameRect());
     105
    88106    // Get the window clip rect for the enclosing layer (in window coordinates).
    89107    RenderLayer* layer = m_pluginElement->renderer()->enclosingLayer();
     
    92110
    93111    // 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);
     112    return intersection(frameRectInWindowCoordinates, windowClipRect);
    97113}
    98114
  • trunk/WebKit2/WebProcess/Plugins/PluginView.h

    r62973 r62993  
    5050
    5151    void viewGeometryDidChange();
     52    WebCore::IntRect clipRectInWindowCoordinates() const;
    5253
    5354    // WebCore::Widget
Note: See TracChangeset for help on using the changeset viewer.