Coverage Report

Created: 2025-09-05 06:52

/src/serenity/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2020, the SerenityOS developers.
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include <LibWeb/Bindings/HTMLSourceElementPrototype.h>
8
#include <LibWeb/Bindings/Intrinsics.h>
9
#include <LibWeb/HTML/AttributeNames.h>
10
#include <LibWeb/HTML/HTMLMediaElement.h>
11
#include <LibWeb/HTML/HTMLSourceElement.h>
12
13
namespace Web::HTML {
14
15
JS_DEFINE_ALLOCATOR(HTMLSourceElement);
16
17
HTMLSourceElement::HTMLSourceElement(DOM::Document& document, DOM::QualifiedName qualified_name)
18
0
    : HTMLElement(document, move(qualified_name))
19
0
{
20
0
}
21
22
0
HTMLSourceElement::~HTMLSourceElement() = default;
23
24
void HTMLSourceElement::initialize(JS::Realm& realm)
25
0
{
26
0
    Base::initialize(realm);
27
0
    WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLSourceElement);
28
0
}
29
30
// https://html.spec.whatwg.org/multipage/embedded-content.html#the-source-element:the-source-element-15
31
void HTMLSourceElement::inserted()
32
0
{
33
    // The source HTML element insertion steps, given insertedNode, are:
34
0
    Base::inserted();
35
36
    // 1. If insertedNode's parent is a media element that has no src attribute and whose networkState has the value
37
    //    NETWORK_EMPTY, then invoke that media element's resource selection algorithm.
38
0
    if (is<HTMLMediaElement>(parent())) {
39
0
        auto& media_element = static_cast<HTMLMediaElement&>(*parent());
40
41
0
        if (!media_element.has_attribute(HTML::AttributeNames::src) && media_element.network_state() == HTMLMediaElement::NetworkState::Empty)
42
0
            media_element.select_resource().release_value_but_fixme_should_propagate_errors();
43
0
    }
44
45
    // FIXME: 2. If insertedNode's next sibling is an img element and its parent is a picture element, then, count this as a
46
    //           relevant mutation for the img element.
47
0
}
48
49
// https://html.spec.whatwg.org/multipage/embedded-content.html#the-source-element:the-source-element-16
50
void HTMLSourceElement::removed_from(DOM::Node* old_parent)
51
0
{
52
    // The source HTML element removing steps, given removedNode and oldParent, are:
53
0
    Base::removed_from(old_parent);
54
55
    // FIXME: 1. If removedNode's next sibling was an img element and oldParent is a picture element, then, count this as a
56
    //           relevant mutation for the img element.
57
0
}
58
59
}