2024-10-29 11:07:02 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								/*
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Copyright  ( c )  2024 ,  Jelle  Raaijmakers  < jelle @ ladybird . org > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 16:52:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/ContentSecurityPolicy/PolicyList.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 11:07:02 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/HTML/Focus.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/HTML/HTMLElement.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/HTML/HTMLOrSVGElement.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/MathML/MathMLElement.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/SVG/SVGElement.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								namespace  Web : : HTML  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/dom.html#dom-dataset-dev
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								template < typename  ElementBase > 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC : : Ref < DOMStringMap >  HTMLOrSVGElement < ElementBase > : : dataset ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 11:07:02 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ! m_dataset ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        m_dataset  =  DOMStringMap : : create ( * static_cast < ElementBase * > ( this ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  * m_dataset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/interaction.html#dom-focus
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								template < typename  ElementBase > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								void  HTMLOrSVGElement < ElementBase > : : focus ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-11 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 1. If the allow focus steps given this's node document return false, then return.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-14 18:04:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( ! static_cast < ElementBase * > ( this ) - > document ( ) . allow_focus ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 11:07:02 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-11 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 2. Run the focusing steps for this.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 11:07:02 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    run_focusing_steps ( static_cast < ElementBase * > ( this ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-11 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // FIXME: 3. If options["focusVisible"] is true, or does not exist but in an implementation-defined way the user agent determines it would be best to do so, then indicate focus.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-14 18:04:12 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-11 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // FIXME: 4. If options["preventScroll"] is false, then scroll a target into view given this, "auto", "center", and "center".
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 11:07:02 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/interaction.html#dom-blur
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								template < typename  ElementBase > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								void  HTMLOrSVGElement < ElementBase > : : blur ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-11 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 1. The user agent should run the unfocusing steps given this.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    //    User agents may instead selectively or uniformly do nothing, for usability reasons.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 11:07:02 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    run_unfocusing_steps ( static_cast < ElementBase * > ( this ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 15:46:37 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#dom-noncedelement-nonce
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 13:27:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								template < typename  ElementBase > 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-14 08:14:16 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  HTMLOrSVGElement < ElementBase > : : attribute_changed ( FlyString  const &  local_name ,  Optional < String >  const & ,  Optional < String >  const &  value ,  Optional < FlyString >  const &  namespace_ ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 13:27:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. If element does not include HTMLOrSVGElement, then return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 2. If localName is not nonce or namespace is not null, then return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( local_name  ! =  HTML : : AttributeNames : : nonce  | |  namespace_ . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 3. If value is null, then set element's [[CryptographicNonce]] to the empty string.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ! value . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        m_cryptographic_nonce  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 4. Otherwise, set element's [[CryptographicNonce]] to value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        m_cryptographic_nonce  =  value . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 15:46:37 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#dom-noncedelement-nonce
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 13:27:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								template < typename  ElementBase > 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-11 17:37:08 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								WebIDL : : ExceptionOr < void >  HTMLOrSVGElement < ElementBase > : : cloned ( DOM : : Node &  copy ,  bool )  const 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 13:27:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 15:46:37 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // The cloning steps for elements that include HTMLOrSVGElement given node, copy, and subtree
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // are to set copy's [[CryptographicNonce]] to node's [[CryptographicNonce]].
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 13:27:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    static_cast < ElementBase & > ( copy ) . m_cryptographic_nonce  =  m_cryptographic_nonce ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 15:46:37 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#dom-noncedelement-nonce
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 13:27:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								template < typename  ElementBase > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								void  HTMLOrSVGElement < ElementBase > : : inserted ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Whenever an element including HTMLOrSVGElement becomes browsing-context connected, the user
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // agent must execute the following steps on the element:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    DOM : : Element &  element  =  * static_cast < ElementBase * > ( this ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-31 12:54:08 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // "A node becomes browsing-context connected when the insertion steps are invoked with it as the argument
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // and it is now browsing-context connected."
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // https://html.spec.whatwg.org/multipage/infrastructure.html#becomes-browsing-context-connected
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ! element . shadow_including_root ( ) . is_browsing_context_connected ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 16:52:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 1. Let CSP list be element's shadow-including root's policy container's CSP list.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    auto  csp_list  =  element . shadow_including_root ( ) . document ( ) . policy_container ( ) - > csp_list ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 13:27:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-25 16:52:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 2. If CSP list contains a header-delivered Content Security Policy, and element has a
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    //    nonce content attribute whose value is not the empty string, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( csp_list - > contains_header_delivered_policy ( )  & &  element . has_attribute ( HTML : : AttributeNames : : nonce ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 13:27:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        // 2.1. Let nonce be element's [[CryptographicNonce]].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        auto  nonce  =  m_cryptographic_nonce ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // 2.2. Set an attribute value for element using "nonce" and the empty string.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        element . set_attribute_value ( HTML : : AttributeNames : : nonce ,  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // 2.3. Set element's [[CryptographicNonce]] to nonce.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        m_cryptographic_nonce  =  nonce ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 11:07:02 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								template < typename  ElementBase > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								void  HTMLOrSVGElement < ElementBase > : : visit_edges ( JS : : Cell : : Visitor &  visitor ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    visitor . visit ( m_dataset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								template  class  HTMLOrSVGElement < HTMLElement > ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								template  class  HTMLOrSVGElement < MathML : : MathMLElement > ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								template  class  HTMLOrSVGElement < SVG : : SVGElement > ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}