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.
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.
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.
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.
23 #ifndef HTMLObjectElement_h
24 #define HTMLObjectElement_h
26 #include "core/CoreExport.h"
27 #include "core/html/FormAssociatedElement.h"
28 #include "core/html/HTMLPlugInElement.h"
32 class HTMLFormElement
;
34 class CORE_EXPORT HTMLObjectElement final
: public HTMLPlugInElement
, public FormAssociatedElement
{
35 DEFINE_WRAPPERTYPEINFO();
36 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLObjectElement
);
38 static PassRefPtrWillBeRawPtr
<HTMLObjectElement
> create(Document
&, HTMLFormElement
*, bool createdByParser
);
39 ~HTMLObjectElement() override
;
40 DECLARE_VIRTUAL_TRACE();
42 const String
& classId() const { return m_classId
; }
44 HTMLFormElement
* formOwner() const override
;
46 bool containsJavaApplet() const;
48 bool hasFallbackContent() const override
;
49 bool useFallbackContent() const override
;
50 void renderFallbackContent() override
;
52 bool isFormControlElement() const override
{ return false; }
54 bool isEnumeratable() const override
{ return true; }
55 bool isInteractiveContent() const override
;
56 bool appendFormData(FormDataList
&, bool) override
;
58 // Implementations of constraint validation API.
59 // Note that the object elements are always barred from constraint validation.
60 String
validationMessage() const override
{ return String(); }
61 bool checkValidity() { return true; }
62 bool reportValidity() { return true; }
63 void setCustomValidity(const String
&) override
{ }
70 bool canContainRangeEndPoint() const override
{ return useFallbackContent(); }
72 bool isExposed() const;
75 HTMLObjectElement(Document
&, HTMLFormElement
*, bool createdByParser
);
77 void parseAttribute(const QualifiedName
&, const AtomicString
&) override
;
78 bool isPresentationAttribute(const QualifiedName
&) const override
;
79 void collectStyleForPresentationAttribute(const QualifiedName
&, const AtomicString
&, MutableStylePropertySet
*) override
;
81 InsertionNotificationRequest
insertedInto(ContainerNode
*) override
;
82 void removedFrom(ContainerNode
*) override
;
84 void didMoveToNewDocument(Document
& oldDocument
) override
;
86 void childrenChanged(const ChildrenChange
&) override
;
88 bool isURLAttribute(const Attribute
&) const override
;
89 bool hasLegalLinkAttribute(const QualifiedName
&) const override
;
90 const QualifiedName
& subResourceAttributeName() const override
;
91 const AtomicString
imageSourceURL() const override
;
93 LayoutPart
* existingLayoutPart() const override
;
95 void updateWidgetInternal() override
;
96 void updateDocNamedItem();
98 void reattachFallbackContent();
100 // FIXME: This function should not deal with url or serviceType
101 // so that we can better share code between <object> and <embed>.
102 void parametersForPlugin(Vector
<String
>& paramNames
, Vector
<String
>& paramValues
, String
& url
, String
& serviceType
);
104 bool hasValidClassId();
106 void reloadPluginOnAttributeChange(const QualifiedName
&);
109 void refFormAssociatedElement() override
{ ref(); }
110 void derefFormAssociatedElement() override
{ deref(); }
113 bool shouldRegisterAsNamedItem() const override
{ return true; }
114 bool shouldRegisterAsExtraNamedItem() const override
{ return true; }
117 bool m_useFallbackContent
: 1;
120 // Intentionally left unimplemented, template specialization needs to be provided for specific
122 template<typename T
> inline const T
& toElement(const FormAssociatedElement
&);
123 template<typename T
> inline const T
* toElement(const FormAssociatedElement
*);
125 // Make toHTMLObjectElement() accept a FormAssociatedElement as input instead of a Node.
126 template<> inline const HTMLObjectElement
* toElement
<HTMLObjectElement
>(const FormAssociatedElement
* element
)
128 ASSERT_WITH_SECURITY_IMPLICATION(!element
|| !element
->isFormControlElement());
129 ASSERT_WITH_SECURITY_IMPLICATION(!element
|| !element
->isLabelElement());
130 const HTMLObjectElement
* objectElement
= static_cast<const HTMLObjectElement
*>(element
);
131 // We need to assert after the cast because FormAssociatedElement doesn't
133 ASSERT_WITH_SECURITY_IMPLICATION(!objectElement
|| objectElement
->hasTagName(HTMLNames::objectTag
));
134 return objectElement
;
137 template<> inline const HTMLObjectElement
& toElement
<HTMLObjectElement
>(const FormAssociatedElement
& element
)
139 ASSERT_WITH_SECURITY_IMPLICATION(!element
.isFormControlElement());
140 ASSERT_WITH_SECURITY_IMPLICATION(!element
.isLabelElement());
141 const HTMLObjectElement
& objectElement
= static_cast<const HTMLObjectElement
&>(element
);
142 // We need to assert after the cast because FormAssociatedElement doesn't
144 ASSERT_WITH_SECURITY_IMPLICATION(objectElement
.hasTagName(HTMLNames::objectTag
));
145 return objectElement
;
150 #endif // HTMLObjectElement_h