mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibWeb: Use the new to_px() helpers in CSS, SVG and layout code
There should be no behavior change from this, only slightly less verbosity. :^)
This commit is contained in:
parent
cdf0d3e905
commit
ca1fa5f748
14 changed files with 141 additions and 149 deletions
|
@ -29,7 +29,7 @@ CSSPixelPoint PositionValue::resolved(Layout::Node const& node, CSSPixelRect con
|
|||
}();
|
||||
},
|
||||
[&](LengthPercentage length_percentage) -> CSSPixels {
|
||||
return length_percentage.resolved(node, Length::make_px(rect.width())).to_px(node);
|
||||
return length_percentage.to_px(node, rect.width());
|
||||
});
|
||||
CSSPixels y = vertical_position.visit(
|
||||
[&](VerticalPreset preset) -> CSSPixels {
|
||||
|
@ -47,7 +47,7 @@ CSSPixelPoint PositionValue::resolved(Layout::Node const& node, CSSPixelRect con
|
|||
}();
|
||||
},
|
||||
[&](LengthPercentage length_percentage) -> CSSPixels {
|
||||
return length_percentage.resolved(node, Length::make_px(rect.height())).to_px(node);
|
||||
return length_percentage.to_px(node, rect.height());
|
||||
});
|
||||
if (x_relative_to == HorizontalEdge::Right)
|
||||
x = rect.width() - x;
|
||||
|
|
|
@ -646,14 +646,14 @@ void BlockFormattingContext::resolve_vertical_box_model_metrics(Box const& box,
|
|||
{
|
||||
auto& box_state = state.get_mutable(box);
|
||||
auto const& computed_values = box.computed_values();
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block_width_for(box, state));
|
||||
auto width_of_containing_block = containing_block_width_for(box, state);
|
||||
|
||||
box_state.margin_top = computed_values.margin().top().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.margin_bottom = computed_values.margin().bottom().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.margin_top = computed_values.margin().top().to_px(box, width_of_containing_block);
|
||||
box_state.margin_bottom = computed_values.margin().bottom().to_px(box, width_of_containing_block);
|
||||
box_state.border_top = computed_values.border_top().width;
|
||||
box_state.border_bottom = computed_values.border_bottom().width;
|
||||
box_state.padding_top = computed_values.padding().top().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.padding_bottom = computed_values.padding().bottom().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.padding_top = computed_values.padding().top().to_px(box, width_of_containing_block);
|
||||
box_state.padding_bottom = computed_values.padding().bottom().to_px(box, width_of_containing_block);
|
||||
}
|
||||
|
||||
CSSPixels BlockFormattingContext::BlockMarginState::current_collapsed_margin() const
|
||||
|
|
|
@ -39,31 +39,31 @@ static CSS::Size to_css_size(CSS::LengthPercentage const& length_percentage)
|
|||
|
||||
CSSPixels FlexFormattingContext::get_pixel_width(Box const& box, CSS::Size const& size) const
|
||||
{
|
||||
auto containing_block_width = CSS::Length::make_px(containing_block_width_for(box));
|
||||
auto containing_block_width = containing_block_width_for(box);
|
||||
if (box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) {
|
||||
auto border_left = box.computed_values().border_left().width;
|
||||
auto border_right = box.computed_values().border_right().width;
|
||||
auto padding_left = box.computed_values().padding().left().resolved(box, containing_block_width).to_px(box);
|
||||
auto padding_right = box.computed_values().padding().right().resolved(box, containing_block_width).to_px(box);
|
||||
return size.resolved(box, containing_block_width).to_px(box) - border_left - border_right - padding_left - padding_right;
|
||||
auto padding_left = box.computed_values().padding().left().to_px(box, containing_block_width);
|
||||
auto padding_right = box.computed_values().padding().right().to_px(box, containing_block_width);
|
||||
return size.to_px(box, containing_block_width) - border_left - border_right - padding_left - padding_right;
|
||||
}
|
||||
|
||||
return size.resolved(box, containing_block_width).to_px(box);
|
||||
return size.to_px(box, containing_block_width);
|
||||
}
|
||||
|
||||
CSSPixels FlexFormattingContext::get_pixel_height(Box const& box, CSS::Size const& size) const
|
||||
{
|
||||
auto containing_block_height = CSS::Length::make_px(containing_block_height_for(box));
|
||||
auto containing_block_height = containing_block_height_for(box);
|
||||
if (box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) {
|
||||
auto containing_block_width = CSS::Length::make_px(containing_block_width_for(box));
|
||||
auto containing_block_width = containing_block_width_for(box);
|
||||
auto border_top = box.computed_values().border_top().width;
|
||||
auto border_bottom = box.computed_values().border_bottom().width;
|
||||
auto padding_top = box.computed_values().padding().top().resolved(box, containing_block_width).to_px(box);
|
||||
auto padding_bottom = box.computed_values().padding().bottom().resolved(box, containing_block_width).to_px(box);
|
||||
return size.resolved(box, containing_block_height).to_px(box) - border_top - border_bottom - padding_top - padding_bottom;
|
||||
auto padding_top = box.computed_values().padding().top().to_px(box, containing_block_width);
|
||||
auto padding_bottom = box.computed_values().padding().bottom().to_px(box, containing_block_width);
|
||||
return size.to_px(box, containing_block_height) - border_top - border_bottom - padding_top - padding_bottom;
|
||||
}
|
||||
|
||||
return size.resolved(box, containing_block_height).to_px(box);
|
||||
return size.to_px(box, containing_block_height);
|
||||
}
|
||||
|
||||
FlexFormattingContext::FlexFormattingContext(LayoutState& state, Box const& flex_container, FormattingContext* parent)
|
||||
|
@ -245,7 +245,6 @@ void FlexFormattingContext::parent_context_did_dimension_child_root_box()
|
|||
void FlexFormattingContext::populate_specified_margins(FlexItem& item, CSS::FlexDirection flex_direction) const
|
||||
{
|
||||
auto width_of_containing_block = m_state.get(*item.box->containing_block()).content_width();
|
||||
auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block);
|
||||
// FIXME: This should also take reverse-ness into account
|
||||
if (flex_direction == CSS::FlexDirection::Row || flex_direction == CSS::FlexDirection::RowReverse) {
|
||||
item.borders.main_before = item.box->computed_values().border_left().width;
|
||||
|
@ -253,15 +252,15 @@ void FlexFormattingContext::populate_specified_margins(FlexItem& item, CSS::Flex
|
|||
item.borders.cross_before = item.box->computed_values().border_top().width;
|
||||
item.borders.cross_after = item.box->computed_values().border_bottom().width;
|
||||
|
||||
item.padding.main_before = item.box->computed_values().padding().left().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.padding.main_after = item.box->computed_values().padding().right().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.padding.cross_before = item.box->computed_values().padding().top().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.padding.cross_after = item.box->computed_values().padding().bottom().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.padding.main_before = item.box->computed_values().padding().left().to_px(item.box, width_of_containing_block);
|
||||
item.padding.main_after = item.box->computed_values().padding().right().to_px(item.box, width_of_containing_block);
|
||||
item.padding.cross_before = item.box->computed_values().padding().top().to_px(item.box, width_of_containing_block);
|
||||
item.padding.cross_after = item.box->computed_values().padding().bottom().to_px(item.box, width_of_containing_block);
|
||||
|
||||
item.margins.main_before = item.box->computed_values().margin().left().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.margins.main_after = item.box->computed_values().margin().right().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.margins.cross_before = item.box->computed_values().margin().top().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.margins.cross_after = item.box->computed_values().margin().bottom().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.margins.main_before = item.box->computed_values().margin().left().to_px(item.box, width_of_containing_block);
|
||||
item.margins.main_after = item.box->computed_values().margin().right().to_px(item.box, width_of_containing_block);
|
||||
item.margins.cross_before = item.box->computed_values().margin().top().to_px(item.box, width_of_containing_block);
|
||||
item.margins.cross_after = item.box->computed_values().margin().bottom().to_px(item.box, width_of_containing_block);
|
||||
|
||||
item.margins.main_before_is_auto = item.box->computed_values().margin().left().is_auto();
|
||||
item.margins.main_after_is_auto = item.box->computed_values().margin().right().is_auto();
|
||||
|
@ -273,15 +272,15 @@ void FlexFormattingContext::populate_specified_margins(FlexItem& item, CSS::Flex
|
|||
item.borders.cross_before = item.box->computed_values().border_left().width;
|
||||
item.borders.cross_after = item.box->computed_values().border_right().width;
|
||||
|
||||
item.padding.main_before = item.box->computed_values().padding().top().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.padding.main_after = item.box->computed_values().padding().bottom().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.padding.cross_before = item.box->computed_values().padding().left().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.padding.cross_after = item.box->computed_values().padding().right().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.padding.main_before = item.box->computed_values().padding().top().to_px(item.box, width_of_containing_block);
|
||||
item.padding.main_after = item.box->computed_values().padding().bottom().to_px(item.box, width_of_containing_block);
|
||||
item.padding.cross_before = item.box->computed_values().padding().left().to_px(item.box, width_of_containing_block);
|
||||
item.padding.cross_after = item.box->computed_values().padding().right().to_px(item.box, width_of_containing_block);
|
||||
|
||||
item.margins.main_before = item.box->computed_values().margin().top().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.margins.main_after = item.box->computed_values().margin().bottom().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.margins.cross_before = item.box->computed_values().margin().left().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.margins.cross_after = item.box->computed_values().margin().right().resolved(item.box, width_of_containing_block_as_length).to_px(item.box);
|
||||
item.margins.main_before = item.box->computed_values().margin().top().to_px(item.box, width_of_containing_block);
|
||||
item.margins.main_after = item.box->computed_values().margin().bottom().to_px(item.box, width_of_containing_block);
|
||||
item.margins.cross_before = item.box->computed_values().margin().left().to_px(item.box, width_of_containing_block);
|
||||
item.margins.cross_after = item.box->computed_values().margin().right().to_px(item.box, width_of_containing_block);
|
||||
|
||||
item.margins.main_before_is_auto = item.box->computed_values().margin().top().is_auto();
|
||||
item.margins.main_after_is_auto = item.box->computed_values().margin().bottom().is_auto();
|
||||
|
@ -1436,7 +1435,7 @@ void FlexFormattingContext::determine_flex_container_used_cross_size()
|
|||
}
|
||||
} else {
|
||||
// Otherwise, resolve the indefinite size at this point.
|
||||
cross_size = cross_size_value.resolved(flex_container(), CSS::Length::make_px(inner_cross_size(*flex_container().containing_block()))).to_px(flex_container());
|
||||
cross_size = cross_size_value.to_px(flex_container(), inner_cross_size(*flex_container().containing_block()));
|
||||
}
|
||||
}
|
||||
auto const& computed_min_size = this->computed_cross_min_size(flex_container());
|
||||
|
@ -1531,15 +1530,15 @@ void FlexFormattingContext::copy_dimensions_from_flex_items_to_boxes()
|
|||
auto const& box = item.box;
|
||||
auto& box_state = m_state.get_mutable(box);
|
||||
|
||||
box_state.padding_left = box->computed_values().padding().left().resolved(box, CSS::Length::make_px(m_flex_container_state.content_width())).to_px(box);
|
||||
box_state.padding_right = box->computed_values().padding().right().resolved(box, CSS::Length::make_px(m_flex_container_state.content_width())).to_px(box);
|
||||
box_state.padding_top = box->computed_values().padding().top().resolved(box, CSS::Length::make_px(m_flex_container_state.content_width())).to_px(box);
|
||||
box_state.padding_bottom = box->computed_values().padding().bottom().resolved(box, CSS::Length::make_px(m_flex_container_state.content_width())).to_px(box);
|
||||
box_state.padding_left = box->computed_values().padding().left().to_px(box, m_flex_container_state.content_width());
|
||||
box_state.padding_right = box->computed_values().padding().right().to_px(box, m_flex_container_state.content_width());
|
||||
box_state.padding_top = box->computed_values().padding().top().to_px(box, m_flex_container_state.content_width());
|
||||
box_state.padding_bottom = box->computed_values().padding().bottom().to_px(box, m_flex_container_state.content_width());
|
||||
|
||||
box_state.margin_left = box->computed_values().margin().left().resolved(box, CSS::Length::make_px(m_flex_container_state.content_width())).to_px(box);
|
||||
box_state.margin_right = box->computed_values().margin().right().resolved(box, CSS::Length::make_px(m_flex_container_state.content_width())).to_px(box);
|
||||
box_state.margin_top = box->computed_values().margin().top().resolved(box, CSS::Length::make_px(m_flex_container_state.content_width())).to_px(box);
|
||||
box_state.margin_bottom = box->computed_values().margin().bottom().resolved(box, CSS::Length::make_px(m_flex_container_state.content_width())).to_px(box);
|
||||
box_state.margin_left = box->computed_values().margin().left().to_px(box, m_flex_container_state.content_width());
|
||||
box_state.margin_right = box->computed_values().margin().right().to_px(box, m_flex_container_state.content_width());
|
||||
box_state.margin_top = box->computed_values().margin().top().to_px(box, m_flex_container_state.content_width());
|
||||
box_state.margin_bottom = box->computed_values().margin().bottom().to_px(box, m_flex_container_state.content_width());
|
||||
|
||||
box_state.border_left = box->computed_values().border_left().width;
|
||||
box_state.border_right = box->computed_values().border_right().width;
|
||||
|
@ -2157,14 +2156,14 @@ CSSPixels FlexFormattingContext::main_gap() const
|
|||
{
|
||||
auto const& computed_values = flex_container().computed_values();
|
||||
auto gap = is_row_layout() ? computed_values.column_gap() : computed_values.row_gap();
|
||||
return gap.resolved(flex_container(), CSS::Length::make_px(inner_main_size(flex_container()))).to_px(flex_container());
|
||||
return gap.to_px(flex_container(), inner_main_size(flex_container()));
|
||||
}
|
||||
|
||||
CSSPixels FlexFormattingContext::cross_gap() const
|
||||
{
|
||||
auto const& computed_values = flex_container().computed_values();
|
||||
auto gap = is_row_layout() ? computed_values.row_gap() : computed_values.column_gap();
|
||||
return gap.resolved(flex_container(), CSS::Length::make_px(inner_cross_size(flex_container()))).to_px(flex_container());
|
||||
return gap.to_px(flex_container(), inner_cross_size(flex_container()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -264,13 +264,13 @@ static CSSPixelSize solve_replaced_size_constraint(LayoutState const& state, CSS
|
|||
|
||||
auto const& containing_block = *box.containing_block();
|
||||
auto const& containing_block_state = state.get(containing_block);
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block_state.content_width());
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block_state.content_height());
|
||||
auto width_of_containing_block = containing_block_state.content_width();
|
||||
auto height_of_containing_block = containing_block_state.content_height();
|
||||
|
||||
CSSPixels specified_min_width = box.computed_values().min_width().is_auto() ? 0 : box.computed_values().min_width().resolved(box, width_of_containing_block).to_px(box);
|
||||
CSSPixels specified_max_width = box.computed_values().max_width().is_none() ? w : box.computed_values().max_width().resolved(box, width_of_containing_block).to_px(box);
|
||||
CSSPixels specified_min_height = box.computed_values().min_height().is_auto() ? 0 : box.computed_values().min_height().resolved(box, height_of_containing_block).to_px(box);
|
||||
CSSPixels specified_max_height = box.computed_values().max_height().is_none() ? h : box.computed_values().max_height().resolved(box, height_of_containing_block).to_px(box);
|
||||
CSSPixels specified_min_width = box.computed_values().min_width().is_auto() ? 0 : box.computed_values().min_width().to_px(box, width_of_containing_block);
|
||||
CSSPixels specified_max_width = box.computed_values().max_width().is_none() ? w : box.computed_values().max_width().to_px(box, width_of_containing_block);
|
||||
CSSPixels specified_min_height = box.computed_values().min_height().is_auto() ? 0 : box.computed_values().min_height().to_px(box, height_of_containing_block);
|
||||
CSSPixels specified_max_height = box.computed_values().max_height().is_none() ? h : box.computed_values().max_height().to_px(box, height_of_containing_block);
|
||||
|
||||
auto min_width = min(specified_min_width, specified_max_width);
|
||||
auto max_width = max(specified_min_width, specified_max_width);
|
||||
|
@ -369,7 +369,7 @@ CSSPixels FormattingContext::tentative_width_for_replaced_element(LayoutState co
|
|||
auto height_of_containing_block = CSS::Length::make_px(containing_block_height_for(box, state));
|
||||
auto computed_height = should_treat_height_as_auto(box, available_space) ? CSS::Size::make_auto() : box.computed_values().height();
|
||||
|
||||
CSSPixels used_width = computed_width.resolved(box, CSS::Length::make_px(available_space.width.to_px())).to_px(box);
|
||||
CSSPixels used_width = computed_width.to_px(box, available_space.width.to_px());
|
||||
|
||||
// If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic width,
|
||||
// then that intrinsic width is the used value of 'width'.
|
||||
|
@ -426,7 +426,8 @@ CSSPixels FormattingContext::compute_width_for_replaced_element(LayoutState cons
|
|||
// 10.3.2 Inline, replaced elements
|
||||
|
||||
auto zero_value = CSS::Length::make_px(0);
|
||||
auto width_of_containing_block_as_length = CSS::Length::make_px(available_space.width.to_px());
|
||||
auto width_of_containing_block = available_space.width.to_px();
|
||||
auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block);
|
||||
|
||||
auto margin_left = box.computed_values().margin().left().resolved(box, width_of_containing_block_as_length).resolved(box);
|
||||
auto margin_right = box.computed_values().margin().right().resolved(box, width_of_containing_block_as_length).resolved(box);
|
||||
|
@ -446,7 +447,7 @@ CSSPixels FormattingContext::compute_width_for_replaced_element(LayoutState cons
|
|||
// but this time using the computed value of 'max-width' as the computed value for 'width'.
|
||||
auto computed_max_width = box.computed_values().max_width();
|
||||
if (!computed_max_width.is_none()) {
|
||||
if (used_width > computed_max_width.resolved(box, width_of_containing_block_as_length).to_px(box)) {
|
||||
if (used_width > computed_max_width.to_px(box, width_of_containing_block)) {
|
||||
used_width = tentative_width_for_replaced_element(state, box, computed_max_width, available_space);
|
||||
}
|
||||
}
|
||||
|
@ -455,7 +456,7 @@ CSSPixels FormattingContext::compute_width_for_replaced_element(LayoutState cons
|
|||
// but this time using the value of 'min-width' as the computed value for 'width'.
|
||||
auto computed_min_width = box.computed_values().min_width();
|
||||
if (!computed_min_width.is_auto()) {
|
||||
if (used_width < computed_min_width.resolved(box, width_of_containing_block_as_length).to_px(box)) {
|
||||
if (used_width < computed_min_width.to_px(box, width_of_containing_block)) {
|
||||
used_width = tentative_width_for_replaced_element(state, box, computed_min_width, available_space);
|
||||
}
|
||||
}
|
||||
|
@ -488,7 +489,7 @@ CSSPixels FormattingContext::tentative_height_for_replaced_element(LayoutState c
|
|||
if (computed_height.is_auto())
|
||||
return 150;
|
||||
|
||||
return computed_height.resolved(box, CSS::Length::make_px(available_space.height.to_px())).to_px(box);
|
||||
return computed_height.to_px(box, available_space.height.to_px());
|
||||
}
|
||||
|
||||
CSSPixels FormattingContext::compute_height_for_replaced_element(LayoutState const& state, ReplacedBox const& box, AvailableSpace const& available_space)
|
||||
|
@ -523,8 +524,8 @@ void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_ele
|
|||
auto margin_right = CSS::Length::make_auto();
|
||||
auto const border_left = computed_values.border_left().width;
|
||||
auto const border_right = computed_values.border_right().width;
|
||||
auto const padding_left = computed_values.padding().left().resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
auto const padding_right = computed_values.padding().right().resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
auto const padding_left = computed_values.padding().left().to_px(box, width_of_containing_block);
|
||||
auto const padding_right = computed_values.padding().right().to_px(box, width_of_containing_block);
|
||||
|
||||
auto try_compute_width = [&](auto const& a_width) {
|
||||
margin_left = computed_values.margin().left().resolved(box, width_of_containing_block_as_length).resolved(box);
|
||||
|
@ -690,15 +691,15 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
|
|||
};
|
||||
auto solve_for = [&](CSS::Length length, ClampToZero clamp_to_zero = ClampToZero::No) {
|
||||
auto unclamped_value = height_of_containing_block
|
||||
- top.resolved(box, height_of_containing_block_as_length).to_px(box)
|
||||
- margin_top.resolved(box, width_of_containing_block_as_length).to_px(box)
|
||||
- top.to_px(box, height_of_containing_block)
|
||||
- margin_top.to_px(box, width_of_containing_block)
|
||||
- box.computed_values().border_top().width
|
||||
- box.computed_values().padding().top().resolved(box, width_of_containing_block_as_length).to_px(box)
|
||||
- height.resolved(box, height_of_containing_block_as_length).to_px(box)
|
||||
- box.computed_values().padding().bottom().resolved(box, width_of_containing_block_as_length).to_px(box)
|
||||
- box.computed_values().padding().top().to_px(box, width_of_containing_block)
|
||||
- height.to_px(box, height_of_containing_block)
|
||||
- box.computed_values().padding().bottom().to_px(box, width_of_containing_block)
|
||||
- box.computed_values().border_bottom().width
|
||||
- margin_bottom.resolved(box, width_of_containing_block_as_length).to_px(box)
|
||||
- bottom.resolved(box, height_of_containing_block_as_length).to_px(box)
|
||||
- margin_bottom.to_px(box, width_of_containing_block)
|
||||
- bottom.to_px(box, height_of_containing_block)
|
||||
+ length.to_px(box);
|
||||
if (clamp_to_zero == ClampToZero::Yes)
|
||||
return CSS::Length::make_px(max(CSSPixels(0), unclamped_value));
|
||||
|
@ -726,7 +727,7 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
|
|||
};
|
||||
|
||||
auto solve_for_margin_top_and_margin_bottom = [&] {
|
||||
auto remainder = solve_for(CSS::Length::make_px(margin_top.resolved(box, width_of_containing_block_as_length).to_px(box) + margin_bottom.resolved(box, width_of_containing_block_as_length).to_px(box))).to_px(box);
|
||||
auto remainder = solve_for(CSS::Length::make_px(margin_top.to_px(box, width_of_containing_block) + margin_bottom.to_px(box, width_of_containing_block))).to_px(box);
|
||||
margin_top = CSS::Length::make_px(remainder / 2);
|
||||
margin_bottom = CSS::Length::make_px(remainder / 2);
|
||||
};
|
||||
|
@ -840,7 +841,7 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
|
|||
}
|
||||
}
|
||||
|
||||
auto used_height = height.resolved(box, height_of_containing_block_as_length).to_px(box);
|
||||
auto used_height = height.to_px(box, height_of_containing_block);
|
||||
auto const& computed_min_height = box.computed_values().min_height();
|
||||
auto const& computed_max_height = box.computed_values().max_height();
|
||||
|
||||
|
@ -853,12 +854,12 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
|
|||
// the final used values for vertical margin/border/padding.
|
||||
|
||||
auto& box_state = m_state.get_mutable(box);
|
||||
box_state.margin_top = margin_top.resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
box_state.margin_bottom = margin_bottom.resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
box_state.margin_top = margin_top.to_px(box, width_of_containing_block);
|
||||
box_state.margin_bottom = margin_bottom.to_px(box, width_of_containing_block);
|
||||
box_state.border_top = box.computed_values().border_top().width;
|
||||
box_state.border_bottom = box.computed_values().border_bottom().width;
|
||||
box_state.padding_top = box.computed_values().padding().top().resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
box_state.padding_bottom = box.computed_values().padding().bottom().resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
box_state.padding_top = box.computed_values().padding().top().to_px(box, width_of_containing_block);
|
||||
box_state.padding_bottom = box.computed_values().padding().bottom().to_px(box, width_of_containing_block);
|
||||
|
||||
// And here is where we assign the box's content height.
|
||||
box_state.set_content_height(used_height);
|
||||
|
@ -947,10 +948,10 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box, Ava
|
|||
|
||||
compute_height_for_absolutely_positioned_element(box, available_space, BeforeOrAfterInsideLayout::After);
|
||||
|
||||
box_state.margin_left = box.computed_values().margin().left().resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
box_state.margin_top = box.computed_values().margin().top().resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
box_state.margin_right = box.computed_values().margin().right().resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
box_state.margin_bottom = box.computed_values().margin().bottom().resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
box_state.margin_left = box.computed_values().margin().left().to_px(box, width_of_containing_block);
|
||||
box_state.margin_top = box.computed_values().margin().top().to_px(box, width_of_containing_block);
|
||||
box_state.margin_right = box.computed_values().margin().right().to_px(box, width_of_containing_block);
|
||||
box_state.margin_bottom = box.computed_values().margin().bottom().to_px(box, width_of_containing_block);
|
||||
|
||||
box_state.border_left = box.computed_values().border_left().width;
|
||||
box_state.border_right = box.computed_values().border_right().width;
|
||||
|
@ -962,10 +963,10 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box, Ava
|
|||
auto const& computed_top = box.computed_values().inset().top();
|
||||
auto const& computed_bottom = box.computed_values().inset().bottom();
|
||||
|
||||
box_state.inset_left = computed_left.resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
box_state.inset_top = computed_top.resolved(box, height_of_containing_block_as_length).to_px(box);
|
||||
box_state.inset_right = computed_right.resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||
box_state.inset_bottom = computed_bottom.resolved(box, height_of_containing_block_as_length).to_px(box);
|
||||
box_state.inset_left = computed_left.to_px(box, width_of_containing_block);
|
||||
box_state.inset_top = computed_top.to_px(box, height_of_containing_block);
|
||||
box_state.inset_right = computed_right.to_px(box, width_of_containing_block);
|
||||
box_state.inset_bottom = computed_bottom.to_px(box, height_of_containing_block);
|
||||
|
||||
if (computed_left.is_auto() && box.computed_values().width().is_auto() && computed_right.is_auto()) {
|
||||
if (box.computed_values().margin().left().is_auto())
|
||||
|
@ -1297,7 +1298,7 @@ CSS::Length FormattingContext::calculate_inner_width(Layout::Box const& box, Ava
|
|||
auto const padding_left = computed_values.padding().left().resolved(box, width_of_containing_block_as_length_for_resolve);
|
||||
auto const padding_right = computed_values.padding().right().resolved(box, width_of_containing_block_as_length_for_resolve);
|
||||
|
||||
auto inner_width = width.resolved(box, width_of_containing_block_as_length_for_resolve).to_px(box)
|
||||
auto inner_width = width.to_px(box, width_of_containing_block)
|
||||
- computed_values.border_left().width
|
||||
- padding_left.to_px(box)
|
||||
- computed_values.border_right().width
|
||||
|
@ -1323,7 +1324,7 @@ CSS::Length FormattingContext::calculate_inner_height(Layout::Box const& box, Av
|
|||
auto const padding_top = computed_values.padding().top().resolved(box, width_of_containing_block);
|
||||
auto const padding_bottom = computed_values.padding().bottom().resolved(box, width_of_containing_block);
|
||||
|
||||
auto inner_height = height.resolved(box, height_of_containing_block_as_length_for_resolve).to_px(box)
|
||||
auto inner_height = height.to_px(box, height_of_containing_block)
|
||||
- computed_values.border_top().width
|
||||
- padding_top.to_px(box)
|
||||
- computed_values.border_bottom().width
|
||||
|
|
|
@ -613,14 +613,14 @@ void GridFormattingContext::initialize_grid_tracks(AvailableSpace const& availab
|
|||
// line.
|
||||
if (!grid_container().computed_values().column_gap().is_auto()) {
|
||||
for (int column_index = 1; column_index < (m_occupation_grid.column_count() * 2) - 1; column_index += 2) {
|
||||
auto column_gap_width = grid_container().computed_values().column_gap().resolved(grid_container(), CSS::Length::make_px(available_space.width.to_px()));
|
||||
m_grid_columns.insert(column_index, TemporaryTrack(column_gap_width.to_px(grid_container()), true));
|
||||
auto column_gap_width = grid_container().computed_values().column_gap().to_px(grid_container(), available_space.width.to_px());
|
||||
m_grid_columns.insert(column_index, TemporaryTrack(column_gap_width, true));
|
||||
}
|
||||
}
|
||||
if (!grid_container().computed_values().row_gap().is_auto()) {
|
||||
for (int row_index = 1; row_index < (m_occupation_grid.row_count() * 2) - 1; row_index += 2) {
|
||||
auto column_gap_height = grid_container().computed_values().row_gap().resolved(grid_container(), CSS::Length::make_px(available_space.height.to_px()));
|
||||
m_grid_rows.insert(row_index, TemporaryTrack(column_gap_height.to_px(grid_container()), true));
|
||||
auto column_gap_height = grid_container().computed_values().row_gap().to_px(grid_container(), available_space.height.to_px());
|
||||
m_grid_rows.insert(row_index, TemporaryTrack(column_gap_height, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,25 +91,25 @@ void InlineFormattingContext::run(Box const&, LayoutMode layout_mode, AvailableS
|
|||
|
||||
void InlineFormattingContext::dimension_box_on_line(Box const& box, LayoutMode layout_mode)
|
||||
{
|
||||
auto width_of_containing_block = CSS::Length::make_px(m_available_space->width.to_px());
|
||||
auto width_of_containing_block = m_available_space->width.to_px();
|
||||
auto& box_state = m_state.get_mutable(box);
|
||||
auto const& computed_values = box.computed_values();
|
||||
|
||||
box_state.margin_left = computed_values.margin().left().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.margin_left = computed_values.margin().left().to_px(box, width_of_containing_block);
|
||||
box_state.border_left = computed_values.border_left().width;
|
||||
box_state.padding_left = computed_values.padding().left().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.padding_left = computed_values.padding().left().to_px(box, width_of_containing_block);
|
||||
|
||||
box_state.margin_right = computed_values.margin().right().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.margin_right = computed_values.margin().right().to_px(box, width_of_containing_block);
|
||||
box_state.border_right = computed_values.border_right().width;
|
||||
box_state.padding_right = computed_values.padding().right().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.padding_right = computed_values.padding().right().to_px(box, width_of_containing_block);
|
||||
|
||||
box_state.margin_top = computed_values.margin().top().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.margin_top = computed_values.margin().top().to_px(box, width_of_containing_block);
|
||||
box_state.border_top = computed_values.border_top().width;
|
||||
box_state.padding_top = computed_values.padding().top().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.padding_top = computed_values.padding().top().to_px(box, width_of_containing_block);
|
||||
|
||||
box_state.padding_bottom = computed_values.padding().bottom().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.padding_bottom = computed_values.padding().bottom().to_px(box, width_of_containing_block);
|
||||
box_state.border_bottom = computed_values.border_bottom().width;
|
||||
box_state.margin_bottom = computed_values.margin().bottom().resolved(box, width_of_containing_block).to_px(box);
|
||||
box_state.margin_bottom = computed_values.margin().bottom().to_px(box, width_of_containing_block);
|
||||
|
||||
if (is<ReplacedBox>(box)) {
|
||||
auto& replaced = verify_cast<ReplacedBox>(box);
|
||||
|
@ -155,7 +155,7 @@ void InlineFormattingContext::dimension_box_on_line(Box const& box, LayoutMode l
|
|||
CSSPixels width = unconstrained_width;
|
||||
auto computed_max_width = box.computed_values().max_width();
|
||||
if (!computed_max_width.is_none()) {
|
||||
auto max_width = computed_max_width.resolved(box, width_of_containing_block).to_px(box);
|
||||
auto max_width = computed_max_width.to_px(box, width_of_containing_block);
|
||||
width = min(width, max_width);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ void InlineLevelIterator::enter_node_with_box_model_metrics(Layout::NodeWithStyl
|
|||
auto& used_values = m_layout_state.get_mutable(node);
|
||||
auto const& computed_values = node.computed_values();
|
||||
|
||||
used_values.margin_left = computed_values.margin().left().resolved(node, CSS::Length::make_px(m_container_state.content_width())).to_px(node);
|
||||
used_values.margin_left = computed_values.margin().left().to_px(node, m_container_state.content_width());
|
||||
used_values.border_left = computed_values.border_left().width;
|
||||
used_values.padding_left = computed_values.padding().left().resolved(node, CSS::Length::make_px(m_container_state.content_width())).to_px(node);
|
||||
used_values.padding_left = computed_values.padding().left().to_px(node, m_container_state.content_width());
|
||||
|
||||
m_extra_leading_metrics->margin += used_values.margin_left;
|
||||
m_extra_leading_metrics->border += used_values.border_left;
|
||||
|
@ -54,9 +54,9 @@ void InlineLevelIterator::exit_node_with_box_model_metrics()
|
|||
auto& used_values = m_layout_state.get_mutable(node);
|
||||
auto const& computed_values = node->computed_values();
|
||||
|
||||
used_values.margin_right = computed_values.margin().right().resolved(node, CSS::Length::make_px(m_container_state.content_width())).to_px(node);
|
||||
used_values.margin_right = computed_values.margin().right().to_px(node, m_container_state.content_width());
|
||||
used_values.border_right = computed_values.border_right().width;
|
||||
used_values.padding_right = computed_values.padding().right().resolved(node, CSS::Length::make_px(m_container_state.content_width())).to_px(node);
|
||||
used_values.padding_right = computed_values.padding().right().to_px(node, m_container_state.content_width());
|
||||
|
||||
m_extra_trailing_metrics->margin += used_values.margin_right;
|
||||
m_extra_trailing_metrics->border += used_values.border_right;
|
||||
|
|
|
@ -57,8 +57,8 @@ void SVGSVGBox::prepare_for_replaced_layout()
|
|||
if (dom_node.has_attribute(HTML::AttributeNames::width) && dom_node.has_attribute(HTML::AttributeNames::height)) {
|
||||
CSSPixelRect rect;
|
||||
// FIXME: Allow for relative lengths here
|
||||
rect.set_width(computed_values().width().resolved(*this, CSS::Length::make_px(0)).to_px(*this));
|
||||
rect.set_height(computed_values().height().resolved(*this, CSS::Length::make_px(0)).to_px(*this));
|
||||
rect.set_width(computed_values().width().to_px(*this, 0));
|
||||
rect.set_height(computed_values().height().to_px(*this, 0));
|
||||
add_to_united_rect(rect);
|
||||
return IterationDecision::Continue;
|
||||
}
|
||||
|
|
|
@ -107,10 +107,9 @@ void TableFormattingContext::compute_table_measures()
|
|||
|
||||
for (auto& cell : m_cells) {
|
||||
auto width_of_containing_block = m_state.get(*table_wrapper().containing_block()).content_width();
|
||||
auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block);
|
||||
auto& computed_values = cell.box->computed_values();
|
||||
CSSPixels padding_left = computed_values.padding().left().resolved(cell.box, width_of_containing_block_as_length).to_px(cell.box);
|
||||
CSSPixels padding_right = computed_values.padding().right().resolved(cell.box, width_of_containing_block_as_length).to_px(cell.box);
|
||||
CSSPixels padding_left = computed_values.padding().left().to_px(cell.box, width_of_containing_block);
|
||||
CSSPixels padding_right = computed_values.padding().right().to_px(cell.box, width_of_containing_block);
|
||||
|
||||
auto is_left_most_cell = cell.column_index == 0;
|
||||
auto is_right_most_cell = cell.column_index == m_columns.size() - 1;
|
||||
|
@ -118,18 +117,18 @@ void TableFormattingContext::compute_table_measures()
|
|||
CSSPixels border_left = should_hide_borders && !is_left_most_cell ? 0 : computed_values.border_left().width;
|
||||
CSSPixels border_right = should_hide_borders && !is_right_most_cell ? 0 : computed_values.border_right().width;
|
||||
|
||||
CSSPixels width = computed_values.width().resolved(cell.box, width_of_containing_block_as_length).to_px(cell.box);
|
||||
CSSPixels width = computed_values.width().to_px(cell.box, width_of_containing_block);
|
||||
auto cell_intrinsic_offsets = padding_left + padding_right + border_left + border_right;
|
||||
auto min_content_width = calculate_min_content_width(cell.box);
|
||||
auto max_content_width = calculate_max_content_width(cell.box);
|
||||
|
||||
CSSPixels min_width = min_content_width;
|
||||
if (!computed_values.min_width().is_auto())
|
||||
min_width = max(min_width, computed_values.min_width().resolved(cell.box, width_of_containing_block_as_length).to_px(cell.box));
|
||||
min_width = max(min_width, computed_values.min_width().to_px(cell.box, width_of_containing_block));
|
||||
|
||||
CSSPixels max_width = computed_values.width().is_auto() ? max_content_width.value() : width;
|
||||
if (!computed_values.max_width().is_none())
|
||||
max_width = min(max_width, computed_values.max_width().resolved(cell.box, width_of_containing_block_as_length).to_px(cell.box));
|
||||
max_width = min(max_width, computed_values.max_width().to_px(cell.box, width_of_containing_block));
|
||||
|
||||
auto computed_width = computed_values.width();
|
||||
if (computed_width.is_percentage()) {
|
||||
|
@ -235,7 +234,7 @@ void TableFormattingContext::compute_table_width()
|
|||
// The used min-width of a table is the greater of the resolved min-width, CAPMIN, and GRIDMIN.
|
||||
auto used_min_width = grid_min;
|
||||
if (!computed_values.min_width().is_auto()) {
|
||||
used_min_width = max(used_min_width, computed_values.min_width().resolved(table_box(), CSS::Length::make_px(width_of_table_wrapper_containing_block)).to_px(table_box()));
|
||||
used_min_width = max(used_min_width, computed_values.min_width().to_px(table_box(), width_of_table_wrapper_containing_block));
|
||||
}
|
||||
|
||||
CSSPixels used_width;
|
||||
|
@ -247,10 +246,10 @@ void TableFormattingContext::compute_table_width()
|
|||
// If the table-root’s width property has a computed value (resolving to
|
||||
// resolved-table-width) other than auto, the used width is the greater
|
||||
// of resolved-table-width, and the used min-width of the table.
|
||||
CSSPixels resolved_table_width = computed_values.width().resolved(table_box(), CSS::Length::make_px(width_of_table_wrapper_containing_block)).to_px(table_box());
|
||||
CSSPixels resolved_table_width = computed_values.width().to_px(table_box(), width_of_table_wrapper_containing_block);
|
||||
used_width = max(resolved_table_width, used_min_width);
|
||||
if (!computed_values.max_width().is_none())
|
||||
used_width = min(used_width, computed_values.max_width().resolved(table_box(), CSS::Length::make_px(width_of_table_wrapper_containing_block)).to_px(table_box()));
|
||||
used_width = min(used_width, computed_values.max_width().to_px(table_box(), width_of_table_wrapper_containing_block));
|
||||
}
|
||||
|
||||
// The assignable table width is the used width of the table minus the total horizontal border spacing (if any).
|
||||
|
@ -407,8 +406,7 @@ void TableFormattingContext::compute_table_height(LayoutMode layout_mode)
|
|||
auto row_computed_height = row.box->computed_values().height();
|
||||
if (row_computed_height.is_length()) {
|
||||
auto height_of_containing_block = m_state.get(*row.box->containing_block()).content_height();
|
||||
auto height_of_containing_block_as_length = CSS::Length::make_px(height_of_containing_block);
|
||||
auto row_used_height = row_computed_height.resolved(row.box, height_of_containing_block_as_length).to_px(row.box);
|
||||
auto row_used_height = row_computed_height.to_px(row.box, height_of_containing_block);
|
||||
row.base_height = max(row.base_height, row_used_height);
|
||||
}
|
||||
}
|
||||
|
@ -427,10 +425,10 @@ void TableFormattingContext::compute_table_height(LayoutMode layout_mode)
|
|||
auto height_of_containing_block = m_state.get(*cell.box->containing_block()).content_height();
|
||||
auto height_of_containing_block_as_length = CSS::Length::make_px(height_of_containing_block);
|
||||
|
||||
cell_state.padding_top = cell.box->computed_values().padding().top().resolved(cell.box, width_of_containing_block_as_length).to_px(cell.box);
|
||||
cell_state.padding_bottom = cell.box->computed_values().padding().bottom().resolved(cell.box, width_of_containing_block_as_length).to_px(cell.box);
|
||||
cell_state.padding_left = cell.box->computed_values().padding().left().resolved(cell.box, width_of_containing_block_as_length).to_px(cell.box);
|
||||
cell_state.padding_right = cell.box->computed_values().padding().right().resolved(cell.box, width_of_containing_block_as_length).to_px(cell.box);
|
||||
cell_state.padding_top = cell.box->computed_values().padding().top().to_px(cell.box, width_of_containing_block);
|
||||
cell_state.padding_bottom = cell.box->computed_values().padding().bottom().to_px(cell.box, width_of_containing_block);
|
||||
cell_state.padding_left = cell.box->computed_values().padding().left().to_px(cell.box, width_of_containing_block);
|
||||
cell_state.padding_right = cell.box->computed_values().padding().right().to_px(cell.box, width_of_containing_block);
|
||||
|
||||
auto is_top_most_cell = cell.row_index == 0;
|
||||
auto is_left_most_cell = cell.column_index == 0;
|
||||
|
@ -445,7 +443,7 @@ void TableFormattingContext::compute_table_height(LayoutMode layout_mode)
|
|||
|
||||
auto cell_computed_height = cell.box->computed_values().height();
|
||||
if (cell_computed_height.is_length()) {
|
||||
auto cell_used_height = cell_computed_height.resolved(cell.box, height_of_containing_block_as_length).to_px(cell.box);
|
||||
auto cell_used_height = cell_computed_height.to_px(cell.box, height_of_containing_block);
|
||||
cell_state.set_content_height(cell_used_height - cell_state.border_box_top() - cell_state.border_box_bottom());
|
||||
|
||||
row.base_height = max(row.base_height, cell_used_height);
|
||||
|
@ -476,7 +474,7 @@ void TableFormattingContext::compute_table_height(LayoutMode layout_mode)
|
|||
// table grid, and will eventually be distributed to the height of the rows if their collective minimum height
|
||||
// ends up smaller than this number.
|
||||
CSSPixels height_of_table_containing_block = m_state.get(*table_wrapper().containing_block()).content_height();
|
||||
auto specified_table_height = table_box().computed_values().height().resolved(table_box(), CSS::Length::make_px(height_of_table_containing_block)).to_px(table_box());
|
||||
auto specified_table_height = table_box().computed_values().height().to_px(table_box(), height_of_table_containing_block);
|
||||
if (m_table_height < specified_table_height) {
|
||||
m_table_height = specified_table_height;
|
||||
}
|
||||
|
@ -499,7 +497,7 @@ void TableFormattingContext::compute_table_height(LayoutMode layout_mode)
|
|||
for (auto& row : m_rows) {
|
||||
auto row_computed_height = row.box->computed_values().height();
|
||||
if (row_computed_height.is_percentage()) {
|
||||
auto row_used_height = row_computed_height.resolved(row.box, CSS::Length::make_px(m_table_height)).to_px(row.box);
|
||||
auto row_used_height = row_computed_height.to_px(row.box, m_table_height);
|
||||
row.reference_height = max(row.reference_height, row_used_height);
|
||||
} else {
|
||||
continue;
|
||||
|
@ -516,11 +514,9 @@ void TableFormattingContext::compute_table_height(LayoutMode layout_mode)
|
|||
for (size_t i = 0; i < cell.column_span; ++i)
|
||||
span_width += m_columns[cell.column_index + i].used_width;
|
||||
|
||||
auto height_of_containing_block_as_length = CSS::Length::make_px(m_table_height);
|
||||
|
||||
auto cell_computed_height = cell.box->computed_values().height();
|
||||
if (cell_computed_height.is_percentage()) {
|
||||
auto cell_used_height = cell_computed_height.resolved(cell.box, height_of_containing_block_as_length).to_px(cell.box);
|
||||
auto cell_used_height = cell_computed_height.to_px(cell.box, m_table_height);
|
||||
cell_state.set_content_height(cell_used_height - cell_state.border_box_top() - cell_state.border_box_bottom());
|
||||
|
||||
row.reference_height = max(row.reference_height, cell_used_height);
|
||||
|
|
|
@ -170,14 +170,14 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
|||
width = natural_image_width;
|
||||
height = natural_image_height;
|
||||
} else if (x_is_auto) {
|
||||
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height())).to_px(layout_node);
|
||||
height = layer.size_y.to_px(layout_node, background_positioning_area.height());
|
||||
width = natural_image_width * (height / natural_image_height);
|
||||
} else if (y_is_auto) {
|
||||
width = layer.size_x.resolved(layout_node, CSS::Length::make_px(background_positioning_area.width())).to_px(layout_node);
|
||||
width = layer.size_x.to_px(layout_node, background_positioning_area.width());
|
||||
height = natural_image_height * (width / natural_image_width);
|
||||
} else {
|
||||
width = layer.size_x.resolved(layout_node, CSS::Length::make_px(background_positioning_area.width())).to_px(layout_node);
|
||||
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height())).to_px(layout_node);
|
||||
width = layer.size_x.to_px(layout_node, background_positioning_area.width());
|
||||
height = layer.size_y.to_px(layout_node, background_positioning_area.height());
|
||||
}
|
||||
|
||||
image_rect.set_size(width, height);
|
||||
|
@ -221,14 +221,14 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
|||
CSSPixels space_y = background_positioning_area.height() - image_rect.height();
|
||||
|
||||
// Position
|
||||
CSSPixels offset_x = layer.position_offset_x.resolved(layout_node, CSS::Length::make_px(space_x)).to_px(layout_node);
|
||||
CSSPixels offset_x = layer.position_offset_x.to_px(layout_node, space_x);
|
||||
if (layer.position_edge_x == CSS::PositionEdge::Right) {
|
||||
image_rect.set_right_without_resize(background_positioning_area.right() - offset_x);
|
||||
} else {
|
||||
image_rect.set_left(background_positioning_area.left() + offset_x);
|
||||
}
|
||||
|
||||
CSSPixels offset_y = layer.position_offset_y.resolved(layout_node, CSS::Length::make_px(space_y)).to_px(layout_node);
|
||||
CSSPixels offset_y = layer.position_offset_y.to_px(layout_node, space_y);
|
||||
if (layer.position_edge_y == CSS::PositionEdge::Bottom) {
|
||||
image_rect.set_bottom_without_resize(background_positioning_area.bottom() - offset_y);
|
||||
} else {
|
||||
|
|
|
@ -21,17 +21,15 @@ BorderRadiiData normalized_border_radii_data(Layout::Node const& node, CSSPixelR
|
|||
BorderRadiusData top_left_radius_px {};
|
||||
BorderRadiusData top_right_radius_px {};
|
||||
|
||||
auto width_length = CSS::Length::make_px(rect.width());
|
||||
bottom_left_radius_px.horizontal_radius = bottom_left_radius.horizontal_radius.resolved(node, width_length).to_px(node);
|
||||
bottom_right_radius_px.horizontal_radius = bottom_right_radius.horizontal_radius.resolved(node, width_length).to_px(node);
|
||||
top_left_radius_px.horizontal_radius = top_left_radius.horizontal_radius.resolved(node, width_length).to_px(node);
|
||||
top_right_radius_px.horizontal_radius = top_right_radius.horizontal_radius.resolved(node, width_length).to_px(node);
|
||||
bottom_left_radius_px.horizontal_radius = bottom_left_radius.horizontal_radius.to_px(node, rect.width());
|
||||
bottom_right_radius_px.horizontal_radius = bottom_right_radius.horizontal_radius.to_px(node, rect.width());
|
||||
top_left_radius_px.horizontal_radius = top_left_radius.horizontal_radius.to_px(node, rect.width());
|
||||
top_right_radius_px.horizontal_radius = top_right_radius.horizontal_radius.to_px(node, rect.width());
|
||||
|
||||
auto height_length = CSS::Length::make_px(rect.height());
|
||||
bottom_left_radius_px.vertical_radius = bottom_left_radius.vertical_radius.resolved(node, height_length).to_px(node);
|
||||
bottom_right_radius_px.vertical_radius = bottom_right_radius.vertical_radius.resolved(node, height_length).to_px(node);
|
||||
top_left_radius_px.vertical_radius = top_left_radius.vertical_radius.resolved(node, height_length).to_px(node);
|
||||
top_right_radius_px.vertical_radius = top_right_radius.vertical_radius.resolved(node, height_length).to_px(node);
|
||||
bottom_left_radius_px.vertical_radius = bottom_left_radius.vertical_radius.to_px(node, rect.height());
|
||||
bottom_right_radius_px.vertical_radius = bottom_right_radius.vertical_radius.to_px(node, rect.height());
|
||||
top_left_radius_px.vertical_radius = top_left_radius.vertical_radius.to_px(node, rect.height());
|
||||
top_right_radius_px.vertical_radius = top_right_radius.vertical_radius.to_px(node, rect.height());
|
||||
|
||||
// Scale overlapping curves according to https://www.w3.org/TR/css-backgrounds-3/#corner-overlap
|
||||
CSSPixels f = 1.0f;
|
||||
|
|
|
@ -112,11 +112,10 @@ LinearGradientData resolve_linear_gradient_data(Layout::Node const& node, CSSPix
|
|||
{
|
||||
auto gradient_angle = linear_gradient.angle_degrees(gradient_size);
|
||||
auto gradient_length_px = Gfx::calculate_gradient_length(gradient_size, gradient_angle);
|
||||
auto gradient_length = CSS::Length::make_px(gradient_length_px);
|
||||
|
||||
auto resolved_color_stops = resolve_color_stop_positions(
|
||||
linear_gradient.color_stop_list(), [&](auto const& length_percentage) {
|
||||
return length_percentage.resolved(node, gradient_length).to_px(node).value() / gradient_length_px;
|
||||
return length_percentage.to_px(node, gradient_length_px).value() / gradient_length_px;
|
||||
},
|
||||
linear_gradient.is_repeating());
|
||||
|
||||
|
@ -137,10 +136,9 @@ ConicGradientData resolve_conic_gradient_data(Layout::Node const& node, CSS::Con
|
|||
RadialGradientData resolve_radial_gradient_data(Layout::Node const& node, CSSPixelSize gradient_size, CSS::RadialGradientStyleValue const& radial_gradient)
|
||||
{
|
||||
// Start center, goes right to ending point, where the gradient line intersects the ending shape
|
||||
auto gradient_length = CSS::Length::make_px(gradient_size.width());
|
||||
auto resolved_color_stops = resolve_color_stop_positions(
|
||||
radial_gradient.color_stop_list(), [&](auto const& length_percentage) {
|
||||
return (length_percentage.resolved(node, gradient_length).to_px(node) / gradient_size.width()).value();
|
||||
return (length_percentage.to_px(node, gradient_size.width()) / gradient_size.width()).value();
|
||||
},
|
||||
radial_gradient.is_repeating());
|
||||
return { resolved_color_stops };
|
||||
|
|
|
@ -428,8 +428,8 @@ Gfx::FloatPoint StackingContext::compute_transform_origin() const
|
|||
auto style_value = m_box->computed_values().transform_origin();
|
||||
// FIXME: respect transform-box property
|
||||
auto reference_box = paintable_box().absolute_border_box_rect();
|
||||
auto x = reference_box.left() + style_value.x.resolved(m_box, CSS::Length::make_px(reference_box.width())).to_px(m_box);
|
||||
auto y = reference_box.top() + style_value.y.resolved(m_box, CSS::Length::make_px(reference_box.height())).to_px(m_box);
|
||||
auto x = reference_box.left() + style_value.x.to_px(m_box, reference_box.width());
|
||||
auto y = reference_box.top() + style_value.y.to_px(m_box, reference_box.height());
|
||||
return { x, y };
|
||||
}
|
||||
|
||||
|
|
|
@ -163,12 +163,12 @@ Optional<float> SVGGraphicsElement::stroke_width() const
|
|||
CSSPixels viewport_height = 0;
|
||||
if (auto* svg_svg_element = first_ancestor_of_type<SVGSVGElement>()) {
|
||||
if (auto* svg_svg_layout_node = svg_svg_element->layout_node()) {
|
||||
viewport_width = svg_svg_layout_node->computed_values().width().resolved(*svg_svg_layout_node, CSS::Length::make_px(0)).to_px(*svg_svg_layout_node);
|
||||
viewport_height = svg_svg_layout_node->computed_values().height().resolved(*svg_svg_layout_node, CSS::Length::make_px(0)).to_px(*svg_svg_layout_node);
|
||||
viewport_width = svg_svg_layout_node->computed_values().width().to_px(*svg_svg_layout_node, 0);
|
||||
viewport_height = svg_svg_layout_node->computed_values().height().to_px(*svg_svg_layout_node, 0);
|
||||
}
|
||||
}
|
||||
auto scaled_viewport_size = CSS::Length::make_px((viewport_width + viewport_height) * 0.5f);
|
||||
return width->resolved(*layout_node(), scaled_viewport_size).to_px(*layout_node()).value();
|
||||
auto scaled_viewport_size = (viewport_width + viewport_height) * 0.5f;
|
||||
return width->to_px(*layout_node(), scaled_viewport_size).value();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue