Skip to content

Commit 17e5993

Browse files
AtkinsSJgmta
authored andcommitted
LibWeb/DOM: Stub out Element.requestPointerLock()
Does just enough to make classic.minecraft.net load and let you play. Without actual pointer lock it's quite awkward though.
1 parent 924e4d2 commit 17e5993

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

Libraries/LibWeb/DOM/Element.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4338,6 +4338,15 @@ double Element::ensure_css_random_base_value(CSS::RandomCachingKey const& random
43384338
});
43394339
}
43404340

4341+
GC::Ref<WebIDL::Promise> Element::request_pointer_lock(Optional<PointerLockOptions>)
4342+
{
4343+
dbgln("FIXME: request_pointer_lock()");
4344+
auto promise = WebIDL::create_promise(realm());
4345+
auto error = WebIDL::NotSupportedError::create(realm(), "request_pointer_lock() is not implemented"_utf16);
4346+
WebIDL::reject_promise(realm(), promise, error);
4347+
return promise;
4348+
}
4349+
43414350
// The element to inherit style from.
43424351
// If a pseudo-element is specified, this will return the element itself.
43434352
// Otherwise, if this element is slotted somewhere, it will return the slot's element to inherit style from.

Libraries/LibWeb/DOM/Element.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ enum class ProximityToTheViewport : u8 {
103103
NotDetermined,
104104
};
105105

106+
// https://w3c.github.io/pointerlock/#pointerlockoptions-dictionary
107+
struct PointerLockOptions {
108+
bool unadjusted_movement = false;
109+
};
110+
106111
class WEB_API Element
107112
: public ParentNode
108113
, public ChildNode<Element>
@@ -523,6 +528,8 @@ class WEB_API Element
523528

524529
double ensure_css_random_base_value(CSS::RandomCachingKey const&);
525530

531+
GC::Ref<WebIDL::Promise> request_pointer_lock(Optional<PointerLockOptions>);
532+
526533
protected:
527534
Element(Document&, DOM::QualifiedName);
528535
virtual void initialize(JS::Realm&) override;

Libraries/LibWeb/DOM/Element.idl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ dictionary CheckVisibilityOptions {
3636
boolean visibilityProperty = false;
3737
};
3838

39+
// https://w3c.github.io/pointerlock/#pointerlockoptions-dictionary
40+
dictionary PointerLockOptions {
41+
boolean unadjustedMovement = false;
42+
};
43+
3944
// https://dom.spec.whatwg.org/#element
4045
[Exposed=Window]
4146
interface Element : Node {
@@ -126,6 +131,9 @@ interface Element : Node {
126131

127132
// https://drafts.csswg.org/css-shadow-parts/#idl
128133
[SameObject, PutForwards=value, ImplementedAs=part_list] readonly attribute DOMTokenList part;
134+
135+
// https://w3c.github.io/pointerlock/#requestPointerLock
136+
Promise<undefined> requestPointerLock(optional PointerLockOptions options = {});
129137
};
130138

131139
dictionary GetHTMLOptions {

0 commit comments

Comments
 (0)