| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-10-04 13:19:50 +02:00
										 |  |  |  * Copyright (c) 2020-2022, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibWeb/DOM/Element.h>
 | 
					
						
							|  |  |  | #include <LibWeb/Forward.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-28 18:20:36 +02:00
										 |  |  | namespace Web::HTML { | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class ListOfActiveFormattingElements { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-03-14 13:21:51 -06:00
										 |  |  |     ListOfActiveFormattingElements() = default; | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  |     ~ListOfActiveFormattingElements(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     struct Entry { | 
					
						
							|  |  |  |         bool is_marker() const { return !element; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |         GC::Ptr<DOM::Element> element; | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool is_empty() const { return m_entries.is_empty(); } | 
					
						
							| 
									
										
										
										
											2020-07-26 19:37:56 +02:00
										 |  |  |     bool contains(const DOM::Element&) const; | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 19:37:56 +02:00
										 |  |  |     void add(DOM::Element& element); | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  |     void add_marker(); | 
					
						
							| 
									
										
										
										
											2022-03-20 02:11:42 +01:00
										 |  |  |     void insert_at(size_t index, DOM::Element& element); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void replace(DOM::Element& to_remove, DOM::Element& to_add); | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 19:37:56 +02:00
										 |  |  |     void remove(DOM::Element&); | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     Vector<Entry> const& entries() const { return m_entries; } | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  |     Vector<Entry>& entries() { return m_entries; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-01 20:07:44 +13:00
										 |  |  |     DOM::Element* last_element_with_tag_name_before_marker(FlyString const& tag_name); | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-28 00:27:46 +02:00
										 |  |  |     void clear_up_to_the_last_marker(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-20 02:11:42 +01:00
										 |  |  |     Optional<size_t> find_index(DOM::Element const&) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-17 10:46:11 +02:00
										 |  |  |     void visit_edges(JS::Cell::Visitor&); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-27 23:22:42 +02:00
										 |  |  | private: | 
					
						
							|  |  |  |     Vector<Entry> m_entries; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |