mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Lint layout_2020 with clippy (#31169)
cargo clippy --fix -p layout_2020 --allow-dirty --broken-code
This commit is contained in:
parent
886f6c58d4
commit
50f56affe3
30 changed files with 224 additions and 244 deletions
|
@ -110,7 +110,7 @@ impl<'a> LayoutContext<'a> {
|
||||||
.read()
|
.read()
|
||||||
.get(&(url.clone(), use_placeholder))
|
.get(&(url.clone(), use_placeholder))
|
||||||
{
|
{
|
||||||
return Some((*existing_webrender_image).clone());
|
return Some(*existing_webrender_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.get_or_request_image_or_meta(node, url.clone(), use_placeholder) {
|
match self.get_or_request_image_or_meta(node, url.clone(), use_placeholder) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub(super) fn build(
|
||||||
} else {
|
} else {
|
||||||
wr::ExtendMode::Clamp
|
wr::ExtendMode::Clamp
|
||||||
},
|
},
|
||||||
&layer,
|
layer,
|
||||||
builder,
|
builder,
|
||||||
),
|
),
|
||||||
Gradient::Radial {
|
Gradient::Radial {
|
||||||
|
@ -48,7 +48,7 @@ pub(super) fn build(
|
||||||
} else {
|
} else {
|
||||||
wr::ExtendMode::Clamp
|
wr::ExtendMode::Clamp
|
||||||
},
|
},
|
||||||
&layer,
|
layer,
|
||||||
builder,
|
builder,
|
||||||
),
|
),
|
||||||
Gradient::Conic { .. } => unimplemented!(),
|
Gradient::Conic { .. } => unimplemented!(),
|
||||||
|
|
|
@ -123,9 +123,9 @@ pub(crate) struct DisplayListBuilder<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DisplayList {
|
impl DisplayList {
|
||||||
pub fn build<'a>(
|
pub fn build(
|
||||||
&mut self,
|
&mut self,
|
||||||
context: &'a LayoutContext,
|
context: &LayoutContext,
|
||||||
fragment_tree: &FragmentTree,
|
fragment_tree: &FragmentTree,
|
||||||
root_stacking_context: &StackingContext,
|
root_stacking_context: &StackingContext,
|
||||||
) -> (FnvHashMap<BrowsingContextId, Size2D<f32, CSSPixel>>, bool) {
|
) -> (FnvHashMap<BrowsingContextId, Size2D<f32, CSSPixel>>, bool) {
|
||||||
|
@ -280,7 +280,7 @@ impl Fragment {
|
||||||
.rect
|
.rect
|
||||||
.to_physical(fragment.parent_style.writing_mode, containing_block)
|
.to_physical(fragment.parent_style.writing_mode, containing_block)
|
||||||
.translate(containing_block.origin.to_vector());
|
.translate(containing_block.origin.to_vector());
|
||||||
let mut baseline_origin = rect.origin.clone();
|
let mut baseline_origin = rect.origin;
|
||||||
baseline_origin.y += Length::from(fragment.font_metrics.ascent);
|
baseline_origin.y += Length::from(fragment.font_metrics.ascent);
|
||||||
let glyphs = glyphs(
|
let glyphs = glyphs(
|
||||||
&fragment.glyphs,
|
&fragment.glyphs,
|
||||||
|
@ -317,8 +317,7 @@ impl Fragment {
|
||||||
.contains(TextDecorationLine::UNDERLINE)
|
.contains(TextDecorationLine::UNDERLINE)
|
||||||
{
|
{
|
||||||
let mut rect = rect;
|
let mut rect = rect;
|
||||||
rect.origin.y =
|
rect.origin.y += Length::from(font_metrics.ascent - font_metrics.underline_offset);
|
||||||
rect.origin.y + Length::from(font_metrics.ascent - font_metrics.underline_offset);
|
|
||||||
rect.size.height = Length::new(font_metrics.underline_size.to_nearest_pixel(dppx));
|
rect.size.height = Length::new(font_metrics.underline_size.to_nearest_pixel(dppx));
|
||||||
self.build_display_list_for_text_decoration(fragment, builder, &rect, &color);
|
self.build_display_list_for_text_decoration(fragment, builder, &rect, &color);
|
||||||
}
|
}
|
||||||
|
@ -350,8 +349,7 @@ impl Fragment {
|
||||||
.contains(TextDecorationLine::LINE_THROUGH)
|
.contains(TextDecorationLine::LINE_THROUGH)
|
||||||
{
|
{
|
||||||
let mut rect = rect;
|
let mut rect = rect;
|
||||||
rect.origin.y =
|
rect.origin.y += Length::from(font_metrics.ascent - font_metrics.strikeout_offset);
|
||||||
rect.origin.y + Length::from(font_metrics.ascent - font_metrics.strikeout_offset);
|
|
||||||
// XXX(ferjm) This does not work on MacOS #942
|
// XXX(ferjm) This does not work on MacOS #942
|
||||||
rect.size.height = Length::new(font_metrics.strikeout_size.to_nearest_pixel(dppx));
|
rect.size.height = Length::new(font_metrics.strikeout_size.to_nearest_pixel(dppx));
|
||||||
self.build_display_list_for_text_decoration(fragment, builder, &rect, &color);
|
self.build_display_list_for_text_decoration(fragment, builder, &rect, &color);
|
||||||
|
@ -590,7 +588,7 @@ impl<'a> BuilderForBoxFragment<'a> {
|
||||||
if let Some(layer) =
|
if let Some(layer) =
|
||||||
&background::layout_layer(self, &source, builder, index, intrinsic)
|
&background::layout_layer(self, &source, builder, index, intrinsic)
|
||||||
{
|
{
|
||||||
gradient::build(&style, &gradient, layer, builder)
|
gradient::build(style, gradient, layer, builder)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Image::Url(ref image_url) => {
|
Image::Url(ref image_url) => {
|
||||||
|
@ -898,7 +896,7 @@ fn clip_for_radii(
|
||||||
if radii.is_zero() {
|
if radii.is_zero() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let clip_chain_id = builder.current_clip_chain_id.clone();
|
let clip_chain_id = builder.current_clip_chain_id;
|
||||||
let parent_space_and_clip = wr::SpaceAndClipInfo {
|
let parent_space_and_clip = wr::SpaceAndClipInfo {
|
||||||
spatial_id: builder.current_scroll_node_id.spatial_id,
|
spatial_id: builder.current_scroll_node_id.spatial_id,
|
||||||
clip_id: ClipId::ClipChain(clip_chain_id),
|
clip_id: ClipId::ClipChain(clip_chain_id),
|
||||||
|
|
|
@ -198,7 +198,7 @@ impl DisplayList {
|
||||||
.spatial_id;
|
.spatial_id;
|
||||||
|
|
||||||
let new_scroll_node_id = self.compositor_info.scroll_tree.add_scroll_tree_node(
|
let new_scroll_node_id = self.compositor_info.scroll_tree.add_scroll_tree_node(
|
||||||
Some(&parent_scroll_node_id),
|
Some(parent_scroll_node_id),
|
||||||
new_spatial_id,
|
new_spatial_id,
|
||||||
Some(ScrollableNodeInfo {
|
Some(ScrollableNodeInfo {
|
||||||
external_id,
|
external_id,
|
||||||
|
@ -374,7 +374,7 @@ impl StackingContext {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
spatial_id,
|
spatial_id,
|
||||||
clip_chain_id: clip_chain_id,
|
clip_chain_id,
|
||||||
initializing_fragment_style: Some(initializing_fragment_style),
|
initializing_fragment_style: Some(initializing_fragment_style),
|
||||||
context_type,
|
context_type,
|
||||||
contents: vec![],
|
contents: vec![],
|
||||||
|
@ -423,9 +423,9 @@ impl StackingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn sort(&mut self) {
|
pub(crate) fn sort(&mut self) {
|
||||||
self.contents.sort_by(|a, b| a.section().cmp(&b.section()));
|
self.contents.sort_by_key(|a| a.section());
|
||||||
self.real_stacking_contexts_and_positioned_stacking_containers
|
self.real_stacking_contexts_and_positioned_stacking_containers
|
||||||
.sort_by(|a, b| a.z_index().cmp(&b.z_index()));
|
.sort_by_key(|a| a.z_index());
|
||||||
|
|
||||||
debug_assert!(self
|
debug_assert!(self
|
||||||
.real_stacking_contexts_and_positioned_stacking_containers
|
.real_stacking_contexts_and_positioned_stacking_containers
|
||||||
|
@ -502,8 +502,8 @@ impl StackingContext {
|
||||||
style.get_used_transform_style().to_webrender(),
|
style.get_used_transform_style().to_webrender(),
|
||||||
effects.mix_blend_mode.to_webrender(),
|
effects.mix_blend_mode.to_webrender(),
|
||||||
&filters,
|
&filters,
|
||||||
&vec![], // filter_datas
|
&[], // filter_datas
|
||||||
&vec![], // filter_primitives
|
&[], // filter_primitives
|
||||||
wr::RasterSpace::Screen,
|
wr::RasterSpace::Screen,
|
||||||
wr::StackingContextFlags::empty(),
|
wr::StackingContextFlags::empty(),
|
||||||
);
|
);
|
||||||
|
@ -541,7 +541,7 @@ impl StackingContext {
|
||||||
|
|
||||||
let background_color = style.resolve_color(style.get_background().background_color.clone());
|
let background_color = style.resolve_color(style.get_background().background_color.clone());
|
||||||
if background_color.alpha > 0.0 {
|
if background_color.alpha > 0.0 {
|
||||||
let common = builder.common_properties(painting_area, &style);
|
let common = builder.common_properties(painting_area, style);
|
||||||
let color = super::rgba(background_color);
|
let color = super::rgba(background_color);
|
||||||
builder
|
builder
|
||||||
.display_list
|
.display_list
|
||||||
|
@ -1212,7 +1212,7 @@ impl BoxFragment {
|
||||||
|
|
||||||
let border_rect = self
|
let border_rect = self
|
||||||
.border_rect()
|
.border_rect()
|
||||||
.to_physical(self.style.writing_mode, &containing_block_rect);
|
.to_physical(self.style.writing_mode, containing_block_rect);
|
||||||
let clip_rect = clip_rect
|
let clip_rect = clip_rect
|
||||||
.for_border_rect(border_rect)
|
.for_border_rect(border_rect)
|
||||||
.translate(containing_block_rect.origin.to_vector())
|
.translate(containing_block_rect.origin.to_vector())
|
||||||
|
@ -1225,7 +1225,7 @@ impl BoxFragment {
|
||||||
|
|
||||||
let clip_id = display_list
|
let clip_id = display_list
|
||||||
.wr
|
.wr
|
||||||
.define_clip_rect(&parent_space_and_clip, clip_rect);
|
.define_clip_rect(parent_space_and_clip, clip_rect);
|
||||||
Some(
|
Some(
|
||||||
display_list
|
display_list
|
||||||
.wr
|
.wr
|
||||||
|
@ -1261,7 +1261,7 @@ impl BoxFragment {
|
||||||
|
|
||||||
let padding_rect = self
|
let padding_rect = self
|
||||||
.padding_rect()
|
.padding_rect()
|
||||||
.to_physical(self.style.writing_mode, &containing_block_rect)
|
.to_physical(self.style.writing_mode, containing_block_rect)
|
||||||
.translate(containing_block_rect.origin.to_vector())
|
.translate(containing_block_rect.origin.to_vector())
|
||||||
.to_webrender();
|
.to_webrender();
|
||||||
|
|
||||||
|
@ -1269,7 +1269,7 @@ impl BoxFragment {
|
||||||
parent_scroll_node_id,
|
parent_scroll_node_id,
|
||||||
parent_clip_id,
|
parent_clip_id,
|
||||||
external_id,
|
external_id,
|
||||||
self.scrollable_overflow(&containing_block_rect)
|
self.scrollable_overflow(containing_block_rect)
|
||||||
.to_webrender(),
|
.to_webrender(),
|
||||||
padding_rect,
|
padding_rect,
|
||||||
sensitivity,
|
sensitivity,
|
||||||
|
@ -1331,7 +1331,7 @@ impl BoxFragment {
|
||||||
|
|
||||||
let frame_rect = self
|
let frame_rect = self
|
||||||
.border_rect()
|
.border_rect()
|
||||||
.to_physical(self.style.writing_mode, &containing_block_rect)
|
.to_physical(self.style.writing_mode, containing_block_rect)
|
||||||
.translate(containing_block_rect.origin.to_vector())
|
.translate(containing_block_rect.origin.to_vector())
|
||||||
.to_webrender();
|
.to_webrender();
|
||||||
|
|
||||||
|
@ -1379,7 +1379,7 @@ impl BoxFragment {
|
||||||
|
|
||||||
let relative_border_rect = self
|
let relative_border_rect = self
|
||||||
.border_rect()
|
.border_rect()
|
||||||
.to_physical(self.style.writing_mode, &containing_block_rect);
|
.to_physical(self.style.writing_mode, containing_block_rect);
|
||||||
let border_rect = relative_border_rect.translate(containing_block_rect.origin.to_vector());
|
let border_rect = relative_border_rect.translate(containing_block_rect.origin.to_vector());
|
||||||
let untyped_border_rect = border_rect.to_untyped();
|
let untyped_border_rect = border_rect.to_untyped();
|
||||||
|
|
||||||
|
@ -1431,7 +1431,7 @@ impl BoxFragment {
|
||||||
) -> Option<LayoutTransform> {
|
) -> Option<LayoutTransform> {
|
||||||
let list = &self.style.get_box().transform;
|
let list = &self.style.get_box().transform;
|
||||||
let transform =
|
let transform =
|
||||||
LayoutTransform::from_untyped(&list.to_transform_3d_matrix(Some(&border_rect)).ok()?.0);
|
LayoutTransform::from_untyped(&list.to_transform_3d_matrix(Some(border_rect)).ok()?.0);
|
||||||
// WebRender will end up dividing by the scale value of this transform, so we
|
// WebRender will end up dividing by the scale value of this transform, so we
|
||||||
// want to ensure we don't feed it a divisor of 0.
|
// want to ensure we don't feed it a divisor of 0.
|
||||||
assert_ne!(transform.m11, 0.);
|
assert_ne!(transform.m11, 0.);
|
||||||
|
|
|
@ -119,8 +119,8 @@ where
|
||||||
.unwrap_or((0, 0));
|
.unwrap_or((0, 0));
|
||||||
let (mut width, mut height) = (width as f64, height as f64);
|
let (mut width, mut height) = (width as f64, height as f64);
|
||||||
if let Some(density) = node.image_density().filter(|density| *density != 1.) {
|
if let Some(density) = node.image_density().filter(|density| *density != 1.) {
|
||||||
width = width / density;
|
width /= density;
|
||||||
height = height / density;
|
height /= density;
|
||||||
}
|
}
|
||||||
Some((resource, PhysicalSize::new(width, height)))
|
Some((resource, PhysicalSize::new(width, height)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl<Node: Clone> NodeAndStyleInfo<Node> {
|
||||||
pub(crate) fn new_replacing_style(&self, style: ServoArc<ComputedValues>) -> Self {
|
pub(crate) fn new_replacing_style(&self, style: ServoArc<ComputedValues>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
node: self.node.clone(),
|
node: self.node.clone(),
|
||||||
pseudo_element_type: self.pseudo_element_type.clone(),
|
pseudo_element_type: self.pseudo_element_type,
|
||||||
style,
|
style,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ fn traverse_pseudo_element_contents<'dom, Node>(
|
||||||
let mut anonymous_style = None;
|
let mut anonymous_style = None;
|
||||||
for item in items {
|
for item in items {
|
||||||
match item {
|
match item {
|
||||||
PseudoElementContentItem::Text(text) => handler.handle_text(&info, text.into()),
|
PseudoElementContentItem::Text(text) => handler.handle_text(info, text.into()),
|
||||||
PseudoElementContentItem::Replaced(contents) => {
|
PseudoElementContentItem::Replaced(contents) => {
|
||||||
let item_style = anonymous_style.get_or_insert_with(|| {
|
let item_style = anonymous_style.get_or_insert_with(|| {
|
||||||
context
|
context
|
||||||
|
|
|
@ -373,8 +373,7 @@ impl FlexContainer {
|
||||||
fragment.content_rect.start_corner += &flow_relative_line_position
|
fragment.content_rect.start_corner += &flow_relative_line_position
|
||||||
}
|
}
|
||||||
line.item_fragments
|
line.item_fragments
|
||||||
})
|
});
|
||||||
.into_iter();
|
|
||||||
|
|
||||||
let fragments = absolutely_positioned_items_with_original_order
|
let fragments = absolutely_positioned_items_with_original_order
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -458,7 +457,7 @@ impl<'a> FlexItem<'a> {
|
||||||
) {
|
) {
|
||||||
(Some(ratio), LengthOrAuto::LengthPercentage(block_size)) => {
|
(Some(ratio), LengthOrAuto::LengthPercentage(block_size)) => {
|
||||||
let block_size = block_size.clamp_between_extremums(
|
let block_size = block_size.clamp_between_extremums(
|
||||||
min_size.block.auto_is(|| Length::zero()),
|
min_size.block.auto_is(Length::zero),
|
||||||
max_size.block,
|
max_size.block,
|
||||||
);
|
);
|
||||||
Some(block_size * ratio)
|
Some(block_size * ratio)
|
||||||
|
@ -469,7 +468,7 @@ impl<'a> FlexItem<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let inline_content_size = box_
|
let inline_content_size = box_
|
||||||
.inline_content_sizes(&flex_context.layout_context)
|
.inline_content_sizes(flex_context.layout_context)
|
||||||
.min_content;
|
.min_content;
|
||||||
let content_size_suggestion = match box_ {
|
let content_size_suggestion = match box_ {
|
||||||
IndependentFormattingContext::NonReplaced(_) => inline_content_size,
|
IndependentFormattingContext::NonReplaced(_) => inline_content_size,
|
||||||
|
@ -479,7 +478,7 @@ impl<'a> FlexItem<'a> {
|
||||||
.inline_size_over_block_size_intrinsic_ratio(box_.style())
|
.inline_size_over_block_size_intrinsic_ratio(box_.style())
|
||||||
{
|
{
|
||||||
inline_content_size.clamp_between_extremums(
|
inline_content_size.clamp_between_extremums(
|
||||||
(min_size.block.auto_is(|| Length::zero()) * ratio).into(),
|
(min_size.block.auto_is(Length::zero) * ratio).into(),
|
||||||
max_size.block.map(|l| (l * ratio).into()),
|
max_size.block.map(|l| (l * ratio).into()),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -507,7 +506,7 @@ impl<'a> FlexItem<'a> {
|
||||||
|
|
||||||
let min_size = LogicalVec2 {
|
let min_size = LogicalVec2 {
|
||||||
inline: min_size.inline.auto_is(automatic_min_size),
|
inline: min_size.inline.auto_is(automatic_min_size),
|
||||||
block: min_size.block.auto_is(|| Length::zero()),
|
block: min_size.block.auto_is(Length::zero),
|
||||||
};
|
};
|
||||||
let margin_auto_is_zero = pbm.margin.auto_is(Length::zero);
|
let margin_auto_is_zero = pbm.margin.auto_is(Length::zero);
|
||||||
|
|
||||||
|
@ -653,7 +652,7 @@ fn collect_flex_lines<'items, LineResult>(
|
||||||
.sum(),
|
.sum(),
|
||||||
items,
|
items,
|
||||||
};
|
};
|
||||||
return vec![each(flex_context, line)];
|
vec![each(flex_context, line)]
|
||||||
} else {
|
} else {
|
||||||
let mut lines = Vec::new();
|
let mut lines = Vec::new();
|
||||||
let mut line_size_so_far = Length::zero();
|
let mut line_size_so_far = Length::zero();
|
||||||
|
@ -709,7 +708,7 @@ impl FlexLine<'_> {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-flexbox/#algo-cross-line
|
// https://drafts.csswg.org/css-flexbox/#algo-cross-line
|
||||||
let line_cross_size = self.cross_size(&item_layout_results, &flex_context);
|
let line_cross_size = self.cross_size(&item_layout_results, flex_context);
|
||||||
let line_size = FlexRelativeVec2 {
|
let line_size = FlexRelativeVec2 {
|
||||||
main: container_main_size,
|
main: container_main_size,
|
||||||
cross: line_cross_size,
|
cross: line_cross_size,
|
||||||
|
@ -791,7 +790,7 @@ impl FlexLine<'_> {
|
||||||
let item_cross_margins = self.items.iter().zip(&item_used_cross_sizes).map(
|
let item_cross_margins = self.items.iter().zip(&item_used_cross_sizes).map(
|
||||||
|(item, &item_cross_content_size)| {
|
|(item, &item_cross_content_size)| {
|
||||||
item.resolve_auto_cross_margins(
|
item.resolve_auto_cross_margins(
|
||||||
&flex_context,
|
flex_context,
|
||||||
line_cross_size,
|
line_cross_size,
|
||||||
item_cross_content_size,
|
item_cross_content_size,
|
||||||
)
|
)
|
||||||
|
|
|
@ -71,11 +71,11 @@ impl BlockFormattingContext {
|
||||||
ends_with_whitespace: false,
|
ends_with_whitespace: false,
|
||||||
};
|
};
|
||||||
let contents = BlockContainer::InlineFormattingContext(ifc);
|
let contents = BlockContainer::InlineFormattingContext(ifc);
|
||||||
let bfc = Self {
|
|
||||||
|
Self {
|
||||||
contents,
|
contents,
|
||||||
contains_floats: false,
|
contains_floats: false,
|
||||||
};
|
}
|
||||||
bfc
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,8 +442,8 @@ fn preserve_segment_break() -> bool {
|
||||||
///
|
///
|
||||||
/// Returns the transformed text as a [String] and also whether or not the input had
|
/// Returns the transformed text as a [String] and also whether or not the input had
|
||||||
/// any uncollapsible content.
|
/// any uncollapsible content.
|
||||||
fn collapse_and_transform_whitespace<'text>(
|
fn collapse_and_transform_whitespace(
|
||||||
input: &'text str,
|
input: &str,
|
||||||
white_space: WhiteSpace,
|
white_space: WhiteSpace,
|
||||||
trim_beginning_white_space: bool,
|
trim_beginning_white_space: bool,
|
||||||
) -> (String, bool) {
|
) -> (String, bool) {
|
||||||
|
|
|
@ -181,7 +181,7 @@ impl<'a> PlacementAmongFloats<'a> {
|
||||||
min_inline_end = min_inline_end.min(right);
|
min_inline_end = min_inline_end.min(right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (max_inline_start, min_inline_end);
|
(max_inline_start, min_inline_end)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find the total inline size provided by the current set of bands under consideration.
|
/// Find the total inline size provided by the current set of bands under consideration.
|
||||||
|
@ -389,7 +389,7 @@ impl FloatContext {
|
||||||
|
|
||||||
// Find the first band this float fits in.
|
// Find the first band this float fits in.
|
||||||
let mut first_band = self.bands.find(ceiling).unwrap();
|
let mut first_band = self.bands.find(ceiling).unwrap();
|
||||||
while !first_band.object_fits(&object, &self.containing_block_info) {
|
while !first_band.object_fits(object, &self.containing_block_info) {
|
||||||
let next_band = self.bands.find_next(first_band.top).unwrap();
|
let next_band = self.bands.find_next(first_band.top).unwrap();
|
||||||
if next_band.top == MAX_AU {
|
if next_band.top == MAX_AU {
|
||||||
break;
|
break;
|
||||||
|
@ -426,7 +426,7 @@ impl FloatContext {
|
||||||
pub fn add_float(&mut self, new_float: &PlacementInfo) -> LogicalVec2<Au> {
|
pub fn add_float(&mut self, new_float: &PlacementInfo) -> LogicalVec2<Au> {
|
||||||
// Place the float.
|
// Place the float.
|
||||||
let ceiling = self.ceiling();
|
let ceiling = self.ceiling();
|
||||||
let new_float_origin = self.place_object(&new_float, ceiling);
|
let new_float_origin = self.place_object(new_float, ceiling);
|
||||||
let new_float_extent = match new_float.side {
|
let new_float_extent = match new_float.side {
|
||||||
FloatSide::Left => new_float_origin.inline + new_float.size.inline,
|
FloatSide::Left => new_float_origin.inline + new_float.size.inline,
|
||||||
FloatSide::Right => new_float_origin.inline,
|
FloatSide::Right => new_float_origin.inline,
|
||||||
|
@ -668,6 +668,12 @@ impl FloatBandTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for FloatBandTree {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FloatBandNode {
|
impl FloatBandNode {
|
||||||
fn new(band: FloatBand) -> FloatBandNode {
|
fn new(band: FloatBand) -> FloatBandNode {
|
||||||
FloatBandNode {
|
FloatBandNode {
|
||||||
|
@ -681,7 +687,7 @@ impl FloatBandNode {
|
||||||
/// Sets the side values of all bands within the given half-open range to be at least
|
/// Sets the side values of all bands within the given half-open range to be at least
|
||||||
/// `new_value`.
|
/// `new_value`.
|
||||||
fn set_range(&self, range: &Range<Au>, side: FloatSide, new_value: Au) -> Arc<FloatBandNode> {
|
fn set_range(&self, range: &Range<Au>, side: FloatSide, new_value: Au) -> Arc<FloatBandNode> {
|
||||||
let mut new_band = self.band.clone();
|
let mut new_band = self.band;
|
||||||
if self.band.top >= range.start && self.band.top < range.end {
|
if self.band.top >= range.start && self.band.top < range.end {
|
||||||
match side {
|
match side {
|
||||||
FloatSide::Left => {
|
FloatSide::Left => {
|
||||||
|
@ -742,7 +748,7 @@ impl FloatBandLink {
|
||||||
return Some(band);
|
return Some(band);
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(this.band.clone())
|
Some(this.band)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the first band whose top is strictly greater than the given `block_position`.
|
/// Returns the first band whose top is strictly greater than the given `block_position`.
|
||||||
|
@ -762,7 +768,7 @@ impl FloatBandLink {
|
||||||
return Some(band);
|
return Some(band);
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(this.band.clone())
|
Some(this.band)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts a new band into the tree. If the band has the same level as a pre-existing one,
|
/// Inserts a new band into the tree. If the band has the same level as a pre-existing one,
|
||||||
|
@ -801,11 +807,11 @@ impl FloatBandLink {
|
||||||
return FloatBandLink(Some(Arc::new(FloatBandNode {
|
return FloatBandLink(Some(Arc::new(FloatBandNode {
|
||||||
level: this.level,
|
level: this.level,
|
||||||
left: left.left.clone(),
|
left: left.left.clone(),
|
||||||
band: left.band.clone(),
|
band: left.band,
|
||||||
right: FloatBandLink(Some(Arc::new(FloatBandNode {
|
right: FloatBandLink(Some(Arc::new(FloatBandNode {
|
||||||
level: this.level,
|
level: this.level,
|
||||||
left: left.right.clone(),
|
left: left.right.clone(),
|
||||||
band: this.band.clone(),
|
band: this.band,
|
||||||
right: this.right.clone(),
|
right: this.right.clone(),
|
||||||
}))),
|
}))),
|
||||||
})));
|
})));
|
||||||
|
@ -834,10 +840,10 @@ impl FloatBandLink {
|
||||||
left: FloatBandLink(Some(Arc::new(FloatBandNode {
|
left: FloatBandLink(Some(Arc::new(FloatBandNode {
|
||||||
level: this.level,
|
level: this.level,
|
||||||
left: this.left.clone(),
|
left: this.left.clone(),
|
||||||
band: this.band.clone(),
|
band: this.band,
|
||||||
right: right.left.clone(),
|
right: right.left.clone(),
|
||||||
}))),
|
}))),
|
||||||
band: right.band.clone(),
|
band: right.band,
|
||||||
right: right.right.clone(),
|
right: right.right.clone(),
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
@ -889,7 +895,7 @@ impl FloatBox {
|
||||||
layout_context,
|
layout_context,
|
||||||
containing_block,
|
containing_block,
|
||||||
&style,
|
&style,
|
||||||
|mut positioning_context| {
|
|positioning_context| {
|
||||||
// Margin is computed this way regardless of whether the element is replaced
|
// Margin is computed this way regardless of whether the element is replaced
|
||||||
// or non-replaced.
|
// or non-replaced.
|
||||||
let pbm = style.padding_border_margin(containing_block);
|
let pbm = style.padding_border_margin(containing_block);
|
||||||
|
@ -901,13 +907,13 @@ impl FloatBox {
|
||||||
IndependentFormattingContext::NonReplaced(ref mut non_replaced) => {
|
IndependentFormattingContext::NonReplaced(ref mut non_replaced) => {
|
||||||
// Calculate inline size.
|
// Calculate inline size.
|
||||||
// https://drafts.csswg.org/css2/#float-width
|
// https://drafts.csswg.org/css2/#float-width
|
||||||
let box_size = non_replaced.style.content_box_size(&containing_block, &pbm);
|
let box_size = non_replaced.style.content_box_size(containing_block, &pbm);
|
||||||
let max_box_size = non_replaced
|
let max_box_size = non_replaced
|
||||||
.style
|
.style
|
||||||
.content_max_box_size(&containing_block, &pbm);
|
.content_max_box_size(containing_block, &pbm);
|
||||||
let min_box_size = non_replaced
|
let min_box_size = non_replaced
|
||||||
.style
|
.style
|
||||||
.content_min_box_size(&containing_block, &pbm)
|
.content_min_box_size(containing_block, &pbm)
|
||||||
.auto_is(Length::zero);
|
.auto_is(Length::zero);
|
||||||
|
|
||||||
let tentative_inline_size = box_size.inline.auto_is(|| {
|
let tentative_inline_size = box_size.inline.auto_is(|| {
|
||||||
|
@ -931,7 +937,7 @@ impl FloatBox {
|
||||||
};
|
};
|
||||||
let independent_layout = non_replaced.layout(
|
let independent_layout = non_replaced.layout(
|
||||||
layout_context,
|
layout_context,
|
||||||
&mut positioning_context,
|
positioning_context,
|
||||||
&containing_block_for_children,
|
&containing_block_for_children,
|
||||||
);
|
);
|
||||||
content_size = LogicalVec2 {
|
content_size = LogicalVec2 {
|
||||||
|
@ -946,7 +952,7 @@ impl FloatBox {
|
||||||
// https://drafts.csswg.org/css2/#float-replaced-width
|
// https://drafts.csswg.org/css2/#float-replaced-width
|
||||||
// https://drafts.csswg.org/css2/#inline-replaced-height
|
// https://drafts.csswg.org/css2/#inline-replaced-height
|
||||||
content_size = replaced.contents.used_size_as_if_inline_element(
|
content_size = replaced.contents.used_size_as_if_inline_element(
|
||||||
&containing_block,
|
containing_block,
|
||||||
&replaced.style,
|
&replaced.style,
|
||||||
None,
|
None,
|
||||||
&pbm,
|
&pbm,
|
||||||
|
@ -1060,7 +1066,7 @@ impl SequentialLayoutState {
|
||||||
// Adjoin `current_margin` and `block_start_margin` since there is no clearance.
|
// Adjoin `current_margin` and `block_start_margin` since there is no clearance.
|
||||||
self.bfc_relative_block_position +
|
self.bfc_relative_block_position +
|
||||||
self.current_margin
|
self.current_margin
|
||||||
.adjoin(&block_start_margin)
|
.adjoin(block_start_margin)
|
||||||
.solve()
|
.solve()
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
@ -1088,7 +1094,7 @@ impl SequentialLayoutState {
|
||||||
|
|
||||||
// Calculate the hypothetical position where the element's top border edge
|
// Calculate the hypothetical position where the element's top border edge
|
||||||
// would have been if the element's `clear` property had been `none`.
|
// would have been if the element's `clear` property had been `none`.
|
||||||
let hypothetical_block_position = self.position_without_clearance(&block_start_margin);
|
let hypothetical_block_position = self.position_without_clearance(block_start_margin);
|
||||||
|
|
||||||
// Check if the hypothetical position is past the relevant floats,
|
// Check if the hypothetical position is past the relevant floats,
|
||||||
// in that case we don't need to add clearance.
|
// in that case we don't need to add clearance.
|
||||||
|
@ -1121,9 +1127,8 @@ impl SequentialLayoutState {
|
||||||
clear: Clear,
|
clear: Clear,
|
||||||
block_start_margin: &CollapsedMargin,
|
block_start_margin: &CollapsedMargin,
|
||||||
) -> Option<Au> {
|
) -> Option<Au> {
|
||||||
return self
|
self.calculate_clear_position(clear, block_start_margin)
|
||||||
.calculate_clear_position(clear, &block_start_margin)
|
.map(|offset| offset - self.position_with_zero_clearance(block_start_margin))
|
||||||
.map(|offset| offset - self.position_with_zero_clearance(&block_start_margin));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A block that is replaced or establishes an independent formatting context can't overlap floats,
|
/// A block that is replaced or establishes an independent formatting context can't overlap floats,
|
||||||
|
@ -1144,15 +1149,15 @@ impl SequentialLayoutState {
|
||||||
// First compute the clear position required by the 'clear' property.
|
// First compute the clear position required by the 'clear' property.
|
||||||
// The code below may then add extra clearance when the element can't fit
|
// The code below may then add extra clearance when the element can't fit
|
||||||
// next to floats not covered by 'clear'.
|
// next to floats not covered by 'clear'.
|
||||||
let clear_position = self.calculate_clear_position(clear, &block_start_margin);
|
let clear_position = self.calculate_clear_position(clear, block_start_margin);
|
||||||
let ceiling =
|
let ceiling =
|
||||||
clear_position.unwrap_or_else(|| self.position_without_clearance(&block_start_margin));
|
clear_position.unwrap_or_else(|| self.position_without_clearance(block_start_margin));
|
||||||
let mut placement = PlacementAmongFloats::new(&self.floats, ceiling, object_size, pbm);
|
let mut placement = PlacementAmongFloats::new(&self.floats, ceiling, object_size, pbm);
|
||||||
let placement_rect = placement.place();
|
let placement_rect = placement.place();
|
||||||
let position = &placement_rect.start_corner;
|
let position = &placement_rect.start_corner;
|
||||||
let has_clearance = clear_position.is_some() || position.block > ceiling;
|
let has_clearance = clear_position.is_some() || position.block > ceiling;
|
||||||
let clearance = if has_clearance {
|
let clearance = if has_clearance {
|
||||||
Some(position.block - self.position_with_zero_clearance(&block_start_margin))
|
Some(position.block - self.position_with_zero_clearance(block_start_margin))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
|
@ -149,8 +149,8 @@ struct LineUnderConstruction {
|
||||||
impl LineUnderConstruction {
|
impl LineUnderConstruction {
|
||||||
fn new(start_position: LogicalVec2<Length>) -> Self {
|
fn new(start_position: LogicalVec2<Length>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inline_position: start_position.inline.clone(),
|
inline_position: start_position.inline,
|
||||||
start_position: start_position,
|
start_position,
|
||||||
max_block_size: LineBlockSizes::zero(),
|
max_block_size: LineBlockSizes::zero(),
|
||||||
has_content: false,
|
has_content: false,
|
||||||
has_floats_waiting_to_be_placed: false,
|
has_floats_waiting_to_be_placed: false,
|
||||||
|
@ -273,7 +273,7 @@ impl LineBlockSizes {
|
||||||
self.baseline_relative_size_for_line_height.as_ref(),
|
self.baseline_relative_size_for_line_height.as_ref(),
|
||||||
other.baseline_relative_size_for_line_height.as_ref(),
|
other.baseline_relative_size_for_line_height.as_ref(),
|
||||||
) {
|
) {
|
||||||
(Some(our_size), Some(other_size)) => Some(our_size.max(&other_size)),
|
(Some(our_size), Some(other_size)) => Some(our_size.max(other_size)),
|
||||||
(our_size, other_size) => our_size.or(other_size).cloned(),
|
(our_size, other_size) => our_size.or(other_size).cloned(),
|
||||||
};
|
};
|
||||||
Self {
|
Self {
|
||||||
|
@ -290,9 +290,9 @@ impl LineBlockSizes {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn adjust_for_baseline_offset(&mut self, baseline_offset: Au) {
|
fn adjust_for_baseline_offset(&mut self, baseline_offset: Au) {
|
||||||
self.baseline_relative_size_for_line_height
|
if let Some(size) = self.baseline_relative_size_for_line_height.as_mut() {
|
||||||
.as_mut()
|
size.adjust_for_nested_baseline_offset(baseline_offset)
|
||||||
.map(|size| size.adjust_for_nested_baseline_offset(baseline_offset));
|
}
|
||||||
self.size_for_baseline_positioning
|
self.size_for_baseline_positioning
|
||||||
.adjust_for_nested_baseline_offset(baseline_offset);
|
.adjust_for_nested_baseline_offset(baseline_offset);
|
||||||
}
|
}
|
||||||
|
@ -460,11 +460,7 @@ impl UnbreakableSegmentUnderConstruction {
|
||||||
}
|
}
|
||||||
|
|
||||||
let segment_items = mem::take(&mut self.line_items);
|
let segment_items = mem::take(&mut self.line_items);
|
||||||
self.line_items = hierarchy
|
self.line_items = hierarchy.into_iter().rev().chain(segment_items).collect();
|
||||||
.into_iter()
|
|
||||||
.rev()
|
|
||||||
.chain(segment_items.into_iter())
|
|
||||||
.collect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,7 +633,7 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
||||||
fn start_inline_box(&mut self, inline_box: &InlineBox) {
|
fn start_inline_box(&mut self, inline_box: &InlineBox) {
|
||||||
let mut inline_box_state = InlineBoxContainerState::new(
|
let mut inline_box_state = InlineBoxContainerState::new(
|
||||||
inline_box,
|
inline_box,
|
||||||
&self.containing_block,
|
self.containing_block,
|
||||||
self.layout_context,
|
self.layout_context,
|
||||||
self.current_inline_container_state(),
|
self.current_inline_container_state(),
|
||||||
inline_box.is_last_fragment,
|
inline_box.is_last_fragment,
|
||||||
|
@ -737,7 +733,7 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
||||||
// This amount includes both the block size of the line and any extra space
|
// This amount includes both the block size of the line and any extra space
|
||||||
// added to move the line down in order to avoid overlapping floats.
|
// added to move the line down in order to avoid overlapping floats.
|
||||||
let increment = block_end_position - self.current_line.start_position.block.into();
|
let increment = block_end_position - self.current_line.start_position.block.into();
|
||||||
sequential_layout_state.advance_block_position(increment.into());
|
sequential_layout_state.advance_block_position(increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut line_items = std::mem::take(&mut self.current_line.line_items);
|
let mut line_items = std::mem::take(&mut self.current_line.line_items);
|
||||||
|
@ -758,7 +754,7 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
||||||
parent_offset: LogicalVec2::zero(),
|
parent_offset: LogicalVec2::zero(),
|
||||||
baseline_offset,
|
baseline_offset,
|
||||||
ifc_containing_block: self.containing_block,
|
ifc_containing_block: self.containing_block,
|
||||||
positioning_context: &mut self.positioning_context,
|
positioning_context: self.positioning_context,
|
||||||
justification_adjustment,
|
justification_adjustment,
|
||||||
line_metrics: &LineMetrics {
|
line_metrics: &LineMetrics {
|
||||||
block_offset: block_start_position.into(),
|
block_offset: block_start_position.into(),
|
||||||
|
@ -1002,9 +998,7 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
||||||
.floats
|
.floats
|
||||||
.containing_block_info
|
.containing_block_info
|
||||||
.inline_start,
|
.inline_start,
|
||||||
block: sequential_layout_state
|
block: sequential_layout_state.current_containing_block_offset(),
|
||||||
.current_containing_block_offset()
|
|
||||||
.into(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let ceiling = self
|
let ceiling = self
|
||||||
|
@ -1012,7 +1006,7 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
||||||
.line_block_start_considering_placement_among_floats();
|
.line_block_start_considering_placement_among_floats();
|
||||||
let mut placement = PlacementAmongFloats::new(
|
let mut placement = PlacementAmongFloats::new(
|
||||||
&sequential_layout_state.floats,
|
&sequential_layout_state.floats,
|
||||||
ceiling + ifc_offset_in_float_container.block.into(),
|
ceiling + ifc_offset_in_float_container.block,
|
||||||
LogicalVec2 {
|
LogicalVec2 {
|
||||||
inline: potential_line_size.inline.into(),
|
inline: potential_line_size.inline.into(),
|
||||||
block: potential_line_size.block.into(),
|
block: potential_line_size.block.into(),
|
||||||
|
@ -1154,7 +1148,7 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
||||||
font_key: FontInstanceKey,
|
font_key: FontInstanceKey,
|
||||||
) {
|
) {
|
||||||
self.current_line_segment.justification_opportunities +=
|
self.current_line_segment.justification_opportunities +=
|
||||||
glyph_store.total_word_separators() as usize;
|
glyph_store.total_word_separators();
|
||||||
|
|
||||||
let inline_advance = Length::from(glyph_store.total_advance());
|
let inline_advance = Length::from(glyph_store.total_advance());
|
||||||
let preserve_spaces = parent_style
|
let preserve_spaces = parent_style
|
||||||
|
@ -1194,7 +1188,7 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
||||||
|
|
||||||
self.push_line_item_to_unbreakable_segment(LineItem::TextRun(TextRunLineItem {
|
self.push_line_item_to_unbreakable_segment(LineItem::TextRun(TextRunLineItem {
|
||||||
text: vec![glyph_store],
|
text: vec![glyph_store],
|
||||||
base_fragment_info: base_fragment_info.into(),
|
base_fragment_info,
|
||||||
parent_style: parent_style.clone(),
|
parent_style: parent_style.clone(),
|
||||||
font_metrics: font_metrics.clone(),
|
font_metrics: font_metrics.clone(),
|
||||||
font_key,
|
font_key,
|
||||||
|
@ -1531,12 +1525,12 @@ impl InlineFormattingContext {
|
||||||
content_block_size == Length::zero() &&
|
content_block_size == Length::zero() &&
|
||||||
collapsible_with_parent_start_margin.0;
|
collapsible_with_parent_start_margin.0;
|
||||||
|
|
||||||
return FlowLayout {
|
FlowLayout {
|
||||||
fragments: ifc.fragments,
|
fragments: ifc.fragments,
|
||||||
content_block_size,
|
content_block_size,
|
||||||
collapsible_margins_in_children,
|
collapsible_margins_in_children,
|
||||||
last_inflow_baseline_offset: ifc.last_baseline_offset,
|
last_inflow_baseline_offset: ifc.last_baseline_offset,
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this [InlineFormattingContext] is empty for the purposes of ignoring
|
/// Return true if this [InlineFormattingContext] is empty for the purposes of ignoring
|
||||||
|
@ -1546,7 +1540,7 @@ impl InlineFormattingContext {
|
||||||
fn inline_level_boxes_are_empty(boxes: &[ArcRefCell<InlineLevelBox>]) -> bool {
|
fn inline_level_boxes_are_empty(boxes: &[ArcRefCell<InlineLevelBox>]) -> bool {
|
||||||
boxes
|
boxes
|
||||||
.iter()
|
.iter()
|
||||||
.all(|inline_level_box| inline_level_box_is_empty(&*inline_level_box.borrow()))
|
.all(|inline_level_box| inline_level_box_is_empty(&inline_level_box.borrow()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inline_level_box_is_empty(inline_level_box: &InlineLevelBox) -> bool {
|
fn inline_level_box_is_empty(inline_level_box: &InlineLevelBox) -> bool {
|
||||||
|
@ -1660,8 +1654,8 @@ impl InlineContainerState {
|
||||||
if style.get_inherited_text().line_height != LineHeight::Normal {
|
if style.get_inherited_text().line_height != LineHeight::Normal {
|
||||||
let half_leading =
|
let half_leading =
|
||||||
(Au::from_f32_px(line_height.px()) - (ascent + descent)).scale_by(0.5);
|
(Au::from_f32_px(line_height.px()) - (ascent + descent)).scale_by(0.5);
|
||||||
ascent = ascent + half_leading;
|
ascent += half_leading;
|
||||||
descent = descent + half_leading;
|
descent += half_leading;
|
||||||
}
|
}
|
||||||
|
|
||||||
LineBlockSizes {
|
LineBlockSizes {
|
||||||
|
@ -1675,7 +1669,7 @@ impl InlineContainerState {
|
||||||
Self::get_block_sizes_with_style(
|
Self::get_block_sizes_with_style(
|
||||||
&self.style,
|
&self.style,
|
||||||
font_metrics,
|
font_metrics,
|
||||||
line_height(&self.style, &font_metrics),
|
line_height(&self.style, font_metrics),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1718,9 +1712,8 @@ impl InlineContainerState {
|
||||||
.scale_by(0.5)
|
.scale_by(0.5)
|
||||||
},
|
},
|
||||||
GenericVerticalAlign::Keyword(VerticalAlignKeyword::TextBottom) => {
|
GenericVerticalAlign::Keyword(VerticalAlignKeyword::TextBottom) => {
|
||||||
(self.font_metrics.descent -
|
self.font_metrics.descent -
|
||||||
child_block_size.size_for_baseline_positioning.descent)
|
child_block_size.size_for_baseline_positioning.descent
|
||||||
.into()
|
|
||||||
},
|
},
|
||||||
GenericVerticalAlign::Length(length_percentage) => {
|
GenericVerticalAlign::Length(length_percentage) => {
|
||||||
Au::from_f32_px(-length_percentage.resolve(child_block_size.line_height).px())
|
Au::from_f32_px(-length_percentage.resolve(child_block_size.line_height).px())
|
||||||
|
@ -1778,7 +1771,7 @@ impl IndependentFormattingContext {
|
||||||
ifc: &mut InlineFormattingContextState,
|
ifc: &mut InlineFormattingContextState,
|
||||||
) {
|
) {
|
||||||
let style = self.style();
|
let style = self.style();
|
||||||
let pbm = style.padding_border_margin(&ifc.containing_block);
|
let pbm = style.padding_border_margin(ifc.containing_block);
|
||||||
let margin = pbm.margin.auto_is(Length::zero);
|
let margin = pbm.margin.auto_is(Length::zero);
|
||||||
let pbm_sums = &(&pbm.padding + &pbm.border) + &margin;
|
let pbm_sums = &(&pbm.padding + &pbm.border) + &margin;
|
||||||
let mut child_positioning_context = None;
|
let mut child_positioning_context = None;
|
||||||
|
@ -1816,13 +1809,13 @@ impl IndependentFormattingContext {
|
||||||
IndependentFormattingContext::NonReplaced(non_replaced) => {
|
IndependentFormattingContext::NonReplaced(non_replaced) => {
|
||||||
let box_size = non_replaced
|
let box_size = non_replaced
|
||||||
.style
|
.style
|
||||||
.content_box_size(&ifc.containing_block, &pbm);
|
.content_box_size(ifc.containing_block, &pbm);
|
||||||
let max_box_size = non_replaced
|
let max_box_size = non_replaced
|
||||||
.style
|
.style
|
||||||
.content_max_box_size(&ifc.containing_block, &pbm);
|
.content_max_box_size(ifc.containing_block, &pbm);
|
||||||
let min_box_size = non_replaced
|
let min_box_size = non_replaced
|
||||||
.style
|
.style
|
||||||
.content_min_box_size(&ifc.containing_block, &pbm)
|
.content_min_box_size(ifc.containing_block, &pbm)
|
||||||
.auto_is(Length::zero);
|
.auto_is(Length::zero);
|
||||||
|
|
||||||
// https://drafts.csswg.org/css2/visudet.html#inlineblock-width
|
// https://drafts.csswg.org/css2/visudet.html#inlineblock-width
|
||||||
|
@ -2148,7 +2141,7 @@ impl FloatBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn place_pending_floats(ifc: &mut InlineFormattingContextState, line_items: &mut Vec<LineItem>) {
|
fn place_pending_floats(ifc: &mut InlineFormattingContextState, line_items: &mut Vec<LineItem>) {
|
||||||
for item in line_items.into_iter() {
|
for item in line_items.iter_mut() {
|
||||||
match item {
|
match item {
|
||||||
LineItem::Float(float_line_item) => {
|
LineItem::Float(float_line_item) => {
|
||||||
if float_line_item.needs_placement {
|
if float_line_item.needs_placement {
|
||||||
|
|
|
@ -507,7 +507,7 @@ impl AtomicLineItem {
|
||||||
// This needs to be added to the calculated block and inline positions.
|
// This needs to be added to the calculated block and inline positions.
|
||||||
self.fragment.content_rect.start_corner.inline += state.inline_position;
|
self.fragment.content_rect.start_corner.inline += state.inline_position;
|
||||||
self.fragment.content_rect.start_corner.block +=
|
self.fragment.content_rect.start_corner.block +=
|
||||||
self.calculate_block_start(&state.line_metrics);
|
self.calculate_block_start(state.line_metrics);
|
||||||
|
|
||||||
// Make the final result relative to the parent box.
|
// Make the final result relative to the parent box.
|
||||||
self.fragment.content_rect.start_corner =
|
self.fragment.content_rect.start_corner =
|
||||||
|
|
|
@ -97,7 +97,7 @@ impl BlockLevelBox {
|
||||||
containing_block: &ContainingBlock,
|
containing_block: &ContainingBlock,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let style = match self {
|
let style = match self {
|
||||||
BlockLevelBox::SameFormattingContextBlock { ref style, .. } => &style,
|
BlockLevelBox::SameFormattingContextBlock { ref style, .. } => style,
|
||||||
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(_) |
|
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(_) |
|
||||||
BlockLevelBox::OutOfFlowFloatBox(_) => return true,
|
BlockLevelBox::OutOfFlowFloatBox(_) => return true,
|
||||||
BlockLevelBox::Independent(ref context) => {
|
BlockLevelBox::Independent(ref context) => {
|
||||||
|
@ -156,7 +156,7 @@ impl BlockLevelBox {
|
||||||
};
|
};
|
||||||
|
|
||||||
if !Self::find_block_margin_collapsing_with_parent_from_slice(
|
if !Self::find_block_margin_collapsing_with_parent_from_slice(
|
||||||
&child_boxes,
|
child_boxes,
|
||||||
collected_margin,
|
collected_margin,
|
||||||
&containing_block_for_children,
|
&containing_block_for_children,
|
||||||
) {
|
) {
|
||||||
|
@ -276,7 +276,7 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
||||||
BlockLevelBox::SameFormattingContextBlock {
|
BlockLevelBox::SameFormattingContextBlock {
|
||||||
style, contents, ..
|
style, contents, ..
|
||||||
} => {
|
} => {
|
||||||
let size = sizing::outer_inline(&style, writing_mode, || {
|
let size = sizing::outer_inline(style, writing_mode, || {
|
||||||
contents.inline_content_sizes(layout_context, style.writing_mode)
|
contents.inline_content_sizes(layout_context, style.writing_mode)
|
||||||
})
|
})
|
||||||
.max(ContentSizes::zero());
|
.max(ContentSizes::zero());
|
||||||
|
@ -674,7 +674,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
||||||
if !collapsible_with_parent_start_margin && start_margin_can_collapse_with_children {
|
if !collapsible_with_parent_start_margin && start_margin_can_collapse_with_children {
|
||||||
if let BlockContainer::BlockLevelBoxes(child_boxes) = contents {
|
if let BlockContainer::BlockLevelBoxes(child_boxes) = contents {
|
||||||
BlockLevelBox::find_block_margin_collapsing_with_parent_from_slice(
|
BlockLevelBox::find_block_margin_collapsing_with_parent_from_slice(
|
||||||
&child_boxes,
|
child_boxes,
|
||||||
&mut block_start_margin,
|
&mut block_start_margin,
|
||||||
containing_block,
|
containing_block,
|
||||||
);
|
);
|
||||||
|
@ -729,7 +729,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
||||||
layout_context,
|
layout_context,
|
||||||
positioning_context,
|
positioning_context,
|
||||||
&containing_block_for_children,
|
&containing_block_for_children,
|
||||||
sequential_layout_state.as_mut().map(|x| &mut **x),
|
sequential_layout_state.as_deref_mut(),
|
||||||
CollapsibleWithParentStartMargin(start_margin_can_collapse_with_children),
|
CollapsibleWithParentStartMargin(start_margin_can_collapse_with_children),
|
||||||
);
|
);
|
||||||
let mut content_block_size = flow_layout.content_block_size;
|
let mut content_block_size = flow_layout.content_block_size;
|
||||||
|
@ -798,8 +798,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
||||||
start_corner: LogicalVec2 {
|
start_corner: LogicalVec2 {
|
||||||
block: (pbm.padding.block_start +
|
block: (pbm.padding.block_start +
|
||||||
pbm.border.block_start +
|
pbm.border.block_start +
|
||||||
clearance.unwrap_or_else(Au::zero).into())
|
clearance.unwrap_or_else(Au::zero).into()),
|
||||||
.into(),
|
|
||||||
inline: pbm.padding.inline_start + pbm.border.inline_start + margin.inline_start,
|
inline: pbm.padding.inline_start + pbm.border.inline_start + margin.inline_start,
|
||||||
},
|
},
|
||||||
size: LogicalVec2 {
|
size: LogicalVec2 {
|
||||||
|
@ -965,8 +964,8 @@ impl NonReplacedFormattingContext {
|
||||||
|
|
||||||
(clearance, (margin_inline_start, margin_inline_end)) =
|
(clearance, (margin_inline_start, margin_inline_end)) =
|
||||||
solve_clearance_and_inline_margins_avoiding_floats(
|
solve_clearance_and_inline_margins_avoiding_floats(
|
||||||
&sequential_layout_state,
|
sequential_layout_state,
|
||||||
&containing_block,
|
containing_block,
|
||||||
&collapsed_margin_block_start,
|
&collapsed_margin_block_start,
|
||||||
&pbm,
|
&pbm,
|
||||||
&content_size + &pbm.padding_border_sums,
|
&content_size + &pbm.padding_border_sums,
|
||||||
|
@ -1062,8 +1061,8 @@ impl NonReplacedFormattingContext {
|
||||||
};
|
};
|
||||||
|
|
||||||
(margin_inline_start, margin_inline_end) = solve_inline_margins_avoiding_floats(
|
(margin_inline_start, margin_inline_end) = solve_inline_margins_avoiding_floats(
|
||||||
&sequential_layout_state,
|
sequential_layout_state,
|
||||||
&containing_block,
|
containing_block,
|
||||||
&pbm,
|
&pbm,
|
||||||
content_size.inline + pbm.padding_border_sums.inline,
|
content_size.inline + pbm.padding_border_sums.inline,
|
||||||
placement_rect.into(),
|
placement_rect.into(),
|
||||||
|
@ -1153,12 +1152,12 @@ fn layout_in_flow_replaced_block_level<'a>(
|
||||||
let size = &content_size + &pbm.padding_border_sums;
|
let size = &content_size + &pbm.padding_border_sums;
|
||||||
(clearance, (margin_inline_start, margin_inline_end)) =
|
(clearance, (margin_inline_start, margin_inline_end)) =
|
||||||
solve_clearance_and_inline_margins_avoiding_floats(
|
solve_clearance_and_inline_margins_avoiding_floats(
|
||||||
&sequential_layout_state,
|
sequential_layout_state,
|
||||||
&containing_block,
|
containing_block,
|
||||||
&collapsed_margin_block_start,
|
&collapsed_margin_block_start,
|
||||||
&pbm,
|
&pbm,
|
||||||
size.clone(),
|
size.clone(),
|
||||||
&style,
|
style,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Clearance prevents margin collapse between this block and previous ones,
|
// Clearance prevents margin collapse between this block and previous ones,
|
||||||
|
@ -1305,14 +1304,14 @@ fn solve_clearance_and_inline_margins_avoiding_floats(
|
||||||
let (clearance, placement_rect) = sequential_layout_state
|
let (clearance, placement_rect) = sequential_layout_state
|
||||||
.calculate_clearance_and_inline_adjustment(
|
.calculate_clearance_and_inline_adjustment(
|
||||||
style.get_box().clear,
|
style.get_box().clear,
|
||||||
&block_start_margin,
|
block_start_margin,
|
||||||
&pbm,
|
pbm,
|
||||||
size.clone().into(),
|
size.clone().into(),
|
||||||
);
|
);
|
||||||
let inline_margins = solve_inline_margins_avoiding_floats(
|
let inline_margins = solve_inline_margins_avoiding_floats(
|
||||||
&sequential_layout_state,
|
sequential_layout_state,
|
||||||
&containing_block,
|
containing_block,
|
||||||
&pbm,
|
pbm,
|
||||||
size.inline,
|
size.inline,
|
||||||
placement_rect.into(),
|
placement_rect.into(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl BoxTree {
|
||||||
where
|
where
|
||||||
Node: 'dom + Copy + LayoutNode<'dom> + Send + Sync,
|
Node: 'dom + Copy + LayoutNode<'dom> + Send + Sync,
|
||||||
{
|
{
|
||||||
let boxes = construct_for_root_element(&context, root_element);
|
let boxes = construct_for_root_element(context, root_element);
|
||||||
|
|
||||||
// Zero box for `:root { display: none }`, one for the root element otherwise.
|
// Zero box for `:root { display: none }`, one for the root element otherwise.
|
||||||
assert!(boxes.len() <= 1);
|
assert!(boxes.len() <= 1);
|
||||||
|
@ -291,7 +291,7 @@ impl BoxTree {
|
||||||
let mut root_fragments = independent_layout
|
let mut root_fragments = independent_layout
|
||||||
.fragments
|
.fragments
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|fragment| ArcRefCell::new(fragment))
|
.map(ArcRefCell::new)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
// Zero box for `:root { display: none }`, one for the root element otherwise.
|
// Zero box for `:root { display: none }`, one for the root element otherwise.
|
||||||
|
|
|
@ -174,7 +174,7 @@ impl IndependentFormattingContext {
|
||||||
let style = &non_replaced.style;
|
let style = &non_replaced.style;
|
||||||
let content_sizes = &mut non_replaced.content_sizes;
|
let content_sizes = &mut non_replaced.content_sizes;
|
||||||
let contents = &mut non_replaced.contents;
|
let contents = &mut non_replaced.contents;
|
||||||
sizing::outer_inline(&style, containing_block_writing_mode, || {
|
sizing::outer_inline(style, containing_block_writing_mode, || {
|
||||||
content_sizes
|
content_sizes
|
||||||
.get_or_insert_with(|| {
|
.get_or_insert_with(|| {
|
||||||
contents.inline_content_sizes(layout_context, style.writing_mode)
|
contents.inline_content_sizes(layout_context, style.writing_mode)
|
||||||
|
|
|
@ -114,6 +114,6 @@ impl Tag {
|
||||||
Some(PseudoElement::After) => FragmentType::AfterPseudoContent,
|
Some(PseudoElement::After) => FragmentType::AfterPseudoContent,
|
||||||
_ => FragmentType::FragmentBody,
|
_ => FragmentType::FragmentBody,
|
||||||
};
|
};
|
||||||
combine_id_with_fragment_type(self.node.id() as usize, fragment_type) as u64
|
combine_id_with_fragment_type(self.node.id(), fragment_type) as u64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,10 +135,7 @@ impl BoxFragment {
|
||||||
BoxFragment {
|
BoxFragment {
|
||||||
base: base_fragment_info.into(),
|
base: base_fragment_info.into(),
|
||||||
style,
|
style,
|
||||||
children: children
|
children: children.into_iter().map(ArcRefCell::new).collect(),
|
||||||
.into_iter()
|
|
||||||
.map(|fragment| ArcRefCell::new(fragment))
|
|
||||||
.collect(),
|
|
||||||
content_rect,
|
content_rect,
|
||||||
padding,
|
padding,
|
||||||
border,
|
border,
|
||||||
|
@ -221,7 +218,7 @@ impl BoxFragment {
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-overflow-3/#scrollable
|
// https://www.w3.org/TR/css-overflow-3/#scrollable
|
||||||
// Only include the scrollable overflow of a child box if it has overflow: visible.
|
// Only include the scrollable overflow of a child box if it has overflow: visible.
|
||||||
let scrollable_overflow = self.scrollable_overflow(&containing_block);
|
let scrollable_overflow = self.scrollable_overflow(containing_block);
|
||||||
let bottom_right = PhysicalPoint::new(
|
let bottom_right = PhysicalPoint::new(
|
||||||
overflow.max_x().max(scrollable_overflow.max_x()),
|
overflow.max_x().max(scrollable_overflow.max_x()),
|
||||||
overflow.max_y().max(scrollable_overflow.max_y()),
|
overflow.max_y().max(scrollable_overflow.max_y()),
|
||||||
|
@ -254,7 +251,7 @@ impl BoxFragment {
|
||||||
let (cb_width, cb_height) = (containing_block.width(), containing_block.height());
|
let (cb_width, cb_height) = (containing_block.width(), containing_block.height());
|
||||||
let content_rect = self
|
let content_rect = self
|
||||||
.content_rect
|
.content_rect
|
||||||
.to_physical(self.style.writing_mode, &containing_block);
|
.to_physical(self.style.writing_mode, containing_block);
|
||||||
|
|
||||||
if let Some(resolved_sticky_insets) = self.resolved_sticky_insets {
|
if let Some(resolved_sticky_insets) = self.resolved_sticky_insets {
|
||||||
return resolved_sticky_insets;
|
return resolved_sticky_insets;
|
||||||
|
|
|
@ -67,11 +67,11 @@ impl<'a, T> ContainingBlockManager<'a, T> {
|
||||||
&self,
|
&self,
|
||||||
for_non_absolute_descendants: &'a T,
|
for_non_absolute_descendants: &'a T,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
return ContainingBlockManager {
|
ContainingBlockManager {
|
||||||
for_non_absolute_descendants,
|
for_non_absolute_descendants,
|
||||||
for_absolute_descendants: self.for_absolute_descendants,
|
for_absolute_descendants: self.for_absolute_descendants,
|
||||||
for_absolute_and_fixed_descendants: self.for_absolute_and_fixed_descendants,
|
for_absolute_and_fixed_descendants: self.for_absolute_and_fixed_descendants,
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn new_for_absolute_descendants(
|
pub(crate) fn new_for_absolute_descendants(
|
||||||
|
@ -79,11 +79,11 @@ impl<'a, T> ContainingBlockManager<'a, T> {
|
||||||
for_non_absolute_descendants: &'a T,
|
for_non_absolute_descendants: &'a T,
|
||||||
for_absolute_descendants: &'a T,
|
for_absolute_descendants: &'a T,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
return ContainingBlockManager {
|
ContainingBlockManager {
|
||||||
for_non_absolute_descendants,
|
for_non_absolute_descendants,
|
||||||
for_absolute_descendants: Some(for_absolute_descendants),
|
for_absolute_descendants: Some(for_absolute_descendants),
|
||||||
for_absolute_and_fixed_descendants: self.for_absolute_and_fixed_descendants,
|
for_absolute_and_fixed_descendants: self.for_absolute_and_fixed_descendants,
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn new_for_absolute_and_fixed_descendants(
|
pub(crate) fn new_for_absolute_and_fixed_descendants(
|
||||||
|
@ -91,10 +91,10 @@ impl<'a, T> ContainingBlockManager<'a, T> {
|
||||||
for_non_absolute_descendants: &'a T,
|
for_non_absolute_descendants: &'a T,
|
||||||
for_absolute_and_fixed_descendants: &'a T,
|
for_absolute_and_fixed_descendants: &'a T,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
return ContainingBlockManager {
|
ContainingBlockManager {
|
||||||
for_non_absolute_descendants,
|
for_non_absolute_descendants,
|
||||||
for_absolute_descendants: None,
|
for_absolute_descendants: None,
|
||||||
for_absolute_and_fixed_descendants,
|
for_absolute_and_fixed_descendants,
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ impl Fragment {
|
||||||
match self {
|
match self {
|
||||||
Fragment::Box(fragment) => fragment.print(tree),
|
Fragment::Box(fragment) => fragment.print(tree),
|
||||||
Fragment::Float(fragment) => {
|
Fragment::Float(fragment) => {
|
||||||
tree.new_level(format!("Float"));
|
tree.new_level("Float".to_string());
|
||||||
fragment.print(tree);
|
fragment.print(tree);
|
||||||
tree.end_level();
|
tree.end_level();
|
||||||
},
|
},
|
||||||
|
@ -163,19 +163,19 @@ impl Fragment {
|
||||||
) -> PhysicalRect<Length> {
|
) -> PhysicalRect<Length> {
|
||||||
match self {
|
match self {
|
||||||
Fragment::Box(fragment) | Fragment::Float(fragment) => {
|
Fragment::Box(fragment) | Fragment::Float(fragment) => {
|
||||||
fragment.scrollable_overflow_for_parent(&containing_block)
|
fragment.scrollable_overflow_for_parent(containing_block)
|
||||||
},
|
},
|
||||||
Fragment::AbsoluteOrFixedPositioned(_) => PhysicalRect::zero(),
|
Fragment::AbsoluteOrFixedPositioned(_) => PhysicalRect::zero(),
|
||||||
Fragment::Anonymous(fragment) => fragment.scrollable_overflow.clone(),
|
Fragment::Anonymous(fragment) => fragment.scrollable_overflow,
|
||||||
Fragment::Text(fragment) => fragment
|
Fragment::Text(fragment) => fragment
|
||||||
.rect
|
.rect
|
||||||
.to_physical(fragment.parent_style.writing_mode, &containing_block),
|
.to_physical(fragment.parent_style.writing_mode, containing_block),
|
||||||
Fragment::Image(fragment) => fragment
|
Fragment::Image(fragment) => fragment
|
||||||
.rect
|
.rect
|
||||||
.to_physical(fragment.style.writing_mode, &containing_block),
|
.to_physical(fragment.style.writing_mode, containing_block),
|
||||||
Fragment::IFrame(fragment) => fragment
|
Fragment::IFrame(fragment) => fragment
|
||||||
.rect
|
.rect
|
||||||
.to_physical(fragment.style.writing_mode, &containing_block),
|
.to_physical(fragment.style.writing_mode, containing_block),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,10 +251,7 @@ impl AnonymousFragment {
|
||||||
AnonymousFragment {
|
AnonymousFragment {
|
||||||
base: BaseFragment::anonymous(),
|
base: BaseFragment::anonymous(),
|
||||||
rect,
|
rect,
|
||||||
children: children
|
children: children.into_iter().map(ArcRefCell::new).collect(),
|
||||||
.into_iter()
|
|
||||||
.map(|fragment| ArcRefCell::new(fragment))
|
|
||||||
.collect(),
|
|
||||||
mode,
|
mode,
|
||||||
scrollable_overflow,
|
scrollable_overflow,
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,10 +104,10 @@ impl FragmentTree {
|
||||||
let fragment_relative_rect = match fragment {
|
let fragment_relative_rect = match fragment {
|
||||||
Fragment::Box(fragment) | Fragment::Float(fragment) => fragment
|
Fragment::Box(fragment) | Fragment::Float(fragment) => fragment
|
||||||
.border_rect()
|
.border_rect()
|
||||||
.to_physical(fragment.style.writing_mode, &containing_block),
|
.to_physical(fragment.style.writing_mode, containing_block),
|
||||||
Fragment::Text(fragment) => fragment
|
Fragment::Text(fragment) => fragment
|
||||||
.rect
|
.rect
|
||||||
.to_physical(fragment.parent_style.writing_mode, &containing_block),
|
.to_physical(fragment.parent_style.writing_mode, containing_block),
|
||||||
Fragment::AbsoluteOrFixedPositioned(_) |
|
Fragment::AbsoluteOrFixedPositioned(_) |
|
||||||
Fragment::Image(_) |
|
Fragment::Image(_) |
|
||||||
Fragment::IFrame(_) |
|
Fragment::IFrame(_) |
|
||||||
|
@ -156,7 +156,7 @@ impl FragmentTree {
|
||||||
return Some(Rect::zero());
|
return Some(Rect::zero());
|
||||||
}
|
}
|
||||||
|
|
||||||
let padding_rect = padding_rect.to_physical(style.writing_mode, &containing_block);
|
let padding_rect = padding_rect.to_physical(style.writing_mode, containing_block);
|
||||||
let border = style.get_border();
|
let border = style.get_border();
|
||||||
Some(Rect::new(
|
Some(Rect::new(
|
||||||
Point2D::new(
|
Point2D::new(
|
||||||
|
@ -187,7 +187,7 @@ impl FragmentTree {
|
||||||
let tag_to_find = Tag::new(requested_node);
|
let tag_to_find = Tag::new(requested_node);
|
||||||
let scroll_area = self.find(|fragment, _, containing_block| {
|
let scroll_area = self.find(|fragment, _, containing_block| {
|
||||||
if fragment.tag() == Some(tag_to_find) {
|
if fragment.tag() == Some(tag_to_find) {
|
||||||
Some(fragment.scrolling_area(&containing_block))
|
Some(fragment.scrolling_area(containing_block))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,8 +57,8 @@ pub(crate) enum AbsoluteBoxOffsets {
|
||||||
impl AbsoluteBoxOffsets {
|
impl AbsoluteBoxOffsets {
|
||||||
pub(crate) fn both_specified(&self) -> bool {
|
pub(crate) fn both_specified(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
AbsoluteBoxOffsets::Both { .. } => return true,
|
AbsoluteBoxOffsets::Both { .. } => true,
|
||||||
_ => return false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ struct ScopeData {
|
||||||
name: String,
|
name: String,
|
||||||
pre: TreeValues,
|
pre: TreeValues,
|
||||||
post: TreeValues,
|
post: TreeValues,
|
||||||
children: Vec<Box<ScopeData>>,
|
children: Vec<ScopeData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ScopeData {
|
impl ScopeData {
|
||||||
|
@ -71,19 +71,19 @@ impl ScopeData {
|
||||||
struct State {
|
struct State {
|
||||||
fragment_tree: Arc<FragmentTree>,
|
fragment_tree: Arc<FragmentTree>,
|
||||||
box_tree: Arc<BoxTree>,
|
box_tree: Arc<BoxTree>,
|
||||||
scope_stack: Vec<Box<ScopeData>>,
|
scope_stack: Vec<ScopeData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A layout debugging scope. The entire state of the box and fragment trees
|
/// A layout debugging scope. The entire state of the box and fragment trees
|
||||||
/// will be output at the beginning and end of this scope.
|
/// will be output at the beginning and end of this scope.
|
||||||
impl Scope {
|
impl Scope {
|
||||||
pub fn new(name: String) -> Scope {
|
pub fn new(name: String) -> Scope {
|
||||||
STATE_KEY.with(|ref r| {
|
STATE_KEY.with(|r| {
|
||||||
if let Some(ref mut state) = *r.borrow_mut() {
|
if let Some(ref mut state) = *r.borrow_mut() {
|
||||||
let box_tree = to_value(&state.box_tree).unwrap();
|
let box_tree = to_value(&state.box_tree).unwrap();
|
||||||
let fragment_tree = to_value(&state.fragment_tree).unwrap();
|
let fragment_tree = to_value(&state.fragment_tree).unwrap();
|
||||||
let data = Box::new(ScopeData::new(name.clone(), box_tree, fragment_tree));
|
let data = Box::new(ScopeData::new(name.clone(), box_tree, fragment_tree));
|
||||||
state.scope_stack.push(data);
|
state.scope_stack.push(*data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Scope
|
Scope
|
||||||
|
@ -93,7 +93,7 @@ impl Scope {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
impl Drop for Scope {
|
impl Drop for Scope {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
STATE_KEY.with(|ref r| {
|
STATE_KEY.with(|r| {
|
||||||
if let Some(ref mut state) = *r.borrow_mut() {
|
if let Some(ref mut state) = *r.borrow_mut() {
|
||||||
let mut current_scope = state.scope_stack.pop().unwrap();
|
let mut current_scope = state.scope_stack.pop().unwrap();
|
||||||
current_scope.post = TreeValues {
|
current_scope.post = TreeValues {
|
||||||
|
@ -110,13 +110,13 @@ impl Drop for Scope {
|
||||||
/// Begin a layout debug trace. If this has not been called,
|
/// Begin a layout debug trace. If this has not been called,
|
||||||
/// creating debug scopes has no effect.
|
/// creating debug scopes has no effect.
|
||||||
pub fn begin_trace(box_tree: Arc<BoxTree>, fragment_tree: Arc<FragmentTree>) {
|
pub fn begin_trace(box_tree: Arc<BoxTree>, fragment_tree: Arc<FragmentTree>) {
|
||||||
assert!(STATE_KEY.with(|ref r| r.borrow().is_none()));
|
assert!(STATE_KEY.with(|r| r.borrow().is_none()));
|
||||||
|
|
||||||
STATE_KEY.with(|ref r| {
|
STATE_KEY.with(|r| {
|
||||||
let box_tree_value = to_value(&box_tree).unwrap();
|
let box_tree_value = to_value(&box_tree).unwrap();
|
||||||
let fragment_tree_value = to_value(&fragment_tree).unwrap();
|
let fragment_tree_value = to_value(&fragment_tree).unwrap();
|
||||||
let state = State {
|
let state = State {
|
||||||
scope_stack: vec![Box::new(ScopeData::new(
|
scope_stack: vec![*Box::new(ScopeData::new(
|
||||||
"root".to_owned(),
|
"root".to_owned(),
|
||||||
box_tree_value,
|
box_tree_value,
|
||||||
fragment_tree_value,
|
fragment_tree_value,
|
||||||
|
@ -132,7 +132,7 @@ pub fn begin_trace(box_tree: Arc<BoxTree>, fragment_tree: Arc<FragmentTree>) {
|
||||||
/// trace to disk in the current directory. The output
|
/// trace to disk in the current directory. The output
|
||||||
/// file can then be viewed with an external tool.
|
/// file can then be viewed with an external tool.
|
||||||
pub fn end_trace(generation: u32) {
|
pub fn end_trace(generation: u32) {
|
||||||
let mut thread_state = STATE_KEY.with(|ref r| r.borrow_mut().take().unwrap());
|
let mut thread_state = STATE_KEY.with(|r| r.borrow_mut().take().unwrap());
|
||||||
assert_eq!(thread_state.scope_stack.len(), 1);
|
assert_eq!(thread_state.scope_stack.len(), 1);
|
||||||
let mut root_scope = thread_state.scope_stack.pop().unwrap();
|
let mut root_scope = thread_state.scope_stack.pop().unwrap();
|
||||||
root_scope.post = TreeValues {
|
root_scope.post = TreeValues {
|
||||||
|
@ -170,6 +170,12 @@ impl DebugId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for DebugId {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
impl Serialize for DebugId {
|
impl Serialize for DebugId {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
|
|
|
@ -195,14 +195,12 @@ impl PositioningContext {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.for_nearest_positioned_ancestor
|
if let Some(hoisted_boxes) = self.for_nearest_positioned_ancestor.as_mut() {
|
||||||
.as_mut()
|
hoisted_boxes
|
||||||
.map(|hoisted_boxes| {
|
.iter_mut()
|
||||||
hoisted_boxes
|
.skip(index.for_nearest_positioned_ancestor)
|
||||||
.iter_mut()
|
.for_each(update_fragment_if_needed);
|
||||||
.skip(index.for_nearest_positioned_ancestor)
|
}
|
||||||
.for_each(update_fragment_if_needed);
|
|
||||||
});
|
|
||||||
self.for_nearest_containing_block_for_all_descendants
|
self.for_nearest_containing_block_for_all_descendants
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.skip(index.for_nearest_containing_block_for_all_descendants)
|
.skip(index.for_nearest_containing_block_for_all_descendants)
|
||||||
|
@ -367,9 +365,9 @@ impl PositioningContext {
|
||||||
pub(crate) fn clear(&mut self) {
|
pub(crate) fn clear(&mut self) {
|
||||||
self.for_nearest_containing_block_for_all_descendants
|
self.for_nearest_containing_block_for_all_descendants
|
||||||
.clear();
|
.clear();
|
||||||
self.for_nearest_positioned_ancestor
|
if let Some(v) = self.for_nearest_positioned_ancestor.as_mut() {
|
||||||
.as_mut()
|
v.clear()
|
||||||
.map(|v| v.clear());
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the length of this [PositioningContext].
|
/// Get the length of this [PositioningContext].
|
||||||
|
@ -546,7 +544,7 @@ impl HoistedAbsolutelyPositionedBox {
|
||||||
let min_size = non_replaced
|
let min_size = non_replaced
|
||||||
.style
|
.style
|
||||||
.content_min_box_size(&containing_block.into(), &pbm)
|
.content_min_box_size(&containing_block.into(), &pbm)
|
||||||
.auto_is(|| Length::zero());
|
.auto_is(Length::zero);
|
||||||
let max_size = non_replaced
|
let max_size = non_replaced
|
||||||
.style
|
.style
|
||||||
.content_max_box_size(&containing_block.into(), &pbm);
|
.content_max_box_size(&containing_block.into(), &pbm);
|
||||||
|
|
|
@ -89,26 +89,26 @@ impl LayoutRPC for LayoutRPCImpl {
|
||||||
// The neat thing here is that in order to answer the following two queries we only
|
// The neat thing here is that in order to answer the following two queries we only
|
||||||
// need to compare nodes for equality. Thus we can safely work only with `OpaqueNode`.
|
// need to compare nodes for equality. Thus we can safely work only with `OpaqueNode`.
|
||||||
fn content_box(&self) -> ContentBoxResponse {
|
fn content_box(&self) -> ContentBoxResponse {
|
||||||
let &LayoutRPCImpl(ref rw_data) = self;
|
let LayoutRPCImpl(rw_data) = self;
|
||||||
let rw_data = rw_data.lock().unwrap();
|
let rw_data = rw_data.lock().unwrap();
|
||||||
ContentBoxResponse(rw_data.content_box_response)
|
ContentBoxResponse(rw_data.content_box_response)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Requests the dimensions of all the content boxes, as in the `getClientRects()` call.
|
/// Requests the dimensions of all the content boxes, as in the `getClientRects()` call.
|
||||||
fn content_boxes(&self) -> ContentBoxesResponse {
|
fn content_boxes(&self) -> ContentBoxesResponse {
|
||||||
let &LayoutRPCImpl(ref rw_data) = self;
|
let LayoutRPCImpl(rw_data) = self;
|
||||||
let rw_data = rw_data.lock().unwrap();
|
let rw_data = rw_data.lock().unwrap();
|
||||||
ContentBoxesResponse(rw_data.content_boxes_response.clone())
|
ContentBoxesResponse(rw_data.content_boxes_response.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nodes_from_point_response(&self) -> Vec<UntrustedNodeAddress> {
|
fn nodes_from_point_response(&self) -> Vec<UntrustedNodeAddress> {
|
||||||
let &LayoutRPCImpl(ref rw_data) = self;
|
let LayoutRPCImpl(rw_data) = self;
|
||||||
let rw_data = rw_data.lock().unwrap();
|
let rw_data = rw_data.lock().unwrap();
|
||||||
rw_data.nodes_from_point_response.clone()
|
rw_data.nodes_from_point_response.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_geometry(&self) -> NodeGeometryResponse {
|
fn node_geometry(&self) -> NodeGeometryResponse {
|
||||||
let &LayoutRPCImpl(ref rw_data) = self;
|
let LayoutRPCImpl(rw_data) = self;
|
||||||
let rw_data = rw_data.lock().unwrap();
|
let rw_data = rw_data.lock().unwrap();
|
||||||
NodeGeometryResponse {
|
NodeGeometryResponse {
|
||||||
client_rect: rw_data.client_rect_response,
|
client_rect: rw_data.client_rect_response,
|
||||||
|
@ -133,39 +133,39 @@ impl LayoutRPC for LayoutRPCImpl {
|
||||||
|
|
||||||
/// Retrieves the resolved value for a CSS style property.
|
/// Retrieves the resolved value for a CSS style property.
|
||||||
fn resolved_style(&self) -> ResolvedStyleResponse {
|
fn resolved_style(&self) -> ResolvedStyleResponse {
|
||||||
let &LayoutRPCImpl(ref rw_data) = self;
|
let LayoutRPCImpl(rw_data) = self;
|
||||||
let rw_data = rw_data.lock().unwrap();
|
let rw_data = rw_data.lock().unwrap();
|
||||||
ResolvedStyleResponse(rw_data.resolved_style_response.clone())
|
ResolvedStyleResponse(rw_data.resolved_style_response.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolved_font_style(&self) -> Option<ServoArc<Font>> {
|
fn resolved_font_style(&self) -> Option<ServoArc<Font>> {
|
||||||
let &LayoutRPCImpl(ref rw_data) = self;
|
let LayoutRPCImpl(rw_data) = self;
|
||||||
let rw_data = rw_data.lock().unwrap();
|
let rw_data = rw_data.lock().unwrap();
|
||||||
rw_data.resolved_font_style_response.clone()
|
rw_data.resolved_font_style_response.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn offset_parent(&self) -> OffsetParentResponse {
|
fn offset_parent(&self) -> OffsetParentResponse {
|
||||||
let &LayoutRPCImpl(ref rw_data) = self;
|
let LayoutRPCImpl(rw_data) = self;
|
||||||
let rw_data = rw_data.lock().unwrap();
|
let rw_data = rw_data.lock().unwrap();
|
||||||
rw_data.offset_parent_response.clone()
|
rw_data.offset_parent_response.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn text_index(&self) -> TextIndexResponse {
|
fn text_index(&self) -> TextIndexResponse {
|
||||||
let &LayoutRPCImpl(ref rw_data) = self;
|
let LayoutRPCImpl(rw_data) = self;
|
||||||
let rw_data = rw_data.lock().unwrap();
|
let rw_data = rw_data.lock().unwrap();
|
||||||
rw_data.text_index_response.clone()
|
rw_data.text_index_response.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn element_inner_text(&self) -> String {
|
fn element_inner_text(&self) -> String {
|
||||||
let &LayoutRPCImpl(ref rw_data) = self;
|
let LayoutRPCImpl(rw_data) = self;
|
||||||
let rw_data = rw_data.lock().unwrap();
|
let rw_data = rw_data.lock().unwrap();
|
||||||
rw_data.element_inner_text_response.clone()
|
rw_data.element_inner_text_response.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inner_window_dimensions(&self) -> Option<Size2D<f32, CSSPixel>> {
|
fn inner_window_dimensions(&self) -> Option<Size2D<f32, CSSPixel>> {
|
||||||
let &LayoutRPCImpl(ref rw_data) = self;
|
let LayoutRPCImpl(rw_data) = self;
|
||||||
let rw_data = rw_data.lock().unwrap();
|
let rw_data = rw_data.lock().unwrap();
|
||||||
rw_data.inner_window_dimensions_response.clone()
|
rw_data.inner_window_dimensions_response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ pub fn process_resolved_style_request<'dom>(
|
||||||
|
|
||||||
let content_rect = box_fragment
|
let content_rect = box_fragment
|
||||||
.content_rect
|
.content_rect
|
||||||
.to_physical(box_fragment.style.writing_mode, &containing_block);
|
.to_physical(box_fragment.style.writing_mode, containing_block);
|
||||||
let margins = box_fragment
|
let margins = box_fragment
|
||||||
.margin
|
.margin
|
||||||
.to_physical(box_fragment.style.writing_mode);
|
.to_physical(box_fragment.style.writing_mode);
|
||||||
|
@ -436,10 +436,10 @@ fn process_offset_parent_query_inner(
|
||||||
let fragment_relative_rect = match fragment {
|
let fragment_relative_rect = match fragment {
|
||||||
Fragment::Box(fragment) | Fragment::Float(fragment) => fragment
|
Fragment::Box(fragment) | Fragment::Float(fragment) => fragment
|
||||||
.border_rect()
|
.border_rect()
|
||||||
.to_physical(fragment.style.writing_mode, &containing_block),
|
.to_physical(fragment.style.writing_mode, containing_block),
|
||||||
Fragment::Text(fragment) => fragment
|
Fragment::Text(fragment) => fragment
|
||||||
.rect
|
.rect
|
||||||
.to_physical(fragment.parent_style.writing_mode, &containing_block),
|
.to_physical(fragment.parent_style.writing_mode, containing_block),
|
||||||
Fragment::AbsoluteOrFixedPositioned(_) |
|
Fragment::AbsoluteOrFixedPositioned(_) |
|
||||||
Fragment::Image(_) |
|
Fragment::Image(_) |
|
||||||
Fragment::IFrame(_) |
|
Fragment::IFrame(_) |
|
||||||
|
@ -555,7 +555,7 @@ fn process_offset_parent_query_inner(
|
||||||
// Again, take the *first* associated CSS layout box.
|
// Again, take the *first* associated CSS layout box.
|
||||||
let padding_box_corner = fragment
|
let padding_box_corner = fragment
|
||||||
.padding_rect()
|
.padding_rect()
|
||||||
.to_physical(fragment.style.writing_mode, &containing_block)
|
.to_physical(fragment.style.writing_mode, containing_block)
|
||||||
.origin
|
.origin
|
||||||
.to_vector() +
|
.to_vector() +
|
||||||
containing_block.origin.to_vector();
|
containing_block.origin.to_vector();
|
||||||
|
|
|
@ -150,9 +150,8 @@ impl ReplacedContent {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let intrinsic = intrinsic_size_in_dots.map_or_else(
|
let intrinsic =
|
||||||
|| IntrinsicSizes::empty(),
|
intrinsic_size_in_dots.map_or_else(IntrinsicSizes::empty, |intrinsic_size_in_dots| {
|
||||||
|intrinsic_size_in_dots| {
|
|
||||||
// FIXME: should 'image-resolution' (when implemented) be used *instead* of
|
// FIXME: should 'image-resolution' (when implemented) be used *instead* of
|
||||||
// `script::dom::htmlimageelement::ImageRequest::current_pixel_density`?
|
// `script::dom::htmlimageelement::ImageRequest::current_pixel_density`?
|
||||||
// https://drafts.csswg.org/css-images-4/#the-image-resolution
|
// https://drafts.csswg.org/css-images-4/#the-image-resolution
|
||||||
|
@ -160,15 +159,14 @@ impl ReplacedContent {
|
||||||
let width = (intrinsic_size_in_dots.width as CSSFloat) / dppx;
|
let width = (intrinsic_size_in_dots.width as CSSFloat) / dppx;
|
||||||
let height = (intrinsic_size_in_dots.height as CSSFloat) / dppx;
|
let height = (intrinsic_size_in_dots.height as CSSFloat) / dppx;
|
||||||
IntrinsicSizes::from_width_and_height(width, height)
|
IntrinsicSizes::from_width_and_height(width, height)
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
let base_fragment_info = BaseFragmentInfo::new_for_node(element.opaque());
|
let base_fragment_info = BaseFragmentInfo::new_for_node(element.opaque());
|
||||||
return Some(Self {
|
Some(Self {
|
||||||
kind,
|
kind,
|
||||||
intrinsic,
|
intrinsic,
|
||||||
base_fragment_info,
|
base_fragment_info,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_image_url<'dom>(
|
pub fn from_image_url<'dom>(
|
||||||
|
@ -246,8 +244,8 @@ impl ReplacedContent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_fragments<'a>(
|
pub fn make_fragments(
|
||||||
&'a self,
|
&self,
|
||||||
style: &ServoArc<ComputedValues>,
|
style: &ServoArc<ComputedValues>,
|
||||||
size: LogicalVec2<Length>,
|
size: LogicalVec2<Length>,
|
||||||
) -> Vec<Fragment> {
|
) -> Vec<Fragment> {
|
||||||
|
@ -334,10 +332,10 @@ impl ReplacedContent {
|
||||||
let intrinsic_size = self.flow_relative_intrinsic_size(style);
|
let intrinsic_size = self.flow_relative_intrinsic_size(style);
|
||||||
let intrinsic_ratio = self.inline_size_over_block_size_intrinsic_ratio(style);
|
let intrinsic_ratio = self.inline_size_over_block_size_intrinsic_ratio(style);
|
||||||
|
|
||||||
let box_size = box_size.unwrap_or(style.content_box_size(containing_block, &pbm));
|
let box_size = box_size.unwrap_or(style.content_box_size(containing_block, pbm));
|
||||||
let max_box_size = style.content_max_box_size(containing_block, &pbm);
|
let max_box_size = style.content_max_box_size(containing_block, pbm);
|
||||||
let min_box_size = style
|
let min_box_size = style
|
||||||
.content_min_box_size(containing_block, &pbm)
|
.content_min_box_size(containing_block, pbm)
|
||||||
.auto_is(Length::zero);
|
.auto_is(Length::zero);
|
||||||
|
|
||||||
let default_object_size = || {
|
let default_object_size = || {
|
||||||
|
|
|
@ -113,14 +113,14 @@ pub(crate) fn outer_inline(
|
||||||
BoxSizing::BorderBox => clamped,
|
BoxSizing::BorderBox => clamped,
|
||||||
};
|
};
|
||||||
ContentSizes {
|
ContentSizes {
|
||||||
min_content: border_box_size.into(),
|
min_content: border_box_size,
|
||||||
max_content: border_box_size.into(),
|
max_content: border_box_size,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => get_content_size().map(|content_box_size| {
|
None => get_content_size().map(|content_box_size| {
|
||||||
match box_sizing {
|
match box_sizing {
|
||||||
// Clamp to 'min-width' and 'max-width', which are sizing the…
|
// Clamp to 'min-width' and 'max-width', which are sizing the…
|
||||||
BoxSizing::ContentBox => clamp(content_box_size.into()) + pb_lengths.into(),
|
BoxSizing::ContentBox => clamp(content_box_size) + pb_lengths.into(),
|
||||||
BoxSizing::BorderBox => clamp(content_box_size + pb_lengths.into()),
|
BoxSizing::BorderBox => clamp(content_box_size + pb_lengths.into()),
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -133,20 +133,16 @@ impl Table {
|
||||||
/// the target and returns a [`ResolvedSlotAndLocation`] for each of them. If there is
|
/// the target and returns a [`ResolvedSlotAndLocation`] for each of them. If there is
|
||||||
/// no slot at the given coordinates or that slot is an empty space, an empty vector
|
/// no slot at the given coordinates or that slot is an empty space, an empty vector
|
||||||
/// is returned.
|
/// is returned.
|
||||||
pub(super) fn resolve_slot_at<'a>(
|
pub(super) fn resolve_slot_at(
|
||||||
&'a self,
|
&self,
|
||||||
coords: TableSlotCoordinates,
|
coords: TableSlotCoordinates,
|
||||||
) -> Vec<ResolvedSlotAndLocation<'a>> {
|
) -> Vec<ResolvedSlotAndLocation<'_>> {
|
||||||
let slot = self.get_slot(coords);
|
let slot = self.get_slot(coords);
|
||||||
match slot {
|
match slot {
|
||||||
Some(TableSlot::Cell(cell)) => vec![ResolvedSlotAndLocation {
|
Some(TableSlot::Cell(cell)) => vec![ResolvedSlotAndLocation { cell, coords }],
|
||||||
cell: &cell,
|
|
||||||
coords,
|
|
||||||
}],
|
|
||||||
Some(TableSlot::Spanned(ref offsets)) => offsets
|
Some(TableSlot::Spanned(ref offsets)) => offsets
|
||||||
.iter()
|
.iter()
|
||||||
.map(|offset| self.resolve_slot_at(coords - *offset))
|
.flat_map(|offset| self.resolve_slot_at(coords - *offset))
|
||||||
.flatten()
|
|
||||||
.collect(),
|
.collect(),
|
||||||
Some(TableSlot::Empty) | None => {
|
Some(TableSlot::Empty) | None => {
|
||||||
warn!("Tried to resolve an empty or nonexistant slot!");
|
warn!("Tried to resolve an empty or nonexistant slot!");
|
||||||
|
@ -170,12 +166,12 @@ impl Table {
|
||||||
|
|
||||||
let coords_of_slots_that_cover_target: Vec<_> = slots_covering_slot_above
|
let coords_of_slots_that_cover_target: Vec<_> = slots_covering_slot_above
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|ref slot| slot.covers_cell_at(target_coords))
|
.filter(|slot| slot.covers_cell_at(target_coords))
|
||||||
.map(|slot| target_coords - slot.coords)
|
.map(|slot| target_coords - slot.coords)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if coords_of_slots_that_cover_target.is_empty() {
|
if coords_of_slots_that_cover_target.is_empty() {
|
||||||
return None;
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(TableSlot::Spanned(coords_of_slots_that_cover_target))
|
Some(TableSlot::Spanned(coords_of_slots_that_cover_target))
|
||||||
}
|
}
|
||||||
|
@ -245,7 +241,7 @@ impl TableBuilder {
|
||||||
TableSlotCoordinates::new(self.current_x(), self.current_y())
|
TableSlotCoordinates::new(self.current_x(), self.current_y())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_row<'builder>(&'builder mut self) {
|
pub fn start_row(&mut self) {
|
||||||
self.table.slots.push(Vec::new());
|
self.table.slots.push(Vec::new());
|
||||||
self.table.size.height += 1;
|
self.table.size.height += 1;
|
||||||
self.create_slots_for_cells_above_with_rowspan(true);
|
self.create_slots_for_cells_above_with_rowspan(true);
|
||||||
|
@ -421,7 +417,7 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let row_content = std::mem::replace(&mut self.current_anonymous_row_content, Vec::new());
|
let row_content = std::mem::take(&mut self.current_anonymous_row_content);
|
||||||
let context = self.context;
|
let context = self.context;
|
||||||
let anonymous_style = self
|
let anonymous_style = self
|
||||||
.context
|
.context
|
||||||
|
|
|
@ -199,10 +199,10 @@ impl<'a> TableLayout<'a> {
|
||||||
Auto => (min_content_width, min_content_width, max_content_width),
|
Auto => (min_content_width, min_content_width, max_content_width),
|
||||||
};
|
};
|
||||||
|
|
||||||
min_content_sizing_guesses.push(min_content_width.into());
|
min_content_sizing_guesses.push(min_content_width);
|
||||||
min_content_percentage_sizing_guesses.push(min_content_percentage_sizing_guess.into());
|
min_content_percentage_sizing_guesses.push(min_content_percentage_sizing_guess);
|
||||||
min_content_specified_sizing_guesses.push(min_content_specified_sizing_guess.into());
|
min_content_specified_sizing_guesses.push(min_content_specified_sizing_guess);
|
||||||
max_content_sizing_guesses.push(max_content_sizing_guess.into());
|
max_content_sizing_guesses.push(max_content_sizing_guess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// > If the assignable table width is less than or equal to the max-content sizing-guess, the
|
// > If the assignable table width is less than or equal to the max-content sizing-guess, the
|
||||||
|
@ -493,7 +493,7 @@ impl Table {
|
||||||
positioning_context: &mut PositioningContext,
|
positioning_context: &mut PositioningContext,
|
||||||
containing_block: &ContainingBlock,
|
containing_block: &ContainingBlock,
|
||||||
) -> IndependentLayout {
|
) -> IndependentLayout {
|
||||||
let mut table_layout = TableLayout::new(&self);
|
let mut table_layout = TableLayout::new(self);
|
||||||
table_layout.compute_measures(layout_context, positioning_context, containing_block);
|
table_layout.compute_measures(layout_context, positioning_context, containing_block);
|
||||||
let (fragments, content_block_size) =
|
let (fragments, content_block_size) =
|
||||||
table_layout.layout_into_box_fragments(positioning_context);
|
table_layout.layout_into_box_fragments(positioning_context);
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl Table {
|
||||||
|
|
||||||
/// Return the slot at the given coordinates, if it exists in the table, otherwise
|
/// Return the slot at the given coordinates, if it exists in the table, otherwise
|
||||||
/// return None.
|
/// return None.
|
||||||
fn get_slot<'a>(&'a self, coords: TableSlotCoordinates) -> Option<&'a TableSlot> {
|
fn get_slot(&self, coords: TableSlotCoordinates) -> Option<&TableSlot> {
|
||||||
self.slots.get(coords.y)?.get(coords.x)
|
self.slots.get(coords.y)?.get(coords.x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ impl Table {
|
||||||
) -> Option<TableSlotCoordinates> {
|
) -> Option<TableSlotCoordinates> {
|
||||||
match self.get_slot(coords) {
|
match self.get_slot(coords) {
|
||||||
Some(&TableSlot::Cell(_)) => Some(coords),
|
Some(&TableSlot::Cell(_)) => Some(coords),
|
||||||
Some(&TableSlot::Spanned(ref offsets)) => Some(coords - offsets[0]),
|
Some(TableSlot::Spanned(offsets)) => Some(coords - offsets[0]),
|
||||||
_ => return None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ impl Table {
|
||||||
|
|
||||||
let slot = self.get_slot(resolved_coords);
|
let slot = self.get_slot(resolved_coords);
|
||||||
match slot {
|
match slot {
|
||||||
Some(&TableSlot::Cell(ref cell)) => Some(cell),
|
Some(TableSlot::Cell(cell)) => Some(cell),
|
||||||
_ => unreachable!(
|
_ => unreachable!(
|
||||||
"Spanned slot should not point to an empty cell or another spanned slot."
|
"Spanned slot should not point to an empty cell or another spanned slot."
|
||||||
),
|
),
|
||||||
|
|
|
@ -260,8 +260,8 @@ fn test_tree_find() {
|
||||||
right: None,
|
right: None,
|
||||||
});
|
});
|
||||||
let mut tree = FloatBandTree::new();
|
let mut tree = FloatBandTree::new();
|
||||||
for ref band in &bands {
|
for band in &bands {
|
||||||
tree = tree.insert((*band).clone());
|
tree = tree.insert(*band);
|
||||||
}
|
}
|
||||||
bands.sort_by(|a, b| a.top.partial_cmp(&b.top).unwrap());
|
bands.sort_by(|a, b| a.top.partial_cmp(&b.top).unwrap());
|
||||||
for lookup in lookups {
|
for lookup in lookups {
|
||||||
|
@ -290,8 +290,8 @@ fn test_tree_find_next() {
|
||||||
bands.sort_by(|a, b| a.top.partial_cmp(&b.top).unwrap());
|
bands.sort_by(|a, b| a.top.partial_cmp(&b.top).unwrap());
|
||||||
bands.dedup_by(|a, b| a.top == b.top);
|
bands.dedup_by(|a, b| a.top == b.top);
|
||||||
let mut tree = FloatBandTree::new();
|
let mut tree = FloatBandTree::new();
|
||||||
for ref band in &bands {
|
for band in &bands {
|
||||||
tree = tree.insert((*band).clone());
|
tree = tree.insert(*band);
|
||||||
}
|
}
|
||||||
for lookup in lookups {
|
for lookup in lookups {
|
||||||
check_tree_find_next(&tree, Au::from_f32_px(lookup as f32), &bands);
|
check_tree_find_next(&tree, Au::from_f32_px(lookup as f32), &bands);
|
||||||
|
@ -307,7 +307,7 @@ fn test_tree_range_setting() {
|
||||||
fn check(bands: Vec<FloatBandWrapper>, ranges: Vec<FloatRangeInput>) {
|
fn check(bands: Vec<FloatBandWrapper>, ranges: Vec<FloatRangeInput>) {
|
||||||
let mut tree = FloatBandTree::new();
|
let mut tree = FloatBandTree::new();
|
||||||
for FloatBandWrapper(ref band) in &bands {
|
for FloatBandWrapper(ref band) in &bands {
|
||||||
tree = tree.insert((*band).clone());
|
tree = tree.insert(*band);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut tops: Vec<Au> = bands.iter().map(|band| band.0.top).collect();
|
let mut tops: Vec<Au> = bands.iter().map(|band| band.0.top).collect();
|
||||||
|
@ -648,7 +648,7 @@ fn check_floats_rule_7(placement: &FloatPlacement) {
|
||||||
fn check_floats_rule_8(floats_and_perturbations: Vec<(FloatInput, u32)>) {
|
fn check_floats_rule_8(floats_and_perturbations: Vec<(FloatInput, u32)>) {
|
||||||
let floats = floats_and_perturbations
|
let floats = floats_and_perturbations
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&(ref float, _)| (*float).clone())
|
.map(|(float, _)| (*float).clone())
|
||||||
.collect();
|
.collect();
|
||||||
let placement = FloatPlacement::place(floats);
|
let placement = FloatPlacement::place(floats);
|
||||||
|
|
||||||
|
@ -658,9 +658,7 @@ fn check_floats_rule_8(floats_and_perturbations: Vec<(FloatInput, u32)>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut placement = placement.clone();
|
let mut placement = placement.clone();
|
||||||
placement.placed_floats[float_index].origin.block =
|
placement.placed_floats[float_index].origin.block -= Au::from_f32_px(perturbation as f32);
|
||||||
placement.placed_floats[float_index].origin.block -
|
|
||||||
Au::from_f32_px(perturbation as f32);
|
|
||||||
|
|
||||||
let result = {
|
let result = {
|
||||||
let mutex_guard = PANIC_HOOK_MUTEX.lock().unwrap();
|
let mutex_guard = PANIC_HOOK_MUTEX.lock().unwrap();
|
||||||
|
@ -677,7 +675,7 @@ fn check_floats_rule_8(floats_and_perturbations: Vec<(FloatInput, u32)>) {
|
||||||
fn check_floats_rule_9(floats_and_perturbations: Vec<(FloatInput, u32)>) {
|
fn check_floats_rule_9(floats_and_perturbations: Vec<(FloatInput, u32)>) {
|
||||||
let floats = floats_and_perturbations
|
let floats = floats_and_perturbations
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&(ref float, _)| (*float).clone())
|
.map(|(float, _)| (*float).clone())
|
||||||
.collect();
|
.collect();
|
||||||
let placement = FloatPlacement::place(floats);
|
let placement = FloatPlacement::place(floats);
|
||||||
|
|
||||||
|
@ -691,12 +689,8 @@ fn check_floats_rule_9(floats_and_perturbations: Vec<(FloatInput, u32)>) {
|
||||||
let placed_float = &mut placement.placed_floats[float_index];
|
let placed_float = &mut placement.placed_floats[float_index];
|
||||||
let perturbation = Au::from_f32_px(perturbation as f32);
|
let perturbation = Au::from_f32_px(perturbation as f32);
|
||||||
match placed_float.info.side {
|
match placed_float.info.side {
|
||||||
FloatSide::Left => {
|
FloatSide::Left => placed_float.origin.inline -= perturbation,
|
||||||
placed_float.origin.inline = placed_float.origin.inline - perturbation
|
FloatSide::Right => placed_float.origin.inline += perturbation,
|
||||||
},
|
|
||||||
FloatSide::Right => {
|
|
||||||
placed_float.origin.inline = placed_float.origin.inline + perturbation
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub struct RecalcStyle<'a> {
|
||||||
|
|
||||||
impl<'a> RecalcStyle<'a> {
|
impl<'a> RecalcStyle<'a> {
|
||||||
pub fn new(context: LayoutContext<'a>) -> Self {
|
pub fn new(context: LayoutContext<'a>) -> Self {
|
||||||
RecalcStyle { context: context }
|
RecalcStyle { context }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn context(&self) -> &LayoutContext<'a> {
|
pub fn context(&self) -> &LayoutContext<'a> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue