| 
									
										
										
										
											2024-04-02 22:44:05 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2024, Shannon Booth <shannon@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibWeb/Bindings/Intrinsics.h>
 | 
					
						
							| 
									
										
										
										
											2024-04-27 12:09:58 +12:00
										 |  |  | #include <LibWeb/Bindings/ScreenOrientationPrototype.h>
 | 
					
						
							| 
									
										
										
										
											2024-04-02 22:44:05 +02:00
										 |  |  | #include <LibWeb/CSS/ScreenOrientation.h>
 | 
					
						
							|  |  |  | #include <LibWeb/HTML/EventNames.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  | GC_DEFINE_ALLOCATOR(ScreenOrientation); | 
					
						
							| 
									
										
										
										
											2024-04-02 22:44:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | ScreenOrientation::ScreenOrientation(JS::Realm& realm) | 
					
						
							|  |  |  |     : DOM::EventTarget(realm) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ScreenOrientation::initialize(JS::Realm& realm) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Base::initialize(realm); | 
					
						
							|  |  |  |     WEB_SET_PROTOTYPE_FOR_INTERFACE(ScreenOrientation); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  | GC::Ref<ScreenOrientation> ScreenOrientation::create(JS::Realm& realm) | 
					
						
							| 
									
										
										
										
											2024-04-02 22:44:05 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-11-14 05:50:17 +13:00
										 |  |  |     return realm.create<ScreenOrientation>(realm); | 
					
						
							| 
									
										
										
										
											2024-04-02 22:44:05 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://w3c.github.io/screen-orientation/#lock-method
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  | WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> ScreenOrientation::lock(Bindings::OrientationLockType) | 
					
						
							| 
									
										
										
										
											2024-04-02 22:44:05 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-10-12 20:56:21 +02:00
										 |  |  |     return WebIDL::NotSupportedError::create(realm(), "FIXME: ScreenOrientation::lock() is not implemented"_string); | 
					
						
							| 
									
										
										
										
											2024-04-02 22:44:05 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://w3c.github.io/screen-orientation/#unlock-method
 | 
					
						
							|  |  |  | void ScreenOrientation::unlock() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     dbgln("FIXME: Stubbed ScreenOrientation::unlock()"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://w3c.github.io/screen-orientation/#type-attribute
 | 
					
						
							|  |  |  | Bindings::OrientationType ScreenOrientation::type() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     dbgln("FIXME: Stubbed ScreenOrientation::type()"); | 
					
						
							|  |  |  |     return Bindings::OrientationType::LandscapePrimary; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://w3c.github.io/screen-orientation/#angle-attribute
 | 
					
						
							|  |  |  | WebIDL::UnsignedShort ScreenOrientation::angle() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     dbgln("FIXME: Stubbed ScreenOrientation::angle()"); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://w3c.github.io/screen-orientation/#onchange-event-handler-attribute
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  | void ScreenOrientation::set_onchange(GC::Ptr<WebIDL::CallbackType> event_handler) | 
					
						
							| 
									
										
										
										
											2024-04-02 22:44:05 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     set_event_handler_attribute(HTML::EventNames::change, event_handler); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://w3c.github.io/screen-orientation/#onchange-event-handler-attribute
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  | GC::Ptr<WebIDL::CallbackType> ScreenOrientation::onchange() | 
					
						
							| 
									
										
										
										
											2024-04-02 22:44:05 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     return event_handler_attribute(HTML::EventNames::change); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |