mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Upgrade Stylo to 2024-12-04 (#34501)
* Upgrade Stylo to 2024-12-04 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D229998 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Update test expectations Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
3fa1d3d9cf
commit
61ca2dde29
16 changed files with 239 additions and 195 deletions
|
@ -19,7 +19,7 @@ use style::computed_values::float::T as FloatProperty;
|
|||
use style::computed_values::position::T as Position;
|
||||
use style::logical_geometry::WritingMode;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::Clear;
|
||||
use style::values::computed::Clear as StyleClear;
|
||||
use style::values::specified::text::TextDecorationLine;
|
||||
|
||||
use crate::context::LayoutContext;
|
||||
|
@ -243,8 +243,8 @@ impl<'a> PlacementAmongFloats<'a> {
|
|||
inline: self.min_inline_start,
|
||||
block: self
|
||||
.ceiling
|
||||
.max(self.float_context.clear_left_position)
|
||||
.max(self.float_context.clear_right_position),
|
||||
.max(self.float_context.clear_inline_start_position)
|
||||
.max(self.float_context.clear_inline_end_position),
|
||||
},
|
||||
size: LogicalVec2 {
|
||||
inline: self.max_inline_end - self.min_inline_start,
|
||||
|
@ -339,10 +339,10 @@ pub struct FloatContext {
|
|||
/// independent block formatting context that contains all of the floats
|
||||
/// this `FloatContext` positions.
|
||||
pub containing_block_info: ContainingBlockPositionInfo,
|
||||
/// The (logically) lowest margin edge of the last left float.
|
||||
pub clear_left_position: Au,
|
||||
/// The (logically) lowest margin edge of the last right float.
|
||||
pub clear_right_position: Au,
|
||||
/// The (logically) lowest margin edge of the last inline-start float.
|
||||
pub clear_inline_start_position: Au,
|
||||
/// The (logically) lowest margin edge of the last inline-end float.
|
||||
pub clear_inline_end_position: Au,
|
||||
}
|
||||
|
||||
impl FloatContext {
|
||||
|
@ -368,8 +368,8 @@ impl FloatContext {
|
|||
Au::zero(),
|
||||
max_inline_size,
|
||||
),
|
||||
clear_left_position: Au::zero(),
|
||||
clear_right_position: Au::zero(),
|
||||
clear_inline_start_position: Au::zero(),
|
||||
clear_inline_end_position: Au::zero(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,11 +394,11 @@ impl FloatContext {
|
|||
pub(crate) fn place_object(&self, object: &PlacementInfo, ceiling: Au) -> LogicalVec2<Au> {
|
||||
let ceiling = match object.clear {
|
||||
Clear::None => ceiling,
|
||||
Clear::Left => ceiling.max(self.clear_left_position),
|
||||
Clear::Right => ceiling.max(self.clear_right_position),
|
||||
Clear::InlineStart => ceiling.max(self.clear_inline_start_position),
|
||||
Clear::InlineEnd => ceiling.max(self.clear_inline_end_position),
|
||||
Clear::Both => ceiling
|
||||
.max(self.clear_left_position)
|
||||
.max(self.clear_right_position),
|
||||
.max(self.clear_inline_start_position)
|
||||
.max(self.clear_inline_end_position),
|
||||
};
|
||||
|
||||
// Find the first band this float fits in.
|
||||
|
@ -461,11 +461,11 @@ impl FloatContext {
|
|||
// Update clear.
|
||||
match new_float.side {
|
||||
FloatSide::InlineStart => {
|
||||
self.clear_left_position
|
||||
self.clear_inline_start_position
|
||||
.max_assign(new_float_rect.max_block_position());
|
||||
},
|
||||
FloatSide::InlineEnd => {
|
||||
self.clear_right_position
|
||||
self.clear_inline_end_position
|
||||
.max_assign(new_float_rect.max_block_position());
|
||||
},
|
||||
}
|
||||
|
@ -498,6 +498,32 @@ impl FloatContext {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum Clear {
|
||||
None,
|
||||
InlineStart,
|
||||
InlineEnd,
|
||||
Both,
|
||||
}
|
||||
|
||||
impl Clear {
|
||||
pub(crate) fn from_style_and_container_writing_mode(
|
||||
style: &ComputedValues,
|
||||
container_writing_mode: WritingMode,
|
||||
) -> Self {
|
||||
match style.get_box().clear {
|
||||
StyleClear::None => Self::None,
|
||||
StyleClear::Both => Self::Both,
|
||||
StyleClear::InlineStart => Self::InlineStart,
|
||||
StyleClear::InlineEnd => Self::InlineEnd,
|
||||
StyleClear::Left if container_writing_mode.is_bidi_ltr() => Self::InlineStart,
|
||||
StyleClear::Left => Self::InlineEnd,
|
||||
StyleClear::Right if container_writing_mode.is_bidi_ltr() => Self::InlineEnd,
|
||||
StyleClear::Right => Self::InlineStart,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Information needed to place an object so that it doesn't collide with existing floats.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PlacementInfo {
|
||||
|
@ -537,19 +563,19 @@ pub struct FloatBand {
|
|||
}
|
||||
|
||||
impl FloatSide {
|
||||
fn from_style_and_container_writing_mode(
|
||||
pub(crate) fn from_style_and_container_writing_mode(
|
||||
style: &ComputedValues,
|
||||
container_writing_mode: WritingMode,
|
||||
) -> Option<FloatSide> {
|
||||
match (style.get_box().float, container_writing_mode.is_bidi_ltr()) {
|
||||
(FloatProperty::None, _) => None,
|
||||
(FloatProperty::Left, true) | (FloatProperty::Right, false) => {
|
||||
Some(FloatSide::InlineStart)
|
||||
},
|
||||
(FloatProperty::Right, true) | (FloatProperty::Left, false) => {
|
||||
Some(FloatSide::InlineEnd)
|
||||
},
|
||||
}
|
||||
Some(match style.get_box().float {
|
||||
FloatProperty::None => return None,
|
||||
FloatProperty::InlineStart => Self::InlineStart,
|
||||
FloatProperty::InlineEnd => Self::InlineEnd,
|
||||
FloatProperty::Left if container_writing_mode.is_bidi_ltr() => Self::InlineStart,
|
||||
FloatProperty::Left => Self::InlineEnd,
|
||||
FloatProperty::Right if container_writing_mode.is_bidi_ltr() => Self::InlineEnd,
|
||||
FloatProperty::Right => Self::InlineStart,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1021,12 +1047,12 @@ impl SequentialLayoutState {
|
|||
// in that case we don't need to add clearance.
|
||||
let clear_position = match clear {
|
||||
Clear::None => unreachable!(),
|
||||
Clear::Left => self.floats.clear_left_position,
|
||||
Clear::Right => self.floats.clear_right_position,
|
||||
Clear::InlineStart => self.floats.clear_inline_start_position,
|
||||
Clear::InlineEnd => self.floats.clear_inline_end_position,
|
||||
Clear::Both => self
|
||||
.floats
|
||||
.clear_left_position
|
||||
.max(self.floats.clear_right_position),
|
||||
.clear_inline_start_position
|
||||
.max(self.floats.clear_inline_end_position),
|
||||
};
|
||||
if hypothetical_block_position >= clear_position {
|
||||
None
|
||||
|
@ -1133,7 +1159,10 @@ impl SequentialLayoutState {
|
|||
container_writing_mode,
|
||||
)
|
||||
.expect("Float box wasn't floated!"),
|
||||
clear: box_fragment.style.get_box().clear,
|
||||
clear: Clear::from_style_and_container_writing_mode(
|
||||
&box_fragment.style,
|
||||
container_writing_mode,
|
||||
),
|
||||
});
|
||||
|
||||
// Re-calculate relative adjustment so that it is not lost when the BoxFragment's
|
||||
|
|
|
@ -96,7 +96,6 @@ use style::computed_values::white_space_collapse::T as WhiteSpaceCollapse;
|
|||
use style::context::QuirksMode;
|
||||
use style::properties::style_structs::InheritedText;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::Clear;
|
||||
use style::values::generics::box_::VerticalAlignKeyword;
|
||||
use style::values::generics::font::LineHeight;
|
||||
use style::values::specified::box_::BaselineSource;
|
||||
|
@ -111,7 +110,7 @@ use unicode_bidi::{BidiInfo, Level};
|
|||
use webrender_api::FontInstanceKey;
|
||||
use xi_unicode::linebreak_property;
|
||||
|
||||
use super::float::PlacementAmongFloats;
|
||||
use super::float::{Clear, PlacementAmongFloats};
|
||||
use crate::cell::ArcRefCell;
|
||||
use crate::context::LayoutContext;
|
||||
use crate::flow::float::{FloatBox, SequentialLayoutState};
|
||||
|
@ -721,7 +720,10 @@ impl<'layout_dta> InlineFormattingContextLayout<'layout_dta> {
|
|||
.contains(FragmentFlags::IS_BR_ELEMENT) &&
|
||||
self.deferred_br_clear == Clear::None
|
||||
{
|
||||
self.deferred_br_clear = inline_box_state.base.style.clone_clear();
|
||||
self.deferred_br_clear = Clear::from_style_and_container_writing_mode(
|
||||
&inline_box_state.base.style,
|
||||
self.containing_block.style.writing_mode,
|
||||
);
|
||||
}
|
||||
|
||||
if inline_box.is_first_fragment {
|
||||
|
|
|
@ -12,8 +12,7 @@ use inline::InlineFormattingContext;
|
|||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||
use serde::Serialize;
|
||||
use servo_arc::Arc;
|
||||
use style::computed_values::clear::T as Clear;
|
||||
use style::computed_values::float::T as Float;
|
||||
use style::computed_values::clear::T as StyleClear;
|
||||
use style::properties::ComputedValues;
|
||||
use style::servo::selector_parser::PseudoElement;
|
||||
use style::values::computed::Size as StyleSize;
|
||||
|
@ -24,7 +23,8 @@ use style::Zero;
|
|||
use crate::cell::ArcRefCell;
|
||||
use crate::context::LayoutContext;
|
||||
use crate::flow::float::{
|
||||
ContainingBlockPositionInfo, FloatBox, PlacementAmongFloats, SequentialLayoutState,
|
||||
Clear, ContainingBlockPositionInfo, FloatBox, FloatSide, PlacementAmongFloats,
|
||||
SequentialLayoutState,
|
||||
};
|
||||
use crate::formatting_contexts::{
|
||||
Baselines, IndependentFormattingContext, IndependentLayout, IndependentLayoutResult,
|
||||
|
@ -120,7 +120,7 @@ impl BlockLevelBox {
|
|||
};
|
||||
|
||||
// FIXME: This should only return false when 'clear' causes clearance.
|
||||
if style.get_box().clear != Clear::None {
|
||||
if style.get_box().clear != StyleClear::None {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -383,11 +383,17 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
|||
&LogicalVec2::zero(),
|
||||
false, /* auto_block_size_stretches_to_containing_block */
|
||||
);
|
||||
let style_box = &float_box.contents.style().get_box();
|
||||
let style = &float_box.contents.style();
|
||||
Some((
|
||||
inline_content_sizes_result,
|
||||
style_box.float,
|
||||
style_box.clear,
|
||||
FloatSide::from_style_and_container_writing_mode(
|
||||
style,
|
||||
containing_block.writing_mode,
|
||||
),
|
||||
Clear::from_style_and_container_writing_mode(
|
||||
style,
|
||||
containing_block.writing_mode,
|
||||
),
|
||||
))
|
||||
},
|
||||
BlockLevelBox::SameFormattingContextBlock {
|
||||
|
@ -406,7 +412,7 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
|||
// A block in the same BFC can overlap floats, it's not moved next to them,
|
||||
// so we shouldn't add its size to the size of the floats.
|
||||
// Instead, we treat it like an independent block with 'clear: both'.
|
||||
Some((inline_content_sizes_result, Float::None, Clear::Both))
|
||||
Some((inline_content_sizes_result, None, Clear::Both))
|
||||
},
|
||||
BlockLevelBox::Independent(ref independent) => {
|
||||
let inline_content_sizes_result = independent.outer_inline_content_sizes(
|
||||
|
@ -417,8 +423,11 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
|||
);
|
||||
Some((
|
||||
inline_content_sizes_result,
|
||||
Float::None,
|
||||
independent.style().get_box().clear,
|
||||
None,
|
||||
Clear::from_style_and_container_writing_mode(
|
||||
independent.style(),
|
||||
containing_block.writing_mode,
|
||||
),
|
||||
))
|
||||
},
|
||||
}
|
||||
|
@ -432,31 +441,32 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
|||
depends_on_block_constraints: bool,
|
||||
/// The maximum size seen so far, not including trailing uncleared floats.
|
||||
max_size: ContentSizes,
|
||||
/// The size of the trailing uncleared floats with 'float: left'.
|
||||
left_floats: ContentSizes,
|
||||
/// The size of the trailing uncleared floats with 'float: right'.
|
||||
right_floats: ContentSizes,
|
||||
/// The size of the trailing uncleared floats on the inline-start side
|
||||
/// of the containing block.
|
||||
start_floats: ContentSizes,
|
||||
/// The size of the trailing uncleared floats on the inline-end side
|
||||
/// of the containing block.
|
||||
end_floats: ContentSizes,
|
||||
}
|
||||
|
||||
impl AccumulatedData {
|
||||
fn max_size_including_uncleared_floats(&self) -> ContentSizes {
|
||||
self.max_size
|
||||
.max(self.left_floats.union(&self.right_floats))
|
||||
self.max_size.max(self.start_floats.union(&self.end_floats))
|
||||
}
|
||||
fn clear_floats(&mut self, clear: Clear) {
|
||||
match clear {
|
||||
Clear::Left => {
|
||||
Clear::InlineStart => {
|
||||
self.max_size = self.max_size_including_uncleared_floats();
|
||||
self.left_floats = ContentSizes::zero();
|
||||
self.start_floats = ContentSizes::zero();
|
||||
},
|
||||
Clear::Right => {
|
||||
Clear::InlineEnd => {
|
||||
self.max_size = self.max_size_including_uncleared_floats();
|
||||
self.right_floats = ContentSizes::zero();
|
||||
self.end_floats = ContentSizes::zero();
|
||||
},
|
||||
Clear::Both => {
|
||||
self.max_size = self.max_size_including_uncleared_floats();
|
||||
self.left_floats = ContentSizes::zero();
|
||||
self.right_floats = ContentSizes::zero();
|
||||
self.start_floats = ContentSizes::zero();
|
||||
self.end_floats = ContentSizes::zero();
|
||||
},
|
||||
Clear::None => {},
|
||||
};
|
||||
|
@ -472,14 +482,14 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
|||
data.depends_on_block_constraints |= depends_on_block_constraints;
|
||||
data.clear_floats(clear);
|
||||
match float {
|
||||
Float::Left => data.left_floats = data.left_floats.union(&size),
|
||||
Float::Right => data.right_floats = data.right_floats.union(&size),
|
||||
Float::None => {
|
||||
Some(FloatSide::InlineStart) => data.start_floats = data.start_floats.union(&size),
|
||||
Some(FloatSide::InlineEnd) => data.end_floats = data.end_floats.union(&size),
|
||||
None => {
|
||||
data.max_size = data
|
||||
.max_size
|
||||
.max(data.left_floats.union(&data.right_floats).union(&size));
|
||||
data.left_floats = ContentSizes::zero();
|
||||
data.right_floats = ContentSizes::zero();
|
||||
.max(data.start_floats.union(&data.end_floats).union(&size));
|
||||
data.start_floats = ContentSizes::zero();
|
||||
data.end_floats = ContentSizes::zero();
|
||||
},
|
||||
}
|
||||
data
|
||||
|
@ -789,6 +799,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
|||
mut sequential_layout_state: Option<&mut SequentialLayoutState>,
|
||||
collapsible_with_parent_start_margin: Option<CollapsibleWithParentStartMargin>,
|
||||
) -> BoxFragment {
|
||||
let containing_block_writing_mode = containing_block.style.writing_mode;
|
||||
let ContainingBlockPaddingAndBorder {
|
||||
containing_block: containing_block_for_children,
|
||||
pbm,
|
||||
|
@ -815,6 +826,8 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
|||
match sequential_layout_state {
|
||||
None => parent_containing_block_position_info = None,
|
||||
Some(ref mut sequential_layout_state) => {
|
||||
let clear =
|
||||
Clear::from_style_and_container_writing_mode(style, containing_block_writing_mode);
|
||||
let mut block_start_margin = CollapsedMargin::new(margin.block_start);
|
||||
|
||||
// The block start margin may collapse with content margins,
|
||||
|
@ -831,7 +844,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
|||
let collapsible_with_parent_start_margin = collapsible_with_parent_start_margin.expect(
|
||||
"We should know whether we are collapsing the block start margin with the parent \
|
||||
when laying out sequentially",
|
||||
).0 && style.get_box().clear == Clear::None;
|
||||
).0 && clear == Clear::None;
|
||||
if !collapsible_with_parent_start_margin && start_margin_can_collapse_with_children {
|
||||
if let BlockContainer::BlockLevelBoxes(child_boxes) = contents {
|
||||
BlockLevelBox::find_block_margin_collapsing_with_parent_from_slice(
|
||||
|
@ -843,8 +856,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
|||
}
|
||||
|
||||
// Introduce clearance if necessary.
|
||||
clearance = sequential_layout_state
|
||||
.calculate_clearance(style.get_box().clear, &block_start_margin);
|
||||
clearance = sequential_layout_state.calculate_clearance(clear, &block_start_margin);
|
||||
if clearance.is_some() {
|
||||
sequential_layout_state.collapse_margins();
|
||||
}
|
||||
|
@ -974,7 +986,6 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
|||
},
|
||||
};
|
||||
|
||||
let containing_block_writing_mode = containing_block.style.writing_mode;
|
||||
if depends_on_block_constraints {
|
||||
base_fragment_info
|
||||
.flags
|
||||
|
@ -1098,6 +1109,7 @@ impl NonReplacedFormattingContext {
|
|||
containing_block: &ContainingBlock<'_>,
|
||||
sequential_layout_state: &mut SequentialLayoutState,
|
||||
) -> BoxFragment {
|
||||
let containing_block_writing_mode = containing_block.style.writing_mode;
|
||||
let ContentBoxSizesAndPBMDeprecated {
|
||||
content_box_size,
|
||||
content_min_box_size,
|
||||
|
@ -1183,7 +1195,10 @@ impl NonReplacedFormattingContext {
|
|||
// The code below may then add extra clearance when the element can't fit
|
||||
// next to floats not covered by 'clear'.
|
||||
let clear_position = sequential_layout_state.calculate_clear_position(
|
||||
self.style.get_box().clear,
|
||||
Clear::from_style_and_container_writing_mode(
|
||||
&self.style,
|
||||
containing_block_writing_mode,
|
||||
),
|
||||
&collapsed_margin_block_start,
|
||||
);
|
||||
let ceiling = clear_position.unwrap_or_else(|| {
|
||||
|
@ -1339,7 +1354,6 @@ impl NonReplacedFormattingContext {
|
|||
);
|
||||
}
|
||||
|
||||
let containing_block_writing_mode = containing_block.style.writing_mode;
|
||||
BoxFragment::new(
|
||||
base_fragment_info,
|
||||
self.style.clone(),
|
||||
|
@ -1733,7 +1747,10 @@ fn solve_clearance_and_inline_margins_avoiding_floats(
|
|||
) -> (Option<Au>, (Au, Au), Au) {
|
||||
let (clearance, placement_rect) = sequential_layout_state
|
||||
.calculate_clearance_and_inline_adjustment(
|
||||
style.get_box().clear,
|
||||
Clear::from_style_and_container_writing_mode(
|
||||
style,
|
||||
containing_block.style.writing_mode,
|
||||
),
|
||||
block_start_margin,
|
||||
pbm,
|
||||
size,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue