1/*
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 *           (C) 1997 Torben Weis (weis@kde.org)
4 *           (C) 1998 Waldo Bastian (bastian@kde.org)
5 *           (C) 1999 Lars Knoll (knoll@kde.org)
6 *           (C) 1999 Antti Koivisto (koivisto@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
31namespace WebCore {
32
33class HTMLCollection;
34class HTMLTableCaptionElement;
35class HTMLTableRowsCollection;
36class HTMLTableSectionElement;
37
38class HTMLTableElement FINAL : public HTMLElement {
39public:
40    static PassRefPtr<HTMLTableElement> create(Document*);
41    static PassRefPtr<HTMLTableElement> create(const QualifiedName&, Document*);
42
43    HTMLTableCaptionElement* caption() const;
44    void setCaption(PassRefPtr<HTMLTableCaptionElement>, ExceptionCode&);
45
46    HTMLTableSectionElement* tHead() const;
47    void setTHead(PassRefPtr<HTMLTableSectionElement>, ExceptionCode&);
48
49    HTMLTableSectionElement* tFoot() const;
50    void setTFoot(PassRefPtr<HTMLTableSectionElement>, ExceptionCode&);
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, ExceptionCode&);
60    void deleteRow(int index, ExceptionCode&);
61
62    PassRefPtr<HTMLCollection> rows();
63    PassRefPtr<HTMLCollection> tBodies();
64
65    String rules() const;
66    String summary() const;
67
68    const StylePropertySet* additionalCellStyle();
69    const StylePropertySet* additionalGroupStyle(bool rows);
70
71private:
72    HTMLTableElement(const QualifiedName&, 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} //namespace
104
105#endif
106