Changeset 87945 in webkit


Ignore:
Timestamp:
Jun 2, 2011 12:59:17 PM (13 years ago)
Author:
andersca@apple.com
Message:

2011-06-02 Anders Carlsson <andersca@apple.com>

Reviewed by Simon Fraser.

Add quirk for plug-ins that return a retained CALayer
https://bugs.webkit.org/show_bug.cgi?id=61948
<rdar://problem/9530390>

  • Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm: (WebKit::NetscapePluginModule::determineQuirks): Set the ReturnsRetainedCoreAnimationLayer quirk for Flash.
  • Shared/Plugins/PluginQuirks.h: Add ReturnsRetainedCoreAnimationLayer quirk.
  • WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp: (WebKit::NPN_GetValue): Handle WKNVExpectsNonretainedLayer by always returning true, and also call NetscapePlugin::setPluginReturnsNonretainedLayer(true) to add a way for plug-ins to opt into returning non-retained layers even if they have the quirk specified.
  • WebProcess/Plugins/Netscape/NetscapePlugin.cpp: (WebKit::NetscapePlugin::NetscapePlugin): Initialize m_pluginReturnsNonretainedLayer to true.
  • WebProcess/Plugins/Netscape/NetscapePlugin.h: (WebKit::NetscapePlugin::setPluginReturnsNonretainedLayer): Add setter.
  • WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: (WebKit::NetscapePlugin::platformPostInitialize): If m_pluginReturnsNonretainedLayer is false, adopt the layer.
Location:
trunk/Source/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r87943 r87945  
     12011-06-02  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Add quirk for plug-ins that return a retained CALayer
     6        https://bugs.webkit.org/show_bug.cgi?id=61948
     7        <rdar://problem/9530390>
     8
     9        * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
     10        (WebKit::NetscapePluginModule::determineQuirks):
     11        Set the ReturnsRetainedCoreAnimationLayer quirk for Flash.
     12
     13        * Shared/Plugins/PluginQuirks.h:
     14        Add ReturnsRetainedCoreAnimationLayer quirk.
     15
     16        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
     17        (WebKit::NPN_GetValue):
     18        Handle WKNVExpectsNonretainedLayer by always returning true, and also
     19        call NetscapePlugin::setPluginReturnsNonretainedLayer(true) to add a way
     20        for plug-ins to opt into returning non-retained layers even if they have
     21        the quirk specified.
     22
     23        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
     24        (WebKit::NetscapePlugin::NetscapePlugin):
     25        Initialize m_pluginReturnsNonretainedLayer to true.
     26
     27        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
     28        (WebKit::NetscapePlugin::setPluginReturnsNonretainedLayer):
     29        Add setter.
     30
     31        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
     32        (WebKit::NetscapePlugin::platformPostInitialize):
     33        If m_pluginReturnsNonretainedLayer is false, adopt the layer.
     34
    1352011-06-02  Brent Fulgham  <bfulgham@webkit.org>
    236
  • trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm

    r86578 r87945  
    419419        // We can short circuit some NPRuntime calls during initialization.
    420420        m_pluginQuirks.add(PluginQuirks::CanShortCircuitSomeNPRuntimeCallsDuringInitialization);
     421
     422        // Flash returns a retained Core Animation layer.
     423        m_pluginQuirks.add(PluginQuirks::ReturnsRetainedCoreAnimationLayer);
    421424    }
    422425
  • trunk/Source/WebKit2/Shared/Plugins/PluginQuirks.h

    r86578 r87945  
    5555        CanShortCircuitSomeNPRuntimeCallsDuringInitialization,
    5656
     57        // Whether calling NPP_GetValue with NPPVpluginCoreAnimationLayer returns a retained Core Animation
     58        // layer or not. According to the NPAPI specifications, plug-in shouldn't return a retained layer but
     59        // WebKit1 expects a retained plug-in layer. We use this for Flash to avoid leaking OpenGL layers.
     60        ReturnsRetainedCoreAnimationLayer,
     61
    5762#ifndef NP_NO_QUICKDRAW
    5863        // Allow the plug-in to use the QuickDraw drawing model, since we know that the plug-in
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp

    r86577 r87945  
    409409
    410410#if PLATFORM(MAC)
    411 // true if the browser supports hardware compositing of Core Animation plug-ins.
     411// Whether the browser supports compositing of Core Animation plug-ins.
    412412static const unsigned WKNVSupportsCompositingCoreAnimationPluginsBool = 74656;
     413
     414// Whether the browser expects a non-retained Core Animation layer.
     415static const unsigned WKNVExpectsNonretainedLayer = 74657;
    413416
    414417// The Core Animation render server port.
     
    469472            break;
    470473        }
    471        
     474
     475        case WKNVExpectsNonretainedLayer: {
     476            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
     477
     478            // Asking for this will make us expect a non-retained layer from the plug-in.
     479            plugin->setPluginReturnsNonretainedLayer(true);
     480            *(NPBool*)value = true;
     481            break;
     482        }
     483
    472484#ifndef NP_NO_QUICKDRAW
    473485        case NPNVsupportsQuickDrawBool:
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

    r86577 r87945  
    7171    , m_drawingModel(static_cast<NPDrawingModel>(-1))
    7272    , m_eventModel(static_cast<NPEventModel>(-1))
     73    , m_pluginReturnsNonretainedLayer(!m_pluginModule->pluginQuirks().contains(PluginQuirks::ReturnsRetainedCoreAnimationLayer))
    7374    , m_currentMouseEvent(0)
    7475    , m_pluginHasFocus(false)
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r86577 r87945  
    5858    NPError popUpContextMenu(NPMenu*);
    5959
     60    void setPluginReturnsNonretainedLayer(bool pluginReturnsNonretainedLayer) { m_pluginReturnsNonretainedLayer = pluginReturnsNonretainedLayer; }
     61
    6062    mach_port_t compositingRenderServerPort();
    6163
     
    226228    NPDrawingModel m_drawingModel;
    227229    NPEventModel m_eventModel;
     230
    228231    RetainPtr<PlatformLayer> m_pluginLayer;
     232    bool m_pluginReturnsNonretainedLayer;
    229233
    230234    NPCocoaEvent* m_currentMouseEvent;
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm

    r86580 r87945  
    234234        if (NPP_GetValue(NPPVpluginCoreAnimationLayer, &value) == NPERR_NO_ERROR && value) {
    235235            ASSERT(!m_pluginLayer);
    236             m_pluginLayer = reinterpret_cast<CALayer *>(value);
     236
     237            // The original Core Animation drawing model required that plug-ins pass a retained layer
     238            // to the browser, which the browser would then adopt. However, the final spec changed this
     239            // (See https://wiki.mozilla.org/NPAPI:CoreAnimationDrawingModel for more information)
     240            // after a version of WebKit1 with the original implementation had shipped, but that now means
     241            // that any plug-ins that expect the WebKit1 behavior would leak the CALayer.
     242            // For plug-ins that we know return retained layers, we have the ReturnsRetainedCoreAnimationLayer
     243            // plug-in quirk. Plug-ins can also check for whether the browser expects a non-retained layer to
     244            // be returned by using NPN_GetValue and pass the WKNVExpectsNonretainedLayer parameter.
     245            // https://bugs.webkit.org/show_bug.cgi?id=58282 describes the bug where WebKit expects retained layers.
     246            if (m_pluginReturnsNonretainedLayer)
     247                m_pluginLayer = reinterpret_cast<CALayer *>(value);
     248            else
     249                m_pluginLayer.adoptNS(reinterpret_cast<CALayer *>(value));
    237250        }
    238251    }
Note: See TracChangeset for help on using the changeset viewer.