Coverage Report

Created: 2025-11-16 07:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) 2020, the SerenityOS developers.
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include <LibWeb/Bindings/HTMLLegendElementPrototype.h>
8
#include <LibWeb/Bindings/Intrinsics.h>
9
#include <LibWeb/HTML/HTMLFieldSetElement.h>
10
#include <LibWeb/HTML/HTMLLegendElement.h>
11
12
namespace Web::HTML {
13
14
JS_DEFINE_ALLOCATOR(HTMLLegendElement);
15
16
HTMLLegendElement::HTMLLegendElement(DOM::Document& document, DOM::QualifiedName qualified_name)
17
0
    : HTMLElement(document, move(qualified_name))
18
0
{
19
0
}
20
21
0
HTMLLegendElement::~HTMLLegendElement() = default;
22
23
void HTMLLegendElement::initialize(JS::Realm& realm)
24
0
{
25
0
    Base::initialize(realm);
26
0
    WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLLegendElement);
27
0
}
28
29
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-legend-form
30
HTMLFormElement* HTMLLegendElement::form()
31
0
{
32
    // The form IDL attribute's behavior depends on whether the legend element is in a fieldset element or not.
33
    // If the legend has a fieldset element as its parent, then the form IDL attribute must return the same value as the form IDL attribute on that fieldset element.
34
0
    if (is<HTML::HTMLFieldSetElement>(parent_element())) {
35
0
        return verify_cast<HTML::HTMLFieldSetElement>(parent_element())->form();
36
0
    }
37
38
    // Otherwise, it must return null.
39
0
    return nullptr;
40
0
}
41
42
}