webengine/osswebengine/WebCore/html/HTMLFormElement.h
changeset 0 dd21522fd290
child 67 4917f9bf7995
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
       
     3  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
       
     4  *           (C) 2000 Dirk Mueller (mueller@kde.org)
       
     5  * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
       
     6  *
       
     7  * This library is free software; you can redistribute it and/or
       
     8  * modify it under the terms of the GNU Library General Public
       
     9  * License as published by the Free Software Foundation; either
       
    10  * version 2 of the License, or (at your option) any later version.
       
    11  *
       
    12  * This library is distributed in the hope that it will be useful,
       
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    15  * Library General Public License for more details.
       
    16  *
       
    17  * You should have received a copy of the GNU Library General Public License
       
    18  * along with this library; see the file COPYING.LIB.  If not, write to
       
    19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    20  * Boston, MA 02110-1301, USA.
       
    21  *
       
    22  */
       
    23 
       
    24 #ifndef HTMLFormElement_h
       
    25 #define HTMLFormElement_h
       
    26 
       
    27 #include "HTMLCollection.h" 
       
    28 #include "HTMLElement.h"
       
    29 
       
    30 #include <wtf/OwnPtr.h>
       
    31 
       
    32 namespace WebCore {
       
    33 
       
    34 class Event;
       
    35 class FormData;
       
    36 class HTMLGenericFormElement;
       
    37 class HTMLImageElement;
       
    38 class HTMLInputElement;
       
    39 class HTMLFormCollection;
       
    40 
       
    41 class HTMLFormElement : public HTMLElement {
       
    42 public:
       
    43     HTMLFormElement(Document*);
       
    44     virtual ~HTMLFormElement();
       
    45 
       
    46     virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
       
    47     virtual int tagPriority() const { return 3; }
       
    48 
       
    49     virtual void attach();
       
    50     virtual void insertedIntoDocument();
       
    51     virtual void removedFromDocument();
       
    52  
       
    53     virtual void handleLocalEvents(Event*, bool useCapture);
       
    54      
       
    55     PassRefPtr<HTMLCollection> elements();
       
    56     void getNamedElements(const AtomicString&, Vector<RefPtr<Node> >&);
       
    57     
       
    58     unsigned length() const;
       
    59     Node* item(unsigned index);
       
    60 
       
    61     String enctype() const { return m_enctype; }
       
    62     void setEnctype(const String&);
       
    63 
       
    64     String encoding() const { return m_enctype; }
       
    65     void setEncoding(const String& enctype) { setEnctype(enctype); }
       
    66 
       
    67     bool autoComplete() const { return m_autocomplete; }
       
    68 
       
    69     virtual void parseMappedAttribute(MappedAttribute*);
       
    70 
       
    71     void registerFormElement(HTMLGenericFormElement*);
       
    72     void removeFormElement(HTMLGenericFormElement*);
       
    73     void registerImgElement(HTMLImageElement*);
       
    74     void removeImgElement(HTMLImageElement*);
       
    75 
       
    76     bool prepareSubmit(Event*);
       
    77     void submit();
       
    78     void submit(Event*, bool activateSubmitButton = false);
       
    79     void reset();
       
    80 
       
    81     void setMalformed(bool malformed) { m_malformed = malformed; }
       
    82     virtual bool isMalformed() { return m_malformed; }
       
    83 
       
    84     virtual bool isURLAttribute(Attribute*) const;
       
    85     
       
    86     void submitClick(Event*);
       
    87     bool formWouldHaveSecureSubmission(const String& url);
       
    88 
       
    89     String name() const;
       
    90     void setName(const String&);
       
    91 
       
    92     String acceptCharset() const;
       
    93     void setAcceptCharset(const String&);
       
    94 
       
    95     String action() const;
       
    96     void setAction(const String&);
       
    97 
       
    98     String method() const;
       
    99     void setMethod(const String&);
       
   100 
       
   101     virtual String target() const;
       
   102     void setTarget(const String&);
       
   103     
       
   104     PassRefPtr<HTMLGenericFormElement> elementForAlias(const AtomicString&);
       
   105     void addElementAlias(HTMLGenericFormElement*, const AtomicString& alias);
       
   106 
       
   107     // FIXME: Change this to be private after getting rid of all the clients.
       
   108     Vector<HTMLGenericFormElement*> formElements;
       
   109 
       
   110     class CheckedRadioButtons {
       
   111     public:
       
   112         void addButton(HTMLGenericFormElement*);
       
   113         void removeButton(HTMLGenericFormElement*);
       
   114         HTMLInputElement* checkedButtonForGroup(const AtomicString& name) const;
       
   115 
       
   116     private:
       
   117         typedef HashMap<AtomicStringImpl*, HTMLInputElement*> NameToInputMap;
       
   118         OwnPtr<NameToInputMap> m_nameToCheckedRadioButtonMap;
       
   119     };
       
   120     
       
   121     CheckedRadioButtons& checkedRadioButtons() { return m_checkedRadioButtons; }
       
   122     
       
   123 private:
       
   124     void parseEnctype(const String&);
       
   125     PassRefPtr<FormData> formData(const char* boundary) const;
       
   126     unsigned formElementIndex(HTMLGenericFormElement*);
       
   127 
       
   128     friend class HTMLFormCollection;
       
   129 
       
   130     typedef HashMap<RefPtr<AtomicStringImpl>, RefPtr<HTMLGenericFormElement> > AliasMap;
       
   131     
       
   132     AliasMap* m_elementAliases;
       
   133     HTMLCollection::CollectionInfo* collectionInfo;
       
   134 
       
   135     CheckedRadioButtons m_checkedRadioButtons;
       
   136     
       
   137     Vector<HTMLImageElement*> imgElements;
       
   138     String m_url;
       
   139     String m_target;
       
   140     String m_enctype;
       
   141     String m_acceptcharset;
       
   142     bool m_post : 1;
       
   143     bool m_multipart : 1;
       
   144     bool m_autocomplete : 1;
       
   145     bool m_insubmit : 1;
       
   146     bool m_doingsubmit : 1;
       
   147     bool m_inreset : 1;
       
   148     bool m_malformed : 1;
       
   149     String oldNameAttr;
       
   150 };
       
   151 
       
   152 } // namespace WebCore
       
   153 
       
   154 #endif // HTMLFormElement_h