/src/serenity/Userland/Libraries/LibWeb/CSS/ScreenOrientation.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2024, Shannon Booth <shannon@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibWeb/Bindings/Intrinsics.h> |
8 | | #include <LibWeb/Bindings/ScreenOrientationPrototype.h> |
9 | | #include <LibWeb/CSS/ScreenOrientation.h> |
10 | | #include <LibWeb/HTML/EventNames.h> |
11 | | |
12 | | namespace Web::CSS { |
13 | | |
14 | | JS_DEFINE_ALLOCATOR(ScreenOrientation); |
15 | | |
16 | | ScreenOrientation::ScreenOrientation(JS::Realm& realm) |
17 | 0 | : DOM::EventTarget(realm) |
18 | 0 | { |
19 | 0 | } |
20 | | |
21 | | void ScreenOrientation::initialize(JS::Realm& realm) |
22 | 0 | { |
23 | 0 | Base::initialize(realm); |
24 | 0 | WEB_SET_PROTOTYPE_FOR_INTERFACE(ScreenOrientation); |
25 | 0 | } |
26 | | |
27 | | JS::NonnullGCPtr<ScreenOrientation> ScreenOrientation::create(JS::Realm& realm) |
28 | 0 | { |
29 | 0 | return realm.heap().allocate<ScreenOrientation>(realm, realm); |
30 | 0 | } |
31 | | |
32 | | // https://w3c.github.io/screen-orientation/#lock-method |
33 | | WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> ScreenOrientation::lock(Bindings::OrientationLockType) |
34 | 0 | { |
35 | 0 | return WebIDL::NotSupportedError::create(realm(), "FIXME: ScreenOrientation::lock() is not implemented"_string); |
36 | 0 | } |
37 | | |
38 | | // https://w3c.github.io/screen-orientation/#unlock-method |
39 | | void ScreenOrientation::unlock() |
40 | 0 | { |
41 | 0 | dbgln("FIXME: Stubbed ScreenOrientation::unlock()"); |
42 | 0 | } |
43 | | |
44 | | // https://w3c.github.io/screen-orientation/#type-attribute |
45 | | Bindings::OrientationType ScreenOrientation::type() const |
46 | 0 | { |
47 | 0 | dbgln("FIXME: Stubbed ScreenOrientation::type()"); |
48 | 0 | return Bindings::OrientationType::LandscapePrimary; |
49 | 0 | } |
50 | | |
51 | | // https://w3c.github.io/screen-orientation/#angle-attribute |
52 | | WebIDL::UnsignedShort ScreenOrientation::angle() const |
53 | 0 | { |
54 | 0 | dbgln("FIXME: Stubbed ScreenOrientation::angle()"); |
55 | 0 | return 0; |
56 | 0 | } |
57 | | |
58 | | // https://w3c.github.io/screen-orientation/#onchange-event-handler-attribute |
59 | | void ScreenOrientation::set_onchange(JS::GCPtr<WebIDL::CallbackType> event_handler) |
60 | 0 | { |
61 | 0 | set_event_handler_attribute(HTML::EventNames::change, event_handler); |
62 | 0 | } |
63 | | |
64 | | // https://w3c.github.io/screen-orientation/#onchange-event-handler-attribute |
65 | | JS::GCPtr<WebIDL::CallbackType> ScreenOrientation::onchange() |
66 | 0 | { |
67 | 0 | return event_handler_attribute(HTML::EventNames::change); |
68 | 0 | } |
69 | | |
70 | | } |