LibWeb: Implement the translate attribute

This commit is contained in:
Callum Law 2025-05-23 22:36:33 +12:00 committed by Jelle Raaijmakers
parent 4b3715ccba
commit 279913a223
Notes: github-actions[bot] 2025-05-23 12:35:07 +00:00
24 changed files with 399 additions and 1 deletions

View file

@ -104,6 +104,25 @@ bool HTMLElement::is_potentially_render_blocking()
return is_implicitly_potentially_render_blocking();
}
// https://html.spec.whatwg.org/multipage/dom.html#dom-translate
bool HTMLElement::translate() const
{
// The translate IDL attribute must, on getting, return true if the element's translation mode is
// translate-enabled, and false otherwise
return translation_mode() == TranslationMode::TranslateEnabled;
}
// https://html.spec.whatwg.org/multipage/dom.html#dom-translate
void HTMLElement::set_translate(bool new_value)
{
// On setting, it must set the content attribute's value to "yes" if the new value is true, and set the content
// attribute's value to "no" otherwise.
if (new_value)
MUST(set_attribute(HTML::AttributeNames::translate, "yes"_string));
else
MUST(set_attribute(HTML::AttributeNames::translate, "no"_string));
}
// https://html.spec.whatwg.org/multipage/dom.html#dom-dir
StringView HTMLElement::dir() const
{