Prechádzať zdrojové kódy

LibWeb: Stub HTMLInputElement.setSelectionRange

Required by Twitter to move the input caret of the 2FA <input> element
to the start. However, we don't currently handle individual <input>
element selections.
Luke Wilde 2 rokov pred
rodič
commit
1011067a60

+ 7 - 0
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<void> 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 {};
+}
+
 }

+ 2 - 0
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<FileAPI::FileList>);
 
+    WebIDL::ExceptionOr<void> set_selection_range(u32 start, u32 end, DeprecatedString const& direction);
+
     WebIDL::ExceptionOr<void> show_picker();
 
     // ^EventTarget

+ 2 - 0
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();
 
 };