mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 16:47:34 +00:00
LibWeb: Use fit-content width if button's computed width is "auto"
Implements following line from the spec: "If the computed value of 'inline-size' is 'auto', then the used value is the fit-content inline size."
This commit is contained in:
parent
7eee3f6952
commit
63939445b1
5 changed files with 54 additions and 1 deletions
|
@ -100,6 +100,7 @@ public:
|
|||
virtual bool is_html_table_row_element() const { return false; }
|
||||
virtual bool is_html_table_cell_element() const { return false; }
|
||||
virtual bool is_html_br_element() const { return false; }
|
||||
virtual bool is_html_button_element() const { return false; }
|
||||
virtual bool is_navigable_container() const { return false; }
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> pre_insert(JS::NonnullGCPtr<Node>, JS::GCPtr<Node>);
|
||||
|
|
|
@ -68,6 +68,8 @@ public:
|
|||
virtual DeprecatedString value() const override;
|
||||
|
||||
private:
|
||||
virtual bool is_html_button_element() const override { return true; }
|
||||
|
||||
HTMLButtonElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
// ^DOM::Element
|
||||
|
@ -75,3 +77,8 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::DOM {
|
||||
template<>
|
||||
inline bool Node::fast_is<HTML::HTMLButtonElement>() const { return is_html_button_element(); }
|
||||
}
|
||||
|
|
|
@ -366,11 +366,18 @@ ErrorOr<void> TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::
|
|||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#button-layout
|
||||
// If the computed value of 'inline-size' is 'auto', then the used value is the fit-content inline size.
|
||||
if (dom_node.is_html_button_element() && dom_node.layout_node()->computed_values().width().is_auto()) {
|
||||
auto& computed_values = verify_cast<NodeWithStyle>(*dom_node.layout_node()).mutable_computed_values();
|
||||
computed_values.set_width(CSS::Size::make_fit_content());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#button-layout
|
||||
// If the element is an input element, or if it is a button element and its computed value for
|
||||
// 'display' is not 'inline-grid', 'grid', 'inline-flex', or 'flex', then the element's box has
|
||||
// a child anonymous button content box with the following behaviors:
|
||||
if (is<HTML::HTMLButtonElement>(dom_node) && !display.is_grid_inside() && !display.is_flex_inside()) {
|
||||
if (dom_node.is_html_button_element() && !display.is_grid_inside() && !display.is_flex_inside()) {
|
||||
auto& parent = *dom_node.layout_node();
|
||||
|
||||
// If the box does not overflow in the vertical axis, then it is centered vertically.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue