| 
									
										
										
										
											2020-06-04 16:06:32 +02:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-08-20 14:55:28 +02:00
										 |  |  |  * Copyright (c) 2020-2024, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2023-02-28 00:05:39 +00:00
										 |  |  |  * Copyright (c) 2023, Luke Wilde <lukew@serenityos.org> | 
					
						
							| 
									
										
										
										
											2020-06-04 16:06:32 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-06-04 16:06:32 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-09 16:05:03 -07:00
										 |  |  | #include <LibWeb/Bindings/PlatformObject.h>
 | 
					
						
							| 
									
										
										
										
											2021-03-08 11:22:18 +01:00
										 |  |  | #include <LibWeb/CSS/CSSStyleSheet.h>
 | 
					
						
							| 
									
										
										
										
											2020-06-04 16:06:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-21 16:23:08 +02:00
										 |  |  | namespace Web::CSS { | 
					
						
							| 
									
										
										
										
											2020-06-04 16:06:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-09 16:05:03 -07:00
										 |  |  | class StyleSheetList final : public Bindings::PlatformObject { | 
					
						
							|  |  |  |     WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::PlatformObject); | 
					
						
							| 
									
										
										
										
											2023-11-19 19:47:52 +01:00
										 |  |  |     JS_DECLARE_ALLOCATOR(StyleSheetList); | 
					
						
							| 
									
										
										
										
											2021-03-08 11:22:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-07 13:29:49 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2024-08-20 14:55:28 +02:00
										 |  |  |     [[nodiscard]] static JS::NonnullGCPtr<StyleSheetList> create(JS::NonnullGCPtr<DOM::Node> document_or_shadow_root); | 
					
						
							| 
									
										
										
										
											2020-06-04 16:06:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-15 21:42:46 +01:00
										 |  |  |     void add_a_css_style_sheet(CSS::CSSStyleSheet&); | 
					
						
							|  |  |  |     void remove_a_css_style_sheet(CSS::CSSStyleSheet&); | 
					
						
							|  |  |  |     void create_a_css_style_sheet(String type, DOM::Element* owner_node, String media, String title, bool alternate, bool origin_clean, Optional<String> location, CSS::CSSStyleSheet* parent_style_sheet, CSS::CSSRule* owner_rule, CSS::CSSStyleSheet&); | 
					
						
							| 
									
										
										
										
											2021-09-29 23:46:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-09 11:08:56 +02:00
										 |  |  |     Vector<JS::NonnullGCPtr<CSSStyleSheet>> const& sheets() const { return m_sheets; } | 
					
						
							|  |  |  |     Vector<JS::NonnullGCPtr<CSSStyleSheet>>& sheets() { return m_sheets; } | 
					
						
							| 
									
										
										
										
											2021-03-08 11:22:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-07 13:14:54 +02:00
										 |  |  |     CSSStyleSheet* item(size_t index) const | 
					
						
							| 
									
										
										
										
											2021-03-08 11:22:18 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (index >= m_sheets.size()) | 
					
						
							|  |  |  |             return {}; | 
					
						
							| 
									
										
										
										
											2022-09-09 11:08:56 +02:00
										 |  |  |         return const_cast<CSSStyleSheet*>(m_sheets[index].ptr()); | 
					
						
							| 
									
										
										
										
											2021-03-08 11:22:18 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-06-04 16:06:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 11:22:18 +01:00
										 |  |  |     size_t length() const { return m_sheets.size(); } | 
					
						
							| 
									
										
										
										
											2020-06-04 16:06:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-25 18:15:51 +12:00
										 |  |  |     virtual Optional<JS::Value> item_value(size_t index) const override; | 
					
						
							| 
									
										
										
										
											2021-09-29 13:03:09 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-20 14:55:28 +02:00
										 |  |  |     [[nodiscard]] DOM::Document& document(); | 
					
						
							|  |  |  |     [[nodiscard]] DOM::Document const& document() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] DOM::Node& document_or_shadow_root() { return m_document_or_shadow_root; } | 
					
						
							|  |  |  |     [[nodiscard]] DOM::Node const& document_or_shadow_root() const { return m_document_or_shadow_root; } | 
					
						
							| 
									
										
										
										
											2022-03-09 19:57:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-04 16:06:32 +02:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2024-08-20 14:55:28 +02:00
										 |  |  |     explicit StyleSheetList(JS::NonnullGCPtr<DOM::Node> document_or_shadow_root); | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-07 08:41:28 +02:00
										 |  |  |     virtual void initialize(JS::Realm&) override; | 
					
						
							| 
									
										
										
										
											2022-08-07 13:29:49 +02:00
										 |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							| 
									
										
										
										
											2020-06-04 16:06:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-15 21:42:46 +01:00
										 |  |  |     void add_sheet(CSSStyleSheet&); | 
					
						
							|  |  |  |     void remove_sheet(CSSStyleSheet&); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-20 14:55:28 +02:00
										 |  |  |     JS::NonnullGCPtr<DOM::Node> m_document_or_shadow_root; | 
					
						
							| 
									
										
										
										
											2022-09-09 11:08:56 +02:00
										 |  |  |     Vector<JS::NonnullGCPtr<CSSStyleSheet>> m_sheets; | 
					
						
							| 
									
										
										
										
											2024-04-16 22:59:40 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://www.w3.org/TR/cssom/#preferred-css-style-sheet-set-name
 | 
					
						
							|  |  |  |     String m_preferred_css_style_sheet_set_name; | 
					
						
							|  |  |  |     // https://www.w3.org/TR/cssom/#last-css-style-sheet-set-name
 | 
					
						
							|  |  |  |     Optional<String> m_last_css_style_sheet_set_name; | 
					
						
							| 
									
										
										
										
											2020-06-04 16:06:32 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |