[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:55:31 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 4eeaef72a8cd675eb94c88a70cd7cb1788229797
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Sep 2 02:11:45 2010 +0000

    2010-09-01  Eric Seidel  <eric at webkit.org>
    
            Reviewed by Dimitri Glazkov.
    
            Remove rendering types from SubframeLoader and split RenderEmbeddedObject::updateWidget in preparation for moving to DOM
            https://bugs.webkit.org/show_bug.cgi?id=45007
    
            This is just moving around code (and attempting to make it more sane).
            I also tried to use more specific types where possible.
            The SubframeLoader no longer uses any rendering types in its API.
    
            I split RenderEmbeddedObject::updateWidget into a bunch of functions.
            It was obvious before, but now super-obvious after the split that these
            new functions do not belong in RenderEmbeddedObject.  Instead they
            need to be moved to their respective DOM classes.  I've added FIXMEs
            next to each of the functions which should be moved, but I've not moved
            any of the logic out of RenderEmbeddedObject.cpp yet in an effort to
            keep this patch as simple as possible.
    
            No functional change, thus no tests.
    
            * html/HTMLEmbedElement.cpp:
            (WebCore::HTMLEmbedElement::updateWidget):
            * html/HTMLFrameElementBase.cpp:
            (WebCore::HTMLFrameElementBase::attach):
            (WebCore::HTMLFrameElementBase::width):
            (WebCore::HTMLFrameElementBase::height):
            * html/HTMLFrameOwnerElement.cpp:
            (WebCore::HTMLFrameOwnerElement::renderPart):
            * html/HTMLFrameOwnerElement.h:
            * html/HTMLObjectElement.cpp:
            (WebCore::HTMLObjectElement::renderWidgetForJSBindings):
            (WebCore::HTMLObjectElement::createRenderer):
            (WebCore::HTMLObjectElement::updateWidget):
            * html/HTMLPlugInElement.cpp:
            (WebCore::HTMLPlugInElement::renderEmbeddedObject):
            * html/HTMLPlugInElement.h:
            * loader/PluginDocument.cpp:
            (WebCore::PluginDocumentParser::appendBytes):
            * loader/SubframeLoader.cpp:
            (WebCore::SubframeLoader::requestObject):
            (WebCore::SubframeLoader::document):
            (WebCore::SubframeLoader::loadPlugin):
            * loader/SubframeLoader.h:
            * rendering/RenderEmbeddedObject.cpp:
            (WebCore::isNetscapePlugin):
            (WebCore::hasFallbackContent):
            (WebCore::parametersFromObject):
            (WebCore::updateWidgetForObjectElement):
            (WebCore::parametersFromEmbed):
            (WebCore::updateWidgetForEmbedElement):
            (WebCore::updateWidgetForMediaElement):
            (WebCore::RenderEmbeddedObject::updateWidget):
            * rendering/RenderEmbeddedObject.h:
            (WebCore::RenderEmbeddedObject::setHasFallbackContent):
            * rendering/RenderLayerCompositor.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66631 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 21ffa46..e5f0416 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,60 @@
+2010-09-01  Eric Seidel  <eric at webkit.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Remove rendering types from SubframeLoader and split RenderEmbeddedObject::updateWidget in preparation for moving to DOM
+        https://bugs.webkit.org/show_bug.cgi?id=45007
+
+        This is just moving around code (and attempting to make it more sane).
+        I also tried to use more specific types where possible.
+        The SubframeLoader no longer uses any rendering types in its API.
+
+        I split RenderEmbeddedObject::updateWidget into a bunch of functions.
+        It was obvious before, but now super-obvious after the split that these
+        new functions do not belong in RenderEmbeddedObject.  Instead they
+        need to be moved to their respective DOM classes.  I've added FIXMEs
+        next to each of the functions which should be moved, but I've not moved
+        any of the logic out of RenderEmbeddedObject.cpp yet in an effort to
+        keep this patch as simple as possible.
+
+        No functional change, thus no tests.
+
+        * html/HTMLEmbedElement.cpp:
+        (WebCore::HTMLEmbedElement::updateWidget):
+        * html/HTMLFrameElementBase.cpp:
+        (WebCore::HTMLFrameElementBase::attach):
+        (WebCore::HTMLFrameElementBase::width):
+        (WebCore::HTMLFrameElementBase::height):
+        * html/HTMLFrameOwnerElement.cpp:
+        (WebCore::HTMLFrameOwnerElement::renderPart):
+        * html/HTMLFrameOwnerElement.h:
+        * html/HTMLObjectElement.cpp:
+        (WebCore::HTMLObjectElement::renderWidgetForJSBindings):
+        (WebCore::HTMLObjectElement::createRenderer):
+        (WebCore::HTMLObjectElement::updateWidget):
+        * html/HTMLPlugInElement.cpp:
+        (WebCore::HTMLPlugInElement::renderEmbeddedObject):
+        * html/HTMLPlugInElement.h:
+        * loader/PluginDocument.cpp:
+        (WebCore::PluginDocumentParser::appendBytes):
+        * loader/SubframeLoader.cpp:
+        (WebCore::SubframeLoader::requestObject):
+        (WebCore::SubframeLoader::document):
+        (WebCore::SubframeLoader::loadPlugin):
+        * loader/SubframeLoader.h:
+        * rendering/RenderEmbeddedObject.cpp:
+        (WebCore::isNetscapePlugin):
+        (WebCore::hasFallbackContent):
+        (WebCore::parametersFromObject):
+        (WebCore::updateWidgetForObjectElement):
+        (WebCore::parametersFromEmbed):
+        (WebCore::updateWidgetForEmbedElement):
+        (WebCore::updateWidgetForMediaElement):
+        (WebCore::RenderEmbeddedObject::updateWidget):
+        * rendering/RenderEmbeddedObject.h:
+        (WebCore::RenderEmbeddedObject::setHasFallbackContent):
+        * rendering/RenderLayerCompositor.h:
+
 2010-09-01  Kinuko Yasuda  <kinuko at chromium.org>
 
         Reviewed by Jian Li.
diff --git a/WebCore/html/HTMLEmbedElement.cpp b/WebCore/html/HTMLEmbedElement.cpp
index fb2b351..e7889b8 100644
--- a/WebCore/html/HTMLEmbedElement.cpp
+++ b/WebCore/html/HTMLEmbedElement.cpp
@@ -186,8 +186,8 @@ void HTMLEmbedElement::attach()
 void HTMLEmbedElement::updateWidget()
 {
     document()->updateStyleIfNeeded();
-    if (m_needWidgetUpdate && renderer() && !isImageType())
-        toRenderEmbeddedObject(renderer())->updateWidget(true);
+    if (m_needWidgetUpdate && renderEmbeddedObject() && !isImageType())
+        renderEmbeddedObject()->updateWidget(true);
 }
 
 void HTMLEmbedElement::insertedIntoDocument()
diff --git a/WebCore/html/HTMLFrameElementBase.cpp b/WebCore/html/HTMLFrameElementBase.cpp
index 6cae891..b967926 100644
--- a/WebCore/html/HTMLFrameElementBase.cpp
+++ b/WebCore/html/HTMLFrameElementBase.cpp
@@ -37,6 +37,7 @@
 #include "HTMLNames.h"
 #include "KURL.h"
 #include "Page.h"
+#include "RenderEmbeddedObject.h"
 #include "RenderFrame.h"
 #include "ScriptController.h"
 #include "ScriptEventListener.h"
@@ -210,10 +211,10 @@ void HTMLFrameElementBase::attach()
     setRemainsAliveOnRemovalFromTree(false);
 
     HTMLFrameOwnerElement::attach();
-    
-    if (RenderPart* renderPart = toRenderPart(renderer())) {
+
+    if (RenderPart* part = renderPart()) {
         if (Frame* frame = contentFrame())
-            renderPart->setWidget(frame->view());
+            part->setWidget(frame->view());
     }
 }
 
@@ -257,20 +258,20 @@ bool HTMLFrameElementBase::isURLAttribute(Attribute *attr) const
 
 int HTMLFrameElementBase::width() const
 {
-    if (!renderer())
+    if (!renderBox())
         return 0;
-    
+
     document()->updateLayoutIgnorePendingStylesheets();
-    return toRenderBox(renderer())->width();
+    return renderBox()->width();
 }
 
 int HTMLFrameElementBase::height() const
 {
-    if (!renderer())
+    if (!renderBox())
         return 0;
-    
+
     document()->updateLayoutIgnorePendingStylesheets();
-    return toRenderBox(renderer())->height();
+    return renderBox()->height();
 }
 
 void HTMLFrameElementBase::setRemainsAliveOnRemovalFromTree(bool value)
diff --git a/WebCore/html/HTMLFrameOwnerElement.cpp b/WebCore/html/HTMLFrameOwnerElement.cpp
index a1a69f3..3f946f0 100644
--- a/WebCore/html/HTMLFrameOwnerElement.cpp
+++ b/WebCore/html/HTMLFrameOwnerElement.cpp
@@ -24,6 +24,7 @@
 #include "DOMWindow.h"
 #include "Frame.h"
 #include "FrameLoader.h"
+#include "RenderPart.h"
 
 #if ENABLE(SVG)
 #include "ExceptionCode.h"
@@ -39,6 +40,15 @@ HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Docum
 {
 }
 
+RenderPart* HTMLFrameOwnerElement::renderPart() const
+{
+    // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers
+    // when using fallback content.
+    if (!renderer() || !renderer()->isRenderPart())
+        return 0;
+    return toRenderPart(renderer());
+}
+
 void HTMLFrameOwnerElement::willRemove()
 {
     if (Frame* frame = contentFrame()) {
diff --git a/WebCore/html/HTMLFrameOwnerElement.h b/WebCore/html/HTMLFrameOwnerElement.h
index 804ab22..c84d7bb 100644
--- a/WebCore/html/HTMLFrameOwnerElement.h
+++ b/WebCore/html/HTMLFrameOwnerElement.h
@@ -28,6 +28,7 @@ namespace WebCore {
 
 class DOMWindow;
 class Frame;
+class RenderPart;
 
 #if ENABLE(SVG)
 class SVGDocument;
@@ -41,6 +42,11 @@ public:
     DOMWindow* contentWindow() const;
     Document* contentDocument() const;
 
+    // Most subclasses use RenderPart (either RenderEmbeddedObject or RenderIFrame)
+    // except for HTMLObjectElement and HTMLEmbedElement which may return any
+    // RenderObject when using fallback content.
+    RenderPart* renderPart() const;
+
 #if ENABLE(SVG)
     SVGDocument* getSVGDocument(ExceptionCode&) const;
 #endif
diff --git a/WebCore/html/HTMLObjectElement.cpp b/WebCore/html/HTMLObjectElement.cpp
index bf2deba..04c00a9 100644
--- a/WebCore/html/HTMLObjectElement.cpp
+++ b/WebCore/html/HTMLObjectElement.cpp
@@ -62,9 +62,7 @@ PassRefPtr<HTMLObjectElement> HTMLObjectElement::create(const QualifiedName& tag
 RenderWidget* HTMLObjectElement::renderWidgetForJSBindings() const
 {
     document()->updateLayoutIgnorePendingStylesheets();
-    if (!renderer() || !renderer()->isWidget())
-        return 0;
-    return toRenderWidget(renderer());
+    return renderPart(); // This will return 0 if the renderer is not a RenderPart.
 }
 
 void HTMLObjectElement::parseMappedAttribute(Attribute* attr)
@@ -132,8 +130,11 @@ bool HTMLObjectElement::rendererIsNeeded(RenderStyle* style)
     return isGearsPlugin || HTMLPlugInElement::rendererIsNeeded(style);
 }
 
-RenderObject *HTMLObjectElement::createRenderer(RenderArena* arena, RenderStyle* style)
+RenderObject* HTMLObjectElement::createRenderer(RenderArena* arena, RenderStyle* style)
 {
+    // Fallback content breaks the DOM->Renderer class relationship of this
+    // class and all superclasses because createObject won't necessarily
+    // return a RenderEmbeddedObject, RenderPart or even RenderWidget.
     if (m_useFallbackContent)
         return RenderObject::createObject(this, style);
     if (isImageType()) {
@@ -163,8 +164,8 @@ void HTMLObjectElement::attach()
 void HTMLObjectElement::updateWidget()
 {
     document()->updateStyleIfNeeded();
-    if (m_needWidgetUpdate && renderer() && !m_useFallbackContent && !isImageType())
-        toRenderEmbeddedObject(renderer())->updateWidget(true);
+    if (m_needWidgetUpdate && renderEmbeddedObject() && !m_useFallbackContent && !isImageType())
+        renderEmbeddedObject()->updateWidget(true);
 }
 
 void HTMLObjectElement::finishParsingChildren()
diff --git a/WebCore/html/HTMLPlugInElement.cpp b/WebCore/html/HTMLPlugInElement.cpp
index 1871b65..5ffb76d 100644
--- a/WebCore/html/HTMLPlugInElement.cpp
+++ b/WebCore/html/HTMLPlugInElement.cpp
@@ -81,6 +81,15 @@ void HTMLPlugInElement::detach()
     HTMLFrameOwnerElement::detach();
 }
 
+RenderEmbeddedObject* HTMLPlugInElement::renderEmbeddedObject() const
+{
+    // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers
+    // when using fallback content.
+    if (!renderer() || !renderer()->isEmbeddedObject())
+        return 0;
+    return toRenderEmbeddedObject(renderer());
+}
+
 PassScriptInstance HTMLPlugInElement::getInstance() const
 {
     Frame* frame = document()->frame();
diff --git a/WebCore/html/HTMLPlugInElement.h b/WebCore/html/HTMLPlugInElement.h
index 8a791b1..29fcdb0 100644
--- a/WebCore/html/HTMLPlugInElement.h
+++ b/WebCore/html/HTMLPlugInElement.h
@@ -32,6 +32,7 @@ struct NPObject;
 
 namespace WebCore {
 
+class RenderEmbeddedObject;
 class RenderWidget;
 class Widget;
 
@@ -50,6 +51,8 @@ public:
     bool isCapturingMouseEvents() const { return m_isCapturingMouseEvents; }
     void setIsCapturingMouseEvents(bool capturing) { m_isCapturingMouseEvents = capturing; }
 
+    RenderEmbeddedObject* renderEmbeddedObject() const;
+
 protected:
     HTMLPlugInElement(const QualifiedName& tagName, Document*);
 
diff --git a/WebCore/loader/PluginDocument.cpp b/WebCore/loader/PluginDocument.cpp
index 08e6fae..ad11dfb 100644
--- a/WebCore/loader/PluginDocument.cpp
+++ b/WebCore/loader/PluginDocument.cpp
@@ -124,7 +124,7 @@ void PluginDocumentParser::appendBytes(DocumentWriter*, const char*, int, bool)
 
     document()->updateLayout();
 
-    if (RenderWidget* renderer = toRenderWidget(m_embedElement->renderer())) {
+    if (RenderPart* renderer = m_embedElement->renderPart()) {
         frame->loader()->client()->redirectDataToPlugin(renderer->widget());
         frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false);
     }
diff --git a/WebCore/loader/SubframeLoader.cpp b/WebCore/loader/SubframeLoader.cpp
index 089e783..979ffc4 100644
--- a/WebCore/loader/SubframeLoader.cpp
+++ b/WebCore/loader/SubframeLoader.cpp
@@ -63,16 +63,6 @@ SubframeLoader::SubframeLoader(Frame* frame)
 {
 }
 
-static HTMLPlugInElement* toPlugInElement(Node* node)
-{
-    if (!node)
-        return 0;
-
-    ASSERT(node->hasTagName(objectTag) || node->hasTagName(embedTag) || node->hasTagName(appletTag));
-
-    return static_cast<HTMLPlugInElement*>(node);
-}
-
 void SubframeLoader::clear()
 {
     m_containsPlugins = false;
@@ -99,7 +89,7 @@ bool SubframeLoader::requestFrame(HTMLFrameOwnerElement* ownerElement, const Str
     return true;
 }
 
-bool SubframeLoader::requestObject(RenderEmbeddedObject* renderer, const String& url, const AtomicString& frameName,
+bool SubframeLoader::requestObject(HTMLPlugInElement* ownerElement, const String& url, const AtomicString& frameName,
     const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues)
 {
     if (url.isEmpty() && mimeType.isEmpty())
@@ -110,6 +100,12 @@ bool SubframeLoader::requestObject(RenderEmbeddedObject* renderer, const String&
         return false;
     }
 
+    // FIXME: None of this code should use renderers!
+    RenderEmbeddedObject* renderer = ownerElement->renderEmbeddedObject();
+    ASSERT(renderer);
+    if (!renderer)
+        return false;
+
     KURL completedURL;
     if (!url.isEmpty())
         completedURL = completeURL(url);
@@ -126,19 +122,19 @@ bool SubframeLoader::requestObject(RenderEmbeddedObject* renderer, const String&
             return false;
         if (m_frame->document() && m_frame->document()->securityOrigin()->isSandboxed(SandboxPlugins))
             return false;
-        return loadPlugin(renderer, completedURL, mimeType, paramNames, paramValues, useFallback);
-    }
 
-    ASSERT(renderer->node()->hasTagName(objectTag) || renderer->node()->hasTagName(embedTag));
-    HTMLPlugInElement* element = static_cast<HTMLPlugInElement*>(renderer->node());
+        ASSERT(ownerElement->hasTagName(objectTag) || ownerElement->hasTagName(embedTag));
+        HTMLPlugInElement* pluginElement = static_cast<HTMLPlugInElement*>(ownerElement);
+
+        return loadPlugin(pluginElement, completedURL, mimeType, paramNames, paramValues, useFallback);
+    }
 
     // If the plug-in element already contains a subframe, loadOrRedirectSubframe will re-use it. Otherwise,
     // it will create a new frame and set it as the RenderPart's widget, causing what was previously 
     // in the widget to be torn down.
-    return loadOrRedirectSubframe(element, completedURL, frameName, true, true);
+    return loadOrRedirectSubframe(ownerElement, completedURL, frameName, true, true);
 }
 
-
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
 PassRefPtr<Widget> SubframeLoader::loadMediaPlayerProxyPlugin(Node* node, const KURL& url,
     const Vector<String>& paramNames, const Vector<String>& paramValues)
@@ -304,7 +300,6 @@ bool SubframeLoader::allowPlugins(ReasonForCallingAllowPlugins reason)
     return allowed;
 }
 
-
 bool SubframeLoader::shouldUsePlugin(const KURL& url, const String& mimeType, bool hasFallback, bool& useFallback)
 {
     if (m_frame->loader()->client()->shouldUsePluginDocument(mimeType)) {
@@ -327,37 +322,46 @@ bool SubframeLoader::shouldUsePlugin(const KURL& url, const String& mimeType, bo
     useFallback = objectType == ObjectContentNone && hasFallback;
     return objectType == ObjectContentNone || objectType == ObjectContentNetscapePlugin || objectType == ObjectContentOtherPlugin;
 }
-  
-bool SubframeLoader::loadPlugin(RenderEmbeddedObject* renderer, const KURL& url, const String& mimeType, 
+
+Document* SubframeLoader::document() const
+{
+    return m_frame->document();
+}
+
+bool SubframeLoader::loadPlugin(HTMLPlugInElement* pluginElement, const KURL& url, const String& mimeType,
     const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback)
 {
-    RefPtr<Widget> widget;
+    RenderEmbeddedObject* renderer = pluginElement->renderEmbeddedObject();
 
-    if (renderer && !useFallback) {
-        HTMLPlugInElement* element = toPlugInElement(renderer->node());
+    // FIXME: This code should not depend on renderer!
+    if (!renderer || useFallback)
+        return false;
 
-        if (!SecurityOrigin::canLoad(url, String(), m_frame->document())) {
-            FrameLoader::reportLocalLoadFailed(m_frame, url.string());
-            return false;
-        }
+    if (!SecurityOrigin::canLoad(url, String(), document())) {
+        FrameLoader::reportLocalLoadFailed(m_frame, url.string());
+        return false;
+    }
 
-        m_frame->loader()->checkIfRunInsecureContent(m_frame->document()->securityOrigin(), url);
+    FrameLoader* frameLoader = m_frame->loader();
+    frameLoader->checkIfRunInsecureContent(document()->securityOrigin(), url);
 
-        widget = m_frame->loader()->client()->createPlugin(IntSize(renderer->contentWidth(), renderer->contentHeight()),
-                                        element, url, paramNames, paramValues, mimeType,
-                                        m_frame->document()->isPluginDocument() && !m_containsPlugins);
-        if (widget) {
-            renderer->setWidget(widget);
-            m_containsPlugins = true;
+    IntSize contentSize(renderer->contentWidth(), renderer->contentHeight());
+    bool loadManually = document()->isPluginDocument() && !m_containsPlugins;
+    RefPtr<Widget> widget = frameLoader->client()->createPlugin(contentSize,
+        pluginElement, url, paramNames, paramValues, mimeType, loadManually);
 
-#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-            renderer->node()->setNeedsStyleRecalc(SyntheticStyleChange);
-#endif
-        } else
-            renderer->setShowsMissingPluginIndicator();
+    if (!widget) {
+        renderer->setShowsMissingPluginIndicator();
+        return false;
     }
 
-    return widget;
+    renderer->setWidget(widget);
+    m_containsPlugins = true;
+
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    pluginElement->setNeedsStyleRecalc(SyntheticStyleChange);
+#endif
+    return true;
 }
 
 KURL SubframeLoader::completeURL(const String& url) const
diff --git a/WebCore/loader/SubframeLoader.h b/WebCore/loader/SubframeLoader.h
index d42ef2c..8ed456c 100644
--- a/WebCore/loader/SubframeLoader.h
+++ b/WebCore/loader/SubframeLoader.h
@@ -40,16 +40,17 @@
 
 namespace WebCore {
 
+class Document;
 class Frame;
 class FrameLoaderClient;
 class HTMLAppletElement;
 class HTMLFrameOwnerElement;
+class HTMLPlugInElement;
 class IntSize;
 class KURL;
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
 class Node;
 #endif
-class RenderEmbeddedObject;
 class Widget;
 
 // This is a slight misnomer. It handles the higher level logic of loading both subframes and plugins.
@@ -60,10 +61,12 @@ public:
     void clear();
 
     bool requestFrame(HTMLFrameOwnerElement*, const String& url, const AtomicString& frameName, bool lockHistory = true, bool lockBackForwardList = true);    
-    bool requestObject(RenderEmbeddedObject*, const String& url, const AtomicString& frameName,
+    bool requestObject(HTMLPlugInElement*, const String& url, const AtomicString& frameName,
         const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues);
 
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    // FIXME: This should take Element* instead of Node*, or better yet the
+    // specific type of Element which this code depends on.
     PassRefPtr<Widget> loadMediaPlayerProxyPlugin(Node*, const KURL&, const Vector<String>& paramNames, const Vector<String>& paramValues);
 #endif
 
@@ -76,11 +79,13 @@ public:
 private:
     Frame* loadOrRedirectSubframe(HTMLFrameOwnerElement*, const KURL&, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList);
     Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer);
-    bool loadPlugin(RenderEmbeddedObject*, const KURL&, const String& mimeType,
+    bool loadPlugin(HTMLPlugInElement*, const KURL&, const String& mimeType,
         const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback);
 
     bool shouldUsePlugin(const KURL&, const String& mimeType, bool hasFallback, bool& useFallback);
 
+    Document* document() const;
+
     bool m_containsPlugins;
     Frame* m_frame;
 
diff --git a/WebCore/rendering/RenderEmbeddedObject.cpp b/WebCore/rendering/RenderEmbeddedObject.cpp
index ccba791..74c6e91 100644
--- a/WebCore/rendering/RenderEmbeddedObject.cpp
+++ b/WebCore/rendering/RenderEmbeddedObject.cpp
@@ -102,6 +102,7 @@ bool RenderEmbeddedObject::allowsAcceleratedCompositing() const
 }
 #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)
@@ -123,6 +124,7 @@ static bool isURLAllowed(Document* doc, const String& url)
 
 typedef HashMap<String, String, CaseFoldingHash> ClassIdToTypeMap;
 
+// FIXME: This belongs in HTMLObjectElement.cpp
 static ClassIdToTypeMap* createClassIdToTypeMap()
 {
     ClassIdToTypeMap* map = new ClassIdToTypeMap;
@@ -135,6 +137,7 @@ static ClassIdToTypeMap* createClassIdToTypeMap()
     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).
@@ -146,6 +149,7 @@ static String serviceTypeForClassId(const String& classId)
     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
@@ -164,163 +168,205 @@ static void mapDataParamToSrc(Vector<String>* paramNames, Vector<String>* paramV
     }
 }
 
-void RenderEmbeddedObject::updateWidget(bool onlyCreateNonNetscapePlugins)
+// FIXME: This belongs in some loader header?
+static bool isNetscapePlugin(Frame* frame, const String& url, const String& serviceType)
 {
-    if (!m_replacementText.isNull() || !node()) // Check the node in case destroy() has been called.
-        return;
-
-    String url;
-    String serviceType;
-    Vector<String> paramNames;
-    Vector<String> paramValues;
-    Frame* frame = frameView()->frame();
+    KURL completedURL;
+    if (!url.isEmpty())
+        completedURL = frame->loader()->completeURL(url);
 
-    // The calls to SubframeLoader::requestObject within this function can result in a plug-in being initialized.
-    // This can run cause arbitrary JavaScript to run and may result in this RenderObject being detached from
-    // the render tree and destroyed, causing a crash like <rdar://problem/6954546>.  By extending our lifetime
-    // artifically to ensure that we remain alive for the duration of plug-in initialization.
-    RenderWidgetProtector protector(this);
+    if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentNetscapePlugin)
+        return true;
+    return false;
+}
 
-    if (node()->hasTagName(objectTag)) {
-        HTMLObjectElement* objectElement = static_cast<HTMLObjectElement*>(node());
+// 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;
+}
 
-        objectElement->setNeedWidgetUpdate(false);
-        if (!objectElement->isFinishedParsingChildren())
-            return;
-            
-        url = objectElement->url();
-        serviceType = objectElement->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());
-                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());
-                }
+// 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();
         }
+        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());
-                }
+    // 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);
+    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());
+    // 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());
+}
 
-        if (!isURLAllowed(document(), url))
-            return;
+// FIXME: This belongs on HTMLObjectElement, HTMLPluginElement or HTMLFrameOwnerElement.
+static void updateWidgetForObjectElement(HTMLObjectElement* objectElement, bool onlyCreateNonNetscapePlugins)
+{
+    objectElement->setNeedWidgetUpdate(false);
+    if (!objectElement->isFinishedParsingChildren())
+        return;
 
-        // Find out if we support fallback content.
-        m_hasFallbackContent = false;
-        for (Node* child = objectElement->firstChild(); child && !m_hasFallbackContent; child = child->nextSibling()) {
-            if ((!child->isTextNode() && !child->hasTagName(paramTag)) // Discount <param>
-                || (child->isTextNode() && !static_cast<Text*>(child)->containsOnlyWhitespace()))
-                m_hasFallbackContent = true;
-        }
+    Frame* frame = objectElement->document()->frame();
+    String url = objectElement->url();
+    String serviceType = objectElement->serviceType();
 
-        if (onlyCreateNonNetscapePlugins) {
-            KURL completedURL;
-            if (!url.isEmpty())
-                completedURL = frame->loader()->completeURL(url);
+    Vector<String> paramNames;
+    Vector<String> paramValues;
+    parametersFromObject(objectElement, paramNames, paramValues, url, serviceType);
 
-            if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentNetscapePlugin)
-                return;
-        }
+    if (!isURLAllowed(objectElement->document(), url))
+        return;
 
-        bool beforeLoadAllowedLoad = objectElement->dispatchBeforeLoadEvent(url);
-        
-        // beforeload events can modify the DOM, potentially causing
-        // RenderWidget::destroy() to be called.  Ensure we haven't been
-        // destroyed before continuing.
-        if (!node())
-            return;
-        
-        bool success = beforeLoadAllowedLoad && frame->loader()->subframeLoader()->requestObject(this, url, objectElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
-    
-        if (!success && m_hasFallbackContent)
-            objectElement->renderFallbackContent();
+    bool fallbackContent = hasFallbackContent(objectElement);
+    objectElement->renderEmbeddedObject()->setHasFallbackContent(fallbackContent);
 
-    } else if (node()->hasTagName(embedTag)) {
-        HTMLEmbedElement* embedElement = static_cast<HTMLEmbedElement*>(node());
-        embedElement->setNeedWidgetUpdate(false);
-        url = embedElement->url();
-        serviceType = embedElement->serviceType();
+    if (onlyCreateNonNetscapePlugins && isNetscapePlugin(frame, url, serviceType))
+        return;
 
-        if (url.isEmpty() && serviceType.isEmpty())
-            return;
-        if (!isURLAllowed(document(), url))
-            return;
+    bool beforeLoadAllowedLoad = objectElement->dispatchBeforeLoadEvent(url);
 
-        // add all attributes set on the embed object
-        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());
-            }
-        }
+    // beforeload events can modify the DOM, potentially causing
+    // RenderWidget::destroy() to be called.  Ensure we haven't been
+    // destroyed before continuing.
+    // FIXME: Should this render fallback content?
+    if (!objectElement->renderer())
+        return;
+
+    bool success = beforeLoadAllowedLoad && frame->loader()->subframeLoader()->requestObject(objectElement, url, objectElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
 
-        if (onlyCreateNonNetscapePlugins) {
-            KURL completedURL;
-            if (!url.isEmpty())
-                completedURL = frame->loader()->completeURL(url);
+    if (!success && fallbackContent)
+        objectElement->renderFallbackContent();
+}
 
-            if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentNetscapePlugin)
-                return;
+// 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();
 
-        if (embedElement->dispatchBeforeLoadEvent(url))
-            frame->loader()->subframeLoader()->requestObject(this, url, embedElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
+    embedElement->setNeedWidgetUpdate(false);
+
+    if (url.isEmpty() && serviceType.isEmpty())
+        return;
+    if (!isURLAllowed(embedElement->document(), url))
+        return;
+
+    Vector<String> paramNames;
+    Vector<String> paramValues;
+    parametersFromEmbed(embedElement, paramNames, paramValues);
+
+    if (onlyCreateNonNetscapePlugins && isNetscapePlugin(frame, url, serviceType))
+        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);
+    }
+}
+
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+// FIXME: This belongs on HTMLMediaElement.
+static void updateWidgetForMediaElement(HTMLMediaElement* mediaElement, bool ignored)
+{
+    Vector<String> paramNames;
+    Vector<String> paramValues;
+    KURL kurl;
+
+    mediaElement->getPluginProxyParams(kurl, paramNames, paramValues);
+    mediaElement->setNeedWidgetUpdate(false);
+    frame->loader()->subframeLoader()->loadMediaPlayerProxyPlugin(mediaElement, kurl, paramNames, paramValues);
+}
+#endif
+
+void RenderEmbeddedObject::updateWidget(bool onlyCreateNonNetscapePlugins)
+{
+    if (!m_replacementText.isNull() || !node()) // Check the node in case destroy() has been called.
+        return;
+
+    // The calls to SubframeLoader::requestObject within this function can result in a plug-in being initialized.
+    // This can run cause arbitrary JavaScript to run and may result in this RenderObject being detached from
+    // the render tree and destroyed, causing a crash like <rdar://problem/6954546>.  By extending our lifetime
+    // artifically to ensure that we remain alive for the duration of plug-in initialization.
+    RenderWidgetProtector protector(this);
+
+    if (node()->hasTagName(objectTag)) {
+        HTMLObjectElement* objectElement = static_cast<HTMLObjectElement*>(node());
+        updateWidgetForObjectElement(objectElement, onlyCreateNonNetscapePlugins);
+    } else if (node()->hasTagName(embedTag)) {
+        HTMLEmbedElement* embedElement = static_cast<HTMLEmbedElement*>(node());
+        updateWidgetForEmbedElement(embedElement, onlyCreateNonNetscapePlugins);
     }
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)        
     else if (node()->hasTagName(videoTag) || node()->hasTagName(audioTag)) {
         HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(node());
-        KURL kurl;
-
-        mediaElement->getPluginProxyParams(kurl, paramNames, paramValues);
-        mediaElement->setNeedWidgetUpdate(false);
-        frame->loader()->subframeLoader()->loadMediaPlayerProxyPlugin(node(), kurl, paramNames, paramValues);
+        updateWidgetForMediaElement(mediaElement, onlyCreateNonNetscapePlugins);
     }
 #endif
 }
diff --git a/WebCore/rendering/RenderEmbeddedObject.h b/WebCore/rendering/RenderEmbeddedObject.h
index 0944094..6376f93 100644
--- a/WebCore/rendering/RenderEmbeddedObject.h
+++ b/WebCore/rendering/RenderEmbeddedObject.h
@@ -41,7 +41,9 @@ public:
     void setShowsCrashedPluginIndicator();
     bool showsMissingPluginIndicator() const { return m_showsMissingPluginIndicator; }
 
+    // FIXME: This belongs on HTMLObjectElement.
     bool hasFallbackContent() const { return m_hasFallbackContent; }
+    void setHasFallbackContent(bool hasFallbackContent) { m_hasFallbackContent = hasFallbackContent; }
 
     void handleMissingPluginIndicatorEvent(Event*);
 
@@ -68,7 +70,7 @@ private:
     bool getReplacementTextGeometry(int tx, int ty, FloatRect& contentRect, Path&, FloatRect& replacementTextRect, Font&, TextRun&, float& textWidth);
 
     String m_replacementText;
-    bool m_hasFallbackContent;
+    bool m_hasFallbackContent; // FIXME: This belongs on HTMLObjectElement.
     bool m_showsMissingPluginIndicator;
     bool m_missingPluginIndicatorIsPressed;
     bool m_mouseDownWasInMissingPluginIndicator;
diff --git a/WebCore/rendering/RenderLayerCompositor.h b/WebCore/rendering/RenderLayerCompositor.h
index c2db3e2..eeac203 100644
--- a/WebCore/rendering/RenderLayerCompositor.h
+++ b/WebCore/rendering/RenderLayerCompositor.h
@@ -155,6 +155,7 @@ public:
     // their parent document.
     bool shouldPropagateCompositingToEnclosingIFrame() const;
 
+    // FIXME: This should be a RenderIFrame*
     HTMLFrameOwnerElement* enclosingIFrameElement() const;
 
     static RenderLayerCompositor* iframeContentsCompositor(RenderIFrame*);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list