[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

eric at webkit.org eric at webkit.org
Wed Dec 22 12:58:15 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 918affb8f0cc06457748cd4a30e8dea3602d6a61
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 3 04:04:29 2010 +0000

    2010-09-02  Eric Seidel  <eric at 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):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66709 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d3c32a5..4c5c878 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,48 @@
+2010-09-02  Eric Seidel  <eric at 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):
+
 2010-09-02  François Sausset  <sausset at gmail.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/html/HTMLEmbedElement.cpp b/WebCore/html/HTMLEmbedElement.cpp
index eeb28e7..74b9715 100644
--- a/WebCore/html/HTMLEmbedElement.cpp
+++ b/WebCore/html/HTMLEmbedElement.cpp
@@ -120,6 +120,19 @@ void HTMLEmbedElement::parseMappedAttribute(Attribute* attr)
         HTMLPlugInImageElement::parseMappedAttribute(attr);
 }
 
+void HTMLEmbedElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues)
+{
+    NamedNodeMap* attributes = this->attributes(true);
+    if (!attributes)
+        return;
+
+    for (unsigned i = 0; i < attributes->length(); ++i) {
+        Attribute* it = attributes->attributeItem(i);
+        paramNames.append(it->localName());
+        paramValues.append(it->value());
+    }
+}
+
 bool HTMLEmbedElement::rendererIsNeeded(RenderStyle* style)
 {
     if (isImageType())
diff --git a/WebCore/html/HTMLEmbedElement.h b/WebCore/html/HTMLEmbedElement.h
index e27b717..d4a4d7f 100644
--- a/WebCore/html/HTMLEmbedElement.h
+++ b/WebCore/html/HTMLEmbedElement.h
@@ -31,6 +31,8 @@ class HTMLEmbedElement : public HTMLPlugInImageElement {
 public:
     static PassRefPtr<HTMLEmbedElement> create(const QualifiedName&, Document*, bool createdByParser);
 
+    void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues);
+
 private:
     HTMLEmbedElement(const QualifiedName&, Document*, bool createdByParser);
 
diff --git a/WebCore/html/HTMLObjectElement.cpp b/WebCore/html/HTMLObjectElement.cpp
index e8884ef..2b879ba 100644
--- a/WebCore/html/HTMLObjectElement.cpp
+++ b/WebCore/html/HTMLObjectElement.cpp
@@ -33,6 +33,7 @@
 #include "HTMLFormElement.h"
 #include "HTMLImageLoader.h"
 #include "HTMLNames.h"
+#include "HTMLParamElement.h"
 #include "MIMETypeRegistry.h"
 #include "RenderEmbeddedObject.h"
 #include "RenderImage.h"
@@ -115,6 +116,126 @@ void HTMLObjectElement::parseMappedAttribute(Attribute* attr)
         HTMLPlugInImageElement::parseMappedAttribute(attr);
 }
 
+typedef HashMap<String, String, CaseFoldingHash> ClassIdToTypeMap;
+
+static ClassIdToTypeMap* createClassIdToTypeMap()
+{
+    ClassIdToTypeMap* map = new ClassIdToTypeMap;
+    map->add("clsid:D27CDB6E-AE6D-11CF-96B8-444553540000", "application/x-shockwave-flash");
+    map->add("clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA", "audio/x-pn-realaudio-plugin");
+    map->add("clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B", "video/quicktime");
+    map->add("clsid:166B1BCA-3F9C-11CF-8075-444553540000", "application/x-director");
+    map->add("clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6", "application/x-mplayer2");
+    map->add("clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95", "application/x-mplayer2");
+    return map;
+}
+
+static String serviceTypeForClassId(const String& classId)
+{
+    // Return early if classId is empty (since we won't do anything below).
+    // Furthermore, if classId is null, calling get() below will crash.
+    if (classId.isEmpty())
+        return String();
+    
+    static ClassIdToTypeMap* map = createClassIdToTypeMap();
+    return map->get(classId);
+}
+
+static void mapDataParamToSrc(Vector<String>* paramNames, Vector<String>* paramValues)
+{
+    // Some plugins don't understand the "data" attribute of the OBJECT tag (i.e. Real and WMP
+    // require "src" attribute).
+    int srcIndex = -1, dataIndex = -1;
+    for (unsigned int i = 0; i < paramNames->size(); ++i) {
+        if (equalIgnoringCase((*paramNames)[i], "src"))
+            srcIndex = i;
+        else if (equalIgnoringCase((*paramNames)[i], "data"))
+            dataIndex = i;
+    }
+    
+    if (srcIndex == -1 && dataIndex != -1) {
+        paramNames->append("src");
+        paramValues->append((*paramValues)[dataIndex]);
+    }
+}
+
+// FIXME: This function should not deal with url or serviceType!
+void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType)
+{
+    HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames;
+    
+    // Scan the PARAM children and store their name/value pairs.
+    // Get the URL and type from the params if we don't already have them.
+    for (Node* child = firstChild(); child; child = child->nextSibling()) {
+        if (!child->hasTagName(paramTag))
+            continue;
+
+        HTMLParamElement* p = static_cast<HTMLParamElement*>(child);
+        String name = p->name();
+        if (name.isEmpty())
+            continue;
+
+        uniqueParamNames.add(name.impl());
+        paramNames.append(p->name());
+        paramValues.append(p->value());
+
+        // FIXME: url adjustment does not belong in this function.
+        if (url.isEmpty() && (equalIgnoringCase(name, "src") || equalIgnoringCase(name, "movie") || equalIgnoringCase(name, "code") || equalIgnoringCase(name, "url")))
+            url = deprecatedParseURL(p->value());
+        // FIXME: serviceType calculation does not belong in this function.
+        if (serviceType.isEmpty() && equalIgnoringCase(name, "type")) {
+            serviceType = p->value();
+            size_t pos = serviceType.find(";");
+            if (pos != notFound)
+                serviceType = serviceType.left(pos);
+        }
+    }
+    
+    // When OBJECT is used for an applet via Sun's Java plugin, the CODEBASE attribute in the tag
+    // points to the Java plugin itself (an ActiveX component) while the actual applet CODEBASE is
+    // in a PARAM tag. See <http://java.sun.com/products/plugin/1.2/docs/tags.html>. This means
+    // we have to explicitly suppress the tag's CODEBASE attribute if there is none in a PARAM,
+    // else our Java plugin will misinterpret it. [4004531]
+    String codebase;
+    if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType)) {
+        codebase = "codebase";
+        uniqueParamNames.add(codebase.impl()); // pretend we found it in a PARAM already
+    }
+    
+    // Turn the attributes of the <object> element into arrays, but don't override <param> values.
+    NamedNodeMap* attributes = this->attributes(true);
+    if (attributes) {
+        for (unsigned i = 0; i < attributes->length(); ++i) {
+            Attribute* it = attributes->attributeItem(i);
+            const AtomicString& name = it->name().localName();
+            if (!uniqueParamNames.contains(name.impl())) {
+                paramNames.append(name.string());
+                paramValues.append(it->value().string());
+            }
+        }
+    }
+    
+    mapDataParamToSrc(&paramNames, &paramValues);
+    
+    // If we still don't have a type, try to map from a specific CLASSID to a type.
+    if (serviceType.isEmpty())
+        serviceType = serviceTypeForClassId(classId());
+}
+
+    
+bool HTMLObjectElement::hasFallbackContent() const
+{
+    for (Node* child = firstChild(); child; child = child->nextSibling()) {
+        // Ignore whitespace-only text, and <param> tags, any other content is fallback content.
+        if (child->isTextNode()) {
+            if (!static_cast<Text*>(child)->containsOnlyWhitespace())
+                return true;
+        } else if (!child->hasTagName(paramTag))
+            return true;
+    }
+    return false;
+}
+
 bool HTMLObjectElement::rendererIsNeeded(RenderStyle* style)
 {
     // FIXME: This check should not be needed, detached documents never render!
diff --git a/WebCore/html/HTMLObjectElement.h b/WebCore/html/HTMLObjectElement.h
index 9fafae9..3ff9218 100644
--- a/WebCore/html/HTMLObjectElement.h
+++ b/WebCore/html/HTMLObjectElement.h
@@ -39,8 +39,13 @@ public:
 
     bool containsJavaApplet() const;
 
+    bool hasFallbackContent() const;
     virtual bool useFallbackContent() const { return m_useFallbackContent; }
 
+    // FIXME: This function should not deal with url or serviceType
+    // so that we can better share code between <object> and <embed>.
+    void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType);
+
 private:
     HTMLObjectElement(const QualifiedName&, Document*, bool createdByParser);
 
diff --git a/WebCore/html/HTMLPlugInImageElement.cpp b/WebCore/html/HTMLPlugInImageElement.cpp
index 75407dd..57a70a9 100644
--- a/WebCore/html/HTMLPlugInImageElement.cpp
+++ b/WebCore/html/HTMLPlugInImageElement.cpp
@@ -26,6 +26,7 @@
 #include "FrameLoaderClient.h"
 #include "HTMLImageLoader.h"
 #include "Image.h"
+#include "Page.h"
 #include "RenderEmbeddedObject.h"
 #include "RenderImage.h"
 
@@ -63,6 +64,46 @@ bool HTMLPlugInImageElement::isImageType()
     return Image::supportsType(m_serviceType);
 }
 
+// We don't use m_url, as it may not be the final URL that the object loads,
+// depending on <param> values. 
+bool HTMLPlugInImageElement::allowedToLoadFrameURL(const String& url)
+{
+    ASSERT(document());
+    ASSERT(document()->frame());
+    if (document()->frame()->page()->frameCount() >= Page::maxNumberOfFrames)
+        return false;
+
+    // We allow one level of self-reference because some sites depend on that.
+    // But we don't allow more than one.
+    KURL completeURL = document()->completeURL(url);
+    bool foundSelfReference = false;
+    for (Frame* frame = document()->frame(); frame; frame = frame->tree()->parent()) {
+        if (equalIgnoringFragmentIdentifier(frame->loader()->url(), completeURL)) {
+            if (foundSelfReference)
+                return false;
+            foundSelfReference = true;
+        }
+    }
+    return true;
+}
+
+// We don't use m_url, or m_serviceType as they may not be the final values
+// that <object> uses depending on <param> values. 
+bool HTMLPlugInImageElement::wouldLoadAsNetscapePlugin(const String& url, const String& serviceType)
+{
+    ASSERT(document());
+    ASSERT(document()->frame());
+    FrameLoader* frameLoader = document()->frame()->loader();
+    ASSERT(frameLoader);
+    KURL completedURL;
+    if (!url.isEmpty())
+        completedURL = frameLoader->completeURL(url);
+
+    if (frameLoader->client()->objectContentType(completedURL, serviceType) == ObjectContentNetscapePlugin)
+        return true;
+    return false;
+}
+
 RenderObject* HTMLPlugInImageElement::createRenderer(RenderArena* arena, RenderStyle* style)
 {
     // Fallback content breaks the DOM->Renderer class relationship of this
@@ -106,7 +147,7 @@ void HTMLPlugInImageElement::attach()
     
 void HTMLPlugInImageElement::detach()
 {
-    // FIXME: Because of the insanity that is HTMLObjectElement::recalcStyle,
+    // FIXME: Because of the insanity that is HTMLPlugInImageElement::recalcStyle,
     // we can end up detaching during an attach() call, before we even have a
     // renderer.  In that case, don't mark the widget for update.
     if (attached() && renderer() && !useFallbackContent())
@@ -115,7 +156,7 @@ void HTMLPlugInImageElement::detach()
     HTMLPlugInElement::detach();
 }
 
-void HTMLPlugInImageElement::updateWidget()
+void HTMLPlugInImageElement::updateWidgetIfNecessary()
 {
     document()->updateStyleIfNeeded();
     if (needsWidgetUpdate() && renderEmbeddedObject() && !useFallbackContent() && !isImageType())
@@ -142,7 +183,7 @@ void HTMLPlugInImageElement::willMoveToNewOwnerDocument()
 
 void HTMLPlugInImageElement::updateWidgetCallback(Node* n)
 {
-    static_cast<HTMLPlugInImageElement*>(n)->updateWidget();
+    static_cast<HTMLPlugInImageElement*>(n)->updateWidgetIfNecessary();
 }
 
 } // namespace WebCore
diff --git a/WebCore/html/HTMLPlugInImageElement.h b/WebCore/html/HTMLPlugInImageElement.h
index 65c5f37..814aaf0 100644
--- a/WebCore/html/HTMLPlugInImageElement.h
+++ b/WebCore/html/HTMLPlugInImageElement.h
@@ -27,6 +27,7 @@
 namespace WebCore {
 
 class HTMLImageLoader;
+class FrameLoader;
 
 // Base class for HTMLObjectElement and HTMLEmbedElement
 class HTMLPlugInImageElement : public HTMLPlugInElement {
@@ -34,8 +35,11 @@ public:
     const String& serviceType() const { return m_serviceType; }
     const String& url() const { return m_url; }
 
+    // These can all move to be protected once updateWidget is moved out of RenderEmbeddedObject.cpp
     bool needsWidgetUpdate() const { return m_needsWidgetUpdate; }
     void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; }
+    bool allowedToLoadFrameURL(const String& url);
+    bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType);
 
     RenderEmbeddedObject* renderEmbeddedObject() const;
 
@@ -60,7 +64,7 @@ private:
     virtual void finishParsingChildren();
     virtual void willMoveToNewOwnerDocument();
 
-    void updateWidget();
+    void updateWidgetIfNecessary();
     virtual bool useFallbackContent() const { return false; }
     
     bool m_needsWidgetUpdate;
diff --git a/WebCore/rendering/RenderEmbeddedObject.cpp b/WebCore/rendering/RenderEmbeddedObject.cpp
index b1b253a..9f8acfd 100644
--- a/WebCore/rendering/RenderEmbeddedObject.cpp
+++ b/WebCore/rendering/RenderEmbeddedObject.cpp
@@ -101,179 +101,33 @@ bool RenderEmbeddedObject::allowsAcceleratedCompositing() const
     return widget() && widget()->isPluginViewBase() && static_cast<PluginViewBase*>(widget())->platformLayer();
 }
 #endif
-
-// FIXME: This belongs in HTMLPluginElement.cpp to be shared by HTMLObjectElement and HTMLEmbedElement.
-static bool isURLAllowed(Document* doc, const String& url)
-{
-    if (doc->frame()->page()->frameCount() >= Page::maxNumberOfFrames)
-        return false;
-
-    // We allow one level of self-reference because some sites depend on that.
-    // But we don't allow more than one.
-    KURL completeURL = doc->completeURL(url);
-    bool foundSelfReference = false;
-    for (Frame* frame = doc->frame(); frame; frame = frame->tree()->parent()) {
-        if (equalIgnoringFragmentIdentifier(frame->loader()->url(), completeURL)) {
-            if (foundSelfReference)
-                return false;
-            foundSelfReference = true;
-        }
-    }
-    return true;
-}
-
-typedef HashMap<String, String, CaseFoldingHash> ClassIdToTypeMap;
-
-// FIXME: This belongs in HTMLObjectElement.cpp
-static ClassIdToTypeMap* createClassIdToTypeMap()
-{
-    ClassIdToTypeMap* map = new ClassIdToTypeMap;
-    map->add("clsid:D27CDB6E-AE6D-11CF-96B8-444553540000", "application/x-shockwave-flash");
-    map->add("clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA", "audio/x-pn-realaudio-plugin");
-    map->add("clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B", "video/quicktime");
-    map->add("clsid:166B1BCA-3F9C-11CF-8075-444553540000", "application/x-director");
-    map->add("clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6", "application/x-mplayer2");
-    map->add("clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95", "application/x-mplayer2");
-    return map;
-}
-
-// FIXME: This belongs in HTMLObjectElement.cpp
-static String serviceTypeForClassId(const String& classId)
-{
-    // Return early if classId is empty (since we won't do anything below).
-    // Furthermore, if classId is null, calling get() below will crash.
-    if (classId.isEmpty())
-        return String();
-
-    static ClassIdToTypeMap* map = createClassIdToTypeMap();
-    return map->get(classId);
-}
-
-// FIXME: This belongs in HTMLObjectElement.cpp
-static void mapDataParamToSrc(Vector<String>* paramNames, Vector<String>* paramValues)
-{
-    // Some plugins don't understand the "data" attribute of the OBJECT tag (i.e. Real and WMP
-    // require "src" attribute).
-    int srcIndex = -1, dataIndex = -1;
-    for (unsigned int i = 0; i < paramNames->size(); ++i) {
-        if (equalIgnoringCase((*paramNames)[i], "src"))
-            srcIndex = i;
-        else if (equalIgnoringCase((*paramNames)[i], "data"))
-            dataIndex = i;
-    }
-
-    if (srcIndex == -1 && dataIndex != -1) {
-        paramNames->append("src");
-        paramValues->append((*paramValues)[dataIndex]);
-    }
-}
-
-// FIXME: This belongs in some loader header?
-static bool isNetscapePlugin(Frame* frame, const String& url, const String& serviceType)
-{
-    KURL completedURL;
-    if (!url.isEmpty())
-        completedURL = frame->loader()->completeURL(url);
-
-    if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentNetscapePlugin)
-        return true;
-    return false;
-}
-
-// FIXME: This belongs on HTMLObjectElement.
-static bool hasFallbackContent(HTMLObjectElement* objectElement)
-{
-    for (Node* child = objectElement->firstChild(); child; child = child->nextSibling()) {
-        if ((!child->isTextNode() && !child->hasTagName(paramTag)) // Discount <param>
-            || (child->isTextNode() && !static_cast<Text*>(child)->containsOnlyWhitespace()))
-            return true;
-    }
-    return false;
-}
-
-// FIXME: This belongs on HTMLObjectElement.
-static void parametersFromObject(HTMLObjectElement* objectElement, Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType)
-{
-    HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames;
-
-    // Scan the PARAM children and store their name/value pairs.
-    // Get the URL and type from the params if we don't already have them.
-    Node* child = objectElement->firstChild();
-    while (child) {
-        if (child->hasTagName(paramTag)) {
-            HTMLParamElement* p = static_cast<HTMLParamElement*>(child);
-            String name = p->name();
-            if (url.isEmpty() && (equalIgnoringCase(name, "src") || equalIgnoringCase(name, "movie") || equalIgnoringCase(name, "code") || equalIgnoringCase(name, "url")))
-                url = deprecatedParseURL(p->value());
-            // FIXME: serviceType calculation does not belong in this function.
-            if (serviceType.isEmpty() && equalIgnoringCase(name, "type")) {
-                serviceType = p->value();
-                size_t pos = serviceType.find(";");
-                if (pos != notFound)
-                    serviceType = serviceType.left(pos);
-            }
-            if (!name.isEmpty()) {
-                uniqueParamNames.add(name.impl());
-                paramNames.append(p->name());
-                paramValues.append(p->value());
-            }
-        }
-        child = child->nextSibling();
-    }
-
-    // When OBJECT is used for an applet via Sun's Java plugin, the CODEBASE attribute in the tag
-    // points to the Java plugin itself (an ActiveX component) while the actual applet CODEBASE is
-    // in a PARAM tag. See <http://java.sun.com/products/plugin/1.2/docs/tags.html>. This means
-    // we have to explicitly suppress the tag's CODEBASE attribute if there is none in a PARAM,
-    // else our Java plugin will misinterpret it. [4004531]
-    String codebase;
-    if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType)) {
-        codebase = "codebase";
-        uniqueParamNames.add(codebase.impl()); // pretend we found it in a PARAM already
-    }
-
-    // Turn the attributes of the <object> element into arrays, but don't override <param> values.
-    NamedNodeMap* attributes = objectElement->attributes();
-    if (attributes) {
-        for (unsigned i = 0; i < attributes->length(); ++i) {
-            Attribute* it = attributes->attributeItem(i);
-            const AtomicString& name = it->name().localName();
-            if (!uniqueParamNames.contains(name.impl())) {
-                paramNames.append(name.string());
-                paramValues.append(it->value().string());
-            }
-        }
-    }
-
-    mapDataParamToSrc(&paramNames, &paramValues);
-
-    // If we still don't have a type, try to map from a specific CLASSID to a type.
-    if (serviceType.isEmpty())
-        serviceType = serviceTypeForClassId(objectElement->classId());
-}
-
+    
 // FIXME: This belongs on HTMLObjectElement, HTMLPluginElement or HTMLFrameOwnerElement.
 static void updateWidgetForObjectElement(HTMLObjectElement* objectElement, bool onlyCreateNonNetscapePlugins)
 {
+    // FIXME: We should ASSERT(objectElement->needsWidgetUpdate()), but currently
+    // FrameView::updateWidget() calls updateWidget(false) without checking if
+    // the widget actually needs updating!
     objectElement->setNeedsWidgetUpdate(false);
+    // FIXME: This should ASSERT isFinishedParsingChildren() instead.
     if (!objectElement->isFinishedParsingChildren())
         return;
 
-    Frame* frame = objectElement->document()->frame();
     String url = objectElement->url();
     String serviceType = objectElement->serviceType();
 
     Vector<String> paramNames;
     Vector<String> paramValues;
-    parametersFromObject(objectElement, paramNames, paramValues, url, serviceType);
+    objectElement->parametersForPlugin(paramNames, paramValues, url, serviceType);
 
-    if (!isURLAllowed(objectElement->document(), url))
+    // Note: url is modified above by parametersForPlugin.
+    if (!objectElement->allowedToLoadFrameURL(url))
         return;
 
-    bool fallbackContent = hasFallbackContent(objectElement);
+    bool fallbackContent = objectElement->hasFallbackContent();
     objectElement->renderEmbeddedObject()->setHasFallbackContent(fallbackContent);
 
-    if (onlyCreateNonNetscapePlugins && isNetscapePlugin(frame, url, serviceType))
+    if (onlyCreateNonNetscapePlugins && objectElement->wouldLoadAsNetscapePlugin(url, serviceType))
         return;
 
     bool beforeLoadAllowedLoad = objectElement->dispatchBeforeLoadEvent(url);
@@ -285,50 +139,41 @@ static void updateWidgetForObjectElement(HTMLObjectElement* objectElement, bool
     if (!objectElement->renderer())
         return;
 
-    bool success = beforeLoadAllowedLoad && frame->loader()->subframeLoader()->requestObject(objectElement, url, objectElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
+    SubframeLoader* loader = objectElement->document()->frame()->loader()->subframeLoader();
+    bool success = beforeLoadAllowedLoad && loader->requestObject(objectElement, url, objectElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
 
     if (!success && fallbackContent)
         objectElement->renderFallbackContent();
 }
 
-// FIXME: This belongs on HTMLEmbedElement.
-static void parametersFromEmbed(HTMLEmbedElement* embedElement, Vector<String>& paramNames, Vector<String>& paramValues)
-{
-    NamedNodeMap* attributes = embedElement->attributes();
-    if (attributes) {
-        for (unsigned i = 0; i < attributes->length(); ++i) {
-            Attribute* it = attributes->attributeItem(i);
-            paramNames.append(it->name().localName().string());
-            paramValues.append(it->value().string());
-        }
-    }
-}
-
 // FIXME: This belongs on HTMLEmbedElement, HTMLPluginElement or HTMLFrameOwnerElement.
 static void updateWidgetForEmbedElement(HTMLEmbedElement* embedElement, bool onlyCreateNonNetscapePlugins)
 {
-    Frame* frame = embedElement->document()->frame();
-    String url = embedElement->url();
-    String serviceType = embedElement->serviceType();
-
+    // FIXME: We should ASSERT(embedElement->needsWidgetUpdate()), but currently
+    // FrameView::updateWidget() calls updateWidget(false) without checking if
+    // the widget actually needs updating!
     embedElement->setNeedsWidgetUpdate(false);
 
+    String url = embedElement->url();
+    String serviceType = embedElement->serviceType();
     if (url.isEmpty() && serviceType.isEmpty())
         return;
-    if (!isURLAllowed(embedElement->document(), url))
+    if (!embedElement->allowedToLoadFrameURL(url))
+        return;
+
+    if (onlyCreateNonNetscapePlugins && embedElement->wouldLoadAsNetscapePlugin(url, serviceType))
         return;
 
     Vector<String> paramNames;
     Vector<String> paramValues;
-    parametersFromEmbed(embedElement, paramNames, paramValues);
+    embedElement->parametersForPlugin(paramNames, paramValues);
 
-    if (onlyCreateNonNetscapePlugins && isNetscapePlugin(frame, url, serviceType))
+    if (!embedElement->dispatchBeforeLoadEvent(url))
         return;
 
-    if (embedElement->dispatchBeforeLoadEvent(url)) {
-        // FIXME: beforeLoad could have detached the renderer!  Just like in the <object> case above.
-        frame->loader()->subframeLoader()->requestObject(embedElement, url, embedElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
-    }
+    SubframeLoader* loader = embedElement->document()->frame()->loader()->subframeLoader();
+    // FIXME: beforeLoad could have detached the renderer!  Just like in the <object> case above.
+    loader->requestObject(embedElement, url, embedElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
 }
 
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
@@ -369,6 +214,8 @@ void RenderEmbeddedObject::updateWidget(bool onlyCreateNonNetscapePlugins)
         updateWidgetForMediaElement(mediaElement, onlyCreateNonNetscapePlugins);
     }
 #endif
+    else
+        ASSERT_NOT_REACHED();
 }
 
 void RenderEmbeddedObject::setShowsMissingPluginIndicator()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list