mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01: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
|
@ -1927,23 +1927,23 @@ impl BlockFlow {
|
|||
.flags
|
||||
.contains(FlowFlags::CONTAINS_TEXT_OR_REPLACED_FRAGMENTS),
|
||||
) {
|
||||
(Float::None, true) => {
|
||||
(None, true) => {
|
||||
computation.content_intrinsic_sizes.preferred_inline_size = max(
|
||||
computation.content_intrinsic_sizes.preferred_inline_size,
|
||||
child_base.intrinsic_inline_sizes.preferred_inline_size,
|
||||
);
|
||||
},
|
||||
(Float::None, false) => {
|
||||
(None, false) => {
|
||||
preferred_inline_size_of_children_without_text_or_replaced_fragments = max(
|
||||
preferred_inline_size_of_children_without_text_or_replaced_fragments,
|
||||
child_base.intrinsic_inline_sizes.preferred_inline_size,
|
||||
)
|
||||
},
|
||||
(Float::Left, _) => {
|
||||
(Some(FloatKind::Left), _) => {
|
||||
left_float_width_accumulator +=
|
||||
child_base.intrinsic_inline_sizes.preferred_inline_size;
|
||||
},
|
||||
(Float::Right, _) => {
|
||||
(Some(FloatKind::Right), _) => {
|
||||
right_float_width_accumulator +=
|
||||
child_base.intrinsic_inline_sizes.preferred_inline_size;
|
||||
},
|
||||
|
|
|
@ -1372,6 +1372,9 @@ where
|
|||
&table_style,
|
||||
);
|
||||
}
|
||||
// FIXME: this should use the writing mode of the containing block.
|
||||
let wrapper_float_kind =
|
||||
FloatKind::from_property_and_writing_mode(float_value, wrapper_style.writing_mode);
|
||||
let wrapper_fragment = Fragment::from_opaque_node_and_style(
|
||||
node.opaque(),
|
||||
PseudoElementType::Normal,
|
||||
|
@ -1380,7 +1383,6 @@ where
|
|||
node.restyle_damage(),
|
||||
SpecificFragmentInfo::TableWrapper,
|
||||
);
|
||||
let wrapper_float_kind = FloatKind::from_property(float_value);
|
||||
let mut wrapper_flow = FlowRef::new(Arc::new(
|
||||
TableWrapperFlow::from_fragment_and_float_kind(wrapper_fragment, wrapper_float_kind),
|
||||
));
|
||||
|
@ -1509,8 +1511,10 @@ where
|
|||
node: &ConcreteThreadSafeLayoutNode,
|
||||
flotation: Float,
|
||||
) -> ConstructionResult {
|
||||
let flotation = FloatKind::from_property(flotation);
|
||||
let marker_fragments = match node.style(self.style_context()).get_list().list_style_image {
|
||||
// FIXME: this should use the writing mode of the containing block.
|
||||
let style = node.style(self.style_context());
|
||||
let flotation = FloatKind::from_property_and_writing_mode(flotation, style.writing_mode);
|
||||
let marker_fragments = match style.get_list().list_style_image {
|
||||
Image::Url(ref url_value) => {
|
||||
let image_info = Box::new(ImageFragmentInfo::new(
|
||||
url_value.url().cloned().map(Into::into),
|
||||
|
@ -1529,31 +1533,31 @@ where
|
|||
Image::Gradient(..) |
|
||||
Image::PaintWorklet(..) |
|
||||
Image::CrossFade(..) |
|
||||
Image::None => match ListStyleTypeContent::from_list_style_type(
|
||||
node.style(self.style_context()).get_list().list_style_type,
|
||||
) {
|
||||
ListStyleTypeContent::None => Vec::new(),
|
||||
ListStyleTypeContent::StaticText(ch) => {
|
||||
let text = format!("{}\u{a0}", ch);
|
||||
let mut unscanned_marker_fragments = LinkedList::new();
|
||||
unscanned_marker_fragments.push_back(Fragment::new(
|
||||
Image::None => {
|
||||
match ListStyleTypeContent::from_list_style_type(style.get_list().list_style_type) {
|
||||
ListStyleTypeContent::None => Vec::new(),
|
||||
ListStyleTypeContent::StaticText(ch) => {
|
||||
let text = format!("{}\u{a0}", ch);
|
||||
let mut unscanned_marker_fragments = LinkedList::new();
|
||||
unscanned_marker_fragments.push_back(Fragment::new(
|
||||
node,
|
||||
SpecificFragmentInfo::UnscannedText(Box::new(
|
||||
UnscannedTextFragmentInfo::new(Box::<str>::from(text), None),
|
||||
)),
|
||||
self.layout_context,
|
||||
));
|
||||
let marker_fragments = TextRunScanner::new().scan_for_runs(
|
||||
&self.layout_context.font_context,
|
||||
unscanned_marker_fragments,
|
||||
);
|
||||
marker_fragments.fragments
|
||||
},
|
||||
ListStyleTypeContent::GeneratedContent(info) => vec![Fragment::new(
|
||||
node,
|
||||
SpecificFragmentInfo::UnscannedText(Box::new(
|
||||
UnscannedTextFragmentInfo::new(Box::<str>::from(text), None),
|
||||
)),
|
||||
SpecificFragmentInfo::GeneratedContent(info),
|
||||
self.layout_context,
|
||||
));
|
||||
let marker_fragments = TextRunScanner::new().scan_for_runs(
|
||||
&self.layout_context.font_context,
|
||||
unscanned_marker_fragments,
|
||||
);
|
||||
marker_fragments.fragments
|
||||
},
|
||||
ListStyleTypeContent::GeneratedContent(info) => vec![Fragment::new(
|
||||
node,
|
||||
SpecificFragmentInfo::GeneratedContent(info),
|
||||
self.layout_context,
|
||||
)],
|
||||
)],
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1564,11 +1568,7 @@ where
|
|||
// there.
|
||||
let mut initial_fragments = IntermediateInlineFragments::new();
|
||||
let main_fragment = self.build_fragment_for_block(node);
|
||||
let flow = match node
|
||||
.style(self.style_context())
|
||||
.get_list()
|
||||
.list_style_position
|
||||
{
|
||||
let flow = match style.get_list().list_style_position {
|
||||
ListStylePosition::Outside => Arc::new(ListItemFlow::from_fragments_and_flotation(
|
||||
main_fragment,
|
||||
marker_fragments,
|
||||
|
@ -1956,7 +1956,9 @@ where
|
|||
|
||||
// Flex items contribute flex flow construction results.
|
||||
(Display::Flex, float_value, _) => {
|
||||
let float_kind = FloatKind::from_property(float_value);
|
||||
// FIXME: this should use the writing mode of the containing block.
|
||||
let float_kind =
|
||||
FloatKind::from_property_and_writing_mode(float_value, style.writing_mode);
|
||||
let construction_result = self.build_flow_for_flex(node, float_kind);
|
||||
self.set_flow_construction_result(node, construction_result)
|
||||
},
|
||||
|
@ -1972,7 +1974,9 @@ where
|
|||
// TODO(pcwalton): Make this only trigger for blocks and handle the other `display`
|
||||
// properties separately.
|
||||
(_, float_value, _) => {
|
||||
let float_kind = FloatKind::from_property(float_value);
|
||||
// FIXME: this should use the writing mode of the containing block.
|
||||
let float_kind =
|
||||
FloatKind::from_property_and_writing_mode(float_value, style.writing_mode);
|
||||
// List items contribute their own special flows.
|
||||
let construction_result = if display.is_list_item() {
|
||||
self.build_flow_for_list_item(node, float_value)
|
||||
|
|
|
@ -8,8 +8,10 @@ use std::fmt;
|
|||
use app_units::{Au, MAX_AU};
|
||||
use log::debug;
|
||||
use serde::Serialize;
|
||||
use style::computed_values::clear::T as StyleClear;
|
||||
use style::computed_values::float::T as StyleFloat;
|
||||
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::ComputedValues;
|
||||
|
||||
use crate::block::FormattingContextType;
|
||||
use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils};
|
||||
|
@ -23,12 +25,19 @@ pub enum FloatKind {
|
|||
}
|
||||
|
||||
impl FloatKind {
|
||||
pub fn from_property(property: StyleFloat) -> Option<FloatKind> {
|
||||
match property {
|
||||
StyleFloat::None => None,
|
||||
StyleFloat::Left => Some(FloatKind::Left),
|
||||
StyleFloat::Right => Some(FloatKind::Right),
|
||||
}
|
||||
pub fn from_property_and_writing_mode(
|
||||
property: StyleFloat,
|
||||
writing_mode: WritingMode,
|
||||
) -> Option<FloatKind> {
|
||||
Some(match property {
|
||||
StyleFloat::None => return None,
|
||||
StyleFloat::Left => Self::Left,
|
||||
StyleFloat::Right => Self::Right,
|
||||
StyleFloat::InlineStart if writing_mode.is_bidi_ltr() => Self::Left,
|
||||
StyleFloat::InlineStart => Self::Right,
|
||||
StyleFloat::InlineEnd if writing_mode.is_bidi_ltr() => Self::Right,
|
||||
StyleFloat::InlineEnd => Self::Left,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,6 +49,22 @@ pub enum ClearType {
|
|||
Both,
|
||||
}
|
||||
|
||||
impl ClearType {
|
||||
pub fn from_style(style: &ComputedValues) -> Option<Self> {
|
||||
Some(match style.get_box().clear {
|
||||
StyleClear::None => return None,
|
||||
StyleClear::Left => Self::Left,
|
||||
StyleClear::Right => Self::Right,
|
||||
StyleClear::Both => Self::Both,
|
||||
// FIXME: these should check the writing mode of the containing block.
|
||||
StyleClear::InlineStart if style.writing_mode.is_bidi_ltr() => Self::Left,
|
||||
StyleClear::InlineStart => Self::Right,
|
||||
StyleClear::InlineEnd if style.writing_mode.is_bidi_ltr() => Self::Right,
|
||||
StyleClear::InlineEnd => Self::Left,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Information about a single float.
|
||||
#[derive(Clone, Copy)]
|
||||
struct Float {
|
||||
|
@ -558,9 +583,9 @@ impl SpeculatedFloatPlacement {
|
|||
}
|
||||
|
||||
match base_flow.flags.float_kind() {
|
||||
StyleFloat::None => {},
|
||||
StyleFloat::Left => self.left += float_inline_size,
|
||||
StyleFloat::Right => self.right += float_inline_size,
|
||||
None => {},
|
||||
Some(FloatKind::Left) => self.left += float_inline_size,
|
||||
Some(FloatKind::Right) => self.right += float_inline_size,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,6 @@ use log::debug;
|
|||
use serde::ser::{SerializeStruct, Serializer};
|
||||
use serde::Serialize;
|
||||
use servo_geometry::{au_rect_to_f32_rect, f32_rect_to_au_rect, MaxRect};
|
||||
use style::computed_values::clear::T as Clear;
|
||||
use style::computed_values::float::T as Float;
|
||||
use style::computed_values::overflow_x::T as StyleOverflow;
|
||||
use style::computed_values::position::T as Position;
|
||||
use style::computed_values::text_align::T as TextAlign;
|
||||
|
@ -57,7 +55,7 @@ use crate::display_list::{
|
|||
DisplayListBuildState, StackingContextCollectionState, StackingContextId,
|
||||
};
|
||||
use crate::flex::FlexFlow;
|
||||
use crate::floats::{Floats, SpeculatedFloatPlacement};
|
||||
use crate::floats::{ClearType, FloatKind, Floats, SpeculatedFloatPlacement};
|
||||
use crate::flow_list::{FlowList, FlowListIterator, MutFlowListIterator};
|
||||
use crate::flow_ref::{FlowRef, WeakFlowRef};
|
||||
use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
|
||||
|
@ -672,13 +670,13 @@ bitflags! {
|
|||
|
||||
impl FlowFlags {
|
||||
#[inline]
|
||||
pub fn float_kind(&self) -> Float {
|
||||
pub fn float_kind(&self) -> Option<FloatKind> {
|
||||
if self.contains(FlowFlags::FLOATS_LEFT) {
|
||||
Float::Left
|
||||
Some(FloatKind::Left)
|
||||
} else if self.contains(FlowFlags::FLOATS_RIGHT) {
|
||||
Float::Right
|
||||
Some(FloatKind::Right)
|
||||
} else {
|
||||
Float::None
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1070,18 +1068,22 @@ impl BaseFlow {
|
|||
}
|
||||
|
||||
if force_nonfloated == ForceNonfloatedFlag::FloatIfNecessary {
|
||||
match style.get_box().float {
|
||||
Float::None => {},
|
||||
Float::Left => flags.insert(FlowFlags::FLOATS_LEFT),
|
||||
Float::Right => flags.insert(FlowFlags::FLOATS_RIGHT),
|
||||
// FIXME: this should use the writing mode of the containing block.
|
||||
match FloatKind::from_property_and_writing_mode(
|
||||
style.get_box().float,
|
||||
style.writing_mode,
|
||||
) {
|
||||
None => {},
|
||||
Some(FloatKind::Left) => flags.insert(FlowFlags::FLOATS_LEFT),
|
||||
Some(FloatKind::Right) => flags.insert(FlowFlags::FLOATS_RIGHT),
|
||||
}
|
||||
}
|
||||
|
||||
match style.get_box().clear {
|
||||
Clear::None => {},
|
||||
Clear::Left => flags.insert(FlowFlags::CLEARS_LEFT),
|
||||
Clear::Right => flags.insert(FlowFlags::CLEARS_RIGHT),
|
||||
Clear::Both => {
|
||||
match ClearType::from_style(style) {
|
||||
None => {},
|
||||
Some(ClearType::Left) => flags.insert(FlowFlags::CLEARS_LEFT),
|
||||
Some(ClearType::Right) => flags.insert(FlowFlags::CLEARS_RIGHT),
|
||||
Some(ClearType::Both) => {
|
||||
flags.insert(FlowFlags::CLEARS_LEFT);
|
||||
flags.insert(FlowFlags::CLEARS_RIGHT);
|
||||
},
|
||||
|
|
|
@ -33,7 +33,6 @@ use serde::ser::{Serialize, SerializeStruct, Serializer};
|
|||
use servo_url::ServoUrl;
|
||||
use style::computed_values::border_collapse::T as BorderCollapse;
|
||||
use style::computed_values::box_sizing::T as BoxSizing;
|
||||
use style::computed_values::clear::T as Clear;
|
||||
use style::computed_values::color::T as Color;
|
||||
use style::computed_values::display::T as Display;
|
||||
use style::computed_values::mix_blend_mode::T as MixBlendMode;
|
||||
|
@ -1507,13 +1506,7 @@ impl Fragment {
|
|||
/// FIXME(pcwalton): Just replace with the clear type from the style module for speed?
|
||||
#[inline(always)]
|
||||
pub fn clear(&self) -> Option<ClearType> {
|
||||
let style = self.style();
|
||||
match style.get_box().clear {
|
||||
Clear::None => None,
|
||||
Clear::Left => Some(ClearType::Left),
|
||||
Clear::Right => Some(ClearType::Right),
|
||||
Clear::Both => Some(ClearType::Both),
|
||||
}
|
||||
ClearType::from_style(self.style())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use bitflags::bitflags;
|
||||
use style::computed_values::float::T as Float;
|
||||
use style::selector_parser::RestyleDamage;
|
||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||
|
||||
|
@ -67,7 +66,7 @@ impl dyn Flow {
|
|||
}
|
||||
|
||||
let self_base = self.mut_base();
|
||||
if self_base.flags.float_kind() != Float::None &&
|
||||
if self_base.flags.float_kind().is_some() &&
|
||||
self_base
|
||||
.restyle_damage
|
||||
.intersects(ServoRestyleDamage::REFLOW)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue