2020-01-18 09:38:21 +01:00
/*
2023-02-20 18:56:08 +01:00
* Copyright ( c ) 2018 - 2023 , Andreas Kling < kling @ serenityos . org >
2020-01-18 09:38:21 +01:00
*
2021-04-22 01:24:48 -07:00
* SPDX - License - Identifier : BSD - 2 - Clause
2020-01-18 09:38:21 +01:00
*/
2019-06-15 18:55:47 +02:00
# pragma once
2023-01-08 19:23:00 -05:00
# include <AK/DeprecatedFlyString.h>
2022-12-04 18:02:33 +00:00
# include <AK/DeprecatedString.h>
2023-01-28 22:23:16 +00:00
# include <LibWeb/ARIA/ARIAMixin.h>
2022-10-04 19:52:25 +02:00
# include <LibWeb/Bindings/ElementPrototype.h>
2023-01-28 20:37:46 +01:00
# include <LibWeb/Bindings/ShadowRootPrototype.h>
2023-05-08 07:02:43 +02:00
# include <LibWeb/CSS/Selector.h>
2023-05-08 06:57:55 +02:00
# include <LibWeb/CSS/StyleProperty.h>
2021-09-29 16:25:48 +01:00
# include <LibWeb/DOM/ChildNode.h>
2020-08-03 20:30:02 +02:00
# include <LibWeb/DOM/NonDocumentTypeChildNode.h>
2020-03-07 10:32:51 +01:00
# include <LibWeb/DOM/ParentNode.h>
2022-02-18 20:52:47 +01:00
# include <LibWeb/DOM/QualifiedName.h>
2023-09-05 13:07:35 -04:00
# include <LibWeb/DOM/Slottable.h>
2020-08-12 14:46:53 +02:00
# include <LibWeb/HTML/AttributeNames.h>
2021-09-09 00:59:09 +02:00
# include <LibWeb/HTML/EventLoop/Task.h>
2023-05-08 07:39:05 +02:00
# include <LibWeb/HTML/ScrollOptions.h>
2020-12-13 17:54:40 +01:00
# include <LibWeb/HTML/TagNames.h>
2023-06-07 17:11:01 +02:00
# include <LibWeb/HTML/Window.h>
2023-07-06 23:44:07 +01:00
# include <LibWeb/IntersectionObserver/IntersectionObserver.h>
2022-09-25 17:03:42 +01:00
# include <LibWeb/WebIDL/ExceptionOr.h>
2019-10-14 18:32:02 +02:00
2020-07-26 19:37:56 +02:00
namespace Web : : DOM {
2019-06-15 18:55:47 +02:00
2023-01-28 20:37:46 +01:00
struct ShadowRootInit {
Bindings : : ShadowRootMode mode ;
bool delegates_focus = false ;
2023-09-01 07:25:40 -04:00
Bindings : : SlotAssignmentMode slot_assignment { Bindings : : SlotAssignmentMode : : Named } ;
2023-01-28 20:37:46 +01:00
} ;
2022-10-04 19:52:25 +02:00
// https://w3c.github.io/csswg-drafts/cssom-view-1/#dictdef-scrollintoviewoptions
2023-03-06 20:53:49 +00:00
struct ScrollIntoViewOptions : public HTML : : ScrollOptions {
2022-10-04 19:52:25 +02:00
Bindings : : ScrollLogicalPosition block { Bindings : : ScrollLogicalPosition : : Start } ;
Bindings : : ScrollLogicalPosition inline_ { Bindings : : ScrollLogicalPosition : : Nearest } ;
} ;
2023-03-29 23:46:18 +01:00
// https://html.spec.whatwg.org/multipage/custom-elements.html#upgrade-reaction
// An upgrade reaction, which will upgrade the custom element and contains a custom element definition; or
struct CustomElementUpgradeReaction {
JS : : Handle < HTML : : CustomElementDefinition > custom_element_definition ;
} ;
// https://html.spec.whatwg.org/multipage/custom-elements.html#callback-reaction
// A callback reaction, which will call a lifecycle callback, and contains a callback function as well as a list of arguments.
struct CustomElementCallbackReaction {
JS : : Handle < WebIDL : : CallbackType > callback ;
JS : : MarkedVector < JS : : Value > arguments ;
} ;
// https://dom.spec.whatwg.org/#concept-element-custom-element-state
// An element’ s custom element state is one of "undefined", "failed", "uncustomized", "precustomized", or "custom".
enum class CustomElementState {
Undefined ,
Failed ,
Uncustomized ,
Precustomized ,
Custom ,
} ;
2020-08-03 20:30:02 +02:00
class Element
: public ParentNode
2021-09-29 16:25:48 +01:00
, public ChildNode < Element >
2022-11-28 17:58:13 -06:00
, public NonDocumentTypeChildNode < Element >
2023-09-05 13:07:35 -04:00
, public SlottableMixin
2023-01-28 22:23:16 +00:00
, public ARIA : : ARIAMixin {
2022-08-28 13:42:07 +02:00
WEB_PLATFORM_OBJECT ( Element , ParentNode ) ;
2020-08-03 20:30:02 +02:00
2019-06-15 18:55:47 +02:00
public :
virtual ~ Element ( ) override ;
2023-09-10 16:06:58 +12:00
DeprecatedFlyString qualified_name ( ) const { return m_qualified_name . as_string ( ) . to_deprecated_fly_string ( ) ; }
2022-12-04 18:02:33 +00:00
DeprecatedString const & html_uppercased_qualified_name ( ) const { return m_html_uppercased_qualified_name ; }
2023-09-10 16:06:58 +12:00
2023-09-17 10:51:43 +12:00
virtual FlyString node_name ( ) const final { return MUST ( FlyString : : from_deprecated_fly_string ( html_uppercased_qualified_name ( ) ) ) ; }
2023-09-10 16:06:58 +12:00
DeprecatedFlyString local_name ( ) const { return m_qualified_name . local_name ( ) . to_deprecated_fly_string ( ) ; }
2020-07-23 18:18:13 +02:00
// NOTE: This is for the JS bindings
2022-12-04 18:02:33 +00:00
DeprecatedString const & tag_name ( ) const { return html_uppercased_qualified_name ( ) ; }
2019-06-15 18:55:47 +02:00
2023-09-10 16:06:58 +12:00
DeprecatedFlyString prefix ( ) const { return m_qualified_name . deprecated_prefix ( ) ; }
2023-03-29 23:46:18 +01:00
void set_prefix ( DeprecatedFlyString const & value ) ;
2023-09-10 16:06:58 +12:00
DeprecatedFlyString namespace_ ( ) const { return m_qualified_name . deprecated_namespace_ ( ) ; }
2020-10-10 02:48:05 +01:00
// NOTE: This is for the JS bindings
2023-09-10 16:06:58 +12:00
DeprecatedFlyString namespace_uri ( ) const { return namespace_ ( ) ; }
2020-10-10 02:48:05 +01:00
2023-01-08 19:23:00 -05:00
bool has_attribute ( DeprecatedFlyString const & name ) const ;
2023-08-09 21:31:35 +01:00
bool has_attribute_ns ( DeprecatedFlyString namespace_ , DeprecatedFlyString const & name ) const ;
2023-05-08 07:10:24 +02:00
bool has_attributes ( ) const ;
2023-09-01 10:42:20 -04:00
2023-09-03 14:58:18 +12:00
DeprecatedString deprecated_attribute ( DeprecatedFlyString const & name ) const { return get_attribute ( name ) ; }
2023-09-03 15:25:25 +12:00
Optional < String > attribute ( DeprecatedFlyString const & name ) const
{
auto ret = deprecated_attribute ( name ) ;
if ( ret . is_null ( ) )
return { } ;
return String : : from_deprecated_string ( ret ) . release_value ( ) ;
}
2023-01-08 19:23:00 -05:00
DeprecatedString get_attribute ( DeprecatedFlyString const & name ) const ;
2023-09-01 10:42:20 -04:00
DeprecatedString get_attribute_value ( DeprecatedFlyString const & local_name , DeprecatedFlyString const & namespace_ = { } ) const ;
2023-08-31 15:00:09 -04:00
WebIDL : : ExceptionOr < void > set_attribute ( DeprecatedFlyString const & name , DeprecatedString const & value ) ;
2023-09-03 01:09:33 +12:00
WebIDL : : ExceptionOr < void > set_attribute ( DeprecatedFlyString const & name , Optional < String > const & value ) ;
2023-01-08 19:23:00 -05:00
WebIDL : : ExceptionOr < void > set_attribute_ns ( DeprecatedFlyString const & namespace_ , DeprecatedFlyString const & qualified_name , DeprecatedString const & value ) ;
2023-09-01 10:42:20 -04:00
void set_attribute_value ( DeprecatedFlyString const & local_name , DeprecatedString const & value , DeprecatedFlyString const & prefix = { } , DeprecatedFlyString const & namespace_ = { } ) ;
2023-03-10 14:56:29 +01:00
WebIDL : : ExceptionOr < JS : : GCPtr < Attr > > set_attribute_node ( Attr & ) ;
WebIDL : : ExceptionOr < JS : : GCPtr < Attr > > set_attribute_node_ns ( Attr & ) ;
2023-09-01 10:42:20 -04:00
2023-09-21 20:09:51 +12:00
// FIXME: This should take a 'FlyString cosnt&'
void remove_attribute ( StringView name ) ;
2023-01-08 19:23:00 -05:00
WebIDL : : ExceptionOr < bool > toggle_attribute ( DeprecatedFlyString const & name , Optional < bool > force ) ;
2023-05-08 07:10:24 +02:00
size_t attribute_list_size ( ) const ;
2022-08-28 13:42:07 +02:00
NamedNodeMap const * attributes ( ) const { return m_attributes . ptr ( ) ; }
2022-12-04 18:02:33 +00:00
Vector < DeprecatedString > get_attribute_names ( ) const ;
2019-06-15 21:08:36 +02:00
2023-01-08 19:23:00 -05:00
JS : : GCPtr < Attr > get_attribute_node ( DeprecatedFlyString const & name ) const ;
2022-11-05 04:37:40 +00:00
2022-08-08 15:19:46 +02:00
DOMTokenList * class_list ( ) ;
2021-10-18 13:21:23 -04:00
2023-01-28 20:37:46 +01:00
WebIDL : : ExceptionOr < JS : : NonnullGCPtr < ShadowRoot > > attach_shadow ( ShadowRootInit init ) ;
JS : : GCPtr < ShadowRoot > shadow_root ( ) const ;
2022-09-25 17:03:42 +01:00
WebIDL : : ExceptionOr < bool > matches ( StringView selectors ) const ;
WebIDL : : ExceptionOr < DOM : : Element const * > closest ( StringView selectors ) const ;
2021-09-30 02:16:36 +02:00
2021-09-30 02:17:23 +02:00
int client_top ( ) const ;
int client_left ( ) const ;
int client_width ( ) const ;
int client_height ( ) const ;
2023-05-08 06:49:38 +02:00
void for_each_attribute ( Function < void ( DeprecatedFlyString const & , DeprecatedString const & ) > ) const ;
2019-06-15 21:08:36 +02:00
2023-03-07 19:54:01 +01:00
bool has_class ( FlyString const & , CaseSensitivity = CaseSensitivity : : CaseSensitive ) const ;
Vector < FlyString > const & class_names ( ) const { return m_classes ; }
2019-06-27 20:40:21 +02:00
2020-07-26 20:01:35 +02:00
virtual void apply_presentational_hints ( CSS : : StyleProperties & ) const { }
2023-09-02 10:05:15 -04:00
2023-09-01 17:45:22 -04:00
// https://dom.spec.whatwg.org/#concept-element-attributes-change-ext
using AttributeChangeSteps = Function < void ( DeprecatedFlyString const & /*local_name*/ , DeprecatedString const & /*old_value*/ , DeprecatedString const & /*value*/ , DeprecatedFlyString const & /*namespace_*/ ) > ;
void add_attribute_change_steps ( AttributeChangeSteps steps ) ;
2023-09-02 10:05:15 -04:00
void run_attribute_change_steps ( DeprecatedFlyString const & local_name , DeprecatedString const & old_value , DeprecatedString const & value , DeprecatedFlyString const & namespace_ ) ;
2023-07-03 17:08:37 +02:00
virtual void attribute_changed ( DeprecatedFlyString const & name , DeprecatedString const & value ) ;
2019-10-04 21:05:52 +02:00
2023-05-22 16:09:15 +02:00
struct [ [ nodiscard ] ] RequiredInvalidationAfterStyleChange {
bool repaint { false } ;
bool rebuild_stacking_context_tree { false } ;
bool relayout { false } ;
bool rebuild_layout_tree { false } ;
void operator | = ( RequiredInvalidationAfterStyleChange const & other )
{
repaint | = other . repaint ;
rebuild_stacking_context_tree | = other . rebuild_stacking_context_tree ;
relayout | = other . relayout ;
rebuild_layout_tree | = other . rebuild_layout_tree ;
}
[ [ nodiscard ] ] bool is_none ( ) const { return ! repaint & & ! rebuild_stacking_context_tree & & ! relayout & & ! rebuild_layout_tree ; }
static RequiredInvalidationAfterStyleChange full ( ) { return { true , true , true , true } ; }
2022-03-16 17:48:50 +01:00
} ;
2023-05-22 16:09:15 +02:00
RequiredInvalidationAfterStyleChange recompute_style ( ) ;
2019-10-14 18:32:02 +02:00
2023-05-25 12:34:54 +02:00
virtual Optional < CSS : : Selector : : PseudoElement > pseudo_element ( ) const { return { } ; }
2023-05-08 06:57:55 +02:00
Layout : : NodeWithStyle * layout_node ( ) ;
Layout : : NodeWithStyle const * layout_node ( ) const ;
2019-10-14 18:32:02 +02:00
2023-09-03 14:58:18 +12:00
DeprecatedString name ( ) const { return deprecated_attribute ( HTML : : AttributeNames : : name ) ; }
2019-10-20 09:09:15 +02:00
2023-02-20 18:56:08 +01:00
CSS : : StyleProperties * computed_css_values ( ) { return m_computed_css_values . ptr ( ) ; }
2022-03-15 19:41:35 +01:00
CSS : : StyleProperties const * computed_css_values ( ) const { return m_computed_css_values . ptr ( ) ; }
2023-05-08 07:51:03 +02:00
void set_computed_css_values ( RefPtr < CSS : : StyleProperties > ) ;
2022-03-15 19:32:17 +01:00
NonnullRefPtr < CSS : : StyleProperties > resolved_css_values ( ) ;
2020-01-02 14:52:34 +01:00
2022-04-11 16:56:52 +02:00
CSS : : CSSStyleDeclaration const * inline_style ( ) const ;
2020-12-07 19:56:53 +01:00
2022-08-07 16:21:26 +02:00
CSS : : CSSStyleDeclaration * style_for_bindings ( ) ;
2021-03-13 22:39:55 +01:00
2022-12-04 18:02:33 +00:00
WebIDL : : ExceptionOr < DeprecatedString > inner_html ( ) const ;
2023-09-21 20:14:57 +12:00
WebIDL : : ExceptionOr < void > set_inner_html ( StringView ) ;
2020-03-25 18:53:20 +01:00
2022-12-04 18:02:33 +00:00
WebIDL : : ExceptionOr < void > insert_adjacent_html ( DeprecatedString position , DeprecatedString text ) ;
2022-09-20 18:28:41 +02:00
2020-08-14 19:40:37 +02:00
bool is_focused ( ) const ;
2021-06-18 16:42:34 -06:00
bool is_active ( ) const ;
2023-08-11 20:14:44 +01:00
bool is_target ( ) const ;
2023-08-12 17:47:33 +01:00
bool is_document_element ( ) const ;
2021-06-18 16:42:34 -06:00
2023-01-08 19:23:00 -05:00
JS : : NonnullGCPtr < HTMLCollection > get_elements_by_class_name ( DeprecatedFlyString const & ) ;
2021-02-07 23:44:01 +01:00
2023-01-28 20:33:36 +01:00
bool is_shadow_host ( ) const ;
2023-01-28 20:22:52 +01:00
ShadowRoot * shadow_root_internal ( ) { return m_shadow_root . ptr ( ) ; }
ShadowRoot const * shadow_root_internal ( ) const { return m_shadow_root . ptr ( ) ; }
2022-08-28 13:42:07 +02:00
void set_shadow_root ( JS : : GCPtr < ShadowRoot > ) ;
2021-02-10 18:21:35 +01:00
2023-05-17 17:05:36 +02:00
void set_custom_properties ( Optional < CSS : : Selector : : PseudoElement > , HashMap < DeprecatedFlyString , CSS : : StyleProperty > custom_properties ) ;
[ [ nodiscard ] ] HashMap < DeprecatedFlyString , CSS : : StyleProperty > const & custom_properties ( Optional < CSS : : Selector : : PseudoElement > ) const ;
2021-05-28 21:21:44 +02:00
2023-08-31 13:25:27 -04:00
int queue_an_element_task ( HTML : : Task : : Source , JS : : SafeFunction < void ( ) > ) ;
2021-09-09 00:59:09 +02:00
2021-09-13 22:42:15 +01:00
bool is_void_element ( ) const ;
bool serializes_as_void ( ) const ;
2022-09-04 01:59:58 +02:00
JS : : NonnullGCPtr < Geometry : : DOMRect > get_bounding_client_rect ( ) const ;
JS : : NonnullGCPtr < Geometry : : DOMRectList > get_client_rects ( ) const ;
2021-09-27 00:55:13 +02:00
2022-10-17 14:41:50 +02:00
virtual JS : : GCPtr < Layout : : Node > create_layout_node ( NonnullRefPtr < CSS : : StyleProperties > ) ;
2022-02-05 13:17:01 +01:00
2022-02-06 19:27:10 +01:00
virtual void did_receive_focus ( ) { }
virtual void did_lose_focus ( ) { }
2022-10-17 14:41:50 +02:00
static JS : : GCPtr < Layout : : Node > create_layout_node_for_display_type ( DOM : : Document & , CSS : : Display const & , NonnullRefPtr < CSS : : StyleProperties > , Element * ) ;
2022-02-24 11:56:03 +00:00
2022-10-17 14:41:50 +02:00
void set_pseudo_element_node ( Badge < Layout : : TreeBuilder > , CSS : : Selector : : PseudoElement , JS : : GCPtr < Layout : : Node > ) ;
JS : : GCPtr < Layout : : Node > get_pseudo_element_node ( CSS : : Selector : : PseudoElement ) const ;
2022-03-03 17:50:12 +00:00
void clear_pseudo_element_nodes ( Badge < Layout : : TreeBuilder > ) ;
void serialize_pseudo_elements_as_json ( JsonArraySerializer < StringBuilder > & children_array ) const ;
2022-11-05 03:58:14 +00:00
i32 tab_index ( ) const ;
void set_tab_index ( i32 tab_index ) ;
2022-11-05 15:10:13 +00:00
bool is_potentially_scrollable ( ) const ;
double scroll_top ( ) const ;
double scroll_left ( ) const ;
void set_scroll_top ( double y ) ;
void set_scroll_left ( double x ) ;
int scroll_width ( ) const ;
int scroll_height ( ) const ;
2022-09-30 16:21:34 +01:00
bool is_actually_disabled ( ) const ;
2022-12-04 18:02:33 +00:00
WebIDL : : ExceptionOr < JS : : GCPtr < Element > > insert_adjacent_element ( DeprecatedString const & where , JS : : NonnullGCPtr < Element > element ) ;
WebIDL : : ExceptionOr < void > insert_adjacent_text ( DeprecatedString const & where , DeprecatedString const & data ) ;
2022-10-01 00:30:15 +01:00
2022-10-04 19:52:25 +02:00
// https://w3c.github.io/csswg-drafts/cssom-view-1/#dom-element-scrollintoview
2022-12-24 13:15:12 +01:00
ErrorOr < void > scroll_into_view ( Optional < Variant < bool , ScrollIntoViewOptions > > = { } ) ;
2022-10-04 19:52:25 +02:00
2022-11-28 17:58:13 -06:00
// https://www.w3.org/TR/wai-aria-1.2/#ARIAMixin
# define ARIA_IMPL(name, attribute) \
DeprecatedString name ( ) const override \
{ \
return get_attribute ( attribute ) ; \
} \
\
WebIDL : : ExceptionOr < void > set_ # # name ( DeprecatedString const & value ) override \
{ \
TRY ( set_attribute ( attribute , value ) ) ; \
return { } ; \
}
// https://www.w3.org/TR/wai-aria-1.2/#accessibilityroleandproperties-correspondence
ARIA_IMPL ( role , " role " ) ;
ARIA_IMPL ( aria_active_descendant , " aria-activedescendant " ) ;
ARIA_IMPL ( aria_atomic , " aria-atomic " ) ;
ARIA_IMPL ( aria_auto_complete , " aria-autocomplete " ) ;
ARIA_IMPL ( aria_busy , " aria-busy " ) ;
ARIA_IMPL ( aria_checked , " aria-checked " ) ;
ARIA_IMPL ( aria_col_count , " aria-colcount " ) ;
ARIA_IMPL ( aria_col_index , " aria-colindex " ) ;
ARIA_IMPL ( aria_col_span , " aria-colspan " ) ;
ARIA_IMPL ( aria_controls , " aria-controls " ) ;
ARIA_IMPL ( aria_current , " aria-current " ) ;
ARIA_IMPL ( aria_described_by , " aria-describedby " ) ;
ARIA_IMPL ( aria_details , " aria-details " ) ;
ARIA_IMPL ( aria_drop_effect , " aria-dropeffect " ) ;
ARIA_IMPL ( aria_error_message , " aria-errormessage " ) ;
ARIA_IMPL ( aria_disabled , " aria-disabled " ) ;
ARIA_IMPL ( aria_expanded , " aria-expanded " ) ;
ARIA_IMPL ( aria_flow_to , " aria-flowto " ) ;
ARIA_IMPL ( aria_grabbed , " aria-grabbed " ) ;
ARIA_IMPL ( aria_has_popup , " aria-haspopup " ) ;
ARIA_IMPL ( aria_hidden , " aria-hidden " ) ;
ARIA_IMPL ( aria_invalid , " aria-invalid " ) ;
ARIA_IMPL ( aria_key_shortcuts , " aria-keyshortcuts " ) ;
ARIA_IMPL ( aria_label , " aria-label " ) ;
ARIA_IMPL ( aria_labelled_by , " aria-labelledby " ) ;
ARIA_IMPL ( aria_level , " aria-level " ) ;
ARIA_IMPL ( aria_live , " aria-live " ) ;
ARIA_IMPL ( aria_modal , " aria-modal " ) ;
ARIA_IMPL ( aria_multi_line , " aria-multiline " ) ;
ARIA_IMPL ( aria_multi_selectable , " aria-multiselectable " ) ;
ARIA_IMPL ( aria_orientation , " aria-orientation " ) ;
ARIA_IMPL ( aria_owns , " aria-owns " ) ;
ARIA_IMPL ( aria_placeholder , " aria-placeholder " ) ;
ARIA_IMPL ( aria_pos_in_set , " aria-posinset " ) ;
ARIA_IMPL ( aria_pressed , " aria-pressed " ) ;
ARIA_IMPL ( aria_read_only , " aria-readonly " ) ;
ARIA_IMPL ( aria_relevant , " aria-relevant " ) ;
ARIA_IMPL ( aria_required , " aria-required " ) ;
ARIA_IMPL ( aria_role_description , " aria-roledescription " ) ;
ARIA_IMPL ( aria_row_count , " aria-rowcount " ) ;
ARIA_IMPL ( aria_row_index , " aria-rowindex " ) ;
ARIA_IMPL ( aria_row_span , " aria-rowspan " ) ;
ARIA_IMPL ( aria_selected , " aria-selected " ) ;
ARIA_IMPL ( aria_set_size , " aria-setsize " ) ;
ARIA_IMPL ( aria_sort , " aria-sort " ) ;
ARIA_IMPL ( aria_value_max , " aria-valuemax " ) ;
ARIA_IMPL ( aria_value_min , " aria-valuemin " ) ;
ARIA_IMPL ( aria_value_now , " aria-valuenow " ) ;
ARIA_IMPL ( aria_value_text , " aria-valuetext " ) ;
# undef ARIA_IMPL
2022-12-11 10:53:37 -06:00
virtual bool exclude_from_accessibility_tree ( ) const override ;
virtual bool include_in_accessibility_tree ( ) const override ;
2023-03-29 23:46:18 +01:00
void enqueue_a_custom_element_upgrade_reaction ( HTML : : CustomElementDefinition & custom_element_definition ) ;
void enqueue_a_custom_element_callback_reaction ( FlyString const & callback_name , JS : : MarkedVector < JS : : Value > arguments ) ;
Vector < Variant < CustomElementUpgradeReaction , CustomElementCallbackReaction > > & custom_element_reaction_queue ( ) { return m_custom_element_reaction_queue ; }
Vector < Variant < CustomElementUpgradeReaction , CustomElementCallbackReaction > > const & custom_element_reaction_queue ( ) const { return m_custom_element_reaction_queue ; }
JS : : ThrowCompletionOr < void > upgrade_element ( JS : : NonnullGCPtr < HTML : : CustomElementDefinition > custom_element_definition ) ;
void try_to_upgrade ( ) ;
bool is_defined ( ) const ;
bool is_custom ( ) const ;
Optional < String > const & is_value ( ) const { return m_is_value ; }
void set_is_value ( Optional < String > const & is ) { m_is_value = is ; }
void set_custom_element_state ( CustomElementState value ) { m_custom_element_state = value ; }
void setup_custom_element_from_constructor ( HTML : : CustomElementDefinition & custom_element_definition , Optional < String > const & is_value ) ;
2023-06-07 17:11:01 +02:00
void scroll ( HTML : : ScrollToOptions const & ) ;
void scroll ( double x , double y ) ;
2023-07-06 23:44:07 +01:00
void register_intersection_observer ( Badge < IntersectionObserver : : IntersectionObserver > , IntersectionObserver : : IntersectionObserverRegistration ) ;
void unregister_intersection_observer ( Badge < IntersectionObserver : : IntersectionObserver > , JS : : NonnullGCPtr < IntersectionObserver : : IntersectionObserver > ) ;
IntersectionObserver : : IntersectionObserverRegistration & get_intersection_observer_registration ( Badge < DOM : : Document > , IntersectionObserver : : IntersectionObserver const & ) ;
2023-08-06 02:15:21 +02:00
enum class ScrollOffsetFor {
Self ,
PseudoBefore ,
PseudoAfter
} ;
CSSPixelPoint scroll_offset ( ScrollOffsetFor type ) const { return m_scroll_offset [ to_underlying ( type ) ] ; }
void set_scroll_offset ( ScrollOffsetFor type , CSSPixelPoint offset ) { m_scroll_offset [ to_underlying ( type ) ] = offset ; }
2023-08-21 11:47:24 +01:00
enum class Dir {
Ltr ,
Rtl ,
Auto ,
} ;
Optional < Dir > dir ( ) const { return m_dir ; }
enum class Directionality {
Ltr ,
Rtl ,
} ;
Directionality directionality ( ) const ;
2020-06-13 22:24:49 +02:00
protected :
2022-09-03 18:47:33 +02:00
Element ( Document & , DOM : : QualifiedName ) ;
2023-08-07 08:41:28 +02:00
virtual void initialize ( JS : : Realm & ) override ;
2022-09-03 18:47:33 +02:00
2021-10-12 17:53:52 +02:00
virtual void children_changed ( ) override ;
2022-11-05 03:58:14 +00:00
virtual i32 default_tab_index_value ( ) const ;
2019-10-05 22:27:52 +02:00
2022-08-28 13:42:07 +02:00
virtual void visit_edges ( Cell : : Visitor & ) override ;
2023-02-25 15:50:34 -06:00
virtual bool id_reference_exists ( DeprecatedString const & ) const override ;
2020-06-13 22:24:49 +02:00
private :
2021-05-04 22:25:43 +01:00
void make_html_uppercased_qualified_name ( ) ;
2023-01-08 19:23:00 -05:00
void invalidate_style_after_attribute_change ( DeprecatedFlyString const & attribute_name ) ;
2022-10-29 13:04:18 +02:00
2022-12-04 18:02:33 +00:00
WebIDL : : ExceptionOr < JS : : GCPtr < Node > > insert_adjacent ( DeprecatedString const & where , JS : : NonnullGCPtr < Node > node ) ;
2022-10-01 00:30:15 +01:00
2023-03-29 23:46:18 +01:00
void enqueue_an_element_on_the_appropriate_element_queue ( ) ;
2020-10-10 02:48:05 +01:00
QualifiedName m_qualified_name ;
2022-12-04 18:02:33 +00:00
DeprecatedString m_html_uppercased_qualified_name ;
2020-01-02 14:52:34 +01:00
2022-09-03 18:47:33 +02:00
JS : : GCPtr < NamedNodeMap > m_attributes ;
2023-09-01 17:45:22 -04:00
Vector < AttributeChangeSteps > m_attribute_change_steps ;
2022-08-28 13:42:07 +02:00
JS : : GCPtr < CSS : : ElementInlineCSSStyleDeclaration > m_inline_style ;
JS : : GCPtr < DOMTokenList > m_class_list ;
JS : : GCPtr < ShadowRoot > m_shadow_root ;
2020-12-07 19:56:53 +01:00
2022-03-15 19:41:35 +01:00
RefPtr < CSS : : StyleProperties > m_computed_css_values ;
2023-01-08 19:23:00 -05:00
HashMap < DeprecatedFlyString , CSS : : StyleProperty > m_custom_properties ;
2023-05-17 17:05:36 +02:00
Array < HashMap < DeprecatedFlyString , CSS : : StyleProperty > , to_underlying ( CSS : : Selector : : PseudoElement : : PseudoElementCount ) > m_pseudo_element_custom_properties ;
2020-05-26 23:07:19 +02:00
2023-03-07 19:54:01 +01:00
Vector < FlyString > m_classes ;
2023-08-21 11:47:24 +01:00
Optional < Dir > m_dir ;
2021-02-10 18:21:35 +01:00
2022-11-30 18:27:26 -05:00
Array < JS : : GCPtr < Layout : : Node > , to_underlying ( CSS : : Selector : : PseudoElement : : PseudoElementCount ) > m_pseudo_element_nodes ;
2023-03-29 23:46:18 +01:00
// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-reaction-queue
// All elements have an associated custom element reaction queue, initially empty. Each item in the custom element reaction queue is of one of two types:
// NOTE: See the structs at the top of this header.
Vector < Variant < CustomElementUpgradeReaction , CustomElementCallbackReaction > > m_custom_element_reaction_queue ;
// https://dom.spec.whatwg.org/#concept-element-custom-element-state
CustomElementState m_custom_element_state { CustomElementState : : Undefined } ;
// https://dom.spec.whatwg.org/#concept-element-custom-element-definition
JS : : GCPtr < HTML : : CustomElementDefinition > m_custom_element_definition ;
// https://dom.spec.whatwg.org/#concept-element-is-value
Optional < String > m_is_value ;
2023-07-06 23:44:07 +01:00
// https://www.w3.org/TR/intersection-observer/#dom-element-registeredintersectionobservers-slot
// Element objects have an internal [[RegisteredIntersectionObservers]] slot, which is initialized to an empty list.
Vector < IntersectionObserver : : IntersectionObserverRegistration > m_registered_intersection_observers ;
2023-08-06 02:15:21 +02:00
Array < CSSPixelPoint , 3 > m_scroll_offset ;
2019-06-15 18:55:47 +02:00
} ;
2019-10-06 20:37:39 +02:00
2021-01-07 17:31:26 +01:00
template < >
2021-01-17 09:34:01 +01:00
inline bool Node : : fast_is < Element > ( ) const { return is_element ( ) ; }
2021-01-07 17:31:26 +01:00
2023-01-08 19:23:00 -05:00
WebIDL : : ExceptionOr < QualifiedName > validate_and_extract ( JS : : Realm & , DeprecatedFlyString namespace_ , DeprecatedFlyString qualified_name ) ;
2022-03-02 10:55:16 +01:00
2021-01-07 17:31:26 +01:00
}