1 /* 2 * Copyright (C) 1999 Lars Knoll (knoll (at) kde.org) 3 * (C) 1999 Antti Koivisto (koivisto (at) kde.org) 4 * Copyright (C) 2004, 2005, 2006, 2007, 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 HTMLElement_h 24 #define HTMLElement_h 25 26 #include "StyledElement.h" 27 28 namespace WebCore { 29 30 class DocumentFragment; 31 class HTMLCollection; 32 class HTMLFormElement; 33 34 enum HTMLTagStatus { TagStatusOptional, TagStatusRequired, TagStatusForbidden }; 35 36 class HTMLElement : public StyledElement { 37 public: 38 static PassRefPtr<HTMLElement> create(const QualifiedName& tagName, Document*); 39 40 PassRefPtr<HTMLCollection> children(); 41 42 virtual String title() const; 43 44 virtual short tabIndex() const; 45 void setTabIndex(int); 46 47 String innerHTML() const; 48 String outerHTML() const; 49 PassRefPtr<DocumentFragment> createContextualFragment(const String&, FragmentScriptingPermission = FragmentScriptingAllowed); 50 void setInnerHTML(const String&, ExceptionCode&); 51 void setOuterHTML(const String&, ExceptionCode&); 52 void setInnerText(const String&, ExceptionCode&); 53 void setOuterText(const String&, ExceptionCode&); 54 55 Element* insertAdjacentElement(const String& where, Element* newChild, ExceptionCode&); 56 void insertAdjacentHTML(const String& where, const String& html, ExceptionCode&); 57 void insertAdjacentText(const String& where, const String& text, ExceptionCode&); 58 59 virtual bool supportsFocus() const; 60 61 virtual bool isContentEditable() const; 62 virtual bool isContentRichlyEditable() const; 63 64 String contentEditable() const; 65 void setContentEditable(const String&); 66 67 virtual bool draggable() const; 68 void setDraggable(bool); 69 70 void click(); 71 72 virtual void accessKeyAction(bool sendToAnyElement); 73 74 virtual HTMLTagStatus endTagRequirement() const; 75 virtual int tagPriority() const; 76 77 virtual bool rendererIsNeeded(RenderStyle*); 78 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 79 80 HTMLFormElement* form() const { return virtualForm(); } 81 82 static void addHTMLAlignmentToStyledElement(StyledElement*, MappedAttribute*); 83 84 protected: 85 HTMLElement(const QualifiedName& tagName, Document*, ConstructionType = CreateElementZeroRefCount); 86 87 void addHTMLAlignment(MappedAttribute*); 88 89 virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const; 90 virtual void parseMappedAttribute(MappedAttribute*); 91 92 virtual bool childAllowed(Node* newChild); // Error-checking during parsing that checks the DTD 93 94 // Helper function to check the DTD for a given child node. 95 virtual bool checkDTD(const Node*); 96 97 static bool inEitherTagList(const Node*); 98 static bool inInlineTagList(const Node*); 99 static bool inBlockTagList(const Node*); 100 static bool isRecognizedTagName(const QualifiedName&); 101 102 HTMLFormElement* findFormAncestor() const; 103 104 private: 105 virtual bool isHTMLElement() const { return true; } 106 107 virtual String nodeName() const; 108 109 void setContentEditable(MappedAttribute*); 110 111 virtual HTMLFormElement* virtualForm() const; 112 113 Node* insertAdjacent(const String& where, Node* newChild, ExceptionCode&); 114 }; 115 116 inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document* document, ConstructionType type) 117 : StyledElement(tagName, document, type) 118 { 119 ASSERT(tagName.localName().impl()); 120 } 121 122 } // namespace WebCore 123 124 #endif // HTMLElement_h 125