2021-09-12 16:55:10 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								/*
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-22 18:31:08 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  Copyright  ( c )  2021 - 2022 ,  Linus  Groh  < linusg @ serenityos . org > 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-03 19:39:48 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  Copyright  ( c )  2021 ,  Sam  Atkins  < atkinssj @ serenityos . org > 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:55:10 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 16:34:04 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/Bindings/Intrinsics.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/Bindings/MediaQueryListPrototype.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:55:10 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/CSS/MediaQueryList.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/DOM/Document.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/DOM/EventDispatcher.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-16 20:43:24 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/DOM/IDLEventListener.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-01 01:33:10 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/HTML/EventHandler.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:55:10 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								namespace  Web : : CSS  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								JS : : NonnullGCPtr < MediaQueryList >  MediaQueryList : : create ( DOM : : Document &  document ,  NonnullRefPtrVector < MediaQuery > & &  media ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 17:40:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  document . heap ( ) . allocate < MediaQueryList > ( document . realm ( ) ,  document ,  move ( media ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-29 12:58:22 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								MediaQueryList : : MediaQueryList ( DOM : : Document &  document ,  NonnullRefPtrVector < MediaQuery > & &  media ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    :  DOM : : EventTarget ( document . realm ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:55:10 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    ,  m_document ( document ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ,  m_media ( move ( media ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 16:34:04 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    set_prototype ( & Bindings : : ensure_web_prototype < Bindings : : MediaQueryListPrototype > ( document . realm ( ) ,  " MediaQueryList " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-03 19:39:48 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    evaluate ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:55:10 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  MediaQueryList : : visit_edges ( Cell : : Visitor &  visitor ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    Base : : visit_edges ( visitor ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    visitor . visit ( m_document . ptr ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:55:10 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								// https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-media
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-04 18:02:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								DeprecatedString  MediaQueryList : : media ( )  const 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:55:10 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 16:40:44 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  serialize_a_media_query_list ( m_media ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:55:10 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-matches
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								bool  MediaQueryList : : matches ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-03 19:39:48 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    for  ( auto &  media  :  m_media )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( media . matches ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:55:10 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-03 19:39:48 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								bool  MediaQueryList : : evaluate ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    bool  now_matches  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( auto &  media  :  m_media )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-06 16:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        now_matches  =  now_matches  | |  media . evaluate ( m_document - > window ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-03 19:39:48 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  now_matches ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 00:18:28 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-addlistener
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-08 14:12:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  MediaQueryList : : add_listener ( DOM : : IDLEventListener *  listener ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 00:18:28 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. If listener is null, terminate these steps.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ! listener ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 2. Append an event listener to the associated list of event listeners with type set to change,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    //    callback set to listener, and capture set to false, unless there already is an event listener
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    //    in that list with the same type, callback, and capture.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    //    (NOTE: capture is set to false by default)
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-08 14:12:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    add_event_listener_without_options ( HTML : : EventNames : : change ,  * listener ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 00:18:28 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-removelistener
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-08 14:12:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  MediaQueryList : : remove_listener ( DOM : : IDLEventListener *  listener ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 00:18:28 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. Remove an event listener from the associated list of event listeners, whose type is change, callback is listener, and capture is false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // NOTE: While the spec doesn't technically use remove_event_listener and instead manipulates the list directly, every major engine uses remove_event_listener.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    //       This means if an event listener removes another event listener that comes after it, the removed event listener will not be invoked.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-08 14:12:01 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    remove_event_listener_without_options ( HTML : : EventNames : : change ,  * listener ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 00:18:28 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 16:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  MediaQueryList : : set_onchange ( WebIDL : : CallbackType *  event_handler ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-01 01:33:10 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    set_event_handler_attribute ( HTML : : EventNames : : change ,  event_handler ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 16:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								WebIDL : : CallbackType *  MediaQueryList : : onchange ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-01 01:33:10 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  event_handler_attribute ( HTML : : EventNames : : change ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:55:10 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}