Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 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 "core/html/HTMLElement.h" |
| 30 | |
| 31 | namespace WebCore { |
| 32 | |
| 33 | class HTMLCollection; |
| 34 | class HTMLTableCaptionElement; |
| 35 | class HTMLTableRowsCollection; |
| 36 | class HTMLTableSectionElement; |
| 37 | |
| 38 | class HTMLTableElement FINAL : public HTMLElement { |
| 39 | public: |
| 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 | |
| 71 | private: |
| 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 | |
Ben Murdoch | e69819b | 2013-07-17 14:56:49 +0100 | [diff] [blame^] | 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 | inline HTMLTableElement* toHTMLTableElement(Node* node) |
| 114 | { |
| 115 | ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLTableElement(node)); |
| 116 | return static_cast<HTMLTableElement*>(node); |
| 117 | } |
| 118 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 119 | } //namespace |
| 120 | |
| 121 | #endif |