• dino@apple.com's avatar
    When a primary plugin is restarted, also start similar plugins · cf69686e
    dino@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=113265
    
    Reviewed by Tim Horton.
    
    Source/WebCore:
    
    If we detect a primary plugin that is snapshotted, we immediately restart it.
    When this happens, we should also restart any other plugins that
    match the same origin and type. This allows sites with a lot of
    (geometrically) nearby plugins to behave as if they are a single big plugin.
    
    Tests: plugins/snapshotting/autoplay-similar-to-dominant-after-delay.html
           plugins/snapshotting/autoplay-similar-to-dominant.html
    
    * WebCore.exp.in: Export mimeTypeFromURL.
    * html/HTMLPlugInImageElement.cpp:
    (WebCore::addPlugInsFromNodeListMatchingPlugInOrigin): Use loadedMimeType helper.
    (WebCore::HTMLPlugInImageElement::restartSimilarPlugIns): New method, which copied the
        existing code from userDidClickSnapshot.
    (WebCore::HTMLPlugInImageElement::userDidClickSnapshot): Move the similar plugin detection
        out into another function and call it.
    (WebCore::HTMLPlugInImageElement::setIsPrimarySnapshottedPlugIn): Call restartSimilarPlugIns.
    (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): Use loadedMimeType helper.
    * html/HTMLPlugInImageElement.h: Declaration of restartSimilarPlugIns.
    (WebCore::HTMLPlugInImageElement::loadedMimeType): New helper method since this
        code was being often duplicated.
    
    Source/WebKit2:
    
    Remember the origin of the primary plugin, so that we can
    autostart anything that is similar.
    
    * WebProcess/WebCoreSupport/WebPlugInClient.cpp:
    (WebKit::WebPlugInClient::WebPlugInClient): Keep a pointer to the WebPage.
    (WebKit::WebPlugInClient::shouldAutoStartFromOrigin): Pass the page onto the process.
    * WebProcess/WebCoreSupport/WebPlugInClient.h:
    (WebPlugInClient): New member variable for the WebPage we were created with.
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::determinePrimarySnapshottedPlugIn): Remember the origin information
        for the primary plugin.
    (WebKit::WebPage::matchesPrimaryPlugIn): Returns true if we're seeing something that
        looks like the primary plugin.
    * WebProcess/WebPage/WebPage.h: New method matchesPrimaryPlugIn.
    * WebProcess/WebProcess.cpp:
    (WebKit::WebProcess::shouldPlugInAutoStartFromOrigin): Check if the page thinks this is
        the primary plugin.
    * WebProcess/WebProcess.h: Accept a reference to the page in shouldPlugInAutoStartFromOrigin.
    
    LayoutTests:
    
    Two new tests. The first has one big plugin (that should be detected as the primary)
    and then a few smaller versions (which should autostart along with the primary).
    The second has one big plugin, and then adds a similar one after a short delay.
    
    * platform/mac-wk2/plugins/snapshotting/autoplay-similar-to-dominant-after-delay-expected.txt: Added.
    * platform/mac-wk2/plugins/snapshotting/autoplay-similar-to-dominant-expected.txt: Added.
    * plugins/snapshotting/autoplay-similar-to-dominant-after-delay.html: Added.
    * plugins/snapshotting/autoplay-similar-to-dominant.html: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146946 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    cf69686e
ChangeLog 8.03 MB
The source could not be displayed because it is larger than 1 MB. You can load it anyway or download it instead.