LibWeb: Compute display: contents as none for unusual elements

https://drafts.csswg.org/css-display-3/#unbox-html specifies certain
elements that have their `display` style computed as `none` when
specified as `contents`.

This fixes at least one WPT test:
http://wpt.live/css/css-display/display-contents-suppression-dynamic-001.html
This commit is contained in:
Michael Watt 2024-11-08 20:14:37 +08:00 committed by Andreas Kling
commit 3b1d1d4582
Notes: github-actions[bot] 2024-11-13 10:12:00 +00:00
31 changed files with 156 additions and 0 deletions

View file

@ -8,6 +8,7 @@
#include <LibWeb/ARIA/Roles.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/HTMLElementPrototype.h>
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/EditingHostManager.h>
#include <LibWeb/DOM/ElementFactory.h>
@ -907,6 +908,15 @@ WebIDL::ExceptionOr<void> HTMLElement::set_popover(Optional<String> value)
return {};
}
void HTMLElement::adjust_computed_style(CSS::StyleProperties& style)
{
// https://drafts.csswg.org/css-display-3/#unbox
if (local_name() == HTML::TagNames::wbr) {
if (style.display().is_contents())
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::None)));
}
}
void HTMLElement::did_receive_focus()
{
if (m_content_editable_state != ContentEditableState::True)