Skip to content

Commit

Permalink
Upgrade Stylo to 2024-12-04 (servo#34501)
Browse files Browse the repository at this point in the history
* Upgrade Stylo to 2024-12-04

Signed-off-by: Oriol Brufau <[email protected]>

* Fixup for https://phabricator.services.mozilla.com/D229998

Signed-off-by: Oriol Brufau <[email protected]>

* Update test expectations

Signed-off-by: Oriol Brufau <[email protected]>

---------

Signed-off-by: Oriol Brufau <[email protected]>
  • Loading branch information
Loirooriol authored Dec 6, 2024
1 parent 3fa1d3d commit 61ca2dd
Show file tree
Hide file tree
Showing 16 changed files with 239 additions and 195 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,25 @@ rustls = { version = "0.21.12", features = ["dangerous_configuration"] }
rustls-pemfile = "1.0.4"
script_layout_interface = { path = "components/shared/script_layout" }
script_traits = { path = "components/shared/script" }
selectors = { git = "https://github.com/servo/stylo", branch = "2024-11-01" }
selectors = { git = "https://github.com/servo/stylo", branch = "2024-12-04" }
serde = "1.0.215"
serde_bytes = "0.11"
serde_json = "1.0"
servo-media = { git = "https://github.com/servo/media" }
servo-media-dummy = { git = "https://github.com/servo/media" }
servo-media-gstreamer = { git = "https://github.com/servo/media" }
servo_arc = { git = "https://github.com/servo/stylo", branch = "2024-11-01", features = ["servo"] }
servo_atoms = { git = "https://github.com/servo/stylo", branch = "2024-11-01" }
servo_arc = { git = "https://github.com/servo/stylo", branch = "2024-12-04", features = ["servo"] }
servo_atoms = { git = "https://github.com/servo/stylo", branch = "2024-12-04" }
smallbitvec = "2.5.3"
smallvec = "1.13"
static_assertions = "1.1"
string_cache = "0.8"
string_cache_codegen = "0.5"
style = { git = "https://github.com/servo/stylo", branch = "2024-11-01", features = ["servo"] }
style_config = { git = "https://github.com/servo/stylo", branch = "2024-11-01" }
style_dom = { git = "https://github.com/servo/stylo", package = "dom", branch = "2024-11-01" }
style_traits = { git = "https://github.com/servo/stylo", branch = "2024-11-01", features = ["servo"] }
style_malloc_size_of = { package = "malloc_size_of", git = "https://github.com/servo/stylo", branch = "2024-11-01", features = ["servo"] }
style = { git = "https://github.com/servo/stylo", branch = "2024-12-04", features = ["servo"] }
style_config = { git = "https://github.com/servo/stylo", branch = "2024-12-04" }
style_dom = { git = "https://github.com/servo/stylo", package = "dom", branch = "2024-12-04" }
style_traits = { git = "https://github.com/servo/stylo", branch = "2024-12-04", features = ["servo"] }
style_malloc_size_of = { package = "malloc_size_of", git = "https://github.com/servo/stylo", branch = "2024-12-04", features = ["servo"] }
surfman = { git = "https://github.com/servo/surfman", rev = "c8d6b4b65aeab739ee7651602e29c8d58ceee123", features = ["chains"] }
syn = { version = "2", default-features = false, features = ["clone-impls", "derive", "parsing"] }
synstructure = "0.13"
Expand All @@ -134,7 +134,7 @@ thin-vec = "0.2.13"
tikv-jemalloc-sys = "0.6.0"
tikv-jemallocator = "0.6.0"
time_03 = { package = "time", version = "0.3", features = ["large-dates", "local-offset", "serde"] }
to_shmem = { git = "https://github.com/servo/stylo", branch = "2024-11-01" }
to_shmem = { git = "https://github.com/servo/stylo", branch = "2024-12-04" }
tokio = "1"
tokio-rustls = "0.24"
tracing = "0.1.41"
Expand Down
8 changes: 4 additions & 4 deletions components/layout/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
70 changes: 37 additions & 33 deletions components/layout/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
));
Expand Down Expand Up @@ -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),
Expand All @@ -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,
)],
)],
}
},
};

Expand All @@ -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,
Expand Down Expand Up @@ -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)
},
Expand All @@ -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)
Expand Down
43 changes: 34 additions & 9 deletions components/layout/floats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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,
})
}
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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,
}
}

Expand Down
Loading

0 comments on commit 61ca2dd

Please sign in to comment.