| 
									
										
										
										
											2021-04-04 00:14:39 +02:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2021-04-22 22:51:19 +02:00
										 |  |  |  * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> | 
					
						
							| 
									
										
										
										
											2021-04-04 00:14:39 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2021-04-04 00:14:39 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibGfx/Rect.h>
 | 
					
						
							| 
									
										
										
										
											2022-09-24 16:34:04 -06:00
										 |  |  | #include <LibWeb/Bindings/Intrinsics.h>
 | 
					
						
							|  |  |  | #include <LibWeb/Bindings/ScreenPrototype.h>
 | 
					
						
							| 
									
										
										
										
											2021-04-04 00:14:39 +02:00
										 |  |  | #include <LibWeb/CSS/Screen.h>
 | 
					
						
							|  |  |  | #include <LibWeb/DOM/Document.h>
 | 
					
						
							|  |  |  | #include <LibWeb/Page/Page.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-31 18:52:54 +02:00
										 |  |  | JS::NonnullGCPtr<Screen> Screen::create(HTML::Window& window) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return *window.heap().allocate<Screen>(window.realm(), window); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-07 23:08:26 +01:00
										 |  |  | Screen::Screen(HTML::Window& window) | 
					
						
							| 
									
										
										
										
											2022-08-31 18:52:54 +02:00
										 |  |  |     : PlatformObject(window.realm()) | 
					
						
							|  |  |  |     , m_window(window) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-09-24 16:34:04 -06:00
										 |  |  |     set_prototype(&Bindings::ensure_web_prototype<Bindings::ScreenPrototype>(window.realm(), "Screen")); | 
					
						
							| 
									
										
										
										
											2022-08-31 18:52:54 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Screen::visit_edges(Cell::Visitor& visitor) | 
					
						
							| 
									
										
										
										
											2021-04-04 00:14:39 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-08-31 18:52:54 +02:00
										 |  |  |     Base::visit_edges(visitor); | 
					
						
							|  |  |  |     visitor.visit(m_window.ptr()); | 
					
						
							| 
									
										
										
										
											2021-04-04 00:14:39 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Gfx::IntRect Screen::screen_rect() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-11-25 17:07:19 +00:00
										 |  |  |     auto screen_rect_in_css_pixels = window().page()->web_exposed_screen_area(); | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |         screen_rect_in_css_pixels.x().value(), | 
					
						
							|  |  |  |         screen_rect_in_css_pixels.y().value(), | 
					
						
							|  |  |  |         screen_rect_in_css_pixels.width().value(), | 
					
						
							|  |  |  |         screen_rect_in_css_pixels.height().value() | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-04-04 00:14:39 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |