HTMLTableElement.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/HTML/HTMLElement.h>
  8. #include <LibWeb/HTML/HTMLTableCaptionElement.h>
  9. #include <LibWeb/HTML/HTMLTableRowElement.h>
  10. #include <LibWeb/HTML/HTMLTableSectionElement.h>
  11. #include <LibWeb/WebIDL/ExceptionOr.h>
  12. namespace Web::HTML {
  13. class HTMLTableElement final : public HTMLElement {
  14. WEB_PLATFORM_OBJECT(HTMLTableElement, HTMLElement);
  15. public:
  16. virtual ~HTMLTableElement() override;
  17. JS::GCPtr<HTMLTableCaptionElement> caption();
  18. WebIDL::ExceptionOr<void> set_caption(HTMLTableCaptionElement*);
  19. JS::NonnullGCPtr<HTMLTableCaptionElement> create_caption();
  20. void delete_caption();
  21. JS::GCPtr<HTMLTableSectionElement> t_head();
  22. WebIDL::ExceptionOr<void> set_t_head(HTMLTableSectionElement* thead);
  23. JS::NonnullGCPtr<HTMLTableSectionElement> create_t_head();
  24. void delete_t_head();
  25. JS::GCPtr<HTMLTableSectionElement> t_foot();
  26. WebIDL::ExceptionOr<void> set_t_foot(HTMLTableSectionElement* tfoot);
  27. JS::NonnullGCPtr<HTMLTableSectionElement> create_t_foot();
  28. void delete_t_foot();
  29. JS::NonnullGCPtr<DOM::HTMLCollection> t_bodies();
  30. JS::NonnullGCPtr<HTMLTableSectionElement> create_t_body();
  31. JS::NonnullGCPtr<DOM::HTMLCollection> rows();
  32. WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> insert_row(long index);
  33. WebIDL::ExceptionOr<void> delete_row(long index);
  34. // https://www.w3.org/TR/html-aria/#el-table
  35. virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::table; }
  36. unsigned border() const;
  37. private:
  38. HTMLTableElement(DOM::Document&, DOM::QualifiedName);
  39. virtual bool is_html_table_element() const override { return true; }
  40. virtual void initialize(JS::Realm&) override;
  41. virtual void visit_edges(Cell::Visitor&) override;
  42. virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
  43. JS::GCPtr<DOM::HTMLCollection> mutable m_rows;
  44. JS::GCPtr<DOM::HTMLCollection> mutable m_t_bodies;
  45. };
  46. }
  47. namespace Web::DOM {
  48. template<>
  49. inline bool Node::fast_is<HTML::HTMLTableElement>() const { return is_html_table_element(); }
  50. }