ladybird/Libraries/LibWeb/HTML/AutocompleteElement.h
Luke Wilde 82bd3d3891 LibWeb: Avoid invoking Trusted Types where avoidable
Prevents observably calling Trusted Types, which can run arbitrary JS,
cause crashes due to use of MUST and allow arbitrary JS to modify
internal elements.
2025-11-06 11:43:06 -05:00

55 lines
1.8 KiB
C++

/*
* Copyright (c) 2025, Altomani Gianluca <altomanigianluca@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Export.h>
#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 WEB_API AutocompleteElement {
public:
enum class AutofillMantle {
Anchor,
Expectation,
};
AutofillMantle get_autofill_mantle() const;
Vector<String> autocomplete_tokens() const;
String autocomplete() const;
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;
};
}