2020-08-01 03:05:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								/*
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-28 22:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  Copyright  ( c )  2020 ,  the  SerenityOS  developers . 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  Copyright  ( c )  2023 ,  Bastiaan  van  der  Plaat  < bastiaan . v . d . plaat @ gmail . com > 
							 
						 
					
						
							
								
									
										
										
										
											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/HTMLMeterElementPrototype.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-18 09:19:56 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/CSS/ComputedProperties.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-08 20:14:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/CSS/StyleValues/DisplayStyleValue.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/DOM/Document.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-10 12:42:13 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/DOM/ElementFactory.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/DOM/ShadowRoot.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-01 03:05:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/HTML/HTMLMeterElement.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/HTML/Numbers.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-10 12:42:13 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/Namespace.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-01 03:05:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								namespace  Web : : HTML  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC_DEFINE_ALLOCATOR ( HTMLMeterElement ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-19 19:47:52 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-18 21:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								HTMLMeterElement : : HTMLMeterElement ( 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 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								HTMLMeterElement : : ~ HTMLMeterElement ( )  =  default ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-01 03:05:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-07 08:41:28 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  HTMLMeterElement : : initialize ( JS : : Realm &  realm ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-10 06:28:20 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-16 13:13:08 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    WEB_SET_PROTOTYPE_FOR_INTERFACE ( HTMLMeterElement ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 16:22:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    Base : : initialize ( realm ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-10 06:28:20 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  HTMLMeterElement : : visit_edges ( Cell : : Visitor &  visitor ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    Base : : visit_edges ( visitor ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    visitor . visit ( m_meter_value_element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-actual
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								double  HTMLMeterElement : : value ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the value attribute is specified and a value could be parsed out of it, then that value is the candidate actual value. Otherwise, the candidate actual value is zero.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    double  candidate_value  =  0.0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-07 18:40:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( auto  value_string  =  get_attribute ( HTML : : AttributeNames : : value ) ;  value_string . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( auto  value  =  parse_floating_point_number ( * value_string ) ;  value . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            candidate_value  =  * value ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the candidate actual value is less than the minimum value, then the actual value is the minimum value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Otherwise, if the candidate actual value is greater than the maximum value, then the actual value is the maximum value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Otherwise, the actual value is the candidate actual value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  clamp ( candidate_value ,  min ( ) ,  max ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								WebIDL : : ExceptionOr < void >  HTMLMeterElement : : set_value ( double  value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-14 10:05:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    TRY ( set_attribute ( HTML : : AttributeNames : : value ,  String : : number ( value ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    update_meter_value_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-minimum
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								double  HTMLMeterElement : : min ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the min attribute is specified and a value could be parsed out of it, then the minimum value is that value. Otherwise, the minimum value is zero.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-07 18:40:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( auto  min_string  =  get_attribute ( HTML : : AttributeNames : : min ) ;  min_string . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( auto  min  =  parse_floating_point_number ( * min_string ) ;  min . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  * min ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								WebIDL : : ExceptionOr < void >  HTMLMeterElement : : set_min ( double  value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-14 10:05:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    TRY ( set_attribute ( HTML : : AttributeNames : : min ,  String : : number ( value ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    update_meter_value_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-maximum
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								double  HTMLMeterElement : : max ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the max attribute is specified and a value could be parsed out of it, then the candidate maximum value is that value. Otherwise, the candidate maximum value is 1.0.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    double  candidate_max  =  1.0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-07 18:40:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( auto  max_string  =  get_attribute ( HTML : : AttributeNames : : max ) ;  max_string . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( auto  max  =  parse_floating_point_number ( * max_string ) ;  max . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            candidate_max  =  * max ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the candidate maximum value is greater than or equal to the minimum value, then the maximum value is the candidate maximum value. Otherwise, the maximum value is the same as the minimum value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  AK : : max ( candidate_max ,  min ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								WebIDL : : ExceptionOr < void >  HTMLMeterElement : : set_max ( double  value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-14 10:05:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    TRY ( set_attribute ( HTML : : AttributeNames : : max ,  String : : number ( value ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    update_meter_value_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-low
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								double  HTMLMeterElement : : low ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the low attribute is specified and a value could be parsed out of it, then the candidate low boundary is that value. Otherwise, the candidate low boundary is the same as the minimum value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    double  candidate_low  =  min ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-07 18:40:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( auto  low_string  =  get_attribute ( HTML : : AttributeNames : : low ) ;  low_string . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( auto  low  =  parse_floating_point_number ( * low_string ) ;  low . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            candidate_low  =  * low ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the candidate low boundary is less than the minimum value, then the low boundary is the minimum value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Otherwise, if the candidate low boundary is greater than the maximum value, then the low boundary is the maximum value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Otherwise, the low boundary is the candidate low boundary.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  clamp ( candidate_low ,  min ( ) ,  max ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								WebIDL : : ExceptionOr < void >  HTMLMeterElement : : set_low ( double  value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-14 10:05:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    TRY ( set_attribute ( HTML : : AttributeNames : : low ,  String : : number ( value ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    update_meter_value_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-high
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								double  HTMLMeterElement : : high ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the high attribute is specified and a value could be parsed out of it, then the candidate high boundary is that value. Otherwise, the candidate high boundary is the same as the maximum value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    double  candidate_high  =  max ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-07 18:40:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( auto  high_string  =  get_attribute ( HTML : : AttributeNames : : high ) ;  high_string . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( auto  high  =  parse_floating_point_number ( * high_string ) ;  high . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            candidate_high  =  * high ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the candidate high boundary is less than the low boundary, then the high boundary is the low boundary.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Otherwise, if the candidate high boundary is greater than the maximum value, then the high boundary is the maximum value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Otherwise, the high boundary is the candidate high boundary.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  clamp ( candidate_high ,  low ( ) ,  max ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								WebIDL : : ExceptionOr < void >  HTMLMeterElement : : set_high ( double  value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-14 10:05:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    TRY ( set_attribute ( HTML : : AttributeNames : : high ,  String : : number ( value ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    update_meter_value_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/form-elements.html#concept-meter-optimum
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								double  HTMLMeterElement : : optimum ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the optimum attribute is specified and a value could be parsed out of it, then the candidate optimum point is that value. Otherwise, the candidate optimum point is the midpoint between the minimum value and the maximum value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    double  candidate_optimum  =  ( max ( )  +  min ( ) )  /  2 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-07 18:40:54 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( auto  optimum_string  =  get_attribute ( HTML : : AttributeNames : : optimum ) ;  optimum_string . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( auto  optimum  =  parse_floating_point_number ( * optimum_string ) ;  optimum . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            candidate_optimum  =  * optimum ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the candidate optimum point is less than the minimum value, then the optimum point is the minimum value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Otherwise, if the candidate optimum point is greater than the maximum value, then the optimum point is the maximum value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Otherwise, the optimum point is the candidate optimum point.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  clamp ( candidate_optimum ,  min ( ) ,  max ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								WebIDL : : ExceptionOr < void >  HTMLMeterElement : : set_optimum ( double  value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-14 10:05:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    TRY ( set_attribute ( HTML : : AttributeNames : : optimum ,  String : : number ( value ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    update_meter_value_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								void  HTMLMeterElement : : inserted ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-23 17:38:24 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    Base : : inserted ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    create_shadow_tree_if_needed ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-20 11:32:17 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  HTMLMeterElement : : adjust_computed_style ( CSS : : ComputedProperties &  style ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-08 20:14:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // https://drafts.csswg.org/css-display-3/#unbox
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( style . display ( ) . is_contents ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        style . set_property ( CSS : : PropertyID : : Display ,  CSS : : DisplayStyleValue : : create ( CSS : : Display : : from_short ( CSS : : Display : : Short : : None ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  HTMLMeterElement : : create_shadow_tree_if_needed ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-25 11:28:58 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( shadow_root ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-14 05:50:17 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto  shadow_root  =  realm ( ) . create < DOM : : ShadowRoot > ( document ( ) ,  * this ,  Bindings : : ShadowRootMode : : Closed ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    set_shadow_root ( shadow_root ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-10 12:42:13 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto  meter_bar_element  =  MUST ( DOM : : create_element ( document ( ) ,  HTML : : TagNames : : div ,  Namespace : : HTML ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-11 16:04:23 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    meter_bar_element - > set_use_pseudo_element ( CSS : : PseudoElement : : SliderTrack ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    MUST ( shadow_root - > append_child ( * meter_bar_element ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-10 12:42:13 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    m_meter_value_element  =  MUST ( DOM : : create_element ( document ( ) ,  HTML : : TagNames : : div ,  Namespace : : HTML ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-11 16:04:23 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    m_meter_value_element - > set_use_pseudo_element ( CSS : : PseudoElement : : SliderFill ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    MUST ( meter_bar_element - > append_child ( * m_meter_value_element ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    update_meter_value_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								void  HTMLMeterElement : : update_meter_value_element ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // UA requirements for regions of the gauge:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    double  value  =  this - > value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    double  min  =  this - > min ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    double  max  =  this - > max ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    double  low  =  this - > low ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    double  high  =  this - > high ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    double  optimum  =  this - > optimum ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // If the optimum point is equal to the low boundary or the high boundary, or anywhere in between them, then the region between the low and high boundaries of the gauge must be treated as the optimum region, and the low and high parts, if any, must be treated as suboptimal.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( optimum  > =  low  & &  optimum  < =  high )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( value  > =  low  & &  value  < =  high ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-18 16:55:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            m_cached_value_state  =  ValueState : : Optimal ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        else 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-18 16:55:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            m_cached_value_state  =  ValueState : : Suboptimal ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Otherwise, if the optimum point is less than the low boundary, then the region between the minimum value and the low boundary must be treated as the optimum region, the region from the low boundary up to the high boundary must be treated as a suboptimal region, and the remaining region must be treated as an even less good region.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    else  if  ( optimum  <  low )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( value  > =  low  & &  value  < =  high ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-18 16:55:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            m_cached_value_state  =  ValueState : : Suboptimal ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        else 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-18 16:55:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            m_cached_value_state  =  ValueState : : EvenLessGood ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Finally, if the optimum point is higher than the high boundary, then the situation is reversed; the region between the high boundary and the maximum value must be treated as the optimum region, the region from the high boundary down to the low boundary must be treated as a suboptimal region, and the remaining region must be treated as an even less good region.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-06 20:30:17 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( value  > =  high  & &  value  < =  max ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-18 16:55:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            m_cached_value_state  =  ValueState : : Optimal ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-06 20:30:17 -03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        else  if  ( value  > =  low  & &  value  < =  high ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-18 16:55:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            m_cached_value_state  =  ValueState : : Suboptimal ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        else 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-18 16:55:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            m_cached_value_state  =  ValueState : : EvenLessGood ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ! m_meter_value_element ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    double  position  =  ( value  -  min )  /  ( max  -  min )  *  100 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-10 12:42:13 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    MUST ( m_meter_value_element - > style_for_bindings ( ) - > set_property ( CSS : : PropertyID : : Width ,  MUST ( String : : formatted ( " {}% " ,  position ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-25 14:32:40 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-13 07:06:33 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-01 03:05:43 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}