HTMLTableElement.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #include <LibWeb/WebIDL/Types.h>
  13. namespace Web::HTML {
  14. class HTMLTableElement final : public HTMLElement {
  15. WEB_PLATFORM_OBJECT(HTMLTableElement, HTMLElement);
  16. JS_DECLARE_ALLOCATOR(HTMLTableElement);
  17. public:
  18. virtual ~HTMLTableElement() override;
  19. JS::GCPtr<HTMLTableCaptionElement> caption();
  20. WebIDL::ExceptionOr<void> set_caption(HTMLTableCaptionElement*);
  21. JS::NonnullGCPtr<HTMLTableCaptionElement> create_caption();
  22. void delete_caption();
  23. JS::GCPtr<HTMLTableSectionElement> t_head();
  24. WebIDL::ExceptionOr<void> set_t_head(HTMLTableSectionElement* thead);
  25. JS::NonnullGCPtr<HTMLTableSectionElement> create_t_head();
  26. void delete_t_head();
  27. JS::GCPtr<HTMLTableSectionElement> t_foot();
  28. WebIDL::ExceptionOr<void> set_t_foot(HTMLTableSectionElement* tfoot);
  29. JS::NonnullGCPtr<HTMLTableSectionElement> create_t_foot();
  30. void delete_t_foot();
  31. JS::NonnullGCPtr<DOM::HTMLCollection> t_bodies();
  32. JS::NonnullGCPtr<HTMLTableSectionElement> create_t_body();
  33. JS::NonnullGCPtr<DOM::HTMLCollection> rows();
  34. WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> insert_row(WebIDL::Long index);
  35. WebIDL::ExceptionOr<void> delete_row(WebIDL::Long index);
  36. // https://www.w3.org/TR/html-aria/#el-table
  37. virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::table; }
  38. unsigned border() const;
  39. unsigned padding() const;
  40. private:
  41. HTMLTableElement(DOM::Document&, DOM::QualifiedName);
  42. virtual bool is_html_table_element() const override { return true; }
  43. virtual void initialize(JS::Realm&) override;
  44. virtual void visit_edges(Cell::Visitor&) override;
  45. virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
  46. virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
  47. JS::GCPtr<DOM::HTMLCollection> mutable m_rows;
  48. JS::GCPtr<DOM::HTMLCollection> mutable m_t_bodies;
  49. unsigned m_padding { 1 };
  50. };
  51. }
  52. namespace Web::DOM {
  53. template<>
  54. inline bool Node::fast_is<HTML::HTMLTableElement>() const { return is_html_table_element(); }
  55. }