Changeset 66657 in webkit


Ignore:
Timestamp:
Sep 2, 2010 3:58:04 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.

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

No functional change, thus no tests.

  • html/HTMLEmbedElement.cpp: (WebCore::HTMLEmbedElement::HTMLEmbedElement): (WebCore::HTMLEmbedElement::create):
  • html/HTMLEmbedElement.h:
  • html/HTMLObjectElement.cpp: (WebCore::HTMLObjectElement::HTMLObjectElement):
  • html/HTMLObjectElement.h:
  • html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): (WebCore::HTMLPlugInImageElement::detach): (WebCore::HTMLPlugInImageElement::finishParsingChildren):
  • html/HTMLPlugInImageElement.h:
  • html/HTMLTagNames.in:
Location:
trunk/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r66655 r66657  
    1515        (WebCore::DOMSelection::collapse):
    1616        (WebCore::DOMSelection::selectAllChildren):
     17
     182010-09-02  Eric Seidel  <eric@webkit.org>
     19
     20        Reviewed by Dimitri Glazkov.
     21
     22        Share more code between HTMLObjectElement and HTMLEmbedElement
     23        https://bugs.webkit.org/show_bug.cgi?id=45054
     24
     25        This pushes more of HTMLObjectElement code down into
     26        HTMLPlugInImageElement so that it can be shared with HTMLEmbedElement.
     27
     28        This patch was originally written in one piece and reviewed by Dimitri.
     29        I'm landing it as four separate changes for easier readability and less
     30        chance of regression.
     31
     32        No functional change, thus no tests.
     33
     34        * html/HTMLEmbedElement.cpp:
     35        (WebCore::HTMLEmbedElement::HTMLEmbedElement):
     36        (WebCore::HTMLEmbedElement::create):
     37        * html/HTMLEmbedElement.h:
     38        * html/HTMLObjectElement.cpp:
     39        (WebCore::HTMLObjectElement::HTMLObjectElement):
     40        * html/HTMLObjectElement.h:
     41        * html/HTMLPlugInImageElement.cpp:
     42        (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement):
     43        (WebCore::HTMLPlugInImageElement::detach):
     44        (WebCore::HTMLPlugInImageElement::finishParsingChildren):
     45        * html/HTMLPlugInImageElement.h:
     46        * html/HTMLTagNames.in:
    1747
    18482010-09-02  Eric Seidel  <eric@webkit.org>
  • trunk/WebCore/html/HTMLEmbedElement.cpp

    r66653 r66657  
    4343using namespace HTMLNames;
    4444
    45 inline HTMLEmbedElement::HTMLEmbedElement(const QualifiedName& tagName, Document* document)
    46     : HTMLPlugInImageElement(tagName, document)
     45inline HTMLEmbedElement::HTMLEmbedElement(const QualifiedName& tagName, Document* document, bool createdByParser)
     46    : HTMLPlugInImageElement(tagName, document, createdByParser)
    4747{
    4848    ASSERT(hasTagName(embedTag));
    4949}
    5050
    51 PassRefPtr<HTMLEmbedElement> HTMLEmbedElement::create(const QualifiedName& tagName, Document* document)
    52 {
    53     return adoptRef(new HTMLEmbedElement(tagName, document));
     51PassRefPtr<HTMLEmbedElement> HTMLEmbedElement::create(const QualifiedName& tagName, Document* document, bool createdByParser)
     52{
     53    return adoptRef(new HTMLEmbedElement(tagName, document, createdByParser));
    5454}
    5555
  • trunk/WebCore/html/HTMLEmbedElement.h

    r66653 r66657  
    3030class HTMLEmbedElement : public HTMLPlugInImageElement {
    3131public:
    32     static PassRefPtr<HTMLEmbedElement> create(const QualifiedName&, Document*);
     32    static PassRefPtr<HTMLEmbedElement> create(const QualifiedName&, Document*, bool createdByParser);
    3333
    3434private:
    35     HTMLEmbedElement(const QualifiedName&, Document*);
     35    HTMLEmbedElement(const QualifiedName&, Document*, bool createdByParser);
    3636
    3737    virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
  • trunk/WebCore/html/HTMLObjectElement.cpp

    r66653 r66657  
    4747
    4848inline HTMLObjectElement::HTMLObjectElement(const QualifiedName& tagName, Document* document, bool createdByParser)
    49     : HTMLPlugInImageElement(tagName, document)
     49    : HTMLPlugInImageElement(tagName, document, createdByParser)
    5050    , m_docNamedItem(true)
    5151    , m_useFallbackContent(false)
    5252{
    53     // HTMLObjectElement tries to delay updating its widget while parsing until
    54     // after all of its children are parsed.
    55     setNeedsWidgetUpdate(!createdByParser);
    5653    ASSERT(hasTagName(objectTag));
    5754}
     
    148145}
    149146
    150 void HTMLObjectElement::finishParsingChildren()
    151 {
    152     HTMLPlugInImageElement::finishParsingChildren();
    153     if (!useFallbackContent()) {
    154         setNeedsWidgetUpdate(true);
    155         if (inDocument())
    156             setNeedsStyleRecalc();
    157     }
    158 }
    159 
    160 void HTMLObjectElement::detach()
    161 {
    162     if (attached() && renderer() && !useFallbackContent())
    163         // Update the widget the next time we attach (detaching destroys the plugin).
    164         setNeedsWidgetUpdate(true);
    165     HTMLPlugInImageElement::detach();
    166 }
    167 
    168147void HTMLObjectElement::insertedIntoDocument()
    169148{
  • trunk/WebCore/html/HTMLObjectElement.h

    r66653 r66657  
    4949    virtual void attach();
    5050    virtual bool rendererIsNeeded(RenderStyle*);
    51     virtual void finishParsingChildren();
    52     virtual void detach();
    5351    virtual void insertedIntoDocument();
    5452    virtual void removedFromDocument();
  • trunk/WebCore/html/HTMLPlugInImageElement.cpp

    r66653 r66657  
    3232namespace WebCore {
    3333
    34 HTMLPlugInImageElement::HTMLPlugInImageElement(const QualifiedName& tagName, Document* document)
     34HTMLPlugInImageElement::HTMLPlugInImageElement(const QualifiedName& tagName, Document* document, bool createdByParser)
    3535    : HTMLPlugInElement(tagName, document)
    36     , m_needsWidgetUpdate(false)
     36    // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay
     37    // widget updates until after all children are parsed.  For HTMLEmbedElement
     38    // this delay is unnecessary, but it is simpler to make both classes share
     39    // the same codepath in this class.
     40    , m_needsWidgetUpdate(!createdByParser)   
    3741{
    3842}
     
    7579}
    7680
     81void HTMLPlugInImageElement::detach()
     82{
     83    if (attached() && renderer() && !useFallbackContent())
     84        // Update the widget the next time we attach (detaching destroys the plugin).
     85        setNeedsWidgetUpdate(true);
     86    HTMLPlugInElement::detach();
     87}
     88
    7789void HTMLPlugInImageElement::updateWidget()
    7890{
     
    8092    if (needsWidgetUpdate() && renderEmbeddedObject() && !useFallbackContent() && !isImageType())
    8193        renderEmbeddedObject()->updateWidget(true);
     94}
     95
     96void HTMLPlugInImageElement::finishParsingChildren()
     97{
     98    HTMLPlugInElement::finishParsingChildren();
     99    if (!useFallbackContent()) {
     100        setNeedsWidgetUpdate(true);
     101        if (inDocument())
     102            setNeedsStyleRecalc();
     103    }
    82104}
    83105
  • trunk/WebCore/html/HTMLPlugInImageElement.h

    r66653 r66657  
    3939
    4040    RenderEmbeddedObject* renderEmbeddedObject() const;
    41    
     41
    4242protected:
    43     HTMLPlugInImageElement(const QualifiedName& tagName, Document*);
     43    HTMLPlugInImageElement(const QualifiedName& tagName, Document*, bool createdByParser);
    4444
    4545    bool isImageType();
    46 
    47     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
    48 
    49     static void updateWidgetCallback(Node*);
    5046
    5147    OwnPtr<HTMLImageLoader> m_imageLoader;
     
    5349    String m_url;
    5450
     51    static void updateWidgetCallback(Node*);
     52    virtual void detach();
     53
    5554private:
    5655    virtual bool canLazyAttach() { return false; }
    57 
     56    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     57   
     58    virtual void finishParsingChildren();
    5859    virtual void willMoveToNewOwnerDocument();
    5960
  • trunk/WebCore/html/HTMLTagNames.in

    r64018 r66657  
    4444dt interfaceName=HTMLElement
    4545em interfaceName=HTMLElement
    46 embed
     46embed constructorNeedsCreatedByParser
    4747fieldset interfaceName=HTMLFieldSetElement, constructorNeedsFormElement
    4848figcaption interfaceName=HTMLElement
  • trunk/WebCore/loader/SubframeLoader.cpp

    r66650 r66657  
    4141#include "HTMLPlugInImageElement.h"
    4242#include "MIMETypeRegistry.h"
    43 #include "Node.h"
    4443#include "Page.h"
    4544#include "PluginData.h"
Note: See TracChangeset for help on using the changeset viewer.