Changeset 66653 in webkit


Ignore:
Timestamp:
Sep 2, 2010 3:05:36 AM (14 years ago)
Author:
eric@webkit.org
Message:

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

Reviewed by Dimitri Glazkov.

Share more code between HTMLObjectElement and HTMLEmbedElement
https://bugs.webkit.org/show_bug.cgi?id=45054

This pushes more of HTMLObjectElement code down into
HTMLPlugInImageElement so that it can be shared with HTMLEmbedElement.

I also moved a little code from HTMLPluginElement to HTMLPlugInImageElement
since HTMLAppletElement does not need to share this same widget update logic.
This is a small correction from the previous change.

This patch was originally written in one piece and reviewed by Dimitri.
I'm landing it as three separate changes for easier readability and less
chance of regression.

No functional change, thus no tests.

  • html/HTMLEmbedElement.cpp:
  • html/HTMLEmbedElement.h:
  • html/HTMLObjectElement.cpp: (WebCore::HTMLObjectElement::attach): (WebCore::HTMLObjectElement::finishParsingChildren): (WebCore::HTMLObjectElement::detach): (WebCore::HTMLObjectElement::recalcStyle): (WebCore::HTMLObjectElement::childrenChanged): (WebCore::HTMLObjectElement::renderFallbackContent):
  • html/HTMLObjectElement.h: (WebCore::HTMLObjectElement::useFallbackContent):
  • html/HTMLPlugInElement.cpp:
  • html/HTMLPlugInElement.h:
  • html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::createRenderer): (WebCore::HTMLPlugInImageElement::updateWidget): (WebCore::HTMLPlugInImageElement::updateWidgetCallback):
  • html/HTMLPlugInImageElement.h: (WebCore::HTMLPlugInImageElement::canLazyAttach): (WebCore::HTMLPlugInImageElement::useFallbackContent):
Location:
trunk/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r66652 r66653  
     12010-09-02  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Share more code between HTMLObjectElement and HTMLEmbedElement
     6        https://bugs.webkit.org/show_bug.cgi?id=45054
     7
     8        This pushes more of HTMLObjectElement code down into
     9        HTMLPlugInImageElement so that it can be shared with HTMLEmbedElement.
     10
     11        I also moved a little code from HTMLPluginElement to HTMLPlugInImageElement
     12        since HTMLAppletElement does not need to share this same widget update logic.
     13        This is a small correction from the previous change.
     14
     15        This patch was originally written in one piece and reviewed by Dimitri.
     16        I'm landing it as three separate changes for easier readability and less
     17        chance of regression.
     18
     19        No functional change, thus no tests.
     20
     21        * html/HTMLEmbedElement.cpp:
     22        * html/HTMLEmbedElement.h:
     23        * html/HTMLObjectElement.cpp:
     24        (WebCore::HTMLObjectElement::attach):
     25        (WebCore::HTMLObjectElement::finishParsingChildren):
     26        (WebCore::HTMLObjectElement::detach):
     27        (WebCore::HTMLObjectElement::recalcStyle):
     28        (WebCore::HTMLObjectElement::childrenChanged):
     29        (WebCore::HTMLObjectElement::renderFallbackContent):
     30        * html/HTMLObjectElement.h:
     31        (WebCore::HTMLObjectElement::useFallbackContent):
     32        * html/HTMLPlugInElement.cpp:
     33        * html/HTMLPlugInElement.h:
     34        * html/HTMLPlugInImageElement.cpp:
     35        (WebCore::HTMLPlugInImageElement::createRenderer):
     36        (WebCore::HTMLPlugInImageElement::updateWidget):
     37        (WebCore::HTMLPlugInImageElement::updateWidgetCallback):
     38        * html/HTMLPlugInImageElement.h:
     39        (WebCore::HTMLPlugInImageElement::canLazyAttach):
     40        (WebCore::HTMLPlugInImageElement::useFallbackContent):
     41
    1422010-09-02  Jer Noble  <jer.noble@apple.com>
    243
  • trunk/WebCore/html/HTMLEmbedElement.cpp

    r66650 r66653  
    152152}
    153153
    154 RenderObject* HTMLEmbedElement::createRenderer(RenderArena* arena, RenderStyle*)
    155 {
    156     if (isImageType()) {
    157         RenderImage* image = new (arena) RenderImage(this);
    158         image->setImageResource(RenderImageResource::create());
    159         return image;
    160     }
    161     return new (arena) RenderEmbeddedObject(this);
    162 }
    163 
    164154void HTMLEmbedElement::attach()
    165155{
     
    181171            toRenderImage(renderer())->imageResource()->setCachedImage(m_imageLoader->image());
    182172    }
    183 }
    184 
    185 void HTMLEmbedElement::updateWidget()
    186 {
    187     document()->updateStyleIfNeeded();
    188     if (needsWidgetUpdate() && renderEmbeddedObject() && !isImageType())
    189         renderEmbeddedObject()->updateWidget(true);
    190173}
    191174
  • trunk/WebCore/html/HTMLEmbedElement.h

    r66650 r66653  
    3939
    4040    virtual void attach();
    41     virtual bool canLazyAttach() { return false; }
    4241    virtual bool rendererIsNeeded(RenderStyle*);
    43     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
    4442    virtual void insertedIntoDocument();
    4543    virtual void removedFromDocument();
     
    4846    virtual bool isURLAttribute(Attribute*) const;
    4947    virtual const QualifiedName& imageSourceAttributeName() const;
    50 
    51     virtual void updateWidget();
    5248
    5349    virtual RenderWidget* renderWidgetForJSBindings() const;
  • trunk/WebCore/html/HTMLObjectElement.cpp

    r66650 r66653  
    132132}
    133133
    134 RenderObject* HTMLObjectElement::createRenderer(RenderArena* arena, RenderStyle* style)
    135 {
    136     // Fallback content breaks the DOM->Renderer class relationship of this
    137     // class and all superclasses because createObject won't necessarily
    138     // return a RenderEmbeddedObject, RenderPart or even RenderWidget.
    139     if (m_useFallbackContent)
    140         return RenderObject::createObject(this, style);
    141     if (isImageType()) {
    142         RenderImage* image = new (arena) RenderImage(this);
    143         image->setImageResource(RenderImageResource::create());
    144         return image;
    145     }
    146     return new (arena) RenderEmbeddedObject(this);
    147 }
    148 
    149134void HTMLObjectElement::attach()
    150135{
     
    156141    HTMLPlugInImageElement::attach();
    157142
    158     if (isImage && renderer() && !m_useFallbackContent) {
     143    if (isImage && renderer() && !useFallbackContent()) {
    159144        if (!m_imageLoader)
    160145            m_imageLoader = adoptPtr(new HTMLImageLoader(this));
     
    163148}
    164149
    165 void HTMLObjectElement::updateWidget()
    166 {
    167     document()->updateStyleIfNeeded();
    168     if (needsWidgetUpdate() && renderEmbeddedObject() && !m_useFallbackContent && !isImageType())
    169         renderEmbeddedObject()->updateWidget(true);
    170 }
    171 
    172150void HTMLObjectElement::finishParsingChildren()
    173151{
    174152    HTMLPlugInImageElement::finishParsingChildren();
    175     if (!m_useFallbackContent) {
     153    if (!useFallbackContent()) {
    176154        setNeedsWidgetUpdate(true);
    177155        if (inDocument())
     
    182160void HTMLObjectElement::detach()
    183161{
    184     if (attached() && renderer() && !m_useFallbackContent)
     162    if (attached() && renderer() && !useFallbackContent())
    185163        // Update the widget the next time we attach (detaching destroys the plugin).
    186164        setNeedsWidgetUpdate(true);
     
    212190void HTMLObjectElement::recalcStyle(StyleChange ch)
    213191{
    214     if (!m_useFallbackContent && needsWidgetUpdate() && renderer() && !isImageType()) {
     192    if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType()) {
    215193        detach();
    216194        attach();
     
    222200{
    223201    updateDocNamedItem();
    224     if (inDocument() && !m_useFallbackContent) {
     202    if (inDocument() && !useFallbackContent()) {
    225203        setNeedsWidgetUpdate(true);
    226204        setNeedsStyleRecalc();
     
    241219void HTMLObjectElement::renderFallbackContent()
    242220{
    243     if (m_useFallbackContent)
     221    if (useFallbackContent())
    244222        return;
    245223   
  • trunk/WebCore/html/HTMLObjectElement.h

    r66650 r66653  
    4040    bool containsJavaApplet() const;
    4141
    42     bool useFallbackContent() const { return m_useFallbackContent; }
     42    virtual bool useFallbackContent() const { return m_useFallbackContent; }
    4343
    4444private:
     
    4848
    4949    virtual void attach();
    50     virtual bool canLazyAttach() { return false; }
    5150    virtual bool rendererIsNeeded(RenderStyle*);
    52     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
    5351    virtual void finishParsingChildren();
    5452    virtual void detach();
     
    6159    virtual bool isURLAttribute(Attribute*) const;
    6260    virtual const QualifiedName& imageSourceAttributeName() const;
    63 
    64     virtual void updateWidget();
    6561
    6662    virtual RenderWidget* renderWidgetForJSBindings() const;
  • trunk/WebCore/html/HTMLPlugInElement.cpp

    r66650 r66653  
    178178#endif /* ENABLE(NETSCAPE_PLUGIN_API) */
    179179
    180 void HTMLPlugInElement::updateWidgetCallback(Node* n)
    181 {
    182     static_cast<HTMLPlugInElement*>(n)->updateWidget();
    183180}
    184 
    185 }
  • trunk/WebCore/html/HTMLPlugInElement.h

    r66650 r66653  
    5757    virtual void detach();
    5858
    59     static void updateWidgetCallback(Node*);
    60 
    6159    virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
    6260    virtual void parseMappedAttribute(Attribute*);
     
    6664
    6765    virtual RenderWidget* renderWidgetForJSBindings() const = 0;
    68 
    69     virtual void updateWidget() { }
    7066
    7167protected:
  • trunk/WebCore/html/HTMLPlugInImageElement.cpp

    r66650 r66653  
    2828#include "Image.h"
    2929#include "RenderEmbeddedObject.h"
     30#include "RenderImage.h"
    3031
    3132namespace WebCore {
     
    5960}
    6061
     62RenderObject* HTMLPlugInImageElement::createRenderer(RenderArena* arena, RenderStyle* style)
     63{
     64    // Fallback content breaks the DOM->Renderer class relationship of this
     65    // class and all superclasses because createObject won't necessarily
     66    // return a RenderEmbeddedObject, RenderPart or even RenderWidget.
     67    if (useFallbackContent())
     68        return RenderObject::createObject(this, style);
     69    if (isImageType()) {
     70        RenderImage* image = new (arena) RenderImage(this);
     71        image->setImageResource(RenderImageResource::create());
     72        return image;
     73    }
     74    return new (arena) RenderEmbeddedObject(this);
     75}
     76
     77void HTMLPlugInImageElement::updateWidget()
     78{
     79    document()->updateStyleIfNeeded();
     80    if (needsWidgetUpdate() && renderEmbeddedObject() && !useFallbackContent() && !isImageType())
     81        renderEmbeddedObject()->updateWidget(true);
     82}
     83
    6184void HTMLPlugInImageElement::willMoveToNewOwnerDocument()
    6285{
     
    6689}
    6790
     91void HTMLPlugInImageElement::updateWidgetCallback(Node* n)
     92{
     93    static_cast<HTMLPlugInImageElement*>(n)->updateWidget();
     94}
     95
    6896} // namespace WebCore
  • trunk/WebCore/html/HTMLPlugInImageElement.h

    r66650 r66653  
    4545    bool isImageType();
    4646
     47    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     48
     49    static void updateWidgetCallback(Node*);
     50
    4751    OwnPtr<HTMLImageLoader> m_imageLoader;
    4852    String m_serviceType;
     
    5054
    5155private:
     56    virtual bool canLazyAttach() { return false; }
     57
    5258    virtual void willMoveToNewOwnerDocument();
    5359
     60    void updateWidget();
     61    virtual bool useFallbackContent() const { return false; }
     62   
    5463    bool m_needsWidgetUpdate;
    5564};
Note: See TracChangeset for help on using the changeset viewer.