diff --git a/Tests/LibWeb/rebaseline-libweb-test b/Tests/LibWeb/rebaseline-libweb-test index f2533cf4dc0..89ddb787fce 100755 --- a/Tests/LibWeb/rebaseline-libweb-test +++ b/Tests/LibWeb/rebaseline-libweb-test @@ -17,4 +17,4 @@ expected_dir=$(echo $input_dir | sed s/input/expected/) test_name=$(basename $t .html) cd $LADYBIRD_SOURCE_DIR/Build/ladybird mkdir -p $expected_dir -./bin/headless-browser $mode_flag --layout-test-mode $input_dir/$test_name.html > $expected_dir/$test_name.txt +./bin/Ladybird.app/Contents/MacOS/headless-browser $mode_flag --layout-test-mode $LADYBIRD_SOURCE_DIR/Tests/LibWeb/$input_dir/$test_name.html > $LADYBIRD_SOURCE_DIR/Tests/LibWeb/$expected_dir/$test_name.txt diff --git a/Userland/Libraries/LibWeb/HTML/AttributeNames.h b/Userland/Libraries/LibWeb/HTML/AttributeNames.h index 01ccfde4920..fadf5ff90d4 100644 --- a/Userland/Libraries/LibWeb/HTML/AttributeNames.h +++ b/Userland/Libraries/LibWeb/HTML/AttributeNames.h @@ -211,6 +211,7 @@ namespace AttributeNames { __ENUMERATE_HTML_ATTRIBUTE(ping) \ __ENUMERATE_HTML_ATTRIBUTE(placeholder) \ __ENUMERATE_HTML_ATTRIBUTE(playsinline) \ + __ENUMERATE_HTML_ATTRIBUTE(popover) \ __ENUMERATE_HTML_ATTRIBUTE(poster) \ __ENUMERATE_HTML_ATTRIBUTE(preload) \ __ENUMERATE_HTML_ATTRIBUTE(readonly) \ diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp index b5a4cf58205..aa6cd12a513 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -645,6 +645,34 @@ WebIDL::ExceptionOr> HTMLElement::attach_inte return { internals }; } +// https://html.spec.whatwg.org/multipage/popover.html#dom-popover +Optional HTMLElement::popover() const +{ + // FIXME: This should probably be `Reflect` in the IDL. + // The popover IDL attribute must reflect the popover attribute, limited to only known values. + auto value = get_attribute(HTML::AttributeNames::popover); + + if (!value.has_value()) + return {}; + + if (value.value().is_empty() || value.value().equals_ignoring_ascii_case("auto"sv)) + return "auto"_string; + + return "manual"_string; +} + +// https://html.spec.whatwg.org/multipage/popover.html#dom-popover +WebIDL::ExceptionOr HTMLElement::set_popover(Optional value) +{ + // FIXME: This should probably be `Reflect` in the IDL. + // The popover IDL attribute must reflect the popover attribute, limited to only known values. + if (value.has_value()) + return set_attribute(HTML::AttributeNames::popover, value.release_value()); + + remove_attribute(HTML::AttributeNames::popover); + return {}; +} + void HTMLElement::did_receive_focus() { if (m_content_editable_state != ContentEditableState::True) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.h b/Userland/Libraries/LibWeb/HTML/HTMLElement.h index 71643bc7bd3..09b6989d35d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.h @@ -77,6 +77,9 @@ public: WebIDL::ExceptionOr> attach_internals(); + WebIDL::ExceptionOr set_popover(Optional value); + Optional popover() const; + protected: HTMLElement(DOM::Document&, DOM::QualifiedName); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLElement.idl index d4031754f23..299668a2fbc 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.idl @@ -35,7 +35,7 @@ interface HTMLElement : Element { [FIXME] undefined showPopover(); [FIXME] undefined hidePopover(); [FIXME] boolean togglePopover(optional boolean force); - [FIXME, CEReactions] attribute DOMString? popover; + [CEReactions] attribute DOMString? popover; // https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface readonly attribute Element? offsetParent;