Home | History | Annotate | Download | only in html
      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 HTMLDocument_h
     24 #define HTMLDocument_h
     25 
     26 #include "core/dom/Document.h"
     27 #include "core/loader/cache/ResourceClient.h"
     28 #include "wtf/HashCountedSet.h"
     29 
     30 namespace WebCore {
     31 
     32 class FrameView;
     33 class HTMLBodyElement;
     34 class HTMLElement;
     35 
     36 class HTMLDocument : public Document, public ResourceClient {
     37 public:
     38     static PassRefPtr<HTMLDocument> create(const DocumentInit& initializer = DocumentInit())
     39     {
     40         return adoptRef(new HTMLDocument(initializer));
     41     }
     42     virtual ~HTMLDocument();
     43 
     44     int width();
     45     int height();
     46 
     47     String dir();
     48     void setDir(const String&);
     49 
     50     String designMode() const;
     51     void setDesignMode(const String&);
     52 
     53     Element* activeElement();
     54     bool hasFocus();
     55 
     56     String bgColor();
     57     void setBgColor(const String&);
     58     String fgColor();
     59     void setFgColor(const String&);
     60     String alinkColor();
     61     void setAlinkColor(const String&);
     62     String linkColor();
     63     void setLinkColor(const String&);
     64     String vlinkColor();
     65     void setVlinkColor(const String&);
     66 
     67     void clear();
     68 
     69     void captureEvents() { }
     70     void releaseEvents() { }
     71 
     72     void addNamedItem(const AtomicString& name);
     73     void removeNamedItem(const AtomicString& name);
     74     bool hasNamedItem(StringImpl* name);
     75 
     76     void addExtraNamedItem(const AtomicString& name);
     77     void removeExtraNamedItem(const AtomicString& name);
     78     bool hasExtraNamedItem(StringImpl* name);
     79 
     80     static bool isCaseSensitiveAttribute(const QualifiedName&);
     81 
     82 protected:
     83     HTMLDocument(const DocumentInit&, DocumentClassFlags extendedDocumentClasses = DefaultDocumentClass);
     84 
     85 private:
     86     HTMLBodyElement* bodyAsHTMLBodyElement() const;
     87     void addItemToMap(HashCountedSet<StringImpl*>&, const AtomicString&);
     88     void removeItemFromMap(HashCountedSet<StringImpl*>&, const AtomicString&);
     89 
     90     HashCountedSet<StringImpl*> m_namedItemCounts;
     91     HashCountedSet<StringImpl*> m_extraNamedItemCounts;
     92 };
     93 
     94 inline bool HTMLDocument::hasNamedItem(StringImpl* name)
     95 {
     96     ASSERT(name);
     97     return m_namedItemCounts.contains(name);
     98 }
     99 
    100 inline bool HTMLDocument::hasExtraNamedItem(StringImpl* name)
    101 {
    102     ASSERT(name);
    103     return m_extraNamedItemCounts.contains(name);
    104 }
    105 
    106 inline HTMLDocument* toHTMLDocument(Document* document)
    107 {
    108     ASSERT_WITH_SECURITY_IMPLICATION(!document || document->isHTMLDocument());
    109     return static_cast<HTMLDocument*>(document);
    110 }
    111 
    112 inline const HTMLDocument* toHTMLDocument(const Document* document)
    113 {
    114     ASSERT_WITH_SECURITY_IMPLICATION(!document || document->isHTMLDocument());
    115     return static_cast<const HTMLDocument*>(document);
    116 }
    117 
    118 // This will catch anyone doing an unnecessary cast.
    119 void toHTMLDocument(const HTMLDocument*);
    120 
    121 } // namespace WebCore
    122 
    123 #endif // HTMLDocument_h
    124