mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Support autocomplete
attribute on form elements
Implement proper support for the `autocomplete` attribute in `input`, `select` and `textarea` elements.
This commit is contained in:
parent
2d7080ecb3
commit
b8f234719d
Notes:
github-actions[bot]
2025-02-26 07:02:12 +00:00
Author: https://github.com/devgianlu
Commit: b8f234719d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3517
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/tcl3 ✅
11 changed files with 644 additions and 9 deletions
54
Libraries/LibWeb/HTML/AutocompleteElement.h
Normal file
54
Libraries/LibWeb/HTML/AutocompleteElement.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Altomani Gianluca <altomanigianluca@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/HTML/FormAssociatedElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
#define AUTOCOMPLETE_ELEMENT(ElementBaseClass, ElementClass) \
|
||||
private: \
|
||||
virtual HTMLElement& autocomplete_element_to_html_element() override \
|
||||
{ \
|
||||
static_assert(IsBaseOf<HTMLElement, ElementClass>); \
|
||||
static_assert(IsBaseOf<FormAssociatedElement, ElementClass>); \
|
||||
return *this; \
|
||||
}
|
||||
|
||||
class AutocompleteElement {
|
||||
public:
|
||||
enum class AutofillMantle {
|
||||
Anchor,
|
||||
Expectation,
|
||||
};
|
||||
AutofillMantle get_autofill_mantle() const;
|
||||
|
||||
Vector<String> autocomplete_tokens() const;
|
||||
String autocomplete() const;
|
||||
WebIDL::ExceptionOr<void> set_autocomplete(String const&);
|
||||
|
||||
// Each input element to which the autocomplete attribute applies [...] has
|
||||
// an autofill hint set, an autofill scope, an autofill field name,
|
||||
// a non-autofill credential type, and an IDL-exposed autofill value.
|
||||
struct AttributeDetails {
|
||||
Vector<String> hint_set;
|
||||
Vector<String> scope;
|
||||
String field_name;
|
||||
Optional<String> credential_type;
|
||||
String value;
|
||||
};
|
||||
AttributeDetails parse_autocomplete_attribute() const;
|
||||
|
||||
virtual HTMLElement& autocomplete_element_to_html_element() = 0;
|
||||
HTMLElement const& autocomplete_element_to_html_element() const { return const_cast<AutocompleteElement&>(*this).autocomplete_element_to_html_element(); }
|
||||
|
||||
protected:
|
||||
AutocompleteElement() = default;
|
||||
virtual ~AutocompleteElement() = default;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue