mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 03:29:49 +00:00
LibWeb: Implement the translate attribute
This commit is contained in:
parent
4b3715ccba
commit
279913a223
Notes:
github-actions[bot]
2025-05-23 12:35:07 +00:00
Author: https://github.com/Calme1709
Commit: 279913a223
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4855
Reviewed-by: https://github.com/gmta ✅
24 changed files with 399 additions and 1 deletions
|
@ -299,6 +299,7 @@ namespace AttributeNames {
|
|||
__ENUMERATE_HTML_ATTRIBUTE(text, "text") \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(title, "title") \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(topmargin, "topmargin") \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(translate, "translate") \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(truespeed, "truespeed") \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(type, "type") \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(usemap, "usemap") \
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -82,6 +82,9 @@ public:
|
|||
|
||||
Optional<String> title() const { return attribute(HTML::AttributeNames::title); }
|
||||
|
||||
bool translate() const;
|
||||
void set_translate(bool);
|
||||
|
||||
StringView dir() const;
|
||||
void set_dir(String const&);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ interface HTMLElement : Element {
|
|||
// metadata attributes
|
||||
[Reflect, CEReactions] attribute DOMString title;
|
||||
[Reflect, CEReactions] attribute DOMString lang;
|
||||
[FIXME, CEReactions] attribute boolean translate;
|
||||
[CEReactions] attribute boolean translate;
|
||||
[CEReactions] attribute DOMString dir;
|
||||
|
||||
// user interaction
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue