Clean up HTMLObjectElement/HTMLEmbedElement layoutObjectIsNeeded
[chromium-blink-merge.git] / third_party / WebKit / Source / core / html / HTMLObjectElement.h
blobd0277d3fe8c7b9ddec1985d9b6d0bfe0059bc3d6
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.
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"
29 namespace blink {
31 class HTMLFormElement;
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 DECLARE_VIRTUAL_TRACE();
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 { }
66 #if !ENABLE(OILPAN)
67 using Node::ref;
68 using Node::deref;
69 #endif
71 virtual bool canContainRangeEndPoint() const override { return useFallbackContent(); }
73 bool isExposed() const;
75 private:
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 void didMoveToNewDocument(Document& oldDocument) override;
87 virtual void childrenChanged(const ChildrenChange&) override;
89 virtual bool isURLAttribute(const Attribute&) const override;
90 virtual bool hasLegalLinkAttribute(const QualifiedName&) const override;
91 virtual const QualifiedName& subResourceAttributeName() const override;
92 virtual const AtomicString imageSourceURL() const override;
94 virtual LayoutPart* existingLayoutPart() const override;
96 virtual void updateWidgetInternal() override;
97 void updateDocNamedItem();
99 void reattachFallbackContent();
101 // FIXME: This function should not deal with url or serviceType
102 // so that we can better share code between <object> and <embed>.
103 void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType);
105 bool hasValidClassId();
107 void reloadPluginOnAttributeChange(const QualifiedName&);
109 #if !ENABLE(OILPAN)
110 virtual void refFormAssociatedElement() override { ref(); }
111 virtual void derefFormAssociatedElement() override { deref(); }
112 #endif
114 virtual bool shouldRegisterAsNamedItem() const override { return true; }
115 virtual bool shouldRegisterAsExtraNamedItem() const override { return true; }
117 String m_classId;
118 bool m_useFallbackContent : 1;
121 // Intentionally left unimplemented, template specialization needs to be provided for specific
122 // return types.
123 template<typename T> inline const T& toElement(const FormAssociatedElement&);
124 template<typename T> inline const T* toElement(const FormAssociatedElement*);
126 // Make toHTMLObjectElement() accept a FormAssociatedElement as input instead of a Node.
127 template<> inline const HTMLObjectElement* toElement<HTMLObjectElement>(const FormAssociatedElement* element)
129 ASSERT_WITH_SECURITY_IMPLICATION(!element || !element->isFormControlElement());
130 ASSERT_WITH_SECURITY_IMPLICATION(!element || !element->isLabelElement());
131 const HTMLObjectElement* objectElement = static_cast<const HTMLObjectElement*>(element);
132 // We need to assert after the cast because FormAssociatedElement doesn't
133 // have hasTagName.
134 ASSERT_WITH_SECURITY_IMPLICATION(!objectElement || objectElement->hasTagName(HTMLNames::objectTag));
135 return objectElement;
138 template<> inline const HTMLObjectElement& toElement<HTMLObjectElement>(const FormAssociatedElement& element)
140 ASSERT_WITH_SECURITY_IMPLICATION(!element.isFormControlElement());
141 ASSERT_WITH_SECURITY_IMPLICATION(!element.isLabelElement());
142 const HTMLObjectElement& objectElement = static_cast<const HTMLObjectElement&>(element);
143 // We need to assert after the cast because FormAssociatedElement doesn't
144 // have hasTagName.
145 ASSERT_WITH_SECURITY_IMPLICATION(objectElement.hasTagName(HTMLNames::objectTag));
146 return objectElement;
149 } // namespace blink
151 #endif // HTMLObjectElement_h