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     HTMLTableElement(const QualifiedName&, Document*);
     40 
     41     virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
     42     virtual int tagPriority() const { return 9; }
     43     virtual bool checkDTD(const Node*);
     44 
     45     HTMLTableCaptionElement* caption() const;
     46     void setCaption(PassRefPtr<HTMLTableCaptionElement>, ExceptionCode&);
     47 
     48     HTMLTableSectionElement* tHead() const;
     49     void setTHead(PassRefPtr<HTMLTableSectionElement>, ExceptionCode&);
     50 
     51     HTMLTableSectionElement* tFoot() const;
     52     void setTFoot(PassRefPtr<HTMLTableSectionElement>, ExceptionCode&);
     53 
     54     PassRefPtr<HTMLElement> createTHead();
     55     void deleteTHead();
     56     PassRefPtr<HTMLElement> createTFoot();
     57     void deleteTFoot();
     58     PassRefPtr<HTMLElement> createCaption();
     59     void deleteCaption();
     60     PassRefPtr<HTMLElement> insertRow(int index, ExceptionCode&);
     61     void deleteRow(int index, ExceptionCode&);
     62 
     63     PassRefPtr<HTMLCollection> rows();
     64     PassRefPtr<HTMLCollection> tBodies();
     65 
     66     String align() const;
     67     void setAlign(const String&);
     68 
     69     String bgColor() const;
     70     void setBgColor(const String&);
     71 
     72     String border() const;
     73     void setBorder(const String&);
     74 
     75     String cellPadding() const;
     76     void setCellPadding(const String&);
     77 
     78     String cellSpacing() const;
     79     void setCellSpacing(const String&);
     80 
     81     String frame() const;
     82     void setFrame(const String&);
     83 
     84     String rules() const;
     85     void setRules(const String&);
     86 
     87     String summary() const;
     88     void setSummary(const String&);
     89 
     90     String width() const;
     91     void setWidth(const String&);
     92 
     93     virtual ContainerNode* addChild(PassRefPtr<Node>);
     94     virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
     95     virtual void parseMappedAttribute(MappedAttribute*);
     96     virtual void attach();
     97     virtual bool isURLAttribute(Attribute*) const;
     98 
     99     // Used to obtain either a solid or outset border decl and to deal with the frame
    100     // and rules attributes.
    101     virtual bool canHaveAdditionalAttributeStyleDecls() const { return true; }
    102     virtual void additionalAttributeStyleDecls(Vector<CSSMutableStyleDeclaration*>&);
    103     void addSharedCellDecls(Vector<CSSMutableStyleDeclaration*>&);
    104     void addSharedGroupDecls(bool rows, Vector<CSSMutableStyleDeclaration*>&);
    105 
    106     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
    107 
    108 private:
    109     void addSharedCellBordersDecl(Vector<CSSMutableStyleDeclaration*>&);
    110     void addSharedCellPaddingDecl(Vector<CSSMutableStyleDeclaration*>&);
    111 
    112     enum TableRules { UnsetRules, NoneRules, GroupsRules, RowsRules, ColsRules, AllRules };
    113     enum CellBorders { NoBorders, SolidBorders, InsetBorders, SolidBordersColsOnly, SolidBordersRowsOnly };
    114 
    115     CellBorders cellBorders() const;
    116 
    117     HTMLTableSectionElement* lastBody() const;
    118 
    119     bool m_borderAttr;          // Sets a precise border width and creates an outset border for the table and for its cells.
    120     bool m_borderColorAttr;     // Overrides the outset border and makes it solid for the table and cells instead.
    121     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.
    122     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
    123                                 // are present, to none otherwise).
    124 
    125     unsigned short m_padding;
    126     RefPtr<CSSMappedAttributeDeclaration> m_paddingDecl;
    127 };
    128 
    129 } //namespace
    130 
    131 #endif
    132