Changeset 112338 in webkit


Ignore:
Timestamp:
Mar 27, 2012 5:16:52 PM (12 years ago)
Author:
andersca@apple.com
Message:

Plug-ins using the Core Animation drawing model should work when hosting the layer tree in the window server
https://bugs.webkit.org/show_bug.cgi?id=82387
<rdar://problem/11031942>

Reviewed by Sam Weinig.

  • PluginProcess/PluginControllerProxy.cpp:

(WebKit::PluginControllerProxy::PluginControllerProxy):
(WebKit::PluginControllerProxy::initialize):
Remove m_pluginCreationParameters; it was used by the old NPRuntime short-circuit code.
Make platformInitialize take creation parameters.

  • PluginProcess/PluginControllerProxy.messages.in:

Add SetLayerHostingMode message.

  • PluginProcess/gtk/PluginControllerProxyGtk.cpp:

(WebKit::PluginControllerProxy::platformInitialize):
Make platformInitialize take creation parameters.

  • PluginProcess/mac/PluginControllerProxyMac.mm:

(WebKit::PluginControllerProxy::platformInitialize):
Call updateLayerHostingContext.

(WebKit::PluginControllerProxy::setLayerHostingMode):
Call updateLayerHostingContext and send back the new context ID.

(WebKit::PluginControllerProxy::updateLayerHostingContext):
Create a new LayerHostingContext given the layer hosting mode.

  • PluginProcess/qt/PluginControllerProxyQt.cpp:

(WebKit::PluginControllerProxy::platformInitialize):
Make platformInitialize take creation parameters.

  • WebProcess/Plugins/Netscape/NetscapePlugin.h:
  • WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:

(WebKit::NetscapePlugin::setLayerHostingMode):
Add stub.

  • WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm:

(WebKit::makeRenderLayer):
Add helper function for creating a new render layer.

(WebKit::PluginProxy::pluginLayer):
Call makeRenderLayer.

(WebKit::PluginProxy::setLayerHostingMode):
Send a message to the plug-in process.

(WebKit::PluginProxy::setLayerHostingContextID):
Update the context ID and make a new render layer.

  • WebProcess/Plugins/PDF/BuiltInPDFView.cpp:

(WebKit::BuiltInPDFView::setLayerHostingMode):
Add stub.

  • WebProcess/Plugins/PDF/BuiltInPDFView.h:
  • WebProcess/Plugins/Plugin.cpp:

(WebKit::Plugin::Parameters::encode):
(WebKit::Plugin::Parameters::decode):

  • WebProcess/Plugins/Plugin.h:

Add the layer hosting mode as a parameter. Add a new setLayerHostingMode pure virtual member function.

  • WebProcess/Plugins/PluginProxy.messages.in:

Add a SetLayerHostingContextID message.

  • WebProcess/Plugins/PluginView.cpp:

(WebKit::PluginView::setLayerHostingMode):
Call down to the plug-in.

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::createPlugin):
Set the layer hosting mode of the page.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::WebPage):
Initialize m_layerHostingMode to false.

  • WebProcess/WebPage/WebPage.h:

(WebKit::WebPage::layerHostingMode):
Add m_layerHostingMode and a getter.

  • WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:

(WebKit::TiledCoreAnimationDrawingArea::setLayerHostingMode):
Call WebPage::setLayerHostingMode.

  • WebProcess/WebPage/mac/WebPageMac.mm:

(WebKit::WebPage::setLayerHostingMode):
Tell all plug-ins that the layer hosting mode changed.

Location:
trunk/Source/WebKit2
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r112312 r112338  
     12012-03-27  Anders Carlsson  <andersca@apple.com>
     2
     3        Plug-ins using the Core Animation drawing model should work when hosting the layer tree in the window server
     4        https://bugs.webkit.org/show_bug.cgi?id=82387
     5        <rdar://problem/11031942>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * PluginProcess/PluginControllerProxy.cpp:
     10        (WebKit::PluginControllerProxy::PluginControllerProxy):
     11        (WebKit::PluginControllerProxy::initialize):
     12        Remove m_pluginCreationParameters; it was used by the old NPRuntime short-circuit code.
     13        Make platformInitialize take creation parameters.
     14
     15        * PluginProcess/PluginControllerProxy.messages.in:
     16        Add SetLayerHostingMode message.
     17
     18        * PluginProcess/gtk/PluginControllerProxyGtk.cpp:
     19        (WebKit::PluginControllerProxy::platformInitialize):
     20        Make platformInitialize take creation parameters.
     21
     22        * PluginProcess/mac/PluginControllerProxyMac.mm:
     23        (WebKit::PluginControllerProxy::platformInitialize):
     24        Call updateLayerHostingContext.
     25
     26        (WebKit::PluginControllerProxy::setLayerHostingMode):
     27        Call updateLayerHostingContext and send back the new context ID.
     28
     29        (WebKit::PluginControllerProxy::updateLayerHostingContext):
     30        Create a new LayerHostingContext given the layer hosting mode.
     31
     32        * PluginProcess/qt/PluginControllerProxyQt.cpp:
     33        (WebKit::PluginControllerProxy::platformInitialize):
     34        Make platformInitialize take creation parameters.
     35
     36        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
     37        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
     38        (WebKit::NetscapePlugin::setLayerHostingMode):
     39        Add stub.
     40
     41        * WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm:
     42        (WebKit::makeRenderLayer):
     43        Add helper function for creating a new render layer.
     44
     45        (WebKit::PluginProxy::pluginLayer):
     46        Call makeRenderLayer.
     47
     48        (WebKit::PluginProxy::setLayerHostingMode):
     49        Send a message to the plug-in process.
     50
     51        (WebKit::PluginProxy::setLayerHostingContextID):
     52        Update the context ID and make a new render layer.
     53
     54        * WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
     55        (WebKit::BuiltInPDFView::setLayerHostingMode):
     56        Add stub.
     57        * WebProcess/Plugins/PDF/BuiltInPDFView.h:
     58
     59        * WebProcess/Plugins/Plugin.cpp:
     60        (WebKit::Plugin::Parameters::encode):
     61        (WebKit::Plugin::Parameters::decode):
     62        * WebProcess/Plugins/Plugin.h:
     63        Add the layer hosting mode as a parameter. Add a new setLayerHostingMode pure virtual member function.
     64
     65        * WebProcess/Plugins/PluginProxy.messages.in:
     66        Add a SetLayerHostingContextID message.
     67
     68        * WebProcess/Plugins/PluginView.cpp:
     69        (WebKit::PluginView::setLayerHostingMode):
     70        Call down to the plug-in.
     71
     72        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     73        (WebKit::WebFrameLoaderClient::createPlugin):
     74        Set the layer hosting mode of the page.
     75
     76        * WebProcess/WebPage/WebPage.cpp:
     77        (WebKit::WebPage::WebPage):
     78        Initialize m_layerHostingMode to false.
     79
     80        * WebProcess/WebPage/WebPage.h:
     81        (WebKit::WebPage::layerHostingMode):
     82        Add m_layerHostingMode and a getter.
     83
     84        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
     85        (WebKit::TiledCoreAnimationDrawingArea::setLayerHostingMode):
     86        Call WebPage::setLayerHostingMode.
     87
     88        * WebProcess/WebPage/mac/WebPageMac.mm:
     89        (WebKit::WebPage::setLayerHostingMode):
     90        Tell all plug-ins that the layer hosting mode changed.
     91
    1922012-03-27  Timothy Hatcher  <timothy@apple.com>
    293
  • trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp

    r111822 r112338  
    7070    , m_pluginDestructionProtectCount(0)
    7171    , m_pluginDestroyTimer(RunLoop::main(), this, &PluginControllerProxy::destroy)
    72     , m_pluginCreationParameters(0)
    7372    , m_waitingForDidUpdate(false)
    7473    , m_pluginCanceledManualStreamLoad(false)
     
    107106    ASSERT(m_windowNPObject);
    108107
    109     m_pluginCreationParameters = &creationParameters;
    110108    bool returnValue = m_plugin->initialize(this, creationParameters.parameters);
    111     m_pluginCreationParameters = 0;
    112109
    113110    if (!returnValue) {
     
    123120    }
    124121
    125     platformInitialize();
     122    platformInitialize(creationParameters);
    126123
    127124    return true;
  • trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h

    r111822 r112338  
    134134    void windowVisibilityChanged(bool);
    135135    void sendComplexTextInput(const String& textInput);
     136    void setLayerHostingMode(uint32_t);
     137
     138    void updateLayerHostingContext(LayerHostingMode);
    136139#endif
    137140
     
    139142    void getFormValue(bool& returnValue, String& formValue);
    140143
    141     bool inInitialize() const { return m_pluginCreationParameters; }
    142 
    143     void platformInitialize();
     144    void platformInitialize(const PluginCreationParameters&);
    144145    void platformDestroy();
    145146    void platformGeometryDidChange();
     
    169170    WebCore::RunLoop::Timer<PluginControllerProxy> m_pluginDestroyTimer;
    170171
    171     // Will point to the plug-in creation parameters of the plug-in we're currently initializing and will be null when we're done initializing.
    172     const PluginCreationParameters* m_pluginCreationParameters;
    173 
    174172    // Whether we're waiting for the plug-in proxy in the web process to draw the contents of its
    175173    // backing store into the web process backing store.
  • trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in

    r99242 r112338  
    9999    # Sent when the containing NSWindow's visibility changes
    100100    WindowVisibilityChanged(bool isVisible)
     101
     102    # Sent when the containing window's layer hosting mode changes
     103    SetLayerHostingMode(uint32_t layerHostingMode)
    101104#endif
    102105
  • trunk/Source/WebKit2/PluginProcess/gtk/PluginControllerProxyGtk.cpp

    r95901 r112338  
    3535namespace WebKit {
    3636
    37 void PluginControllerProxy::platformInitialize()
     37void PluginControllerProxy::platformInitialize(const PluginCreationParameters&)
    3838{
    3939    notImplemented();
  • trunk/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm

    r109804 r112338  
    3030
    3131#import "LayerHostingContext.h"
     32#import "PluginCreationParameters.h"
    3233#import "PluginProcess.h"
    3334#import "PluginProxyMessages.h"
     
    5455}
    5556
    56 void PluginControllerProxy::platformInitialize()
     57void PluginControllerProxy::platformInitialize(const PluginCreationParameters& creationParameters)
    5758{
    58     CALayer * platformLayer = m_plugin->pluginLayer();
    59     if (!platformLayer)
    60         return;
    61 
    6259    ASSERT(!m_layerHostingContext);
    63     m_layerHostingContext = LayerHostingContext::createForPort(PluginProcess::shared().compositingRenderServerPort());
    64     m_layerHostingContext->setRootLayer(platformLayer);
     60    updateLayerHostingContext(creationParameters.parameters.layerHostingMode);
    6561}
    6662
     
    113109}
    114110
     111void PluginControllerProxy::setLayerHostingMode(uint32_t opaqueLayerHostingMode)
     112{
     113    LayerHostingMode layerHostingMode = static_cast<LayerHostingMode>(opaqueLayerHostingMode);
     114    updateLayerHostingContext(layerHostingMode);
     115
     116    m_connection->connection()->send(Messages::PluginProxy::SetLayerHostingContextID(m_layerHostingContext->contextID()), m_pluginInstanceID);
     117}
     118
     119void PluginControllerProxy::updateLayerHostingContext(LayerHostingMode layerHostingMode)
     120{
     121    CALayer *platformLayer = m_plugin->pluginLayer();
     122    if (!platformLayer)
     123        return;
     124
     125    if (m_layerHostingContext) {
     126        if (m_layerHostingContext->layerHostingMode() == layerHostingMode)
     127            return;
     128
     129        m_layerHostingContext->invalidate();
     130    }
     131
     132    switch (layerHostingMode) {
     133        case LayerHostingModeDefault:
     134            m_layerHostingContext = LayerHostingContext::createForPort(PluginProcess::shared().compositingRenderServerPort());
     135            break;
     136#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
     137        case LayerHostingModeInWindowServer:
     138            m_layerHostingContext = LayerHostingContext::createForWindowServer();
     139            break;
     140#endif
     141    }
     142
     143    m_layerHostingContext->setRootLayer(platformLayer);
     144}
     145
    115146} // namespace WebKit
    116147
  • trunk/Source/WebKit2/PluginProcess/qt/PluginControllerProxyQt.cpp

    r95901 r112338  
    3636namespace WebKit {
    3737
    38 void PluginControllerProxy::platformInitialize()
     38void PluginControllerProxy::platformInitialize(const PluginCreationParameters&)
    3939{
    4040    notImplemented();
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r111822 r112338  
    206206    virtual uint64_t pluginComplexTextInputIdentifier() const;
    207207    virtual void sendComplexTextInput(const String& textInput);
     208    virtual void setLayerHostingMode(LayerHostingMode) OVERRIDE;
    208209
    209210    void pluginFocusOrWindowFocusChanged();
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm

    r108920 r112338  
    10231023}
    10241024
     1025void NetscapePlugin::setLayerHostingMode(LayerHostingMode)
     1026{
     1027}
     1028
    10251029void NetscapePlugin::pluginFocusOrWindowFocusChanged()
    10261030{
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm

    r95901 r112338  
    3030
    3131#import "PluginController.h"
     32#import "PluginControllerProxyMessages.h"
     33#import "PluginProcessConnection.h"
    3234#import <WebKitSystemInterface.h>
    3335
    3436namespace WebKit {
    3537
     38static void makeRenderLayer(CALayer *pluginLayer, uint32_t layerHostingContextID)
     39{
     40    CALayer *renderLayer = WKMakeRenderLayer(layerHostingContextID);
     41    [renderLayer setFrame:[pluginLayer bounds]];
     42    [renderLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
     43    [pluginLayer setSublayers:[NSArray arrayWithObject:renderLayer]];
     44}
     45
    3646PlatformLayer* PluginProxy::pluginLayer()
    3747{
    3848    if (!m_pluginLayer && m_remoteLayerClientID) {
    39         CALayer *renderLayer = WKMakeRenderLayer(m_remoteLayerClientID);
    40 
    4149        // Create a layer with flipped geometry and add the real plug-in layer as a sublayer
    4250        // so the coordinate system will match the event coordinate system.
    4351        m_pluginLayer.adoptNS([[CALayer alloc] init]);
    4452        [m_pluginLayer.get() setGeometryFlipped:YES];
    45        
    46         [renderLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
    47         [m_pluginLayer.get() addSublayer:renderLayer];
     53
     54        makeRenderLayer(m_pluginLayer.get(), m_remoteLayerClientID);
    4855    }
    4956
     
    6673}
    6774
     75void PluginProxy::setLayerHostingMode(LayerHostingMode layerHostingMode)
     76{
     77    m_connection->connection()->send(Messages::PluginControllerProxy::SetLayerHostingMode(layerHostingMode), m_pluginInstanceID);
     78}
     79
     80void PluginProxy::setLayerHostingContextID(uint32_t layerHostingContextID)
     81{
     82    ASSERT(m_pluginLayer.get());
     83
     84    m_remoteLayerClientID = layerHostingContextID;
     85    makeRenderLayer(m_pluginLayer.get(), m_remoteLayerClientID);
     86}
     87
     88
    6889} // namespace WebKit
    6990
  • trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp

    r109405 r112338  
    641641}
    642642
     643void BuiltInPDFView::setLayerHostingMode(LayerHostingMode)
     644{
     645}
     646
    643647#endif
    644648
  • trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h

    r109405 r112338  
    106106    virtual uint64_t pluginComplexTextInputIdentifier() const;
    107107    virtual void sendComplexTextInput(const String& textInput);
     108    virtual void setLayerHostingMode(LayerHostingMode) OVERRIDE;
    108109#endif
    109110
  • trunk/Source/WebKit2/WebProcess/Plugins/Plugin.cpp

    r111822 r112338  
    4040    encoder->encode(mimeType);
    4141    encoder->encode(loadManually);
     42#if PLATFORM(MAC)
     43    encoder->encodeEnum(layerHostingMode);
     44#endif
    4245}
    4346
     
    5861    if (!decoder->decode(parameters.loadManually))
    5962        return false;
    60 
     63#if PLATFORM(MAC)
     64    if (!decoder->decodeEnum(parameters.layerHostingMode))
     65        return false;
     66#endif
    6167    if (parameters.names.size() != parameters.values.size()) {
    6268        decoder->markInvalid();
  • trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h

    r111822 r112338  
    3434#include <wtf/Vector.h>
    3535
     36#if PLATFORM(MAC)
     37#include "LayerHostingContext.h"
     38#endif
     39
    3640struct NPObject;
    3741
     
    6670        String mimeType;
    6771        bool loadManually;
     72#if PLATFORM(MAC)
     73        LayerHostingMode layerHostingMode;
     74#endif
    6875
    6976        void encode(CoreIPC::ArgumentEncoder*) const;
     
    194201    // Send the complex text input to the plug-in.
    195202    virtual void sendComplexTextInput(const String& textInput) = 0;
     203
     204    // Tells the plug-in about changes to the layer hosting mode.
     205    virtual void setLayerHostingMode(LayerHostingMode) = 0;
    196206#endif
    197207
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h

    r99241 r112338  
    101101    virtual uint64_t pluginComplexTextInputIdentifier() const;
    102102    virtual void sendComplexTextInput(const String& textInput);
     103    virtual void setLayerHostingMode(LayerHostingMode) OVERRIDE;
    103104#endif
    104105
     
    133134    void pluginFocusOrWindowFocusChanged(bool);
    134135    void setComplexTextInputState(uint64_t);
     136    void setLayerHostingContextID(uint32_t);
    135137#endif
    136138
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.messages.in

    r98928 r112338  
    6161    PluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus)
    6262
    63     # Change whether complext text input is enabled for this plug-in.
     63    # Change whether complex text input is enabled for this plug-in.
    6464    SetComplexTextInputState(uint64_t complexTextInputState)
     65
     66    # Update the layer hosting context ID. Called whenever the layer hosting state changes.
     67    SetLayerHostingContextID(uint32_t layerHostingContextID)
    6568#endif
    6669}
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp

    r111822 r112338  
    435435}
    436436
     437void PluginView::setLayerHostingMode(LayerHostingMode layerHostingMode)
     438{
     439    if (!m_plugin)
     440        return;
     441
     442    m_plugin->setLayerHostingMode(layerHostingMode);
     443}
     444
    437445#endif
    438446
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h

    r111822 r112338  
    6666    void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates);
    6767    bool sendComplexTextInput(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
     68    void setLayerHostingMode(LayerHostingMode);
    6869#endif
    6970
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r112184 r112338  
    12681268    parameters.mimeType = mimeType;
    12691269    parameters.loadManually = loadManually;
     1270#if PLATFORM(MAC)
     1271    parameters.layerHostingMode = webPage->layerHostingMode();
     1272#endif
    12701273
    12711274#if PLUGIN_ARCHITECTURE(X11)
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r112084 r112338  
    189189    , m_windowIsVisible(false)
    190190    , m_isSmartInsertDeleteEnabled(parameters.isSmartInsertDeleteEnabled)
     191    , m_layerHostingMode(LayerHostingModeDefault)
    191192    , m_keyboardEventBeingInterpreted(0)
    192193#elif PLATFORM(WIN)
     
    24522453        (*it)->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates);
    24532454}
    2454 
    24552455#endif
    24562456
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r111276 r112338  
    8282#if PLATFORM(MAC)
    8383#include "DictionaryPopupInfo.h"
     84#include "LayerHostingContext.h"
    8485#include <wtf/RetainPtr.h>
    8586OBJC_CLASS NSDictionary;
     
    300301    void removePluginView(PluginView*);
    301302
     303    LayerHostingMode layerHostingMode() const { return m_layerHostingMode; }
     304    void setLayerHostingMode(LayerHostingMode);
     305
    302306    bool windowIsVisible() const { return m_windowIsVisible; }
    303307    const WebCore::IntRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; }
     
    701705    HashSet<PluginView*> m_pluginViews;
    702706
     707    // The layer hosting mode.
     708    LayerHostingMode m_layerHostingMode;
     709
    703710    RetainPtr<WKAccessibilityWebPageObject> m_mockAccessibilityElement;
    704711
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

    r112175 r112338  
    324324        m_layerHostingContext->setRootLayer(m_rootLayer.get());
    325325
     326        m_webPage->setLayerHostingMode(layerHostingMode);
     327
    326328        // Finally, inform the UIProcess that the context has changed.
    327329        LayerTreeContext layerTreeContext;
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r111125 r112338  
    712712}
    713713
     714void WebPage::setLayerHostingMode(LayerHostingMode layerHostingMode)
     715{
     716    m_layerHostingMode = layerHostingMode;
     717
     718    for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
     719        (*it)->setLayerHostingMode(layerHostingMode);
     720}
     721
    714722} // namespace WebKit
Note: See TracChangeset for help on using the changeset viewer.