Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / HTMLObjectElement.h
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 "core/html/FormAssociatedElement.h"
27 #include "core/html/HTMLPlugInElement.h"
28
29 namespace blink {
30
31 class HTMLFormElement;
32
33 class HTMLObjectElement final : public HTMLPlugInElement, public FormAssociatedElement {
34     DEFINE_WRAPPERTYPEINFO();
35     WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLObjectElement);
36 public:
37     static PassRefPtrWillBeRawPtr<HTMLObjectElement> create(Document&, HTMLFormElement*, bool createdByParser);
38     virtual ~HTMLObjectElement();
39     virtual void trace(Visitor*) override;
40
41     const String& classId() const { return m_classId; }
42
43     virtual HTMLFormElement* formOwner() const override;
44
45     bool containsJavaApplet() const;
46
47     virtual bool hasFallbackContent() const override;
48     virtual bool useFallbackContent() const override;
49     virtual void renderFallbackContent() override;
50
51     virtual bool isFormControlElement() const override { return false; }
52
53     virtual bool isEnumeratable() const override { return true; }
54     virtual bool isInteractiveContent() const override;
55     virtual bool appendFormData(FormDataList&, bool) override;
56
57     virtual bool isObjectElement() const override { return true; }
58
59     // Implementations of constraint validation API.
60     // Note that the object elements are always barred from constraint validation.
61     virtual String validationMessage() const override { return String(); }
62     bool checkValidity() { return true; }
63     bool reportValidity() { return true; }
64     virtual void setCustomValidity(const String&) override { }
65
66 #if !ENABLE(OILPAN)
67     using Node::ref;
68     using Node::deref;
69 #endif
70
71     virtual bool canContainRangeEndPoint() const override { return useFallbackContent(); }
72
73     bool isExposed() const;
74
75 private:
76     HTMLObjectElement(Document&, HTMLFormElement*, bool createdByParser);
77
78     virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
79     virtual bool isPresentationAttribute(const QualifiedName&) const override;
80     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) override;
81
82     virtual InsertionNotificationRequest insertedInto(ContainerNode*) override;
83     virtual void removedFrom(ContainerNode*) override;
84
85     virtual bool rendererIsNeeded(const RenderStyle&) override;
86     virtual void didMoveToNewDocument(Document& oldDocument) override;
87
88     virtual void childrenChanged(const ChildrenChange&) override;
89
90     virtual bool isURLAttribute(const Attribute&) const override;
91     virtual bool hasLegalLinkAttribute(const QualifiedName&) const override;
92     virtual const QualifiedName& subResourceAttributeName() const override;
93     virtual const AtomicString imageSourceURL() const override;
94
95     virtual RenderPart* existingRenderPart() const override;
96
97     virtual void updateWidgetInternal() override;
98     void updateDocNamedItem();
99
100     void reattachFallbackContent();
101
102     // FIXME: This function should not deal with url or serviceType
103     // so that we can better share code between <object> and <embed>.
104     void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType);
105
106     bool hasValidClassId();
107
108     void reloadPluginOnAttributeChange(const QualifiedName&);
109
110 #if !ENABLE(OILPAN)
111     virtual void refFormAssociatedElement() override { ref(); }
112     virtual void derefFormAssociatedElement() override { deref(); }
113 #endif
114
115     virtual bool shouldRegisterAsNamedItem() const override { return true; }
116     virtual bool shouldRegisterAsExtraNamedItem() const override { return true; }
117
118     String m_classId;
119     bool m_useFallbackContent : 1;
120 };
121
122 // Intentionally left unimplemented, template specialization needs to be provided for specific
123 // return types.
124 template<typename T> inline const T& toElement(const FormAssociatedElement&);
125 template<typename T> inline const T* toElement(const FormAssociatedElement*);
126
127 // Make toHTMLObjectElement() accept a FormAssociatedElement as input instead of a Node.
128 template<> inline const HTMLObjectElement* toElement<HTMLObjectElement>(const FormAssociatedElement* element)
129 {
130     ASSERT_WITH_SECURITY_IMPLICATION(!element || !element->isFormControlElement());
131     ASSERT_WITH_SECURITY_IMPLICATION(!element || !element->isLabelElement());
132     const HTMLObjectElement* objectElement = static_cast<const HTMLObjectElement*>(element);
133     // We need to assert after the cast because FormAssociatedElement doesn't
134     // have hasTagName.
135     ASSERT_WITH_SECURITY_IMPLICATION(!objectElement || objectElement->hasTagName(HTMLNames::objectTag));
136     return objectElement;
137 }
138
139 template<> inline const HTMLObjectElement& toElement<HTMLObjectElement>(const FormAssociatedElement& element)
140 {
141     ASSERT_WITH_SECURITY_IMPLICATION(!element.isFormControlElement());
142     ASSERT_WITH_SECURITY_IMPLICATION(!element.isLabelElement());
143     const HTMLObjectElement& objectElement = static_cast<const HTMLObjectElement&>(element);
144     // We need to assert after the cast because FormAssociatedElement doesn't
145     // have hasTagName.
146     ASSERT_WITH_SECURITY_IMPLICATION(objectElement.hasTagName(HTMLNames::objectTag));
147     return objectElement;
148 }
149
150 } // namespace blink
151
152 #endif // HTMLObjectElement_h