mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibWeb: Remove redundant Length::resolved() calls
Now that calc() is also resolved in to_px(), code in the form `foo.resolved(bar).to_px(bar)` can be simplified to `foo.to_px(bar)`.
This commit is contained in:
parent
6df3f9920d
commit
b715943035
9 changed files with 60 additions and 72 deletions
|
@ -67,7 +67,7 @@ void BlockFormattingContext::apply_transformations_to_children(Box& box)
|
||||||
continue;
|
continue;
|
||||||
transformation.values.first().visit(
|
transformation.values.first().visit(
|
||||||
[&](CSS::Length& value) {
|
[&](CSS::Length& value) {
|
||||||
transform_y_offset += value.resolved(child_box).to_px(child_box);
|
transform_y_offset += value.to_px(child_box);
|
||||||
},
|
},
|
||||||
[&](float value) {
|
[&](float value) {
|
||||||
transform_y_offset += value;
|
transform_y_offset += value;
|
||||||
|
@ -264,7 +264,7 @@ void BlockFormattingContext::compute_width_for_floating_box(Box& box)
|
||||||
width = CSS::Length(min(max(result.preferred_minimum_width, available_width), result.preferred_width), CSS::Length::Type::Px);
|
width = CSS::Length(min(max(result.preferred_minimum_width, available_width), result.preferred_width), CSS::Length::Type::Px);
|
||||||
}
|
}
|
||||||
|
|
||||||
float final_width = width.resolved(box).to_px(box);
|
float final_width = width.to_px(box);
|
||||||
box.set_content_width(final_width);
|
box.set_content_width(final_width);
|
||||||
box.box_model().margin.left = margin_left.to_px(box);
|
box.box_model().margin.left = margin_left.to_px(box);
|
||||||
box.box_model().margin.right = margin_right.to_px(box);
|
box.box_model().margin.right = margin_right.to_px(box);
|
||||||
|
@ -299,7 +299,7 @@ float BlockFormattingContext::compute_theoretical_height(Box const& box)
|
||||||
|| (computed_values.height().has_value() && computed_values.height()->is_percentage() && !is_absolute(containing_block.computed_values().height()))) {
|
|| (computed_values.height().has_value() && computed_values.height()->is_percentage() && !is_absolute(containing_block.computed_values().height()))) {
|
||||||
height = compute_auto_height_for_block_level_element(box, ConsiderFloats::No);
|
height = compute_auto_height_for_block_level_element(box, ConsiderFloats::No);
|
||||||
} else {
|
} else {
|
||||||
height = computed_values.height().has_value() ? computed_values.height()->resolved(box, containing_block_height).resolved(box).to_px(box) : 0;
|
height = computed_values.height().has_value() ? computed_values.height()->resolved(box, containing_block_height).to_px(box) : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,13 +323,13 @@ void BlockFormattingContext::compute_height(Box& box)
|
||||||
// First, resolve the top/bottom parts of the surrounding box model.
|
// First, resolve the top/bottom parts of the surrounding box model.
|
||||||
|
|
||||||
// FIXME: While negative values are generally allowed for margins, for now just ignore those for height calculation
|
// FIXME: While negative values are generally allowed for margins, for now just ignore those for height calculation
|
||||||
box.box_model().margin.top = max(computed_values.margin().top.resolved(box, width_of_containing_block_as_length).resolved(box).to_px(box), 0);
|
box.box_model().margin.top = max(computed_values.margin().top.resolved(box, width_of_containing_block_as_length).to_px(box), 0);
|
||||||
box.box_model().margin.bottom = max(computed_values.margin().bottom.resolved(box, width_of_containing_block_as_length).resolved(box).to_px(box), 0);
|
box.box_model().margin.bottom = max(computed_values.margin().bottom.resolved(box, width_of_containing_block_as_length).to_px(box), 0);
|
||||||
|
|
||||||
box.box_model().border.top = computed_values.border_top().width;
|
box.box_model().border.top = computed_values.border_top().width;
|
||||||
box.box_model().border.bottom = computed_values.border_bottom().width;
|
box.box_model().border.bottom = computed_values.border_bottom().width;
|
||||||
box.box_model().padding.top = computed_values.padding().top.resolved(box, width_of_containing_block_as_length).resolved(box).to_px(box);
|
box.box_model().padding.top = computed_values.padding().top.resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||||
box.box_model().padding.bottom = computed_values.padding().bottom.resolved(box, width_of_containing_block_as_length).resolved(box).to_px(box);
|
box.box_model().padding.bottom = computed_values.padding().bottom.resolved(box, width_of_containing_block_as_length).to_px(box);
|
||||||
|
|
||||||
auto height = compute_theoretical_height(box);
|
auto height = compute_theoretical_height(box);
|
||||||
box.set_content_height(height);
|
box.set_content_height(height);
|
||||||
|
|
|
@ -107,10 +107,10 @@ void Box::paint_box_shadow(PaintContext& context)
|
||||||
for (auto const& layer : box_shadow_data) {
|
for (auto const& layer : box_shadow_data) {
|
||||||
resolved_box_shadow_data.empend(
|
resolved_box_shadow_data.empend(
|
||||||
layer.color,
|
layer.color,
|
||||||
static_cast<int>(layer.offset_x.resolved(*this).to_px(*this)),
|
static_cast<int>(layer.offset_x.to_px(*this)),
|
||||||
static_cast<int>(layer.offset_y.resolved(*this).to_px(*this)),
|
static_cast<int>(layer.offset_y.to_px(*this)),
|
||||||
static_cast<int>(layer.blur_radius.resolved(*this).to_px(*this)),
|
static_cast<int>(layer.blur_radius.to_px(*this)),
|
||||||
static_cast<int>(layer.spread_distance.resolved(*this).to_px(*this)),
|
static_cast<int>(layer.spread_distance.to_px(*this)),
|
||||||
layer.placement == CSS::BoxShadowPlacement::Outer ? Painting::BoxShadowPlacement::Outer : Painting::BoxShadowPlacement::Inner);
|
layer.placement == CSS::BoxShadowPlacement::Outer ? Painting::BoxShadowPlacement::Outer : Painting::BoxShadowPlacement::Inner);
|
||||||
}
|
}
|
||||||
Painting::paint_box_shadow(context, enclosing_int_rect(absolute_border_box_rect()), resolved_box_shadow_data);
|
Painting::paint_box_shadow(context, enclosing_int_rect(absolute_border_box_rect()), resolved_box_shadow_data);
|
||||||
|
|
|
@ -22,7 +22,7 @@ static float get_pixel_size(Box const& box, Optional<CSS::LengthPercentage> cons
|
||||||
if (!length_percentage.has_value())
|
if (!length_percentage.has_value())
|
||||||
return 0;
|
return 0;
|
||||||
auto inner_main_size = CSS::Length::make_px(box.containing_block()->content_width());
|
auto inner_main_size = CSS::Length::make_px(box.containing_block()->content_width());
|
||||||
return length_percentage->resolved(box, inner_main_size).resolved(box).to_px(box);
|
return length_percentage->resolved(box, inner_main_size).to_px(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_undefined_or_auto(Optional<CSS::LengthPercentage> const& length_percentage)
|
static bool is_undefined_or_auto(Optional<CSS::LengthPercentage> const& length_percentage)
|
||||||
|
@ -120,15 +120,15 @@ void FlexFormattingContext::populate_specified_margins(FlexItem& item, CSS::Flex
|
||||||
auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block);
|
auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block);
|
||||||
// FIXME: This should also take reverse-ness into account
|
// FIXME: This should also take reverse-ness into account
|
||||||
if (flex_direction == CSS::FlexDirection::Row || flex_direction == CSS::FlexDirection::RowReverse) {
|
if (flex_direction == CSS::FlexDirection::Row || flex_direction == CSS::FlexDirection::RowReverse) {
|
||||||
item.margins.main_before = item.box.computed_values().margin().left.resolved(item.box, width_of_containing_block_as_length).resolved(item.box).to_px(item.box);
|
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).resolved(item.box).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).resolved(item.box).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).resolved(item.box).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);
|
||||||
} else {
|
} else {
|
||||||
item.margins.main_before = item.box.computed_values().margin().top.resolved(item.box, width_of_containing_block_as_length).resolved(item.box).to_px(item.box);
|
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).resolved(item.box).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).resolved(item.box).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).resolved(item.box).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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ void FlexFormattingContext::generate_anonymous_flex_items()
|
||||||
|
|
||||||
auto& maybe_width = flex_container().computed_values().width();
|
auto& maybe_width = flex_container().computed_values().width();
|
||||||
if (maybe_width.has_value()) {
|
if (maybe_width.has_value()) {
|
||||||
auto width = maybe_width->resolved(flex_container(), CSS::Length::make_px(container_width)).resolved(flex_container()).to_px(flex_container());
|
auto width = maybe_width->resolved(flex_container(), CSS::Length::make_px(container_width)).to_px(flex_container());
|
||||||
flex_container().set_content_width(width);
|
flex_container().set_content_width(width);
|
||||||
} else {
|
} else {
|
||||||
flex_container().set_content_width(0);
|
flex_container().set_content_width(0);
|
||||||
|
@ -161,7 +161,7 @@ void FlexFormattingContext::generate_anonymous_flex_items()
|
||||||
auto container_height = flex_container().containing_block()->content_height();
|
auto container_height = flex_container().containing_block()->content_height();
|
||||||
auto& maybe_height = flex_container().computed_values().height();
|
auto& maybe_height = flex_container().computed_values().height();
|
||||||
if (maybe_height.has_value()) {
|
if (maybe_height.has_value()) {
|
||||||
auto height = maybe_height->resolved(flex_container(), CSS::Length::make_px(container_height)).resolved(flex_container()).to_px(flex_container());
|
auto height = maybe_height->resolved(flex_container(), CSS::Length::make_px(container_height)).to_px(flex_container());
|
||||||
flex_container().set_content_height(height);
|
flex_container().set_content_height(height);
|
||||||
} else {
|
} else {
|
||||||
flex_container().set_content_height(0);
|
flex_container().set_content_height(0);
|
||||||
|
@ -256,7 +256,7 @@ float FlexFormattingContext::specified_main_size_of_child_box(Box const& child_b
|
||||||
auto& value = is_row_layout() ? child_box.computed_values().width() : child_box.computed_values().height();
|
auto& value = is_row_layout() ? child_box.computed_values().width() : child_box.computed_values().height();
|
||||||
if (!value.has_value())
|
if (!value.has_value())
|
||||||
return 0;
|
return 0;
|
||||||
return value->resolved(child_box, CSS::Length::make_px(main_size_of_parent)).resolved(child_box).to_px(child_box);
|
return value->resolved(child_box, CSS::Length::make_px(main_size_of_parent)).to_px(child_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
float FlexFormattingContext::specified_main_min_size(Box const& box) const
|
float FlexFormattingContext::specified_main_min_size(Box const& box) const
|
||||||
|
|
|
@ -157,10 +157,10 @@ static Gfx::FloatSize solve_replaced_size_constraint(float w, float h, const Rep
|
||||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.content_width());
|
auto width_of_containing_block = CSS::Length::make_px(containing_block.content_width());
|
||||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.content_height());
|
auto height_of_containing_block = CSS::Length::make_px(containing_block.content_height());
|
||||||
|
|
||||||
auto specified_min_width = box.computed_values().min_width().has_value() ? box.computed_values().min_width()->resolved(box, width_of_containing_block).resolved(box).to_px(box) : 0;
|
auto specified_min_width = box.computed_values().min_width().has_value() ? box.computed_values().min_width()->resolved(box, width_of_containing_block).to_px(box) : 0;
|
||||||
auto specified_max_width = box.computed_values().max_width().has_value() ? box.computed_values().max_width()->resolved(box, width_of_containing_block).resolved(box).to_px(box) : w;
|
auto specified_max_width = box.computed_values().max_width().has_value() ? box.computed_values().max_width()->resolved(box, width_of_containing_block).to_px(box) : w;
|
||||||
auto specified_min_height = box.computed_values().min_height().has_value() ? box.computed_values().min_height()->resolved(box, height_of_containing_block).resolved(box).to_px(box) : 0;
|
auto specified_min_height = box.computed_values().min_height().has_value() ? box.computed_values().min_height()->resolved(box, height_of_containing_block).to_px(box) : 0;
|
||||||
auto specified_max_height = box.computed_values().max_height().has_value() ? box.computed_values().max_height()->resolved(box, height_of_containing_block).resolved(box).to_px(box) : h;
|
auto specified_max_height = box.computed_values().max_height().has_value() ? box.computed_values().max_height()->resolved(box, height_of_containing_block).to_px(box) : h;
|
||||||
|
|
||||||
auto min_width = min(specified_min_width, specified_max_width);
|
auto min_width = min(specified_min_width, specified_max_width);
|
||||||
auto max_width = max(specified_min_width, specified_max_width);
|
auto max_width = max(specified_min_width, specified_max_width);
|
||||||
|
@ -573,12 +573,12 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
|
||||||
auto specified_max_height = computed_values.max_height().has_value() ? computed_values.max_height()->resolved(box, height_of_containing_block).resolved(box) : CSS::Length::make_auto();
|
auto specified_max_height = computed_values.max_height().has_value() ? computed_values.max_height()->resolved(box, height_of_containing_block).resolved(box) : CSS::Length::make_auto();
|
||||||
auto specified_min_height = computed_values.min_height().has_value() ? computed_values.min_height()->resolved(box, height_of_containing_block).resolved(box) : CSS::Length::make_auto();
|
auto specified_min_height = computed_values.min_height().has_value() ? computed_values.min_height()->resolved(box, height_of_containing_block).resolved(box) : CSS::Length::make_auto();
|
||||||
|
|
||||||
box.box_model().margin.top = computed_values.margin().top.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box.box_model().margin.top = computed_values.margin().top.resolved(box, width_of_containing_block).to_px(box);
|
||||||
box.box_model().margin.bottom = computed_values.margin().bottom.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box.box_model().margin.bottom = computed_values.margin().bottom.resolved(box, width_of_containing_block).to_px(box);
|
||||||
box.box_model().border.top = computed_values.border_top().width;
|
box.box_model().border.top = computed_values.border_top().width;
|
||||||
box.box_model().border.bottom = computed_values.border_bottom().width;
|
box.box_model().border.bottom = computed_values.border_bottom().width;
|
||||||
box.box_model().padding.top = computed_values.padding().top.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box.box_model().padding.top = computed_values.padding().top.resolved(box, width_of_containing_block).to_px(box);
|
||||||
box.box_model().padding.bottom = computed_values.padding().bottom.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box.box_model().padding.bottom = computed_values.padding().bottom.resolved(box, width_of_containing_block).to_px(box);
|
||||||
|
|
||||||
if (specified_height.is_auto() && !specified_top.is_auto() && specified_bottom.is_auto()) {
|
if (specified_height.is_auto() && !specified_top.is_auto() && specified_bottom.is_auto()) {
|
||||||
const auto& margin = box.box_model().margin;
|
const auto& margin = box.box_model().margin;
|
||||||
|
@ -620,20 +620,20 @@ void FormattingContext::layout_absolutely_positioned_element(Box& box)
|
||||||
auto independent_formatting_context = layout_inside(box, LayoutMode::Default);
|
auto independent_formatting_context = layout_inside(box, LayoutMode::Default);
|
||||||
compute_height_for_absolutely_positioned_element(box);
|
compute_height_for_absolutely_positioned_element(box);
|
||||||
|
|
||||||
box_model.margin.left = box.computed_values().margin().left.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box_model.margin.left = box.computed_values().margin().left.resolved(box, width_of_containing_block).to_px(box);
|
||||||
box_model.margin.top = box.computed_values().margin().top.resolved(box, height_of_containing_block).resolved(box).to_px(box);
|
box_model.margin.top = box.computed_values().margin().top.resolved(box, height_of_containing_block).to_px(box);
|
||||||
box_model.margin.right = box.computed_values().margin().right.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box_model.margin.right = box.computed_values().margin().right.resolved(box, width_of_containing_block).to_px(box);
|
||||||
box_model.margin.bottom = box.computed_values().margin().bottom.resolved(box, height_of_containing_block).resolved(box).to_px(box);
|
box_model.margin.bottom = box.computed_values().margin().bottom.resolved(box, height_of_containing_block).to_px(box);
|
||||||
|
|
||||||
box_model.border.left = box.computed_values().border_left().width;
|
box_model.border.left = box.computed_values().border_left().width;
|
||||||
box_model.border.right = box.computed_values().border_right().width;
|
box_model.border.right = box.computed_values().border_right().width;
|
||||||
box_model.border.top = box.computed_values().border_top().width;
|
box_model.border.top = box.computed_values().border_top().width;
|
||||||
box_model.border.bottom = box.computed_values().border_bottom().width;
|
box_model.border.bottom = box.computed_values().border_bottom().width;
|
||||||
|
|
||||||
box_model.offset.left = box.computed_values().offset().left.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box_model.offset.left = box.computed_values().offset().left.resolved(box, width_of_containing_block).to_px(box);
|
||||||
box_model.offset.top = box.computed_values().offset().top.resolved(box, height_of_containing_block).resolved(box).to_px(box);
|
box_model.offset.top = box.computed_values().offset().top.resolved(box, height_of_containing_block).to_px(box);
|
||||||
box_model.offset.right = box.computed_values().offset().right.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box_model.offset.right = box.computed_values().offset().right.resolved(box, width_of_containing_block).to_px(box);
|
||||||
box_model.offset.bottom = box.computed_values().offset().bottom.resolved(box, height_of_containing_block).resolved(box).to_px(box);
|
box_model.offset.bottom = box.computed_values().offset().bottom.resolved(box, height_of_containing_block).to_px(box);
|
||||||
|
|
||||||
auto is_auto = [](auto const& length_percentage) {
|
auto is_auto = [](auto const& length_percentage) {
|
||||||
return length_percentage.is_length() && length_percentage.length().is_auto();
|
return length_percentage.is_length() && length_percentage.length().is_auto();
|
||||||
|
|
|
@ -108,12 +108,12 @@ void InlineFormattingContext::dimension_box_on_line(Box& box, LayoutMode layout_
|
||||||
auto width_of_containing_block = CSS::Length::make_px(containing_block().content_width());
|
auto width_of_containing_block = CSS::Length::make_px(containing_block().content_width());
|
||||||
auto& box_model = box.box_model();
|
auto& box_model = box.box_model();
|
||||||
|
|
||||||
box_model.margin.left = box.computed_values().margin().left.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box_model.margin.left = box.computed_values().margin().left.resolved(box, width_of_containing_block).to_px(box);
|
||||||
box_model.border.left = box.computed_values().border_left().width;
|
box_model.border.left = box.computed_values().border_left().width;
|
||||||
box_model.padding.left = box.computed_values().padding().left.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box_model.padding.left = box.computed_values().padding().left.resolved(box, width_of_containing_block).to_px(box);
|
||||||
box_model.margin.right = box.computed_values().margin().right.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box_model.margin.right = box.computed_values().margin().right.resolved(box, width_of_containing_block).to_px(box);
|
||||||
box_model.border.right = box.computed_values().border_right().width;
|
box_model.border.right = box.computed_values().border_right().width;
|
||||||
box_model.padding.right = box.computed_values().padding().right.resolved(box, width_of_containing_block).resolved(box).to_px(box);
|
box_model.padding.right = box.computed_values().padding().right.resolved(box, width_of_containing_block).to_px(box);
|
||||||
|
|
||||||
if (is<ReplacedBox>(box)) {
|
if (is<ReplacedBox>(box)) {
|
||||||
auto& replaced = verify_cast<ReplacedBox>(box);
|
auto& replaced = verify_cast<ReplacedBox>(box);
|
||||||
|
@ -141,7 +141,7 @@ void InlineFormattingContext::dimension_box_on_line(Box& box, LayoutMode layout_
|
||||||
inline_block.set_content_width(width);
|
inline_block.set_content_width(width);
|
||||||
} else {
|
} else {
|
||||||
auto container_width = CSS::Length::make_px(containing_block().content_width());
|
auto container_width = CSS::Length::make_px(containing_block().content_width());
|
||||||
inline_block.set_content_width(width_value->resolved(box, container_width).resolved(inline_block).to_px(inline_block));
|
inline_block.set_content_width(width_value->resolved(box, container_width).to_px(inline_block));
|
||||||
}
|
}
|
||||||
auto independent_formatting_context = layout_inside(inline_block, layout_mode);
|
auto independent_formatting_context = layout_inside(inline_block, layout_mode);
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ void InlineFormattingContext::dimension_box_on_line(Box& box, LayoutMode layout_
|
||||||
BlockFormattingContext::compute_height(inline_block);
|
BlockFormattingContext::compute_height(inline_block);
|
||||||
} else {
|
} else {
|
||||||
auto container_height = CSS::Length::make_px(containing_block().content_height());
|
auto container_height = CSS::Length::make_px(containing_block().content_height());
|
||||||
inline_block.set_content_height(height_value->resolved(box, container_height).resolved(inline_block).to_px(inline_block));
|
inline_block.set_content_height(height_value->resolved(box, container_height).to_px(inline_block));
|
||||||
}
|
}
|
||||||
|
|
||||||
independent_formatting_context->parent_context_did_dimension_child_root_box();
|
independent_formatting_context->parent_context_did_dimension_child_root_box();
|
||||||
|
|
|
@ -61,10 +61,10 @@ void InlineNode::paint(PaintContext& context, PaintPhase phase)
|
||||||
for (auto const& layer : computed_box_shadow) {
|
for (auto const& layer : computed_box_shadow) {
|
||||||
resolved_box_shadow_data.empend(
|
resolved_box_shadow_data.empend(
|
||||||
layer.color,
|
layer.color,
|
||||||
static_cast<int>(layer.offset_x.resolved(*this).to_px(*this)),
|
static_cast<int>(layer.offset_x.to_px(*this)),
|
||||||
static_cast<int>(layer.offset_y.resolved(*this).to_px(*this)),
|
static_cast<int>(layer.offset_y.to_px(*this)),
|
||||||
static_cast<int>(layer.blur_radius.resolved(*this).to_px(*this)),
|
static_cast<int>(layer.blur_radius.to_px(*this)),
|
||||||
static_cast<int>(layer.spread_distance.resolved(*this).to_px(*this)),
|
static_cast<int>(layer.spread_distance.to_px(*this)),
|
||||||
layer.placement == CSS::BoxShadowPlacement::Outer ? Painting::BoxShadowPlacement::Outer : Painting::BoxShadowPlacement::Inner);
|
layer.placement == CSS::BoxShadowPlacement::Outer ? Painting::BoxShadowPlacement::Outer : Painting::BoxShadowPlacement::Inner);
|
||||||
}
|
}
|
||||||
Painting::paint_box_shadow(context, enclosing_int_rect(absolute_fragment_rect), resolved_box_shadow_data);
|
Painting::paint_box_shadow(context, enclosing_int_rect(absolute_fragment_rect), resolved_box_shadow_data);
|
||||||
|
|
|
@ -463,7 +463,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
||||||
if (border.line_style == CSS::LineStyle::None)
|
if (border.line_style == CSS::LineStyle::None)
|
||||||
border.width = 0;
|
border.width = 0;
|
||||||
else
|
else
|
||||||
border.width = specified_style.length_or_fallback(width_property, CSS::Length::make_px(0)).resolved(*this).to_px(*this);
|
border.width = specified_style.length_or_fallback(width_property, CSS::Length::make_px(0)).to_px(*this);
|
||||||
};
|
};
|
||||||
|
|
||||||
do_border_style(computed_values.border_left(), CSS::PropertyID::BorderLeftWidth, CSS::PropertyID::BorderLeftColor, CSS::PropertyID::BorderLeftStyle);
|
do_border_style(computed_values.border_left(), CSS::PropertyID::BorderLeftWidth, CSS::PropertyID::BorderLeftColor, CSS::PropertyID::BorderLeftStyle);
|
||||||
|
|
|
@ -88,22 +88,14 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
||||||
width = image.width();
|
width = image.width();
|
||||||
height = image.height();
|
height = image.height();
|
||||||
} else if (x_is_auto) {
|
} else if (x_is_auto) {
|
||||||
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height()))
|
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height())).to_px(layout_node);
|
||||||
.resolved(layout_node)
|
|
||||||
.to_px(layout_node);
|
|
||||||
width = roundf(image.width() * ((float)height / (float)image.height()));
|
width = roundf(image.width() * ((float)height / (float)image.height()));
|
||||||
} else if (y_is_auto) {
|
} else if (y_is_auto) {
|
||||||
width = layer.size_x.resolved(layout_node, CSS::Length::make_px(background_positioning_area.width()))
|
width = layer.size_x.resolved(layout_node, CSS::Length::make_px(background_positioning_area.width())).to_px(layout_node);
|
||||||
.resolved(layout_node)
|
|
||||||
.to_px(layout_node);
|
|
||||||
height = roundf(image.height() * ((float)width / (float)image.width()));
|
height = roundf(image.height() * ((float)width / (float)image.width()));
|
||||||
} else {
|
} else {
|
||||||
width = layer.size_x.resolved(layout_node, CSS::Length::make_px(background_positioning_area.width()))
|
width = layer.size_x.resolved(layout_node, CSS::Length::make_px(background_positioning_area.width())).to_px(layout_node);
|
||||||
.resolved(layout_node)
|
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height())).to_px(layout_node);
|
||||||
.to_px(layout_node);
|
|
||||||
height = layer.size_y.resolved(layout_node, CSS::Length::make_px(background_positioning_area.height()))
|
|
||||||
.resolved(layout_node)
|
|
||||||
.to_px(layout_node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
image_rect.set_size(width, height);
|
image_rect.set_size(width, height);
|
||||||
|
@ -143,18 +135,14 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
||||||
int space_y = background_positioning_area.height() - image_rect.height();
|
int space_y = background_positioning_area.height() - image_rect.height();
|
||||||
|
|
||||||
// Position
|
// Position
|
||||||
int offset_x = layer.position_offset_x.resolved(layout_node, CSS::Length::make_px(space_x))
|
int offset_x = layer.position_offset_x.resolved(layout_node, CSS::Length::make_px(space_x)).to_px(layout_node);
|
||||||
.resolved(layout_node)
|
|
||||||
.to_px(layout_node);
|
|
||||||
if (layer.position_edge_x == CSS::PositionEdge::Right) {
|
if (layer.position_edge_x == CSS::PositionEdge::Right) {
|
||||||
image_rect.set_right_without_resize(background_positioning_area.right() - offset_x);
|
image_rect.set_right_without_resize(background_positioning_area.right() - offset_x);
|
||||||
} else {
|
} else {
|
||||||
image_rect.set_left(background_positioning_area.left() + offset_x);
|
image_rect.set_left(background_positioning_area.left() + offset_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
int offset_y = layer.position_offset_y.resolved(layout_node, CSS::Length::make_px(space_y))
|
int offset_y = layer.position_offset_y.resolved(layout_node, CSS::Length::make_px(space_y)).to_px(layout_node);
|
||||||
.resolved(layout_node)
|
|
||||||
.to_px(layout_node);
|
|
||||||
if (layer.position_edge_y == CSS::PositionEdge::Bottom) {
|
if (layer.position_edge_y == CSS::PositionEdge::Bottom) {
|
||||||
image_rect.set_bottom_without_resize(background_positioning_area.bottom() - offset_y);
|
image_rect.set_bottom_without_resize(background_positioning_area.bottom() - offset_y);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -17,10 +17,10 @@ BorderRadiusData normalized_border_radius_data(Layout::Node const& node, Gfx::Fl
|
||||||
// Spec just says "Refer to corresponding dimension of the border box."
|
// Spec just says "Refer to corresponding dimension of the border box."
|
||||||
// For now, all relative values are relative to the width.
|
// For now, all relative values are relative to the width.
|
||||||
auto width_length = CSS::Length::make_px(rect.width());
|
auto width_length = CSS::Length::make_px(rect.width());
|
||||||
auto bottom_left_radius_px = bottom_left_radius.resolved(node, width_length).resolved(node).to_px(node);
|
auto bottom_left_radius_px = bottom_left_radius.resolved(node, width_length).to_px(node);
|
||||||
auto bottom_right_radius_px = bottom_right_radius.resolved(node, width_length).resolved(node).to_px(node);
|
auto bottom_right_radius_px = bottom_right_radius.resolved(node, width_length).to_px(node);
|
||||||
auto top_left_radius_px = top_left_radius.resolved(node, width_length).resolved(node).to_px(node);
|
auto top_left_radius_px = top_left_radius.resolved(node, width_length).to_px(node);
|
||||||
auto top_right_radius_px = top_right_radius.resolved(node, width_length).resolved(node).to_px(node);
|
auto top_right_radius_px = top_right_radius.resolved(node, width_length).to_px(node);
|
||||||
|
|
||||||
// Scale overlapping curves according to https://www.w3.org/TR/css-backgrounds-3/#corner-overlap
|
// Scale overlapping curves according to https://www.w3.org/TR/css-backgrounds-3/#corner-overlap
|
||||||
auto f = 1.0f;
|
auto f = 1.0f;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue