mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Adjust buttons computed display style
This commit is contained in:
parent
4bcb34d7a0
commit
f54793315c
Notes:
github-actions[bot]
2025-11-01 13:03:55 +00:00
Author: https://github.com/lpas
Commit: f54793315c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6481
Reviewed-by: https://github.com/AtkinsSJ ✅
5 changed files with 41 additions and 20 deletions
|
|
@ -5,6 +5,8 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/Bindings/HTMLButtonElementPrototype.h>
|
||||
#include <LibWeb/CSS/ComputedProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/HTML/CommandEvent.h>
|
||||
|
|
@ -29,6 +31,23 @@ void HTMLButtonElement::initialize(JS::Realm& realm)
|
|||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
void HTMLButtonElement::adjust_computed_style(CSS::ComputedProperties& style)
|
||||
{
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#button-layout
|
||||
// If the computed value of 'display' is 'inline-grid', 'grid', 'inline-flex', 'flex', 'none', or 'contents', then behave as the computed value.
|
||||
auto display = style.display();
|
||||
if (display.is_flex_inside() || display.is_grid_inside() || display.is_none() || display.is_contents()) {
|
||||
// No-op
|
||||
} else if (display.is_inline_outside()) {
|
||||
// Otherwise, if the computed value of 'display' is a value such that the outer display type is 'inline', then behave as 'inline-block'.
|
||||
// AD-HOC https://github.com/whatwg/html/issues/11857
|
||||
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::InlineBlock)));
|
||||
} else {
|
||||
// Otherwise, behave as 'flow-root'.
|
||||
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::FlowRoot)));
|
||||
}
|
||||
}
|
||||
|
||||
HTMLButtonElement::TypeAttributeState HTMLButtonElement::type_state() const
|
||||
{
|
||||
auto value = get_attribute_value(HTML::AttributeNames::type);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue