Changeset 66992 in webkit


Ignore:
Timestamp:
Sep 8, 2010 10:08:14 AM (14 years ago)
Author:
aestes@apple.com
Message:

2010-09-08 Andy Estes <aestes@apple.com>

Reviewed by Eric Carlson.

Fallback content should be rendered when an <object> doesn't specify a
data, type or classid attribute.
https://bugs.webkit.org/show_bug.cgi?id=45364
<rdar://problem/8375816>

HTML5 says that if no data or type attribute is specified on an <object>,
fallback content should be rendered. However, WebKit has traditionally
supported specifying a URL and MIME type in <param> elements.

To more closely match the spec while maintaining compatibility with
content that relied on our old behavior, we will continue to load
a resource specified by <param> elements if we can determine a priori
that it will be handled by a plug-in.

If we can't make this determination, and the <object> element has no
"data" or "type" attribute, the <param> elements will be ignored and
fallback content will be rendered. Otherwise, there is no change in
behavior.

  • html/HTMLObjectElement.cpp: (WebCore::HTMLObjectElement::parametersForPlugin): If an empty url is passed to this function and a <param> exists that specifies a url that references a plug-in resource, set it to url, making it the url that will be loaded by the <object> element. (WebCore::HTMLObjectElement::updateWidget): If no type attribute was specified, but there is a classid attribute, try to map the classid to a MIME type. This needs to be done before calling HTMLObjectElement::parametersForPlugin().
  • loader/SubframeLoader.cpp: (WebCore::SubframeLoader::resourceWillUsePlugin): Make a public method that determines if a resource will load a plug-in based on its url and MIME type. This is equivalent to calling SubframeLoader::shouldUsePlugin(), but does not burden the caller with the details of fallback content.
  • loader/SubframeLoader.h:

2010-09-08 Andy Estes <aestes@apple.com>

Reviewed by Eric Carlson.

Fallback content should be rendered when an <object> doesn't specify a
data, type or classid attribute.
https://bugs.webkit.org/show_bug.cgi?id=45364
<rdar://problem/8375816>

  • fast/replaced/object-param-url-control-char.html:
  • fast/replaced/object-with-embed-url-param-expected.txt:
  • fast/replaced/object-with-embed-url-param.html:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r66986 r66992  
     12010-09-08  Andy Estes  <aestes@apple.com>
     2
     3        Reviewed by Eric Carlson.
     4
     5        Fallback content should be rendered when an <object> doesn't specify a
     6        data, type or classid attribute.
     7        https://bugs.webkit.org/show_bug.cgi?id=45364
     8        <rdar://problem/8375816>
     9
     10        * fast/replaced/object-param-url-control-char.html:
     11        * fast/replaced/object-with-embed-url-param-expected.txt:
     12        * fast/replaced/object-with-embed-url-param.html:
     13
    1142010-09-08  Martin Robinson  <mrobinson@igalia.com>
    215
  • trunk/LayoutTests/fast/replaced/object-param-url-control-char.html

    r66137 r66992  
    2222    </head>
    2323    <body>
    24         <object width="0" height="0">
     24        <object width="0" height="0" type="application/x-webkit-test-netscape">
    2525            <param name="movie" value="
    2626  uRl('scheme://url-with-control-char/')
  • trunk/LayoutTests/fast/replaced/object-with-embed-url-param-expected.txt

    r66156 r66992  
    1    
    21This test verifies that the right URL is loaded when there is an <object> with a 'src' <param> and a fallback <embed>.
    32
     
    54An <object> with a 'src' <param> should load the URL from the 'src' <param> and does.
    65An <object> with no URL specified and a nested <embed> should load the URL from the 'src' @attr of the <embed> and does.
    7 
     6An <object> with a URL specified in a 'src' <param> and a nested <embed> should load the URL from the 'src' @attr of the <embed> and does.
     7An <object> with a URL specified in a 'src' <param> and a MIME type specified in a 'type' <param> should load the URL from the 'src' <param> and does.
     8     
  • trunk/LayoutTests/fast/replaced/object-with-embed-url-param.html

    r66173 r66992  
    1010            var object2Result = "";
    1111            var embed3Result = "";
     12            var embed4Result = "";
     13            var object5Result = "";
     14            var notified = false;
    1215
    1316            document.addEventListener("beforeload", function(event) {
    14 
    1517                if (event.url == "")
    1618                    return;
     
    2224                } else if (event.target.id == "embed3") {
    2325                    embed3Result = (event.url == "embed-attr" ? "does" : "does not");
     26                } else if (event.target.id == "embed4") {
     27                    embed4Result = (event.url == "embed-attr" ? "does" : "does not");
     28                } else if (event.target.id == "object5") {
     29                    object5Result = (event.url == "object-param" ? "does" : "does not");
    2430                }
    2531
    26                 if (object1Result != "" && object2Result != "" && embed3Result != "") {
     32                if (!notified && object1Result != "" && object2Result != "" && embed3Result != "" && embed4Result != "" && object5Result != "") {
    2733                    debug("An &lt;object&gt; with a 'data' @attr and a 'src' &lt;param&gt; should load the URL from the 'data' @attr and " + object1Result + ".");
    2834                    debug("An &lt;object&gt; with a 'src' &lt;param&gt; should load the URL from the 'src' &lt;param&gt; and " + object2Result + ".");
    2935                    debug("An &lt;object&gt; with no URL specified and a nested &lt;embed&gt; should load the URL from the 'src' @attr of the &lt;embed&gt; and " + embed3Result + ".");
     36                    debug("An &lt;object&gt; with a URL specified in a 'src' &lt;param&gt; and a nested &lt;embed&gt; should load the URL from the 'src' @attr of the &lt;embed&gt; and " + embed3Result + ".");
     37                    debug("An &lt;object&gt; with a URL specified in a 'src' &lt;param&gt; and a MIME type specified in a 'type' &lt;param&gt; should load the URL from the 'src' &lt;param&gt; and " + object5Result + ".");
     38                    notified = true;
    3039                    if (window.layoutTestController)
    3140                        layoutTestController.notifyDone();
     
    3948    </head>
    4049    <body>
     50        <p>This test verifies that the right URL is loaded when there is an &lt;object&gt; with a 'src' &lt;param&gt; and a fallback &lt;embed&gt;.</p>
     51        <div id="console"></div>
    4152        <object id="object1" type="application/x-webkit-test-netscape" data="object-attr">
    42             <param id="param1" name="src" value="object-param"></param>
     53            <param name="src" value="object-param"></param>
    4354            <embed id="embed1" type="application/x-webkit-test-netscape" src="embed-attr">
    4455        </object>
    4556        <object id="object2" type="application/x-webkit-test-netscape">
    46             <param id="param2" name="movie" value="object-param"></param>
     57            <param name="movie" value="object-param"></param>
    4758            <embed id="embed2" type="application/x-webkit-test-netscape" src="embed-attr">
    4859        </object>
     
    5061            <embed id="embed3" type="application/x-webkit-test-netscape" src="embed-attr">
    5162        </object>
    52         <p>This test verifies that the right URL is loaded when there is an &lt;object&gt; with a 'src' &lt;param&gt; and a fallback &lt;embed&gt;.</p>
    53         <div id="console"></div>
     63        <object id="object4">
     64            <param name="code" value="object-param"></param>
     65            <embed id="embed4" type="application/x-webkit-test-netscape" src="embed-attr">
     66        </object>
     67        <object id="object5">
     68            <param name="url" value="object-param"></param>
     69            <param name="type" value="application/x-webkit-test-netscape"></param>
     70        </object>
    5471    </body>
    5572</html>
  • trunk/WebCore/ChangeLog

    r66989 r66992  
     12010-09-08  Andy Estes  <aestes@apple.com>
     2
     3        Reviewed by Eric Carlson.
     4
     5        Fallback content should be rendered when an <object> doesn't specify a
     6        data, type or classid attribute.
     7        https://bugs.webkit.org/show_bug.cgi?id=45364
     8        <rdar://problem/8375816>
     9
     10        HTML5 says that if no data or type attribute is specified on an <object>,
     11        fallback content should be rendered. However, WebKit has traditionally
     12        supported specifying a URL and MIME type in <param> elements.
     13
     14        To more closely match the spec while maintaining compatibility with
     15        content that relied on our old behavior, we will continue to load
     16        a resource specified by <param> elements if we can determine a priori
     17        that it will be handled by a plug-in.
     18
     19        If we can't make this determination, and the <object> element has no
     20        "data" or "type" attribute, the <param> elements will be ignored and
     21        fallback content will be rendered. Otherwise, there is no change in
     22        behavior.
     23
     24        * html/HTMLObjectElement.cpp:
     25        (WebCore::HTMLObjectElement::parametersForPlugin): If an empty url is
     26        passed to this function and a <param> exists that specifies a url that
     27        references a plug-in resource, set it to url, making it the url that
     28        will be loaded by the <object> element.
     29        (WebCore::HTMLObjectElement::updateWidget): If no type attribute was
     30        specified, but there is a classid attribute, try to map the classid to
     31        a MIME type. This needs to be done before calling
     32        HTMLObjectElement::parametersForPlugin().
     33        * loader/SubframeLoader.cpp:
     34        (WebCore::SubframeLoader::resourceWillUsePlugin): Make a public method
     35        that determines if a resource will load a plug-in based on its url and
     36        MIME type. This is equivalent to calling
     37        SubframeLoader::shouldUsePlugin(), but does not burden the caller with
     38        the details of fallback content.
     39        * loader/SubframeLoader.h:
     40
    1412010-09-08  Pavel Podivilov  <podivilov@chromium.org>
    242
  • trunk/WebCore/html/HTMLObjectElement.cpp

    r66711 r66992  
    164164{
    165165    HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames;
     166    String urlParam;
    166167   
    167168    // Scan the PARAM children and store their name/value pairs.
     
    181182
    182183        // FIXME: url adjustment does not belong in this function.
    183         if (url.isEmpty() && (equalIgnoringCase(name, "src") || equalIgnoringCase(name, "movie") || equalIgnoringCase(name, "code") || equalIgnoringCase(name, "url")))
    184             url = deprecatedParseURL(p->value());
     184        if (url.isEmpty() && urlParam.isEmpty() && (equalIgnoringCase(name, "src") || equalIgnoringCase(name, "movie") || equalIgnoringCase(name, "code") || equalIgnoringCase(name, "url")))
     185            urlParam = deprecatedParseURL(p->value());
    185186        // FIXME: serviceType calculation does not belong in this function.
    186187        if (serviceType.isEmpty() && equalIgnoringCase(name, "type")) {
     
    218219    mapDataParamToSrc(&paramNames, &paramValues);
    219220   
    220     // If we still don't have a type, try to map from a specific CLASSID to a type.
    221     if (serviceType.isEmpty())
    222         serviceType = serviceTypeForClassId(classId());
     221    // HTML5 says that an object resource's URL is specified by the object's data
     222    // attribute, not by a param element. However, for compatibility, allow the
     223    // resource's URL to be given by a param named "src", "movie", "code" or "url"
     224    // if we know that resource points to a plug-in.
     225    if (url.isEmpty() && !urlParam.isEmpty()) {
     226        SubframeLoader* loader = document()->frame()->loader()->subframeLoader();
     227        if (loader->resourceWillUsePlugin(urlParam, serviceType))
     228            url = urlParam;
     229    }
    223230}
    224231
     
    251258
    252259    String url = this->url();
     260   
     261    // If the object does not specify a MIME type via a type attribute, but does
     262    // contain a classid attribute, try to map the classid to a MIME type.
    253263    String serviceType = this->serviceType();
     264    if (serviceType.isEmpty())
     265        serviceType = serviceTypeForClassId(classId());
    254266
    255267    // FIXME: These should be joined into a PluginParameters class.
  • trunk/WebCore/loader/SubframeLoader.cpp

    r66815 r66992  
    8888    return true;
    8989}
     90   
     91bool SubframeLoader::resourceWillUsePlugin(const String& url, const String& mimeType)
     92{
     93    KURL completedURL;
     94    if (!url.isEmpty())
     95        completedURL = completeURL(url);
     96    bool useFallback;
     97    return shouldUsePlugin(completedURL, mimeType, false, useFallback);
     98}
    9099
    91100bool SubframeLoader::requestObject(HTMLPlugInImageElement* ownerElement, const String& url, const AtomicString& frameName,
  • trunk/WebCore/loader/SubframeLoader.h

    r66650 r66992  
    7676
    7777    bool containsPlugins() const { return m_containsPlugins; }
     78   
     79    bool resourceWillUsePlugin(const String&, const String&);
    7880
    7981private:
Note: See TracChangeset for help on using the changeset viewer.