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/html/FormAssociatedElement.h"
27 #include "core/html/HTMLPlugInElement.h"
31 class HTMLFormElement;
33 class HTMLObjectElement final : public HTMLPlugInElement, public FormAssociatedElement {
34 DEFINE_WRAPPERTYPEINFO();
35 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLObjectElement);
37 static PassRefPtrWillBeRawPtr<HTMLObjectElement> create(Document&, HTMLFormElement*, bool createdByParser);
38 virtual ~HTMLObjectElement();
39 virtual void trace(Visitor*) override;
41 const String& classId() const { return m_classId; }
43 virtual HTMLFormElement* formOwner() const override;
45 bool containsJavaApplet() const;
47 virtual bool hasFallbackContent() const override;
48 virtual bool useFallbackContent() const override;
49 virtual void renderFallbackContent() override;
51 virtual bool isFormControlElement() const override { return false; }
53 virtual bool isEnumeratable() const override { return true; }
54 virtual bool isInteractiveContent() const override;
55 virtual bool appendFormData(FormDataList&, bool) override;
57 virtual bool isObjectElement() const override { return true; }
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 { }
71 virtual bool canContainRangeEndPoint() const override { return useFallbackContent(); }
73 bool isExposed() const;
76 HTMLObjectElement(Document&, HTMLFormElement*, bool createdByParser);
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;
82 virtual InsertionNotificationRequest insertedInto(ContainerNode*) override;
83 virtual void removedFrom(ContainerNode*) override;
85 virtual bool rendererIsNeeded(const RenderStyle&) override;
86 virtual void didMoveToNewDocument(Document& oldDocument) override;
88 virtual void childrenChanged(const ChildrenChange&) override;
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;
95 virtual RenderPart* existingRenderPart() const override;
97 virtual void updateWidgetInternal() override;
98 void updateDocNamedItem();
100 void reattachFallbackContent();
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);
106 bool hasValidClassId();
108 void reloadPluginOnAttributeChange(const QualifiedName&);
111 virtual void refFormAssociatedElement() override { ref(); }
112 virtual void derefFormAssociatedElement() override { deref(); }
115 virtual bool shouldRegisterAsNamedItem() const override { return true; }
116 virtual bool shouldRegisterAsExtraNamedItem() const override { return true; }
119 bool m_useFallbackContent : 1;
122 // Intentionally left unimplemented, template specialization needs to be provided for specific
124 template<typename T> inline const T& toElement(const FormAssociatedElement&);
125 template<typename T> inline const T* toElement(const FormAssociatedElement*);
127 // Make toHTMLObjectElement() accept a FormAssociatedElement as input instead of a Node.
128 template<> inline const HTMLObjectElement* toElement<HTMLObjectElement>(const FormAssociatedElement* element)
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
135 ASSERT_WITH_SECURITY_IMPLICATION(!objectElement || objectElement->hasTagName(HTMLNames::objectTag));
136 return objectElement;
139 template<> inline const HTMLObjectElement& toElement<HTMLObjectElement>(const FormAssociatedElement& element)
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
146 ASSERT_WITH_SECURITY_IMPLICATION(objectElement.hasTagName(HTMLNames::objectTag));
147 return objectElement;
152 #endif // HTMLObjectElement_h