Changeset 66709 in webkit


Ignore:
Timestamp:
Sep 2, 2010 9:04:29 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-09-02 Eric Seidel <eric@webkit.org>

Reviewed by Dimitri Glazkov.

Move more code from RenderEmbeddedObject into the DOM
https://bugs.webkit.org/show_bug.cgi?id=45055

No logic changes here, just taking the code which
I ripped out of RenderEmbeddedObject::updateWidget
into static methods before and moving it into
the applicable DOM classes.

HTMLObjectElement::parametersForPlugin does too much
but in order to fix it I may need to add a PluginParameters
class so we can ask things about the parameters. <object>
needs to get multiple bits of information out of its parameters
array. Right now it does it all in one walk. In order to share
code with HTMLEmbedElement, we need the "generate the params array"
code to be separate from the "make advanced <object> specific decision
from the params array". But that will need to be in a later patch.

No functional changes, thus no tests.

  • html/HTMLEmbedElement.cpp: (WebCore::HTMLEmbedElement::parametersForPlugin):
  • html/HTMLEmbedElement.h:
  • html/HTMLObjectElement.cpp: (WebCore::createClassIdToTypeMap): (WebCore::serviceTypeForClassId): (WebCore::mapDataParamToSrc): (WebCore::HTMLObjectElement::parametersForPlugin): (WebCore::HTMLObjectElement::hasFallbackContent):
  • html/HTMLObjectElement.h:
  • html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::allowedToLoadFrameURL): (WebCore::HTMLPlugInImageElement::wouldLoadAsNetscapePlugin): (WebCore::HTMLPlugInImageElement::detach): (WebCore::HTMLPlugInImageElement::updateWidgetIfNecessary): (WebCore::HTMLPlugInImageElement::updateWidgetCallback):
  • html/HTMLPlugInImageElement.h:
  • rendering/RenderEmbeddedObject.cpp: (WebCore::updateWidgetForObjectElement): (WebCore::updateWidgetForEmbedElement): (WebCore::RenderEmbeddedObject::updateWidget):
Location:
trunk/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r66708 r66709  
     12010-09-02  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Move more code from RenderEmbeddedObject into the DOM
     6        https://bugs.webkit.org/show_bug.cgi?id=45055
     7
     8        No logic changes here, just taking the code which
     9        I ripped out of RenderEmbeddedObject::updateWidget
     10        into static methods before and moving it into
     11        the applicable DOM classes.
     12
     13        HTMLObjectElement::parametersForPlugin does too much
     14        but in order to fix it I may need to add a PluginParameters
     15        class so we can ask things about the parameters. <object>
     16        needs to get multiple bits of information out of its parameters
     17        array.  Right now it does it all in one walk.  In order to share
     18        code with HTMLEmbedElement, we need the "generate the params array"
     19        code to be separate from the "make advanced <object> specific decision
     20        from the params array".  But that will need to be in a later patch.
     21
     22        No functional changes, thus no tests.
     23
     24        * html/HTMLEmbedElement.cpp:
     25        (WebCore::HTMLEmbedElement::parametersForPlugin):
     26        * html/HTMLEmbedElement.h:
     27        * html/HTMLObjectElement.cpp:
     28        (WebCore::createClassIdToTypeMap):
     29        (WebCore::serviceTypeForClassId):
     30        (WebCore::mapDataParamToSrc):
     31        (WebCore::HTMLObjectElement::parametersForPlugin):
     32        (WebCore::HTMLObjectElement::hasFallbackContent):
     33        * html/HTMLObjectElement.h:
     34        * html/HTMLPlugInImageElement.cpp:
     35        (WebCore::HTMLPlugInImageElement::allowedToLoadFrameURL):
     36        (WebCore::HTMLPlugInImageElement::wouldLoadAsNetscapePlugin):
     37        (WebCore::HTMLPlugInImageElement::detach):
     38        (WebCore::HTMLPlugInImageElement::updateWidgetIfNecessary):
     39        (WebCore::HTMLPlugInImageElement::updateWidgetCallback):
     40        * html/HTMLPlugInImageElement.h:
     41        * rendering/RenderEmbeddedObject.cpp:
     42        (WebCore::updateWidgetForObjectElement):
     43        (WebCore::updateWidgetForEmbedElement):
     44        (WebCore::RenderEmbeddedObject::updateWidget):
     45
    1462010-09-02  François Sausset  <sausset@gmail.com>
    247
  • trunk/WebCore/html/HTMLEmbedElement.cpp

    r66659 r66709  
    121121}
    122122
     123void HTMLEmbedElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues)
     124{
     125    NamedNodeMap* attributes = this->attributes(true);
     126    if (!attributes)
     127        return;
     128
     129    for (unsigned i = 0; i < attributes->length(); ++i) {
     130        Attribute* it = attributes->attributeItem(i);
     131        paramNames.append(it->localName());
     132        paramValues.append(it->value());
     133    }
     134}
     135
    123136bool HTMLEmbedElement::rendererIsNeeded(RenderStyle* style)
    124137{
  • trunk/WebCore/html/HTMLEmbedElement.h

    r66659 r66709  
    3232    static PassRefPtr<HTMLEmbedElement> create(const QualifiedName&, Document*, bool createdByParser);
    3333
     34    void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues);
     35
    3436private:
    3537    HTMLEmbedElement(const QualifiedName&, Document*, bool createdByParser);
  • trunk/WebCore/html/HTMLObjectElement.cpp

    r66659 r66709  
    3434#include "HTMLImageLoader.h"
    3535#include "HTMLNames.h"
     36#include "HTMLParamElement.h"
    3637#include "MIMETypeRegistry.h"
    3738#include "RenderEmbeddedObject.h"
     
    116117}
    117118
     119typedef HashMap<String, String, CaseFoldingHash> ClassIdToTypeMap;
     120
     121static ClassIdToTypeMap* createClassIdToTypeMap()
     122{
     123    ClassIdToTypeMap* map = new ClassIdToTypeMap;
     124    map->add("clsid:D27CDB6E-AE6D-11CF-96B8-444553540000", "application/x-shockwave-flash");
     125    map->add("clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA", "audio/x-pn-realaudio-plugin");
     126    map->add("clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B", "video/quicktime");
     127    map->add("clsid:166B1BCA-3F9C-11CF-8075-444553540000", "application/x-director");
     128    map->add("clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6", "application/x-mplayer2");
     129    map->add("clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95", "application/x-mplayer2");
     130    return map;
     131}
     132
     133static String serviceTypeForClassId(const String& classId)
     134{
     135    // Return early if classId is empty (since we won't do anything below).
     136    // Furthermore, if classId is null, calling get() below will crash.
     137    if (classId.isEmpty())
     138        return String();
     139   
     140    static ClassIdToTypeMap* map = createClassIdToTypeMap();
     141    return map->get(classId);
     142}
     143
     144static void mapDataParamToSrc(Vector<String>* paramNames, Vector<String>* paramValues)
     145{
     146    // Some plugins don't understand the "data" attribute of the OBJECT tag (i.e. Real and WMP
     147    // require "src" attribute).
     148    int srcIndex = -1, dataIndex = -1;
     149    for (unsigned int i = 0; i < paramNames->size(); ++i) {
     150        if (equalIgnoringCase((*paramNames)[i], "src"))
     151            srcIndex = i;
     152        else if (equalIgnoringCase((*paramNames)[i], "data"))
     153            dataIndex = i;
     154    }
     155   
     156    if (srcIndex == -1 && dataIndex != -1) {
     157        paramNames->append("src");
     158        paramValues->append((*paramValues)[dataIndex]);
     159    }
     160}
     161
     162// FIXME: This function should not deal with url or serviceType!
     163void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType)
     164{
     165    HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames;
     166   
     167    // Scan the PARAM children and store their name/value pairs.
     168    // Get the URL and type from the params if we don't already have them.
     169    for (Node* child = firstChild(); child; child = child->nextSibling()) {
     170        if (!child->hasTagName(paramTag))
     171            continue;
     172
     173        HTMLParamElement* p = static_cast<HTMLParamElement*>(child);
     174        String name = p->name();
     175        if (name.isEmpty())
     176            continue;
     177
     178        uniqueParamNames.add(name.impl());
     179        paramNames.append(p->name());
     180        paramValues.append(p->value());
     181
     182        // 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());
     185        // FIXME: serviceType calculation does not belong in this function.
     186        if (serviceType.isEmpty() && equalIgnoringCase(name, "type")) {
     187            serviceType = p->value();
     188            size_t pos = serviceType.find(";");
     189            if (pos != notFound)
     190                serviceType = serviceType.left(pos);
     191        }
     192    }
     193   
     194    // When OBJECT is used for an applet via Sun's Java plugin, the CODEBASE attribute in the tag
     195    // points to the Java plugin itself (an ActiveX component) while the actual applet CODEBASE is
     196    // in a PARAM tag. See <http://java.sun.com/products/plugin/1.2/docs/tags.html>. This means
     197    // we have to explicitly suppress the tag's CODEBASE attribute if there is none in a PARAM,
     198    // else our Java plugin will misinterpret it. [4004531]
     199    String codebase;
     200    if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType)) {
     201        codebase = "codebase";
     202        uniqueParamNames.add(codebase.impl()); // pretend we found it in a PARAM already
     203    }
     204   
     205    // Turn the attributes of the <object> element into arrays, but don't override <param> values.
     206    NamedNodeMap* attributes = this->attributes(true);
     207    if (attributes) {
     208        for (unsigned i = 0; i < attributes->length(); ++i) {
     209            Attribute* it = attributes->attributeItem(i);
     210            const AtomicString& name = it->name().localName();
     211            if (!uniqueParamNames.contains(name.impl())) {
     212                paramNames.append(name.string());
     213                paramValues.append(it->value().string());
     214            }
     215        }
     216    }
     217   
     218    mapDataParamToSrc(&paramNames, &paramValues);
     219   
     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());
     223}
     224
     225   
     226bool HTMLObjectElement::hasFallbackContent() const
     227{
     228    for (Node* child = firstChild(); child; child = child->nextSibling()) {
     229        // Ignore whitespace-only text, and <param> tags, any other content is fallback content.
     230        if (child->isTextNode()) {
     231            if (!static_cast<Text*>(child)->containsOnlyWhitespace())
     232                return true;
     233        } else if (!child->hasTagName(paramTag))
     234            return true;
     235    }
     236    return false;
     237}
     238
    118239bool HTMLObjectElement::rendererIsNeeded(RenderStyle* style)
    119240{
  • trunk/WebCore/html/HTMLObjectElement.h

    r66659 r66709  
    4040    bool containsJavaApplet() const;
    4141
     42    bool hasFallbackContent() const;
    4243    virtual bool useFallbackContent() const { return m_useFallbackContent; }
     44
     45    // FIXME: This function should not deal with url or serviceType
     46    // so that we can better share code between <object> and <embed>.
     47    void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType);
    4348
    4449private:
  • trunk/WebCore/html/HTMLPlugInImageElement.cpp

    r66659 r66709  
    2727#include "HTMLImageLoader.h"
    2828#include "Image.h"
     29#include "Page.h"
    2930#include "RenderEmbeddedObject.h"
    3031#include "RenderImage.h"
     
    6263
    6364    return Image::supportsType(m_serviceType);
     65}
     66
     67// We don't use m_url, as it may not be the final URL that the object loads,
     68// depending on <param> values.
     69bool HTMLPlugInImageElement::allowedToLoadFrameURL(const String& url)
     70{
     71    ASSERT(document());
     72    ASSERT(document()->frame());
     73    if (document()->frame()->page()->frameCount() >= Page::maxNumberOfFrames)
     74        return false;
     75
     76    // We allow one level of self-reference because some sites depend on that.
     77    // But we don't allow more than one.
     78    KURL completeURL = document()->completeURL(url);
     79    bool foundSelfReference = false;
     80    for (Frame* frame = document()->frame(); frame; frame = frame->tree()->parent()) {
     81        if (equalIgnoringFragmentIdentifier(frame->loader()->url(), completeURL)) {
     82            if (foundSelfReference)
     83                return false;
     84            foundSelfReference = true;
     85        }
     86    }
     87    return true;
     88}
     89
     90// We don't use m_url, or m_serviceType as they may not be the final values
     91// that <object> uses depending on <param> values.
     92bool HTMLPlugInImageElement::wouldLoadAsNetscapePlugin(const String& url, const String& serviceType)
     93{
     94    ASSERT(document());
     95    ASSERT(document()->frame());
     96    FrameLoader* frameLoader = document()->frame()->loader();
     97    ASSERT(frameLoader);
     98    KURL completedURL;
     99    if (!url.isEmpty())
     100        completedURL = frameLoader->completeURL(url);
     101
     102    if (frameLoader->client()->objectContentType(completedURL, serviceType) == ObjectContentNetscapePlugin)
     103        return true;
     104    return false;
    64105}
    65106
     
    107148void HTMLPlugInImageElement::detach()
    108149{
    109     // FIXME: Because of the insanity that is HTMLObjectElement::recalcStyle,
     150    // FIXME: Because of the insanity that is HTMLPlugInImageElement::recalcStyle,
    110151    // we can end up detaching during an attach() call, before we even have a
    111152    // renderer.  In that case, don't mark the widget for update.
     
    116157}
    117158
    118 void HTMLPlugInImageElement::updateWidget()
     159void HTMLPlugInImageElement::updateWidgetIfNecessary()
    119160{
    120161    document()->updateStyleIfNeeded();
     
    143184void HTMLPlugInImageElement::updateWidgetCallback(Node* n)
    144185{
    145     static_cast<HTMLPlugInImageElement*>(n)->updateWidget();
     186    static_cast<HTMLPlugInImageElement*>(n)->updateWidgetIfNecessary();
    146187}
    147188
  • trunk/WebCore/html/HTMLPlugInImageElement.h

    r66659 r66709  
    2828
    2929class HTMLImageLoader;
     30class FrameLoader;
    3031
    3132// Base class for HTMLObjectElement and HTMLEmbedElement
     
    3536    const String& url() const { return m_url; }
    3637
     38    // These can all move to be protected once updateWidget is moved out of RenderEmbeddedObject.cpp
    3739    bool needsWidgetUpdate() const { return m_needsWidgetUpdate; }
    3840    void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; }
     41    bool allowedToLoadFrameURL(const String& url);
     42    bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType);
    3943
    4044    RenderEmbeddedObject* renderEmbeddedObject() const;
     
    6165    virtual void willMoveToNewOwnerDocument();
    6266
    63     void updateWidget();
     67    void updateWidgetIfNecessary();
    6468    virtual bool useFallbackContent() const { return false; }
    6569   
  • trunk/WebCore/rendering/RenderEmbeddedObject.cpp

    r66650 r66709  
    102102}
    103103#endif
    104 
    105 // FIXME: This belongs in HTMLPluginElement.cpp to be shared by HTMLObjectElement and HTMLEmbedElement.
    106 static bool isURLAllowed(Document* doc, const String& url)
    107 {
    108     if (doc->frame()->page()->frameCount() >= Page::maxNumberOfFrames)
    109         return false;
    110 
    111     // We allow one level of self-reference because some sites depend on that.
    112     // But we don't allow more than one.
    113     KURL completeURL = doc->completeURL(url);
    114     bool foundSelfReference = false;
    115     for (Frame* frame = doc->frame(); frame; frame = frame->tree()->parent()) {
    116         if (equalIgnoringFragmentIdentifier(frame->loader()->url(), completeURL)) {
    117             if (foundSelfReference)
    118                 return false;
    119             foundSelfReference = true;
    120         }
    121     }
    122     return true;
    123 }
    124 
    125 typedef HashMap<String, String, CaseFoldingHash> ClassIdToTypeMap;
    126 
    127 // FIXME: This belongs in HTMLObjectElement.cpp
    128 static ClassIdToTypeMap* createClassIdToTypeMap()
    129 {
    130     ClassIdToTypeMap* map = new ClassIdToTypeMap;
    131     map->add("clsid:D27CDB6E-AE6D-11CF-96B8-444553540000", "application/x-shockwave-flash");
    132     map->add("clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA", "audio/x-pn-realaudio-plugin");
    133     map->add("clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B", "video/quicktime");
    134     map->add("clsid:166B1BCA-3F9C-11CF-8075-444553540000", "application/x-director");
    135     map->add("clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6", "application/x-mplayer2");
    136     map->add("clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95", "application/x-mplayer2");
    137     return map;
    138 }
    139 
    140 // FIXME: This belongs in HTMLObjectElement.cpp
    141 static String serviceTypeForClassId(const String& classId)
    142 {
    143     // Return early if classId is empty (since we won't do anything below).
    144     // Furthermore, if classId is null, calling get() below will crash.
    145     if (classId.isEmpty())
    146         return String();
    147 
    148     static ClassIdToTypeMap* map = createClassIdToTypeMap();
    149     return map->get(classId);
    150 }
    151 
    152 // FIXME: This belongs in HTMLObjectElement.cpp
    153 static void mapDataParamToSrc(Vector<String>* paramNames, Vector<String>* paramValues)
    154 {
    155     // Some plugins don't understand the "data" attribute of the OBJECT tag (i.e. Real and WMP
    156     // require "src" attribute).
    157     int srcIndex = -1, dataIndex = -1;
    158     for (unsigned int i = 0; i < paramNames->size(); ++i) {
    159         if (equalIgnoringCase((*paramNames)[i], "src"))
    160             srcIndex = i;
    161         else if (equalIgnoringCase((*paramNames)[i], "data"))
    162             dataIndex = i;
    163     }
    164 
    165     if (srcIndex == -1 && dataIndex != -1) {
    166         paramNames->append("src");
    167         paramValues->append((*paramValues)[dataIndex]);
    168     }
    169 }
    170 
    171 // FIXME: This belongs in some loader header?
    172 static bool isNetscapePlugin(Frame* frame, const String& url, const String& serviceType)
    173 {
    174     KURL completedURL;
    175     if (!url.isEmpty())
    176         completedURL = frame->loader()->completeURL(url);
    177 
    178     if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentNetscapePlugin)
    179         return true;
    180     return false;
    181 }
    182 
    183 // FIXME: This belongs on HTMLObjectElement.
    184 static bool hasFallbackContent(HTMLObjectElement* objectElement)
    185 {
    186     for (Node* child = objectElement->firstChild(); child; child = child->nextSibling()) {
    187         if ((!child->isTextNode() && !child->hasTagName(paramTag)) // Discount <param>
    188             || (child->isTextNode() && !static_cast<Text*>(child)->containsOnlyWhitespace()))
    189             return true;
    190     }
    191     return false;
    192 }
    193 
    194 // FIXME: This belongs on HTMLObjectElement.
    195 static void parametersFromObject(HTMLObjectElement* objectElement, Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType)
    196 {
    197     HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames;
    198 
    199     // Scan the PARAM children and store their name/value pairs.
    200     // Get the URL and type from the params if we don't already have them.
    201     Node* child = objectElement->firstChild();
    202     while (child) {
    203         if (child->hasTagName(paramTag)) {
    204             HTMLParamElement* p = static_cast<HTMLParamElement*>(child);
    205             String name = p->name();
    206             if (url.isEmpty() && (equalIgnoringCase(name, "src") || equalIgnoringCase(name, "movie") || equalIgnoringCase(name, "code") || equalIgnoringCase(name, "url")))
    207                 url = deprecatedParseURL(p->value());
    208             // FIXME: serviceType calculation does not belong in this function.
    209             if (serviceType.isEmpty() && equalIgnoringCase(name, "type")) {
    210                 serviceType = p->value();
    211                 size_t pos = serviceType.find(";");
    212                 if (pos != notFound)
    213                     serviceType = serviceType.left(pos);
    214             }
    215             if (!name.isEmpty()) {
    216                 uniqueParamNames.add(name.impl());
    217                 paramNames.append(p->name());
    218                 paramValues.append(p->value());
    219             }
    220         }
    221         child = child->nextSibling();
    222     }
    223 
    224     // When OBJECT is used for an applet via Sun's Java plugin, the CODEBASE attribute in the tag
    225     // points to the Java plugin itself (an ActiveX component) while the actual applet CODEBASE is
    226     // in a PARAM tag. See <http://java.sun.com/products/plugin/1.2/docs/tags.html>. This means
    227     // we have to explicitly suppress the tag's CODEBASE attribute if there is none in a PARAM,
    228     // else our Java plugin will misinterpret it. [4004531]
    229     String codebase;
    230     if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType)) {
    231         codebase = "codebase";
    232         uniqueParamNames.add(codebase.impl()); // pretend we found it in a PARAM already
    233     }
    234 
    235     // Turn the attributes of the <object> element into arrays, but don't override <param> values.
    236     NamedNodeMap* attributes = objectElement->attributes();
    237     if (attributes) {
    238         for (unsigned i = 0; i < attributes->length(); ++i) {
    239             Attribute* it = attributes->attributeItem(i);
    240             const AtomicString& name = it->name().localName();
    241             if (!uniqueParamNames.contains(name.impl())) {
    242                 paramNames.append(name.string());
    243                 paramValues.append(it->value().string());
    244             }
    245         }
    246     }
    247 
    248     mapDataParamToSrc(&paramNames, &paramValues);
    249 
    250     // If we still don't have a type, try to map from a specific CLASSID to a type.
    251     if (serviceType.isEmpty())
    252         serviceType = serviceTypeForClassId(objectElement->classId());
    253 }
    254 
     104   
    255105// FIXME: This belongs on HTMLObjectElement, HTMLPluginElement or HTMLFrameOwnerElement.
    256106static void updateWidgetForObjectElement(HTMLObjectElement* objectElement, bool onlyCreateNonNetscapePlugins)
    257107{
     108    // FIXME: We should ASSERT(objectElement->needsWidgetUpdate()), but currently
     109    // FrameView::updateWidget() calls updateWidget(false) without checking if
     110    // the widget actually needs updating!
    258111    objectElement->setNeedsWidgetUpdate(false);
     112    // FIXME: This should ASSERT isFinishedParsingChildren() instead.
    259113    if (!objectElement->isFinishedParsingChildren())
    260114        return;
    261115
    262     Frame* frame = objectElement->document()->frame();
    263116    String url = objectElement->url();
    264117    String serviceType = objectElement->serviceType();
     
    266119    Vector<String> paramNames;
    267120    Vector<String> paramValues;
    268     parametersFromObject(objectElement, paramNames, paramValues, url, serviceType);
    269 
    270     if (!isURLAllowed(objectElement->document(), url))
    271         return;
    272 
    273     bool fallbackContent = hasFallbackContent(objectElement);
     121    objectElement->parametersForPlugin(paramNames, paramValues, url, serviceType);
     122
     123    // Note: url is modified above by parametersForPlugin.
     124    if (!objectElement->allowedToLoadFrameURL(url))
     125        return;
     126
     127    bool fallbackContent = objectElement->hasFallbackContent();
    274128    objectElement->renderEmbeddedObject()->setHasFallbackContent(fallbackContent);
    275129
    276     if (onlyCreateNonNetscapePlugins && isNetscapePlugin(frame, url, serviceType))
     130    if (onlyCreateNonNetscapePlugins && objectElement->wouldLoadAsNetscapePlugin(url, serviceType))
    277131        return;
    278132
     
    286140        return;
    287141
    288     bool success = beforeLoadAllowedLoad && frame->loader()->subframeLoader()->requestObject(objectElement, url, objectElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
     142    SubframeLoader* loader = objectElement->document()->frame()->loader()->subframeLoader();
     143    bool success = beforeLoadAllowedLoad && loader->requestObject(objectElement, url, objectElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
    289144
    290145    if (!success && fallbackContent)
     
    292147}
    293148
    294 // FIXME: This belongs on HTMLEmbedElement.
    295 static void parametersFromEmbed(HTMLEmbedElement* embedElement, Vector<String>& paramNames, Vector<String>& paramValues)
    296 {
    297     NamedNodeMap* attributes = embedElement->attributes();
    298     if (attributes) {
    299         for (unsigned i = 0; i < attributes->length(); ++i) {
    300             Attribute* it = attributes->attributeItem(i);
    301             paramNames.append(it->name().localName().string());
    302             paramValues.append(it->value().string());
    303         }
    304     }
    305 }
    306 
    307149// FIXME: This belongs on HTMLEmbedElement, HTMLPluginElement or HTMLFrameOwnerElement.
    308150static void updateWidgetForEmbedElement(HTMLEmbedElement* embedElement, bool onlyCreateNonNetscapePlugins)
    309151{
    310     Frame* frame = embedElement->document()->frame();
     152    // FIXME: We should ASSERT(embedElement->needsWidgetUpdate()), but currently
     153    // FrameView::updateWidget() calls updateWidget(false) without checking if
     154    // the widget actually needs updating!
     155    embedElement->setNeedsWidgetUpdate(false);
     156
    311157    String url = embedElement->url();
    312158    String serviceType = embedElement->serviceType();
    313 
    314     embedElement->setNeedsWidgetUpdate(false);
    315 
    316159    if (url.isEmpty() && serviceType.isEmpty())
    317160        return;
    318     if (!isURLAllowed(embedElement->document(), url))
     161    if (!embedElement->allowedToLoadFrameURL(url))
     162        return;
     163
     164    if (onlyCreateNonNetscapePlugins && embedElement->wouldLoadAsNetscapePlugin(url, serviceType))
    319165        return;
    320166
    321167    Vector<String> paramNames;
    322168    Vector<String> paramValues;
    323     parametersFromEmbed(embedElement, paramNames, paramValues);
    324 
    325     if (onlyCreateNonNetscapePlugins && isNetscapePlugin(frame, url, serviceType))
    326         return;
    327 
    328     if (embedElement->dispatchBeforeLoadEvent(url)) {
    329         // FIXME: beforeLoad could have detached the renderer!  Just like in the <object> case above.
    330         frame->loader()->subframeLoader()->requestObject(embedElement, url, embedElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
    331     }
     169    embedElement->parametersForPlugin(paramNames, paramValues);
     170
     171    if (!embedElement->dispatchBeforeLoadEvent(url))
     172        return;
     173
     174    SubframeLoader* loader = embedElement->document()->frame()->loader()->subframeLoader();
     175    // FIXME: beforeLoad could have detached the renderer!  Just like in the <object> case above.
     176    loader->requestObject(embedElement, url, embedElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
    332177}
    333178
     
    370215    }
    371216#endif
     217    else
     218        ASSERT_NOT_REACHED();
    372219}
    373220
Note: See TracChangeset for help on using the changeset viewer.