Changeset 104746 in webkit


Ignore:
Timestamp:
Jan 11, 2012 2:13:24 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

https://bugs.webkit.org/show_bug.cgi?id=76088
The common case of content type = text/plain is not optimized and the plugin database is initialized instead

In the dom/DOMImplementation.cpp file you can find the comment that text/plain is
optimized so that the plugin database is not loaded. Unfortunately, this has been
regressed since the patch for http://bugs.webkit.org/show_bug.cgi?id=16815 which
refactored a bunch of the plugin code. Now, the plugin database is initialized
before we handle text/plain. This line in DOMImplementation.cpp triggers
the plugin initialization:

pluginData = frame->page()->pluginData();

The case of image types != PDF and the case of HTML5 video content type are also
not optimized to be handled before plugin initialization.

The solution is to refactor so all of these content types are handled before
we initialize the plugin database.

Patch by Adam Treat <atreat@rim.com> on 2012-01-11
Reviewed by Adam Treat.

  • dom/DOMImplementation.cpp:

(WebCore::DOMImplementation::createDocument):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r104742 r104746  
     12012-01-11  Adam Treat  <atreat@rim.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=76088
     4        The common case of content type = text/plain is not optimized and the plugin database is initialized instead
     5
     6        In the dom/DOMImplementation.cpp file you can find the comment that text/plain is
     7        optimized so that the plugin database is not loaded. Unfortunately, this has been
     8        regressed since the patch for http://bugs.webkit.org/show_bug.cgi?id=16815 which
     9        refactored a bunch of the plugin code.  Now, the plugin database is initialized
     10        before we handle text/plain.  This line in DOMImplementation.cpp triggers
     11        the plugin initialization:
     12
     13                pluginData = frame->page()->pluginData();
     14
     15        The case of image types != PDF and the case of HTML5 video content type are also
     16        not optimized to be handled before plugin initialization.
     17
     18        The solution is to refactor so all of these content types are handled before
     19        we initialize the plugin database.
     20
     21        Reviewed by Adam Treat.
     22
     23        * dom/DOMImplementation.cpp:
     24        (WebCore::DOMImplementation::createDocument):
     25
    1262012-01-11  Alexandre Elias  <aelias@google.com>
    227
  • trunk/Source/WebCore/dom/DOMImplementation.cpp

    r100696 r104746  
    319319    if (type == "text/html")
    320320        return HTMLDocument::create(frame, url);
     321
     322    // Plugins cannot take text/plain from us either.
     323    if (type == "text/plain")
     324        return TextDocument::create(frame, url);
     325
    321326    if (type == "application/xhtml+xml")
    322327        return Document::createXHTML(frame, url);
    323328
    324329#if ENABLE(FTPDIR)
    325     // Plugins cannot take FTP from us either
     330    // Plugins cannot take FTP from us either.
    326331    if (type == "application/x-ftp-directory")
    327332        return FTPDirectoryDocument::create(frame, url);
    328333#endif
    329334
     335    // PDF is the only image type for which a plugin can override built-in support.
     336    if (Image::supportsType(type) && type != "application/pdf" && type != "text/pdf")
     337        return ImageDocument::create(frame, url);
     338
     339#if ENABLE(VIDEO)
     340     // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument as
     341     // this can not be taken by plugins either.
     342     if (MediaPlayer::supportsType(ContentType(type)))
     343         return MediaDocument::create(frame, url);
     344#endif
     345
     346    // The plugin database is initialized at this point if plugins are enabled
     347    // which is non-zero overhead.
    330348    PluginData* pluginData = 0;
    331349    if (frame && frame->page() && frame->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin))
    332350        pluginData = frame->page()->pluginData();
    333351
    334     // PDF is one image type for which a plugin can override built-in support.
    335     // We do not want QuickTime to take over all image types, obviously.
    336     if ((type == "application/pdf" || type == "text/pdf") && pluginData && pluginData->supportsMimeType(type))
     352    // At this point anything that can be supported can be overridden by plugins.
     353    if (pluginData && pluginData->supportsMimeType(type))
    337354        return PluginDocument::create(frame, url);
     355
     356    // Handle PDF for instance if it was not handled by a plugin.
    338357    if (Image::supportsType(type))
    339358        return ImageDocument::create(frame, url);
    340359
    341 #if ENABLE(VIDEO)
    342      // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument
    343      if (MediaPlayer::supportsType(ContentType(type)))
    344          return MediaDocument::create(frame, url);
    345 #endif
    346 
    347     // Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed.
    348     // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle,
    349     // and also serves as an optimization to prevent loading the plug-in database in the common case.
    350     if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type))
    351         return PluginDocument::create(frame, url);
     360    // Handle a text document was not handled by a plugin.
    352361    if (isTextMIMEType(type))
    353362        return TextDocument::create(frame, url);
Note: See TracChangeset for help on using the changeset viewer.