mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:57:46 +00:00
LibWeb: Resolve Lengths to CSSPixels
This commit is contained in:
parent
7d40e3eb0d
commit
8cc0bdf777
13 changed files with 44 additions and 44 deletions
|
@ -42,10 +42,10 @@ CSSPixels FlexFormattingContext::get_pixel_width(Box const& box, Optional<CSS::S
|
|||
if (!size.has_value())
|
||||
return 0;
|
||||
auto inner_width = CSS::Length::make_px(containing_block_width_for(box));
|
||||
float border_left = box.computed_values().border_left().width;
|
||||
float border_right = box.computed_values().border_right().width;
|
||||
float padding_left = box.computed_values().padding().left().resolved(box, inner_width).to_px(box);
|
||||
float padding_right = box.computed_values().padding().right().resolved(box, inner_width).to_px(box);
|
||||
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, inner_width).to_px(box);
|
||||
auto padding_right = box.computed_values().padding().right().resolved(box, inner_width).to_px(box);
|
||||
if (box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) {
|
||||
return size->resolved(box, inner_width).to_px(box) - border_left - border_right - padding_left - padding_right;
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ CSSPixels FlexFormattingContext::get_pixel_height(Box const& box, Optional<CSS::
|
|||
if (!length_percentage.has_value())
|
||||
return 0;
|
||||
auto inner_height = CSS::Length::make_px(containing_block_height_for(box));
|
||||
float border_top = box.computed_values().border_top().width;
|
||||
float border_bottom = box.computed_values().border_bottom().width;
|
||||
float padding_top = box.computed_values().padding().top().resolved(box, inner_height).to_px(box);
|
||||
float padding_bottom = box.computed_values().padding().bottom().resolved(box, inner_height).to_px(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, inner_height).to_px(box);
|
||||
auto padding_bottom = box.computed_values().padding().bottom().resolved(box, inner_height).to_px(box);
|
||||
if (box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) {
|
||||
return length_percentage->resolved(box, inner_height).to_px(box) - border_top - border_bottom - padding_top - padding_bottom;
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
// m_font is used by Length::to_px() when resolving sizes against this layout node.
|
||||
// That's why it has to be set before everything else.
|
||||
m_font = computed_style.computed_font();
|
||||
computed_values.set_font_size(computed_style.property(CSS::PropertyID::FontSize)->to_length().to_px(*this));
|
||||
computed_values.set_font_size(computed_style.property(CSS::PropertyID::FontSize)->to_length().to_px(*this).value());
|
||||
computed_values.set_font_weight(computed_style.property(CSS::PropertyID::FontWeight)->to_integer());
|
||||
m_line_height = computed_style.line_height(*this);
|
||||
|
||||
|
@ -555,9 +555,9 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
auto resolve_border_width = [&]() {
|
||||
auto value = computed_style.property(width_property);
|
||||
if (value->is_calculated())
|
||||
return CSS::Length::make_calculated(value->as_calculated()).to_px(*this);
|
||||
return CSS::Length::make_calculated(value->as_calculated()).to_px(*this).value();
|
||||
if (value->has_length())
|
||||
return value->to_length().to_px(*this);
|
||||
return value->to_length().to_px(*this).value();
|
||||
if (value->is_identifier()) {
|
||||
// FIXME: These values should depend on something, e.g. a font size.
|
||||
switch (value->to_identifier()) {
|
||||
|
|
|
@ -121,7 +121,7 @@ void TableFormattingContext::compute_table_measures()
|
|||
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.value();
|
||||
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));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue