mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Make containing_block_{width,height}_for(...) take non-box nodes
There's no reason for this API to require a Layout::Box as input. Any node that can have layout state is welcome, so this patch makes it take NodeWithStyleAndBoxModelMetrics.
This commit is contained in:
parent
57f3b18109
commit
88949b10d8
Notes:
sideshowbarker
2024-07-17 02:38:39 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/88949b10d8 Pull-request: https://github.com/SerenityOS/serenity/pull/20587
2 changed files with 21 additions and 21 deletions
|
@ -1199,7 +1199,7 @@ void FormattingContext::compute_height_for_absolutely_positioned_replaced_elemen
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/css-position-3/#relpos-insets
|
||||
void FormattingContext::compute_inset(Box const& box)
|
||||
void FormattingContext::compute_inset(NodeWithStyleAndBoxModelMetrics const& box)
|
||||
{
|
||||
if (box.computed_values().position() != CSS::Position::Relative)
|
||||
return;
|
||||
|
@ -1512,12 +1512,12 @@ CSS::Length FormattingContext::calculate_inner_height(Layout::Box const& box, Av
|
|||
return height.resolved(box, height_of_containing_block_as_length_for_resolve);
|
||||
}
|
||||
|
||||
CSSPixels FormattingContext::containing_block_width_for(Box const& box) const
|
||||
CSSPixels FormattingContext::containing_block_width_for(NodeWithStyleAndBoxModelMetrics const& node) const
|
||||
{
|
||||
auto const& containing_block_state = m_state.get(*box.containing_block());
|
||||
auto const& box_state = m_state.get(box);
|
||||
auto const& containing_block_state = m_state.get(*node.containing_block());
|
||||
auto const& node_state = m_state.get(node);
|
||||
|
||||
switch (box_state.width_constraint) {
|
||||
switch (node_state.width_constraint) {
|
||||
case SizeConstraint::MinContent:
|
||||
return 0;
|
||||
case SizeConstraint::MaxContent:
|
||||
|
@ -1528,12 +1528,12 @@ CSSPixels FormattingContext::containing_block_width_for(Box const& box) const
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
CSSPixels FormattingContext::containing_block_height_for(Box const& box) const
|
||||
CSSPixels FormattingContext::containing_block_height_for(NodeWithStyleAndBoxModelMetrics const& node) const
|
||||
{
|
||||
auto const& containing_block_state = m_state.get(*box.containing_block());
|
||||
auto const& box_state = m_state.get(box);
|
||||
auto const& containing_block_state = m_state.get(*node.containing_block());
|
||||
auto const& node_state = m_state.get(node);
|
||||
|
||||
switch (box_state.height_constraint) {
|
||||
switch (node_state.height_constraint) {
|
||||
case SizeConstraint::MinContent:
|
||||
return 0;
|
||||
case SizeConstraint::MaxContent:
|
||||
|
@ -1544,12 +1544,12 @@ CSSPixels FormattingContext::containing_block_height_for(Box const& box) const
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
AvailableSize FormattingContext::containing_block_width_as_available_size(Box const& box) const
|
||||
AvailableSize FormattingContext::containing_block_width_as_available_size(NodeWithStyleAndBoxModelMetrics const& node) const
|
||||
{
|
||||
auto const& containing_block_state = m_state.get(*box.containing_block());
|
||||
auto const& box_state = m_state.get(box);
|
||||
auto const& containing_block_state = m_state.get(*node.containing_block());
|
||||
auto const& node_state = m_state.get(node);
|
||||
|
||||
switch (box_state.width_constraint) {
|
||||
switch (node_state.width_constraint) {
|
||||
case SizeConstraint::MinContent:
|
||||
return AvailableSize::make_min_content();
|
||||
case SizeConstraint::MaxContent:
|
||||
|
@ -1560,12 +1560,12 @@ AvailableSize FormattingContext::containing_block_width_as_available_size(Box co
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
AvailableSize FormattingContext::containing_block_height_as_available_size(Box const& box) const
|
||||
AvailableSize FormattingContext::containing_block_height_as_available_size(NodeWithStyleAndBoxModelMetrics const& node) const
|
||||
{
|
||||
auto const& containing_block_state = m_state.get(*box.containing_block());
|
||||
auto const& box_state = m_state.get(box);
|
||||
auto const& containing_block_state = m_state.get(*node.containing_block());
|
||||
auto const& node_state = m_state.get(node);
|
||||
|
||||
switch (box_state.height_constraint) {
|
||||
switch (node_state.height_constraint) {
|
||||
case SizeConstraint::MinContent:
|
||||
return AvailableSize::make_min_content();
|
||||
case SizeConstraint::MaxContent:
|
||||
|
|
|
@ -80,11 +80,11 @@ public:
|
|||
[[nodiscard]] CSSPixels box_baseline(Box const&) const;
|
||||
[[nodiscard]] CSSPixelRect content_box_rect_in_static_position_ancestor_coordinate_space(Box const&, Box const& ancestor_box) const;
|
||||
|
||||
[[nodiscard]] CSSPixels containing_block_width_for(Box const&) const;
|
||||
[[nodiscard]] CSSPixels containing_block_height_for(Box const&) const;
|
||||
[[nodiscard]] CSSPixels containing_block_width_for(NodeWithStyleAndBoxModelMetrics const&) const;
|
||||
[[nodiscard]] CSSPixels containing_block_height_for(NodeWithStyleAndBoxModelMetrics const&) const;
|
||||
|
||||
[[nodiscard]] AvailableSize containing_block_width_as_available_size(Box const&) const;
|
||||
[[nodiscard]] AvailableSize containing_block_height_as_available_size(Box const&) const;
|
||||
[[nodiscard]] AvailableSize containing_block_width_as_available_size(NodeWithStyleAndBoxModelMetrics const&) const;
|
||||
[[nodiscard]] AvailableSize containing_block_height_as_available_size(NodeWithStyleAndBoxModelMetrics const&) const;
|
||||
|
||||
[[nodiscard]] CSSPixels calculate_stretch_fit_width(Box const&, AvailableSize const&) const;
|
||||
[[nodiscard]] CSSPixels calculate_stretch_fit_height(Box const&, AvailableSize const&) const;
|
||||
|
|
Loading…
Reference in a new issue