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