Home | History | Annotate | Download | only in html
      1 /*
      2  * Copyright (C) 1997 Martin Jones (mjones (at) kde.org)
      3  *           (C) 1997 Torben Weis (weis (at) kde.org)
      4  *           (C) 1998 Waldo Bastian (bastian (at) kde.org)
      5  *           (C) 1999 Lars Knoll (knoll (at) kde.org)
      6  *           (C) 1999 Antti Koivisto (koivisto (at) kde.org)
      7  * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
      8  *
      9  * This library is free software; you can redistribute it and/or
     10  * modify it under the terms of the GNU Library General Public
     11  * License as published by the Free Software Foundation; either
     12  * version 2 of the License, or (at your option) any later version.
     13  *
     14  * This library is distributed in the hope that it will be useful,
     15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     17  * Library General Public License for more details.
     18  *
     19  * You should have received a copy of the GNU Library General Public License
     20  * along with this library; see the file COPYING.LIB.  If not, write to
     21  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     22  * Boston, MA 02110-1301, USA.
     23  *
     24  */
     25 
     26 #ifndef HTMLTableElement_h
     27 #define HTMLTableElement_h
     28 
     29 #include "HTMLElement.h"
     30 
     31 namespace WebCore {
     32 
     33 class HTMLCollection;
     34 class HTMLTableCaptionElement;
     35 class HTMLTableSectionElement;
     36 
     37 class HTMLTableElement : public HTMLElement {
     38 public:
     39     static PassRefPtr<HTMLTableElement> create(Document*);
     40     static PassRefPtr<HTMLTableElement> create(const QualifiedName&, Document*);
     41 
     42     HTMLTableCaptionElement* caption() const;
     43     void setCaption(PassRefPtr<HTMLTableCaptionElement>, ExceptionCode&);
     44 
     45     HTMLTableSectionElement* tHead() const;
     46     void setTHead(PassRefPtr<HTMLTableSectionElement>, ExceptionCode&);
     47 
     48     HTMLTableSectionElement* tFoot() const;
     49     void setTFoot(PassRefPtr<HTMLTableSectionElement>, ExceptionCode&);
     50 
     51     PassRefPtr<HTMLElement> createTHead();
     52     void deleteTHead();
     53     PassRefPtr<HTMLElement> createTFoot();
     54     void deleteTFoot();
     55     PassRefPtr<HTMLElement> createCaption();
     56     void deleteCaption();
     57     PassRefPtr<HTMLElement> insertRow(int index, ExceptionCode&);
     58     void deleteRow(int index, ExceptionCode&);
     59 
     60     PassRefPtr<HTMLCollection> rows();
     61     PassRefPtr<HTMLCollection> tBodies();
     62 
     63     String rules() const;
     64     String summary() const;
     65 
     66     virtual void attach();
     67 
     68     void addSharedCellDecls(Vector<CSSMutableStyleDeclaration*>&);
     69     void addSharedGroupDecls(bool rows, Vector<CSSMutableStyleDeclaration*>&);
     70 
     71 private:
     72     HTMLTableElement(const QualifiedName&, Document*);
     73 
     74     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
     75     virtual void parseMappedAttribute(Attribute*);
     76     virtual bool isURLAttribute(Attribute*) const;
     77 
     78     // Used to obtain either a solid or outset border decl and to deal with the frame
     79     // and rules attributes.
     80     virtual bool canHaveAdditionalAttributeStyleDecls() const { return true; }
     81     virtual void additionalAttributeStyleDecls(Vector<CSSMutableStyleDeclaration*>&);
     82 
     83     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
     84 
     85     void addSharedCellBordersDecl(Vector<CSSMutableStyleDeclaration*>&);
     86     void addSharedCellPaddingDecl(Vector<CSSMutableStyleDeclaration*>&);
     87 
     88     enum TableRules { UnsetRules, NoneRules, GroupsRules, RowsRules, ColsRules, AllRules };
     89     enum CellBorders { NoBorders, SolidBorders, InsetBorders, SolidBordersColsOnly, SolidBordersRowsOnly };
     90 
     91     CellBorders cellBorders() const;
     92 
     93     HTMLTableSectionElement* lastBody() const;
     94 
     95     bool m_borderAttr;          // Sets a precise border width and creates an outset border for the table and for its cells.
     96     bool m_borderColorAttr;     // Overrides the outset border and makes it solid for the table and cells instead.
     97     bool m_frameAttr;           // Implies a thin border width if no border is set and then a certain set of solid/hidden borders based off the value.
     98     TableRules m_rulesAttr;     // Implies a thin border width, a collapsing border model, and all borders on the table becoming set to hidden (if frame/border
     99                                 // are present, to none otherwise).
    100 
    101     unsigned short m_padding;
    102     RefPtr<CSSMappedAttributeDeclaration> m_paddingDecl;
    103 };
    104 
    105 } //namespace
    106 
    107 #endif
    108