Changeset 66710 in webkit


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

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

Reviewed by Dimitri Glazkov.

Move updateWidget implementations into the DOM
https://bugs.webkit.org/show_bug.cgi?id=45058

Unfortunately it's not yet possible to share an updateWidget
implementation between <embed> and <object>. That would amount to
(positive) functional changes for <embed> which I'd will separate
into a later patch. I will also have to untangle <object>'s <param>
walk from its url/serviceType calculations.

However after this patch it's slap-you-across-the-face obvious that
RenderEmbeddedObject::updateWidget was the wrong place for this code.
RenderEmbeddedObject::updateWidget still exists, but only as a
pseudo-virtual-method dispatcher. Unless we add updateWidget() to
HTMLElement, we won't be able to use real virtual dispatch.

I may need to consider making "having a widget" a has-a relationship
with some sort of WidgetContainer object which Media and Plugin can
share. Or its also possible that Media's use of the widget code here
is just wrong. Certainly now that updateWidget was moved into HTMLMediaElement
it becomes obvious that HTMLMediaElement has duplicate code for updating widgets.

No functional changes, thus no tests.

  • html/HTMLEmbedElement.cpp: (WebCore::HTMLEmbedElement::updateWidget):
  • html/HTMLEmbedElement.h:
  • html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::updateWidget):
  • html/HTMLMediaElement.h:
  • html/HTMLObjectElement.cpp: (WebCore::HTMLObjectElement::updateWidget):
  • html/HTMLObjectElement.h: (WebCore::HTMLObjectElement::useFallbackContent):
  • html/HTMLPlugInImageElement.h: (WebCore::HTMLPlugInImageElement::needsWidgetUpdate): (WebCore::HTMLPlugInImageElement::setNeedsWidgetUpdate):
  • loader/FrameLoader.cpp:
  • rendering/RenderEmbeddedObject.cpp: (WebCore::RenderEmbeddedObject::updateWidget):
Location:
trunk/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r66709 r66710  
     12010-09-02  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Move updateWidget implementations into the DOM
     6        https://bugs.webkit.org/show_bug.cgi?id=45058
     7
     8        Unfortunately it's not yet possible to share an updateWidget
     9        implementation between <embed> and <object>.  That would amount to
     10        (positive) functional changes for <embed> which I'd will separate
     11        into a later patch.  I will also have to untangle <object>'s <param>
     12        walk from its url/serviceType calculations.
     13
     14        However after this patch it's slap-you-across-the-face obvious that
     15        RenderEmbeddedObject::updateWidget was the wrong place for this code.
     16        RenderEmbeddedObject::updateWidget still exists, but only as a
     17        pseudo-virtual-method dispatcher.  Unless we add updateWidget() to
     18        HTMLElement, we won't be able to use real virtual dispatch.
     19
     20        I may need to consider making "having a widget" a has-a relationship
     21        with some sort of WidgetContainer object which Media and Plugin can
     22        share.  Or its also possible that Media's use of the widget code here
     23        is just wrong.  Certainly now that updateWidget was moved into HTMLMediaElement
     24        it becomes obvious that HTMLMediaElement has duplicate code for updating widgets.
     25
     26        No functional changes, thus no tests.
     27
     28        * html/HTMLEmbedElement.cpp:
     29        (WebCore::HTMLEmbedElement::updateWidget):
     30        * html/HTMLEmbedElement.h:
     31        * html/HTMLMediaElement.cpp:
     32        (WebCore::HTMLMediaElement::updateWidget):
     33        * html/HTMLMediaElement.h:
     34        * html/HTMLObjectElement.cpp:
     35        (WebCore::HTMLObjectElement::updateWidget):
     36        * html/HTMLObjectElement.h:
     37        (WebCore::HTMLObjectElement::useFallbackContent):
     38        * html/HTMLPlugInImageElement.h:
     39        (WebCore::HTMLPlugInImageElement::needsWidgetUpdate):
     40        (WebCore::HTMLPlugInImageElement::setNeedsWidgetUpdate):
     41        * loader/FrameLoader.cpp:
     42        * rendering/RenderEmbeddedObject.cpp:
     43        (WebCore::RenderEmbeddedObject::updateWidget):
     44
    1452010-09-02  Eric Seidel  <eric@webkit.org>
    246
  • trunk/WebCore/html/HTMLEmbedElement.cpp

    r66709 r66710  
    134134}
    135135
     136// FIXME: This should be unified with HTMLObjectElement::updateWidget and
     137// moved down into HTMLPluginImageElement.cpp
     138void HTMLEmbedElement::updateWidget(bool onlyCreateNonNetscapePlugins)
     139{
     140    // FIXME: We should ASSERT(needsWidgetUpdate()), but currently
     141    // FrameView::updateWidget() calls updateWidget(false) without checking if
     142    // the widget actually needs updating!
     143    setNeedsWidgetUpdate(false);
     144
     145    if (m_url.isEmpty() && m_serviceType.isEmpty())
     146        return;
     147
     148    // Note these pass m_url and m_serviceType to allow better code sharing with
     149    // <object> which modifies url and serviceType before calling these.
     150    if (!allowedToLoadFrameURL(m_url))
     151        return;
     152    if (onlyCreateNonNetscapePlugins && wouldLoadAsNetscapePlugin(m_url, m_serviceType))
     153        return;
     154
     155    // FIXME: These should be joined into a PluginParameters class.
     156    Vector<String> paramNames;
     157    Vector<String> paramValues;
     158    parametersForPlugin(paramNames, paramValues);
     159
     160    if (!dispatchBeforeLoadEvent(m_url))
     161        return;
     162
     163    SubframeLoader* loader = document()->frame()->loader()->subframeLoader();
     164    // FIXME: beforeLoad could have detached the renderer!  Just like in the <object> case above.
     165    loader->requestObject(this, m_url, getAttribute(nameAttr), m_serviceType, paramNames, paramValues);
     166}
     167
    136168bool HTMLEmbedElement::rendererIsNeeded(RenderStyle* style)
    137169{
  • trunk/WebCore/html/HTMLEmbedElement.h

    r66709 r66710  
    3232    static PassRefPtr<HTMLEmbedElement> create(const QualifiedName&, Document*, bool createdByParser);
    3333
    34     void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues);
     34    void updateWidget(bool onlyCreateNonNetscapePlugins);
    3535
    3636private:
     
    5151
    5252    virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
     53
     54    void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues);
    5355};
    5456
  • trunk/WebCore/html/HTMLMediaElement.cpp

    r66311 r66710  
    20112011        m_needWidgetUpdate = false;
    20122012}
     2013
     2014void HTMLMediaElement::updateWidget(bool)
     2015{
     2016    mediaElement->setNeedWidgetUpdate(false);
     2017
     2018    Vector<String> paramNames;
     2019    Vector<String> paramValues;
     2020    KURL kurl;
     2021   
     2022    mediaElement->getPluginProxyParams(kurl, paramNames, paramValues);
     2023    SubframeLoader* loader = document()->frame()->loader()->subframeLoader();
     2024    loader->loadMediaPlayerProxyPlugin(mediaElement, kurl, paramNames, paramValues);
     2025}
     2026
    20132027#endif // ENABLE(PLUGIN_PROXY_FOR_VIDEO)
    20142028
  • trunk/WebCore/html/HTMLMediaElement.h

    r66311 r66710  
    154154    virtual void finishParsingChildren();
    155155    void createMediaPlayerProxy();
     156    void updateWidget(bool onlyCreateNonNetscapePlugins);
    156157#endif
    157158
  • trunk/WebCore/html/HTMLObjectElement.cpp

    r66709 r66710  
    237237}
    238238
     239// FIXME: This should be unified with HTMLEmbedElement::updateWidget and
     240// moved down into HTMLPluginImageElement.cpp
     241void HTMLObjectElement::updateWidget(bool onlyCreateNonNetscapePlugins)
     242{
     243    // FIXME: We should ASSERT(needsWidgetUpdate()), but currently
     244    // FrameView::updateWidget() calls updateWidget(false) without checking if
     245    // the widget actually needs updating!
     246    setNeedsWidgetUpdate(false);
     247    // FIXME: This should ASSERT isFinishedParsingChildren() instead.
     248    if (!isFinishedParsingChildren())
     249        return;
     250
     251    String url = this->url();
     252    String serviceType = this->serviceType();
     253
     254    // FIXME: These should be joined into a PluginParameters class.
     255    Vector<String> paramNames;
     256    Vector<String> paramValues;
     257    parametersForPlugin(paramNames, paramValues, url, serviceType);
     258
     259    // Note: url is modified above by parametersForPlugin.
     260    if (!allowedToLoadFrameURL(url))
     261        return;
     262
     263    bool fallbackContent = hasFallbackContent();
     264    renderEmbeddedObject()->setHasFallbackContent(fallbackContent);
     265
     266    if (onlyCreateNonNetscapePlugins && wouldLoadAsNetscapePlugin(url, serviceType))
     267        return;
     268
     269    bool beforeLoadAllowedLoad = dispatchBeforeLoadEvent(url);
     270
     271    // beforeload events can modify the DOM, potentially causing
     272    // RenderWidget::destroy() to be called.  Ensure we haven't been
     273    // destroyed before continuing.
     274    // FIXME: Should this render fallback content?
     275    if (!renderer())
     276        return;
     277
     278    SubframeLoader* loader = document()->frame()->loader()->subframeLoader();
     279    bool success = beforeLoadAllowedLoad && loader->requestObject(this, url, getAttribute(nameAttr), serviceType, paramNames, paramValues);
     280
     281    if (!success && fallbackContent)
     282        renderFallbackContent();
     283}
     284
    239285bool HTMLObjectElement::rendererIsNeeded(RenderStyle* style)
    240286{
  • trunk/WebCore/html/HTMLObjectElement.h

    r66709 r66710  
    3232    static PassRefPtr<HTMLObjectElement> create(const QualifiedName&, Document*, bool createdByParser);
    3333
    34     void renderFallbackContent();
    35 
    3634    bool isDocNamedItem() const { return m_docNamedItem; }
    3735
     
    4038    bool containsJavaApplet() const;
    4139
    42     bool hasFallbackContent() const;
     40    void updateWidget(bool onlyCreateNonNetscapePlugins);
     41
    4342    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);
     43    void renderFallbackContent();
    4844
    4945private:
     
    6763    void updateDocNamedItem();
    6864
     65    bool hasFallbackContent() const;
     66   
     67    // FIXME: This function should not deal with url or serviceType
     68    // so that we can better share code between <object> and <embed>.
     69    void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType);
     70
    6971    AtomicString m_id;
    7072    String m_classId;
  • trunk/WebCore/html/HTMLPlugInImageElement.h

    r66709 r66710  
    3636    const String& url() const { return m_url; }
    3737
    38     // These can all move to be protected once updateWidget is moved out of RenderEmbeddedObject.cpp
    39     bool needsWidgetUpdate() const { return m_needsWidgetUpdate; }
    40     void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; }
    41     bool allowedToLoadFrameURL(const String& url);
    42     bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType);
    43 
    4438    RenderEmbeddedObject* renderEmbeddedObject() const;
    4539
     
    5650    virtual void attach();
    5751    virtual void detach();
     52
     53    bool needsWidgetUpdate() const { return m_needsWidgetUpdate; }
     54    void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; }
     55
     56    bool allowedToLoadFrameURL(const String& url);
     57    bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType);
    5858
    5959private:
  • trunk/WebCore/loader/FrameLoader.cpp

    r66677 r66710  
    10431043}
    10441044
     1045// FIXME: This does not belong in FrameLoader!
    10451046void FrameLoader::handleFallbackContent()
    10461047{
  • trunk/WebCore/rendering/RenderEmbeddedObject.cpp

    r66709 r66710  
    102102}
    103103#endif
    104    
    105 // FIXME: This belongs on HTMLObjectElement, HTMLPluginElement or HTMLFrameOwnerElement.
    106 static void updateWidgetForObjectElement(HTMLObjectElement* objectElement, bool onlyCreateNonNetscapePlugins)
    107 {
    108     // FIXME: We should ASSERT(objectElement->needsWidgetUpdate()), but currently
    109     // FrameView::updateWidget() calls updateWidget(false) without checking if
    110     // the widget actually needs updating!
    111     objectElement->setNeedsWidgetUpdate(false);
    112     // FIXME: This should ASSERT isFinishedParsingChildren() instead.
    113     if (!objectElement->isFinishedParsingChildren())
    114         return;
    115 
    116     String url = objectElement->url();
    117     String serviceType = objectElement->serviceType();
    118 
    119     Vector<String> paramNames;
    120     Vector<String> paramValues;
    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();
    128     objectElement->renderEmbeddedObject()->setHasFallbackContent(fallbackContent);
    129 
    130     if (onlyCreateNonNetscapePlugins && objectElement->wouldLoadAsNetscapePlugin(url, serviceType))
    131         return;
    132 
    133     bool beforeLoadAllowedLoad = objectElement->dispatchBeforeLoadEvent(url);
    134 
    135     // beforeload events can modify the DOM, potentially causing
    136     // RenderWidget::destroy() to be called.  Ensure we haven't been
    137     // destroyed before continuing.
    138     // FIXME: Should this render fallback content?
    139     if (!objectElement->renderer())
    140         return;
    141 
    142     SubframeLoader* loader = objectElement->document()->frame()->loader()->subframeLoader();
    143     bool success = beforeLoadAllowedLoad && loader->requestObject(objectElement, url, objectElement->getAttribute(nameAttr), serviceType, paramNames, paramValues);
    144 
    145     if (!success && fallbackContent)
    146         objectElement->renderFallbackContent();
    147 }
    148 
    149 // FIXME: This belongs on HTMLEmbedElement, HTMLPluginElement or HTMLFrameOwnerElement.
    150 static void updateWidgetForEmbedElement(HTMLEmbedElement* embedElement, bool onlyCreateNonNetscapePlugins)
    151 {
    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 
    157     String url = embedElement->url();
    158     String serviceType = embedElement->serviceType();
    159     if (url.isEmpty() && serviceType.isEmpty())
    160         return;
    161     if (!embedElement->allowedToLoadFrameURL(url))
    162         return;
    163 
    164     if (onlyCreateNonNetscapePlugins && embedElement->wouldLoadAsNetscapePlugin(url, serviceType))
    165         return;
    166 
    167     Vector<String> paramNames;
    168     Vector<String> paramValues;
    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);
    177 }
    178 
    179 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
    180 // FIXME: This belongs on HTMLMediaElement.
    181 static void updateWidgetForMediaElement(HTMLMediaElement* mediaElement, bool ignored)
    182 {
    183     Vector<String> paramNames;
    184     Vector<String> paramValues;
    185     KURL kurl;
    186 
    187     mediaElement->getPluginProxyParams(kurl, paramNames, paramValues);
    188     mediaElement->setNeedWidgetUpdate(false);
    189     frame->loader()->subframeLoader()->loadMediaPlayerProxyPlugin(mediaElement, kurl, paramNames, paramValues);
    190 }
    191 #endif
    192 
     104
     105// FIXME: This should be moved into FrameView (the only caller)
    193106void RenderEmbeddedObject::updateWidget(bool onlyCreateNonNetscapePlugins)
    194107{
     
    202115    RenderWidgetProtector protector(this);
    203116
    204     if (node()->hasTagName(objectTag)) {
    205         HTMLObjectElement* objectElement = static_cast<HTMLObjectElement*>(node());
    206         updateWidgetForObjectElement(objectElement, onlyCreateNonNetscapePlugins);
    207     } else if (node()->hasTagName(embedTag)) {
    208         HTMLEmbedElement* embedElement = static_cast<HTMLEmbedElement*>(node());
    209         updateWidgetForEmbedElement(embedElement, onlyCreateNonNetscapePlugins);
    210     }
     117    if (node()->hasTagName(objectTag))
     118        static_cast<HTMLObjectElement*>(node())->updateWidget(onlyCreateNonNetscapePlugins);
     119    else if (node()->hasTagName(embedTag))
     120        static_cast<HTMLEmbedElement*>(node())->updateWidget(onlyCreateNonNetscapePlugins);
    211121#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)       
    212     else if (node()->hasTagName(videoTag) || node()->hasTagName(audioTag)) {
    213         HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(node());
    214         updateWidgetForMediaElement(mediaElement, onlyCreateNonNetscapePlugins);
    215     }
     122    else if (node()->hasTagName(videoTag) || node()->hasTagName(audioTag))
     123        static_cast<HTMLMediaElement*>(node())->updateWidget(onlyCreateNonNetscapePlugins);
    216124#endif
    217125    else
Note: See TracChangeset for help on using the changeset viewer.