2020-08-01 03:05:43 +01:00
/*
2021-04-28 22:46:44 +02:00
* Copyright ( c ) 2020 , the SerenityOS developers .
2020-08-01 03:05:43 +01:00
*
2021-04-22 01:24:48 -07:00
* SPDX - License - Identifier : BSD - 2 - Clause
2020-08-01 03:05:43 +01:00
*/
2024-04-27 12:09:58 +12:00
# include <LibWeb/Bindings/HTMLLegendElementPrototype.h>
2022-09-30 17:16:16 -06:00
# include <LibWeb/Bindings/Intrinsics.h>
2023-11-24 17:38:31 +01:00
# include <LibWeb/HTML/HTMLFieldSetElement.h>
2020-08-01 03:05:43 +01:00
# include <LibWeb/HTML/HTMLLegendElement.h>
2024-11-05 08:07:13 +00:00
# include <LibWeb/Layout/LegendBox.h>
2020-08-01 03:05:43 +01:00
namespace Web : : HTML {
2024-11-15 04:01:23 +13:00
GC_DEFINE_ALLOCATOR ( HTMLLegendElement ) ;
2023-11-19 19:47:52 +01:00
2022-02-18 21:00:52 +01:00
HTMLLegendElement : : HTMLLegendElement ( DOM : : Document & document , DOM : : QualifiedName qualified_name )
2021-02-07 11:20:15 +01:00
: HTMLElement ( document , move ( qualified_name ) )
2020-08-01 03:05:43 +01:00
{
}
2022-03-14 13:21:51 -06:00
HTMLLegendElement : : ~ HTMLLegendElement ( ) = default ;
2023-01-10 06:28:20 -05:00
2023-08-07 08:41:28 +02:00
void HTMLLegendElement : : initialize ( JS : : Realm & realm )
2023-01-10 06:28:20 -05:00
{
2023-08-07 08:41:28 +02:00
Base : : initialize ( realm ) ;
2024-03-16 13:13:08 +01:00
WEB_SET_PROTOTYPE_FOR_INTERFACE ( HTMLLegendElement ) ;
2023-01-10 06:28:20 -05:00
}
2023-11-24 17:38:31 +01:00
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-legend-form
HTMLFormElement * HTMLLegendElement : : form ( )
{
// The form IDL attribute's behavior depends on whether the legend element is in a fieldset element or not.
// 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.
if ( is < HTML : : HTMLFieldSetElement > ( parent_element ( ) ) ) {
return verify_cast < HTML : : HTMLFieldSetElement > ( parent_element ( ) ) - > form ( ) ;
}
// Otherwise, it must return null.
return nullptr ;
}
2024-11-19 14:47:18 +01:00
GC : : Ptr < Layout : : Node > HTMLLegendElement : : create_layout_node ( CSS : : StyleProperties style )
2024-11-05 08:07:13 +00:00
{
return heap ( ) . allocate < Layout : : LegendBox > ( document ( ) , * this , move ( style ) ) ;
}
Layout : : LegendBox * HTMLLegendElement : : layout_node ( )
{
return static_cast < Layout : : LegendBox * > ( Node : : layout_node ( ) ) ;
}
Layout : : LegendBox const * HTMLLegendElement : : layout_node ( ) const
{
return static_cast < Layout : : LegendBox const * > ( Node : : layout_node ( ) ) ;
}
2020-08-01 03:05:43 +01:00
}