| 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 | #pragma once |
| 27 | |
| 28 | #include "HTMLElement.h" |
| 29 | |
| 30 | namespace WebCore { |
| 31 | |
| 32 | class HTMLCollection; |
| 33 | class HTMLTableCaptionElement; |
| 34 | class HTMLTableRowsCollection; |
| 35 | class HTMLTableSectionElement; |
| 36 | |
| 37 | class HTMLTableElement final : public HTMLElement { |
| 38 | WTF_MAKE_ISO_ALLOCATED(HTMLTableElement); |
| 39 | public: |
| 40 | static Ref<HTMLTableElement> create(Document&); |
| 41 | static Ref<HTMLTableElement> create(const QualifiedName&, Document&); |
| 42 | |
| 43 | WEBCORE_EXPORT RefPtr<HTMLTableCaptionElement> caption() const; |
| 44 | WEBCORE_EXPORT ExceptionOr<void> setCaption(RefPtr<HTMLTableCaptionElement>&&); |
| 45 | |
| 46 | WEBCORE_EXPORT RefPtr<HTMLTableSectionElement> tHead() const; |
| 47 | WEBCORE_EXPORT ExceptionOr<void> setTHead(RefPtr<HTMLTableSectionElement>&&); |
| 48 | |
| 49 | WEBCORE_EXPORT RefPtr<HTMLTableSectionElement> () const; |
| 50 | WEBCORE_EXPORT ExceptionOr<void> (RefPtr<HTMLTableSectionElement>&&); |
| 51 | |
| 52 | WEBCORE_EXPORT Ref<HTMLTableSectionElement> createTHead(); |
| 53 | WEBCORE_EXPORT void deleteTHead(); |
| 54 | WEBCORE_EXPORT Ref<HTMLTableSectionElement> (); |
| 55 | WEBCORE_EXPORT void (); |
| 56 | WEBCORE_EXPORT Ref<HTMLTableSectionElement> createTBody(); |
| 57 | WEBCORE_EXPORT Ref<HTMLTableCaptionElement> createCaption(); |
| 58 | WEBCORE_EXPORT void deleteCaption(); |
| 59 | WEBCORE_EXPORT ExceptionOr<Ref<HTMLElement>> insertRow(int index = -1); |
| 60 | WEBCORE_EXPORT ExceptionOr<void> deleteRow(int index); |
| 61 | |
| 62 | WEBCORE_EXPORT Ref<HTMLCollection> rows(); |
| 63 | WEBCORE_EXPORT Ref<HTMLCollection> tBodies(); |
| 64 | |
| 65 | const AtomicString& rules() const; |
| 66 | const AtomicString& summary() const; |
| 67 | |
| 68 | const StyleProperties* additionalCellStyle(); |
| 69 | const StyleProperties* additionalGroupStyle(bool rows); |
| 70 | |
| 71 | private: |
| 72 | HTMLTableElement(const QualifiedName&, Document&); |
| 73 | |
| 74 | void parseAttribute(const QualifiedName&, const AtomicString&) final; |
| 75 | bool isPresentationAttribute(const QualifiedName&) const final; |
| 76 | void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) final; |
| 77 | bool isURLAttribute(const Attribute&) const final; |
| 78 | |
| 79 | // Used to obtain either a solid or outset border decl and to deal with the frame and rules attributes. |
| 80 | const StyleProperties* additionalPresentationAttributeStyle() const final; |
| 81 | |
| 82 | void addSubresourceAttributeURLs(ListHashSet<URL>&) const final; |
| 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 | Ref<StyleProperties> createSharedCellStyle(); |
| 90 | |
| 91 | HTMLTableSectionElement* lastBody() const; |
| 92 | |
| 93 | bool m_borderAttr { false }; // Sets a precise border width and creates an outset border for the table and for its cells. |
| 94 | bool m_borderColorAttr { false }; // Overrides the outset border and makes it solid for the table and cells instead. |
| 95 | bool m_frameAttr { false }; // 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 { UnsetRules }; // Implies a thin border width, a collapsing border model, and all borders on the table becoming set to hidden (if frame/border are present, to none otherwise). |
| 97 | unsigned short m_padding { 1 }; |
| 98 | RefPtr<StyleProperties> m_sharedCellStyle; |
| 99 | }; |
| 100 | |
| 101 | } //namespace |
| 102 | |