Coverage Report

Created: 2026-02-16 07:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <LibWeb/HTML/HTMLElement.h>
10
#include <LibWeb/HTML/HTMLTableCaptionElement.h>
11
#include <LibWeb/HTML/HTMLTableRowElement.h>
12
#include <LibWeb/HTML/HTMLTableSectionElement.h>
13
#include <LibWeb/WebIDL/ExceptionOr.h>
14
#include <LibWeb/WebIDL/Types.h>
15
16
namespace Web::HTML {
17
18
class HTMLTableElement final : public HTMLElement {
19
    WEB_PLATFORM_OBJECT(HTMLTableElement, HTMLElement);
20
    JS_DECLARE_ALLOCATOR(HTMLTableElement);
21
22
public:
23
    virtual ~HTMLTableElement() override;
24
25
    JS::GCPtr<HTMLTableCaptionElement> caption();
26
    WebIDL::ExceptionOr<void> set_caption(HTMLTableCaptionElement*);
27
    JS::NonnullGCPtr<HTMLTableCaptionElement> create_caption();
28
    void delete_caption();
29
30
    JS::GCPtr<HTMLTableSectionElement> t_head();
31
    WebIDL::ExceptionOr<void> set_t_head(HTMLTableSectionElement* thead);
32
    JS::NonnullGCPtr<HTMLTableSectionElement> create_t_head();
33
    void delete_t_head();
34
35
    JS::GCPtr<HTMLTableSectionElement> t_foot();
36
    WebIDL::ExceptionOr<void> set_t_foot(HTMLTableSectionElement* tfoot);
37
    JS::NonnullGCPtr<HTMLTableSectionElement> create_t_foot();
38
    void delete_t_foot();
39
40
    JS::NonnullGCPtr<DOM::HTMLCollection> t_bodies();
41
    JS::NonnullGCPtr<HTMLTableSectionElement> create_t_body();
42
43
    JS::NonnullGCPtr<DOM::HTMLCollection> rows();
44
    WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> insert_row(WebIDL::Long index);
45
    WebIDL::ExceptionOr<void> delete_row(WebIDL::Long index);
46
47
    // https://www.w3.org/TR/html-aria/#el-table
48
0
    virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::table; }
49
50
    unsigned border() const;
51
    unsigned padding() const;
52
53
private:
54
    HTMLTableElement(DOM::Document&, DOM::QualifiedName);
55
56
0
    virtual bool is_html_table_element() const override { return true; }
57
58
    virtual void initialize(JS::Realm&) override;
59
    virtual void visit_edges(Cell::Visitor&) override;
60
61
    virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
62
    virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value) override;
63
64
    JS::GCPtr<DOM::HTMLCollection> mutable m_rows;
65
    JS::GCPtr<DOM::HTMLCollection> mutable m_t_bodies;
66
    unsigned m_padding { 1 };
67
};
68
69
}
70
71
namespace Web::DOM {
72
template<>
73
0
inline bool Node::fast_is<HTML::HTMLTableElement>() const { return is_html_table_element(); }
74
}