mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
LibJS+LibWeb: Wrap raw JS::Cell*/& fields in GCPtr/NonnullGCPtr
This commit is contained in:
parent
1df3652e27
commit
7c0c1c8f49
214 changed files with 825 additions and 827 deletions
|
@ -131,9 +131,9 @@ void FlexFormattingContext::run(Box const& run_box, LayoutMode, AvailableSpace c
|
|||
|
||||
// 3. Determine the flex base size and hypothetical main size of each item
|
||||
for (auto& item : m_flex_items) {
|
||||
if (item.box.is_replaced_box()) {
|
||||
if (item.box->is_replaced_box()) {
|
||||
// FIXME: Get rid of prepare_for_replaced_layout() and make replaced elements figure out their intrinsic size lazily.
|
||||
static_cast<ReplacedBox&>(item.box).prepare_for_replaced_layout();
|
||||
static_cast<ReplacedBox&>(*item.box).prepare_for_replaced_layout();
|
||||
}
|
||||
determine_flex_base_size_and_hypothetical_main_size(item);
|
||||
}
|
||||
|
@ -239,49 +239,49 @@ 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 = 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;
|
||||
item.borders.main_after = item.box.computed_values().border_right().width;
|
||||
item.borders.cross_before = item.box.computed_values().border_top().width;
|
||||
item.borders.cross_after = item.box.computed_values().border_bottom().width;
|
||||
item.borders.main_before = item.box->computed_values().border_left().width;
|
||||
item.borders.main_after = item.box->computed_values().border_right().width;
|
||||
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().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.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().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_is_auto = item.box.computed_values().margin().left().is_auto();
|
||||
item.margins.main_after_is_auto = item.box.computed_values().margin().right().is_auto();
|
||||
item.margins.cross_before_is_auto = item.box.computed_values().margin().top().is_auto();
|
||||
item.margins.cross_after_is_auto = item.box.computed_values().margin().bottom().is_auto();
|
||||
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();
|
||||
item.margins.cross_before_is_auto = item.box->computed_values().margin().top().is_auto();
|
||||
item.margins.cross_after_is_auto = item.box->computed_values().margin().bottom().is_auto();
|
||||
} else {
|
||||
item.borders.main_before = item.box.computed_values().border_top().width;
|
||||
item.borders.main_after = item.box.computed_values().border_bottom().width;
|
||||
item.borders.cross_before = item.box.computed_values().border_left().width;
|
||||
item.borders.cross_after = item.box.computed_values().border_right().width;
|
||||
item.borders.main_before = item.box->computed_values().border_top().width;
|
||||
item.borders.main_after = item.box->computed_values().border_bottom().width;
|
||||
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().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.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().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_is_auto = item.box.computed_values().margin().top().is_auto();
|
||||
item.margins.main_after_is_auto = item.box.computed_values().margin().bottom().is_auto();
|
||||
item.margins.cross_before_is_auto = item.box.computed_values().margin().left().is_auto();
|
||||
item.margins.cross_after_is_auto = item.box.computed_values().margin().right().is_auto();
|
||||
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();
|
||||
item.margins.cross_before_is_auto = item.box->computed_values().margin().left().is_auto();
|
||||
item.margins.cross_after_is_auto = item.box->computed_values().margin().right().is_auto();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -585,13 +585,13 @@ CSSPixels FlexFormattingContext::calculate_indefinite_main_size(FlexItem const&
|
|||
// https://drafts.csswg.org/css-flexbox-1/#propdef-flex-basis
|
||||
CSS::FlexBasisData FlexFormattingContext::used_flex_basis_for_item(FlexItem const& item) const
|
||||
{
|
||||
auto flex_basis = item.box.computed_values().flex_basis();
|
||||
auto flex_basis = item.box->computed_values().flex_basis();
|
||||
|
||||
if (flex_basis.type == CSS::FlexBasis::Auto) {
|
||||
// https://drafts.csswg.org/css-flexbox-1/#valdef-flex-basis-auto
|
||||
// When specified on a flex item, the auto keyword retrieves the value of the main size property as the used flex-basis.
|
||||
// If that value is itself auto, then the used value is content.
|
||||
auto const& main_size = is_row_layout() ? item.box.computed_values().width() : item.box.computed_values().height();
|
||||
auto const& main_size = is_row_layout() ? item.box->computed_values().width() : item.box->computed_values().height();
|
||||
|
||||
if (main_size.is_auto()) {
|
||||
flex_basis.type = CSS::FlexBasis::Content;
|
||||
|
@ -647,11 +647,11 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
|
|||
// - an intrinsic aspect ratio,
|
||||
// - a used flex basis of content, and
|
||||
// - a definite cross size,
|
||||
if (item.box.has_intrinsic_aspect_ratio()
|
||||
if (item.box->has_intrinsic_aspect_ratio()
|
||||
&& item.used_flex_basis.type == CSS::FlexBasis::Content
|
||||
&& has_definite_cross_size(item.box)) {
|
||||
// flex_base_size is calculated from definite cross size and intrinsic aspect ratio
|
||||
return resolved_definite_cross_size(item) * item.box.intrinsic_aspect_ratio().value();
|
||||
return resolved_definite_cross_size(item) * item.box->intrinsic_aspect_ratio().value();
|
||||
}
|
||||
|
||||
// C. If the used flex basis is content or depends on its available space,
|
||||
|
@ -735,8 +735,8 @@ Optional<CSSPixels> FlexFormattingContext::transferred_size_suggestion(FlexItem
|
|||
// If the item has a preferred aspect ratio and its preferred cross size is definite,
|
||||
// then the transferred size suggestion is that size
|
||||
// (clamped by its minimum and maximum cross sizes if they are definite), converted through the aspect ratio.
|
||||
if (item.box.has_intrinsic_aspect_ratio() && has_definite_cross_size(item.box)) {
|
||||
auto aspect_ratio = item.box.intrinsic_aspect_ratio().value();
|
||||
if (item.box->has_intrinsic_aspect_ratio() && has_definite_cross_size(item.box)) {
|
||||
auto aspect_ratio = item.box->intrinsic_aspect_ratio().value();
|
||||
// FIXME: Clamp cross size to min/max cross size before this conversion.
|
||||
return resolved_definite_cross_size(item) * aspect_ratio;
|
||||
}
|
||||
|
@ -757,7 +757,7 @@ CSSPixels FlexFormattingContext::content_based_minimum_size(FlexItem const& item
|
|||
|
||||
// otherwise, the smaller of its transferred size suggestion and its content size suggestion
|
||||
// if the element is replaced and its transferred size suggestion exists;
|
||||
if (item.box.is_replaced_box()) {
|
||||
if (item.box->is_replaced_box()) {
|
||||
if (auto transferred_size_suggestion = this->transferred_size_suggestion(item); transferred_size_suggestion.has_value()) {
|
||||
return min(transferred_size_suggestion.value(), content_size_suggestion(item));
|
||||
}
|
||||
|
@ -899,9 +899,9 @@ void FlexFormattingContext::resolve_flexible_lengths_for_line(FlexLine& line)
|
|||
|
||||
for (FlexItem& item : line.items) {
|
||||
if (used_flex_factor == FlexFactor::FlexGrowFactor) {
|
||||
item.flex_factor = item.box.computed_values().flex_grow();
|
||||
item.flex_factor = item.box->computed_values().flex_grow();
|
||||
} else if (used_flex_factor == FlexFactor::FlexShrinkFactor) {
|
||||
item.flex_factor = item.box.computed_values().flex_shrink();
|
||||
item.flex_factor = item.box->computed_values().flex_shrink();
|
||||
}
|
||||
// Freeze, setting its target main size to its hypothetical main size…
|
||||
// - any item that has a flex factor of zero
|
||||
|
@ -1092,7 +1092,7 @@ void FlexFormattingContext::determine_hypothetical_cross_size_of_item(FlexItem&
|
|||
}
|
||||
|
||||
auto cross_size = [&]() {
|
||||
if (item.box.computed_values().box_sizing() == CSS::BoxSizing::BorderBox) {
|
||||
if (item.box->computed_values().box_sizing() == CSS::BoxSizing::BorderBox) {
|
||||
return max(CSSPixels(0.0f), resolved_definite_cross_size(item) - item.padding.cross_before - item.padding.cross_after - item.borders.cross_before - item.borders.cross_after);
|
||||
}
|
||||
|
||||
|
@ -1358,7 +1358,7 @@ void FlexFormattingContext::dump_items() const
|
|||
dbgln("{} flex-line #{}:", flex_container().debug_description(), i);
|
||||
for (size_t j = 0; j < m_flex_lines[i].items.size(); ++j) {
|
||||
auto& item = m_flex_lines[i].items[j];
|
||||
dbgln("{} flex-item #{}: {} (main:{}, cross:{})", flex_container().debug_description(), j, item.box.debug_description(), item.main_size.value_or(-1), item.cross_size.value_or(-1));
|
||||
dbgln("{} flex-item #{}: {} (main:{}, cross:{})", flex_container().debug_description(), j, item.box->debug_description(), item.main_size.value_or(-1), item.cross_size.value_or(-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1533,20 +1533,20 @@ 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().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.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().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.border_left = box.computed_values().border_left().width;
|
||||
box_state.border_right = box.computed_values().border_right().width;
|
||||
box_state.border_top = box.computed_values().border_top().width;
|
||||
box_state.border_bottom = box.computed_values().border_bottom().width;
|
||||
box_state.border_left = box->computed_values().border_left().width;
|
||||
box_state.border_right = box->computed_values().border_right().width;
|
||||
box_state.border_top = box->computed_values().border_top().width;
|
||||
box_state.border_bottom = box->computed_values().border_bottom().width;
|
||||
|
||||
set_main_size(box, item.main_size.value());
|
||||
set_cross_size(box, item.cross_size.value());
|
||||
|
@ -1604,10 +1604,10 @@ CSSPixels FlexFormattingContext::calculate_intrinsic_main_size_of_flex_container
|
|||
|
||||
CSSPixels result = contribution - outer_flex_base_size;
|
||||
if (result > 0) {
|
||||
if (item.box.computed_values().flex_grow() >= 1) {
|
||||
result /= item.box.computed_values().flex_grow();
|
||||
if (item.box->computed_values().flex_grow() >= 1) {
|
||||
result /= item.box->computed_values().flex_grow();
|
||||
} else {
|
||||
result *= item.box.computed_values().flex_grow();
|
||||
result *= item.box->computed_values().flex_grow();
|
||||
}
|
||||
} else if (result < 0) {
|
||||
if (item.scaled_flex_shrink_factor == 0)
|
||||
|
@ -1636,8 +1636,8 @@ CSSPixels FlexFormattingContext::calculate_intrinsic_main_size_of_flex_container
|
|||
float sum_of_flex_shrink_factors = 0;
|
||||
for (auto& item : flex_line.items) {
|
||||
greatest_desired_flex_fraction = max(greatest_desired_flex_fraction, item.desired_flex_fraction);
|
||||
sum_of_flex_grow_factors += item.box.computed_values().flex_grow();
|
||||
sum_of_flex_shrink_factors += item.box.computed_values().flex_shrink();
|
||||
sum_of_flex_grow_factors += item.box->computed_values().flex_grow();
|
||||
sum_of_flex_shrink_factors += item.box->computed_values().flex_shrink();
|
||||
}
|
||||
float chosen_flex_fraction = greatest_desired_flex_fraction;
|
||||
|
||||
|
@ -1663,7 +1663,7 @@ CSSPixels FlexFormattingContext::calculate_intrinsic_main_size_of_flex_container
|
|||
for (auto& item : flex_line.items) {
|
||||
float product = 0;
|
||||
if (item.desired_flex_fraction > 0)
|
||||
product = flex_line.chosen_flex_fraction * item.box.computed_values().flex_grow();
|
||||
product = flex_line.chosen_flex_fraction * item.box->computed_values().flex_grow();
|
||||
else if (item.desired_flex_fraction < 0)
|
||||
product = flex_line.chosen_flex_fraction * item.scaled_flex_shrink_factor;
|
||||
auto result = item.flex_base_size + product;
|
||||
|
@ -1923,7 +1923,7 @@ bool FlexFormattingContext::flex_item_is_stretched(FlexItem const& item) const
|
|||
if (alignment != CSS::AlignItems::Stretch)
|
||||
return false;
|
||||
// If the cross size property of the flex item computes to auto, and neither of the cross-axis margins are auto, the flex item is stretched.
|
||||
auto const& computed_cross_size = is_row_layout() ? item.box.computed_values().height() : item.box.computed_values().width();
|
||||
auto const& computed_cross_size = is_row_layout() ? item.box->computed_values().height() : item.box->computed_values().width();
|
||||
return computed_cross_size.is_auto() && !item.margins.cross_before_is_auto && !item.margins.cross_after_is_auto;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue