mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibWeb: Implement bare-bones HTMLElement.dir
This commit is contained in:
parent
de494ccf38
commit
bfdb30c74a
Notes:
sideshowbarker
2024-07-17 04:31:14 +09:00
Author: https://github.com/Igoorx
Commit: bfdb30c74a
Pull-request: https://github.com/SerenityOS/serenity/pull/15931
Reviewed-by: https://github.com/ADKaster
4 changed files with 29 additions and 0 deletions
|
@ -55,6 +55,7 @@ namespace AttributeNames {
|
|||
__ENUMERATE_HTML_ATTRIBUTE(declare) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(default_) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(defer) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(dir) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(direction) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(dirname) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(disabled) \
|
||||
|
|
|
@ -53,6 +53,24 @@ void HTMLElement::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_dataset.ptr());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#dom-dir
|
||||
String HTMLElement::dir() const
|
||||
{
|
||||
auto dir = attribute(HTML::AttributeNames::dir);
|
||||
#define __ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTE(keyword) \
|
||||
if (dir.equals_ignoring_case(#keyword##sv)) \
|
||||
return #keyword##sv;
|
||||
ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTES
|
||||
#undef __ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTE
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void HTMLElement::set_dir(String const& dir)
|
||||
{
|
||||
MUST(set_attribute(HTML::AttributeNames::dir, dir));
|
||||
}
|
||||
|
||||
HTMLElement::ContentEditableState HTMLElement::content_editable_state() const
|
||||
{
|
||||
auto contenteditable = attribute(HTML::AttributeNames::contenteditable);
|
||||
|
|
|
@ -12,6 +12,12 @@
|
|||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#attr-dir
|
||||
#define ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTES \
|
||||
__ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTE(ltr) \
|
||||
__ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTE(rtl) \
|
||||
__ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTE(auto)
|
||||
|
||||
class HTMLElement
|
||||
: public DOM::Element
|
||||
, public HTML::GlobalEventHandlers {
|
||||
|
@ -22,6 +28,9 @@ public:
|
|||
|
||||
String title() const { return attribute(HTML::AttributeNames::title); }
|
||||
|
||||
String dir() const;
|
||||
void set_dir(String const&);
|
||||
|
||||
virtual bool is_editable() const final;
|
||||
String content_editable() const;
|
||||
WebIDL::ExceptionOr<void> set_content_editable(String const&);
|
||||
|
|
|
@ -7,6 +7,7 @@ interface HTMLElement : Element {
|
|||
|
||||
[Reflect] attribute DOMString title;
|
||||
[Reflect] attribute DOMString lang;
|
||||
attribute DOMString dir;
|
||||
|
||||
[Reflect] attribute boolean hidden;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue