1/*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004-2017 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#pragma once
24
25#include "FormAssociatedElement.h"
26#include "HTMLPlugInImageElement.h"
27
28namespace WebCore {
29
30class HTMLFormElement;
31
32class HTMLObjectElement final : public HTMLPlugInImageElement, public FormAssociatedElement {
33 WTF_MAKE_ISO_ALLOCATED(HTMLObjectElement);
34public:
35 static Ref<HTMLObjectElement> create(const QualifiedName&, Document&, HTMLFormElement*);
36
37 bool isExposed() const { return m_isExposed; }
38 bool containsJavaApplet() const;
39
40 bool hasFallbackContent() const;
41 bool useFallbackContent() const final { return m_useFallbackContent; }
42 void renderFallbackContent();
43
44 bool willValidate() const final { return false; }
45
46 // Implementation of constraint validation API.
47 // Note that the object elements are always barred from constraint validation.
48 static bool checkValidity() { return true; }
49 static bool reportValidity() { return true; }
50
51 void setCustomValidity(const String&) final { }
52 String validationMessage() const final { return String(); }
53
54 using HTMLPlugInImageElement::ref;
55 using HTMLPlugInImageElement::deref;
56
57 HTMLFormElement* form() const final { return FormAssociatedElement::form(); }
58
59private:
60 HTMLObjectElement(const QualifiedName&, Document&, HTMLFormElement*);
61
62 void parseAttribute(const QualifiedName&, const AtomString&) final;
63 bool isPresentationAttribute(const QualifiedName&) const final;
64 void collectStyleForPresentationAttribute(const QualifiedName&, const AtomString&, MutableStyleProperties&) final;
65
66 InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final;
67 void didFinishInsertingNode() final;
68 void removedFromAncestor(RemovalType, ContainerNode&) final;
69
70 void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final;
71
72 void childrenChanged(const ChildChange&) final;
73
74 bool isURLAttribute(const Attribute&) const final;
75 const AtomString& imageSourceURL() const final;
76
77 RenderWidget* renderWidgetLoadingPlugin() const final;
78
79 void addSubresourceAttributeURLs(ListHashSet<URL>&) const final;
80
81 void updateWidget(CreatePlugins) final;
82 void updateExposedState();
83
84 // FIXME: This function should not deal with url or serviceType
85 // so that we can better share code between <object> and <embed>.
86 void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType);
87
88 bool hasValidClassId();
89
90 void refFormAssociatedElement() final { ref(); }
91 void derefFormAssociatedElement() final { deref(); }
92
93 FormNamedItem* asFormNamedItem() final { return this; }
94 FormAssociatedElement* asFormAssociatedElement() final { return this; }
95 HTMLObjectElement& asHTMLElement() final { return *this; }
96 const HTMLObjectElement& asHTMLElement() const final { return *this; }
97
98 bool isFormControlElement() const final { return false; }
99
100 bool isEnumeratable() const final { return true; }
101 bool appendFormData(DOMFormData&, bool) final;
102
103 bool canContainRangeEndPoint() const final;
104
105 bool m_isExposed { true };
106 bool m_useFallbackContent { false };
107};
108
109} // namespace WebCore
110