1/*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB.  If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifndef HTMLObjectElement_h
24#define HTMLObjectElement_h
25
26#include "FormAssociatedElement.h"
27#include "HTMLPlugInImageElement.h"
28
29namespace WebCore {
30
31class HTMLFormElement;
32
33class HTMLObjectElement : public HTMLPlugInImageElement, public FormAssociatedElement {
34public:
35    static PassRefPtr<HTMLObjectElement> create(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
36    virtual ~HTMLObjectElement();
37
38    bool isDocNamedItem() const { return m_docNamedItem; }
39
40    const String& classId() const { return m_classId; }
41
42    bool containsJavaApplet() const;
43
44    virtual bool useFallbackContent() const { return m_useFallbackContent; }
45    void renderFallbackContent();
46
47    // Implementations of FormAssociatedElement
48    HTMLFormElement* form() const { return FormAssociatedElement::form(); }
49
50    virtual bool isFormControlElement() const { return false; }
51
52    virtual bool isEnumeratable() const { return true; }
53    virtual bool appendFormData(FormDataList&, bool);
54
55    // Implementations of constraint validation API.
56    // Note that the object elements are always barred from constraint validation.
57    String validationMessage() { return String(); }
58    bool checkValidity() { return true; }
59    void setCustomValidity(const String&) { }
60
61    virtual void attributeChanged(Attribute*, bool preserveDecls = false);
62
63    using TreeShared<ContainerNode>::ref;
64    using TreeShared<ContainerNode>::deref;
65
66private:
67    HTMLObjectElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
68
69    virtual void parseMappedAttribute(Attribute*);
70    virtual void insertedIntoTree(bool deep);
71    virtual void removedFromTree(bool deep);
72
73    virtual bool rendererIsNeeded(RenderStyle*);
74    virtual void insertedIntoDocument();
75    virtual void removedFromDocument();
76    virtual void willMoveToNewOwnerDocument();
77
78    virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
79
80    virtual bool isURLAttribute(Attribute*) const;
81    virtual const QualifiedName& imageSourceAttributeName() const;
82
83    virtual RenderWidget* renderWidgetForJSBindings() const;
84
85    virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
86
87    virtual void updateWidget(PluginCreationOption);
88    void updateDocNamedItem();
89
90    bool hasFallbackContent() const;
91
92    // FIXME: This function should not deal with url or serviceType
93    // so that we can better share code between <object> and <embed>.
94    void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType);
95
96    bool hasValidClassId();
97
98    virtual void refFormAssociatedElement() { ref(); }
99    virtual void derefFormAssociatedElement() { deref(); }
100    virtual HTMLFormElement* virtualForm() const;
101
102    virtual const AtomicString& formControlName() const;
103
104    AtomicString m_id;
105    String m_classId;
106    bool m_docNamedItem : 1;
107    bool m_useFallbackContent : 1;
108};
109
110}
111
112#endif
113