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. 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 "FormAssociatedElement.h" 27#include "HTMLPlugInImageElement.h" 28 29namespace WebCore { 30 31class HTMLFormElement; 32 33class HTMLObjectElement FINAL : public HTMLPlugInImageElement, public FormAssociatedElement { 34public: 35 static PassRefPtr<HTMLObjectElement> create(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser); 36 virtual ~HTMLObjectElement(); 37 38 bool isDocNamedItem() const { return m_docNamedItem; } 39 40 const String& classId() const { return m_classId; } 41 42 bool containsJavaApplet() const; 43 44 virtual bool useFallbackContent() const { return m_useFallbackContent; } 45 void renderFallbackContent(); 46 47 // Implementations of FormAssociatedElement 48 HTMLFormElement* form() const { return FormAssociatedElement::form(); } 49 50 virtual bool isFormControlElement() const { return false; } 51 52 virtual bool isEnumeratable() const { return true; } 53 virtual bool appendFormData(FormDataList&, bool); 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 66private: 67 HTMLObjectElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser); 68 69 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 70 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE; 71 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE; 72 73 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 74 virtual void removedFrom(ContainerNode*) OVERRIDE; 75 76 virtual bool rendererIsNeeded(const NodeRenderingContext&); 77 virtual void didMoveToNewDocument(Document* oldDocument) OVERRIDE; 78 79 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); 80 81 virtual bool isURLAttribute(const Attribute&) const OVERRIDE; 82 virtual const AtomicString& imageSourceURL() const OVERRIDE; 83 84 virtual RenderWidget* renderWidgetForJSBindings() const; 85 86 virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; 87 88 virtual void updateWidget(PluginCreationOption); 89 void updateDocNamedItem(); 90 91 bool hasFallbackContent() const; 92 93 // FIXME: This function should not deal with url or serviceType 94 // so that we can better share code between <object> and <embed>. 95 void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType); 96 97 bool shouldAllowQuickTimeClassIdQuirk(); 98 bool hasValidClassId(); 99 100 virtual void refFormAssociatedElement() { ref(); } 101 virtual void derefFormAssociatedElement() { deref(); } 102 virtual HTMLFormElement* virtualForm() const; 103 104#if ENABLE(MICRODATA) 105 virtual String itemValueText() const OVERRIDE; 106 virtual void setItemValueText(const String&, ExceptionCode&) OVERRIDE; 107#endif 108 109 String m_classId; 110 bool m_docNamedItem : 1; 111 bool m_useFallbackContent : 1; 112}; 113 114inline HTMLObjectElement* toHTMLObjectElement(Node* node) 115{ 116 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(HTMLNames::objectTag)); 117 return static_cast<HTMLObjectElement*>(node); 118} 119 120} 121 122#endif 123