From 1011067a60d6d6284c5ffc104d5a3c3dcc7f9900 Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Fri, 30 Dec 2022 23:00:11 +0000 Subject: [PATCH] LibWeb: Stub HTMLInputElement.setSelectionRange Required by Twitter to move the input caret of the 2FA element to the start. However, we don't currently handle individual element selections. --- Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 7 +++++++ Userland/Libraries/LibWeb/HTML/HTMLInputElement.h | 2 ++ Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl | 2 ++ 3 files changed, 11 insertions(+) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 3c8316930b..ba0c9a1c15 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -837,4 +837,11 @@ i32 HTMLInputElement::default_tab_index_value() const return 0; } +// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-setselectionrange +WebIDL::ExceptionOr HTMLInputElement::set_selection_range(u32 start, u32 end, DeprecatedString const& direction) +{ + dbgln("(STUBBED) HTMLInputElement::set_selection_range(start={}, end={}, direction='{}'). Called on: {}", start, end, direction, debug_description()); + return {}; +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index d6027e39f4..7ee434f7b8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -87,6 +87,8 @@ public: // https://html.spec.whatwg.org/multipage/input.html#update-the-file-selection void update_the_file_selection(JS::NonnullGCPtr); + WebIDL::ExceptionOr set_selection_range(u32 start, u32 end, DeprecatedString const& direction); + WebIDL::ExceptionOr show_picker(); // ^EventTarget diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl index 2db4de4496..def33de5af 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl @@ -38,6 +38,8 @@ interface HTMLInputElement : HTMLElement { [Reflect] attribute DOMString align; [Reflect=usemap] attribute DOMString useMap; + undefined setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction); + undefined showPicker(); };