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 "CachedResourceClient.h"
     27 #include "Document.h"
     28 #include <wtf/HashCountedSet.h>
     29 #include <wtf/text/AtomicStringHash.h>
     30 
     31 namespace WebCore {
     32 
     33 class FrameView;
     34 class HTMLElement;
     35 
     36 class HTMLDocument : public Document, public CachedResourceClient {
     37 public:
     38     static PassRefPtr<HTMLDocument> create(Frame* frame, const KURL& url)
     39     {
     40         return adoptRef(new HTMLDocument(frame, url));
     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     virtual void setCompatibilityModeFromDoctype();
     54 
     55     Element* activeElement();
     56     bool hasFocus();
     57 
     58     String bgColor();
     59     void setBgColor(const String&);
     60     String fgColor();
     61     void setFgColor(const String&);
     62     String alinkColor();
     63     void setAlinkColor(const String&);
     64     String linkColor();
     65     void setLinkColor(const String&);
     66     String vlinkColor();
     67     void setVlinkColor(const String&);
     68 
     69     void clear();
     70 
     71     void captureEvents();
     72     void releaseEvents();
     73 
     74     void addNamedItem(const AtomicString& name);
     75     void removeNamedItem(const AtomicString& name);
     76     bool hasNamedItem(AtomicStringImpl* name);
     77 
     78     void addExtraNamedItem(const AtomicString& name);
     79     void removeExtraNamedItem(const AtomicString& name);
     80     bool hasExtraNamedItem(AtomicStringImpl* name);
     81 
     82 protected:
     83     HTMLDocument(Frame*, const KURL&);
     84 
     85 #ifdef ANDROID_INSTRUMENT
     86     // Overridden to resolve the ambiguous
     87     void* operator new(size_t size);
     88     void* operator new[](size_t size);
     89     void operator delete(void* p, size_t size);
     90     void operator delete[](void* p, size_t size);
     91 #endif
     92 
     93 private:
     94     virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
     95 
     96     virtual bool isFrameSet() const;
     97     virtual PassRefPtr<DocumentParser> createParser();
     98 
     99     void addItemToMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
    100     void removeItemFromMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
    101 
    102     HashCountedSet<AtomicStringImpl*> m_namedItemCounts;
    103     HashCountedSet<AtomicStringImpl*> m_extraNamedItemCounts;
    104 };
    105 
    106 inline bool HTMLDocument::hasNamedItem(AtomicStringImpl* name)
    107 {
    108     ASSERT(name);
    109     return m_namedItemCounts.contains(name);
    110 }
    111 
    112 inline bool HTMLDocument::hasExtraNamedItem(AtomicStringImpl* name)
    113 {
    114     ASSERT(name);
    115     return m_extraNamedItemCounts.contains(name);
    116 }
    117 
    118 } // namespace WebCore
    119 
    120 #endif // HTMLDocument_h
    121