1 /* 2 * Copyright (C) 1999 Lars Knoll (knoll (at) kde.org) 3 * (C) 1999 Antti Koivisto (koivisto (at) 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 WebCore { 30 31 class HTMLFormElement; 32 33 class HTMLObjectElement FINAL : public HTMLPlugInElement, public FormAssociatedElement { 34 public: 35 static PassRefPtr<HTMLObjectElement> create(Document&, HTMLFormElement*, bool createdByParser); 36 virtual ~HTMLObjectElement(); 37 38 const String& classId() const { return m_classId; } 39 40 virtual HTMLFormElement* formOwner() const OVERRIDE; 41 42 bool containsJavaApplet() const; 43 44 virtual bool useFallbackContent() const OVERRIDE; 45 virtual void renderFallbackContent() OVERRIDE; 46 47 virtual bool isFormControlElement() const { return false; } 48 49 virtual bool isEnumeratable() const { return true; } 50 virtual bool isInteractiveContent() const OVERRIDE; 51 virtual bool appendFormData(FormDataList&, bool); 52 53 virtual bool isObjectElement() const OVERRIDE { return true; } 54 55 // Implementations of constraint validation API. 56 // Note that the object elements are always barred from constraint validation. 57 virtual String validationMessage() const OVERRIDE { return String(); } 58 bool checkValidity() { return true; } 59 virtual void setCustomValidity(const String&) OVERRIDE { } 60 61 using Node::ref; 62 using Node::deref; 63 64 virtual bool canContainRangeEndPoint() const { return useFallbackContent(); } 65 66 bool isExposed() const; 67 68 private: 69 HTMLObjectElement(Document&, HTMLFormElement*, bool createdByParser); 70 71 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 72 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE; 73 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE; 74 75 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 76 virtual void removedFrom(ContainerNode*) OVERRIDE; 77 78 virtual bool rendererIsNeeded(const RenderStyle&); 79 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; 80 81 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); 82 83 virtual bool isURLAttribute(const Attribute&) const OVERRIDE; 84 virtual const AtomicString imageSourceURL() const OVERRIDE; 85 86 virtual RenderWidget* existingRenderWidget() const OVERRIDE; 87 88 virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; 89 90 virtual void updateWidgetInternal() OVERRIDE; 91 void updateDocNamedItem(); 92 93 void reattachFallbackContent(); 94 95 bool hasFallbackContent() const; 96 97 // FIXME: This function should not deal with url or serviceType 98 // so that we can better share code between <object> and <embed>. 99 void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType); 100 101 bool shouldAllowQuickTimeClassIdQuirk(); 102 bool hasValidClassId(); 103 104 virtual void refFormAssociatedElement() { ref(); } 105 virtual void derefFormAssociatedElement() { deref(); } 106 107 virtual bool shouldRegisterAsNamedItem() const OVERRIDE { return true; } 108 virtual bool shouldRegisterAsExtraNamedItem() const OVERRIDE { return true; } 109 110 String m_classId; 111 bool m_useFallbackContent : 1; 112 }; 113 114 DEFINE_NODE_TYPE_CASTS(HTMLObjectElement, hasTagName(HTMLNames::objectTag)); 115 116 inline const HTMLObjectElement* toHTMLObjectElement(const FormAssociatedElement* element) 117 { 118 ASSERT_WITH_SECURITY_IMPLICATION(!element || !element->isFormControlElement()); 119 const HTMLObjectElement* objectElement = static_cast<const HTMLObjectElement*>(element); 120 // We need to assert after the cast because FormAssociatedElement doesn't 121 // have hasTagName. 122 ASSERT_WITH_SECURITY_IMPLICATION(!objectElement || objectElement->hasTagName(HTMLNames::objectTag)); 123 return objectElement; 124 } 125 126 inline const HTMLObjectElement& toHTMLObjectElement(const FormAssociatedElement& element) 127 { 128 ASSERT_WITH_SECURITY_IMPLICATION(!element.isFormControlElement()); 129 const HTMLObjectElement& objectElement = static_cast<const HTMLObjectElement&>(element); 130 // We need to assert after the cast because FormAssociatedElement doesn't 131 // have hasTagName. 132 ASSERT_WITH_SECURITY_IMPLICATION(objectElement.hasTagName(HTMLNames::objectTag)); 133 return objectElement; 134 } 135 136 } 137 138 #endif 139