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 "core/html/HTMLElement.h"
     30 
     31 namespace WebCore {
     32 
     33 class ExceptionState;
     34 class HTMLCollection;
     35 class HTMLTableCaptionElement;
     36 class HTMLTableRowsCollection;
     37 class HTMLTableSectionElement;
     38 
     39 class HTMLTableElement FINAL : public HTMLElement {
     40 public:
     41     static PassRefPtr<HTMLTableElement> create(Document&);
     42 
     43     HTMLTableCaptionElement* caption() const;
     44     void setCaption(PassRefPtr<HTMLTableCaptionElement>, ExceptionState&);
     45 
     46     HTMLTableSectionElement* tHead() const;
     47     void setTHead(PassRefPtr<HTMLTableSectionElement>, ExceptionState&);
     48 
     49     HTMLTableSectionElement* tFoot() const;
     50     void setTFoot(PassRefPtr<HTMLTableSectionElement>, ExceptionState&);
     51 
     52     PassRefPtr<HTMLElement> createTHead();
     53     void deleteTHead();
     54     PassRefPtr<HTMLElement> createTFoot();
     55     void deleteTFoot();
     56     PassRefPtr<HTMLElement> createTBody();
     57     PassRefPtr<HTMLElement> createCaption();
     58     void deleteCaption();
     59     PassRefPtr<HTMLElement> insertRow(int index, ExceptionState&);
     60     void deleteRow(int index, ExceptionState&);
     61 
     62     PassRefPtr<HTMLCollection> rows();
     63     PassRefPtr<HTMLCollection> tBodies();
     64 
     65     const AtomicString& rules() const;
     66     const AtomicString& summary() const;
     67 
     68     const StylePropertySet* additionalCellStyle();
     69     const StylePropertySet* additionalGroupStyle(bool rows);
     70 
     71 private:
     72     explicit HTMLTableElement(Document&);
     73 
     74     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     75     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
     76     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
     77     virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
     78 
     79     // Used to obtain either a solid or outset border decl and to deal with the frame and rules attributes.
     80     virtual const StylePropertySet* additionalPresentationAttributeStyle() OVERRIDE;
     81 
     82     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
     83 
     84     enum TableRules { UnsetRules, NoneRules, GroupsRules, RowsRules, ColsRules, AllRules };
     85     enum CellBorders { NoBorders, SolidBorders, InsetBorders, SolidBordersColsOnly, SolidBordersRowsOnly };
     86 
     87     CellBorders cellBorders() const;
     88 
     89     PassRefPtr<StylePropertySet> createSharedCellStyle();
     90 
     91     HTMLTableSectionElement* lastBody() const;
     92 
     93     bool m_borderAttr;          // Sets a precise border width and creates an outset border for the table and for its cells.
     94     bool m_borderColorAttr;     // Overrides the outset border and makes it solid for the table and cells instead.
     95     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.
     96     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
     97                                 // are present, to none otherwise).
     98 
     99     unsigned short m_padding;
    100     RefPtr<StylePropertySet> m_sharedCellStyle;
    101 };
    102 
    103 inline bool isHTMLTableElement(const Node* node)
    104 {
    105     return node->hasTagName(HTMLNames::tableTag);
    106 }
    107 
    108 inline bool isHTMLTableElement(const Element* element)
    109 {
    110     return element->hasTagName(HTMLNames::tableTag);
    111 }
    112 
    113 DEFINE_NODE_TYPE_CASTS(HTMLTableElement, hasTagName(HTMLNames::tableTag));
    114 
    115 } //namespace
    116 
    117 #endif
    118