ladybird/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
Luke Wilde 3bb5c6207f LibWeb: Make FormAssociatedElement inherit from HTMLElement
The new event target implementation requires us to downcast an
EventTarget to a FormAssociatedElement to check if the current Element
EventTarget has a form owner to setup a with scope for the form owner.

This also makes all form associated elements inherit from
FormAssociatedElement where it was previously missing.

https://html.spec.whatwg.org/#form-associated-element
2022-02-08 17:47:44 +00:00

34 lines
731 B
C++

/*
* Copyright (c) 2020, the SerenityOS developers.
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/HTMLFormElement.h>
#include <LibWeb/HTML/HTMLSelectElement.h>
namespace Web::HTML {
HTMLSelectElement::HTMLSelectElement(DOM::Document& document, QualifiedName qualified_name)
: FormAssociatedElement(document, move(qualified_name))
{
}
HTMLSelectElement::~HTMLSelectElement()
{
}
void HTMLSelectElement::inserted()
{
HTMLElement::inserted();
set_form(first_ancestor_of_type<HTMLFormElement>());
}
void HTMLSelectElement::removed_from(DOM::Node* old_parent)
{
HTMLElement::removed_from(old_parent);
set_form(nullptr);
}
}