mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Upgrade Stylo to 2024-10-04 (#33767)
* Upgrade Stylo to 2024-10-04 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D220285 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://bugzilla.mozilla.org/show_bug.cgi?id=1918093 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D222817 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D222856 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D222532 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D222533 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D222534 Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Fixup for https://phabricator.services.mozilla.com/D223878 Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
65c866285f
commit
c75f6627ba
16 changed files with 156 additions and 121 deletions
|
@ -25,7 +25,7 @@ use style::properties::ComputedValues;
|
|||
use style::values::computed::image::Image;
|
||||
use style::values::computed::{
|
||||
BorderImageSideWidth, BorderImageWidth, BorderStyle, Color, LengthPercentage,
|
||||
LengthPercentageOrAuto, NonNegativeLengthOrNumber, NumberOrPercentage, OutlineStyle,
|
||||
NonNegativeLengthOrNumber, NumberOrPercentage, OutlineStyle,
|
||||
};
|
||||
use style::values::generics::rect::Rect;
|
||||
use style::values::generics::NonNegative;
|
||||
|
@ -49,7 +49,7 @@ use crate::display_list::stacking_context::StackingContextSection;
|
|||
use crate::fragment_tree::{
|
||||
BackgroundMode, BoxFragment, Fragment, FragmentFlags, FragmentTree, Tag, TextFragment,
|
||||
};
|
||||
use crate::geom::{PhysicalPoint, PhysicalRect};
|
||||
use crate::geom::{LengthPercentageOrAuto, PhysicalPoint, PhysicalRect};
|
||||
use crate::replaced::NaturalSizes;
|
||||
use crate::style_ext::ComputedValuesExt;
|
||||
|
||||
|
@ -1332,7 +1332,7 @@ pub(super) fn compute_margin_box_radius(
|
|||
layout_rect: LayoutSize,
|
||||
fragment: &BoxFragment,
|
||||
) -> wr::BorderRadius {
|
||||
let margin = fragment.style.get_margin();
|
||||
let margin = fragment.style.physical_margin();
|
||||
let adjust_radius = |radius: f32, margin: f32| -> f32 {
|
||||
if margin <= 0. || (radius / margin) >= 1. {
|
||||
(radius + margin).max(0.)
|
||||
|
@ -1344,13 +1344,14 @@ pub(super) fn compute_margin_box_radius(
|
|||
layout_rect: LayoutSize,
|
||||
margin: Size2D<LengthPercentageOrAuto, UnknownUnit>|
|
||||
-> LayoutSize {
|
||||
let zero = LengthPercentage::zero();
|
||||
let width = margin
|
||||
.width
|
||||
.auto_is(LengthPercentage::zero)
|
||||
.auto_is(|| &zero)
|
||||
.to_used_value(Au::from_f32_px(layout_rect.width));
|
||||
let height = margin
|
||||
.height
|
||||
.auto_is(LengthPercentage::zero)
|
||||
.auto_is(|| &zero)
|
||||
.to_used_value(Au::from_f32_px(layout_rect.height));
|
||||
LayoutSize::new(
|
||||
adjust_radius(radius.width, width.to_f32_px()),
|
||||
|
@ -1361,22 +1362,22 @@ pub(super) fn compute_margin_box_radius(
|
|||
top_left: compute_margin_radius(
|
||||
radius.top_left,
|
||||
layout_rect,
|
||||
Size2D::new(margin.margin_left.clone(), margin.margin_top.clone()),
|
||||
Size2D::new(margin.left.clone(), margin.top.clone()),
|
||||
),
|
||||
top_right: compute_margin_radius(
|
||||
radius.top_right,
|
||||
layout_rect,
|
||||
Size2D::new(margin.margin_right.clone(), margin.margin_top.clone()),
|
||||
Size2D::new(margin.right.clone(), margin.top.clone()),
|
||||
),
|
||||
bottom_left: compute_margin_radius(
|
||||
radius.bottom_left,
|
||||
layout_rect,
|
||||
Size2D::new(margin.margin_left.clone(), margin.margin_bottom.clone()),
|
||||
Size2D::new(margin.left.clone(), margin.bottom.clone()),
|
||||
),
|
||||
bottom_right: compute_margin_radius(
|
||||
radius.bottom_right,
|
||||
layout_rect,
|
||||
Size2D::new(margin.margin_right.clone(), margin.margin_bottom.clone()),
|
||||
Size2D::new(margin.right.clone(), margin.bottom.clone()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1364,16 +1364,14 @@ impl BoxFragment {
|
|||
// Percentages sticky positions offsets are resovled against the size of the
|
||||
// nearest scroll frame instead of the containing block like for other types
|
||||
// of positioning.
|
||||
let position = self.style.get_position();
|
||||
let scroll_frame_height = Au::from_f32_px(scroll_frame_size_for_resolve.height);
|
||||
let scroll_frame_width = Au::from_f32_px(scroll_frame_size_for_resolve.width);
|
||||
let offsets = self.style.physical_box_offsets();
|
||||
let offsets = PhysicalSides::<AuOrAuto>::new(
|
||||
position.top.map(|v| v.to_used_value(scroll_frame_height)),
|
||||
position.right.map(|v| v.to_used_value(scroll_frame_width)),
|
||||
position
|
||||
.bottom
|
||||
.map(|v| v.to_used_value(scroll_frame_height)),
|
||||
position.left.map(|v| v.to_used_value(scroll_frame_width)),
|
||||
offsets.top.map(|v| v.to_used_value(scroll_frame_height)),
|
||||
offsets.right.map(|v| v.to_used_value(scroll_frame_width)),
|
||||
offsets.bottom.map(|v| v.to_used_value(scroll_frame_height)),
|
||||
offsets.left.map(|v| v.to_used_value(scroll_frame_width)),
|
||||
);
|
||||
self.resolved_sticky_insets = Some(offsets);
|
||||
|
||||
|
|
|
@ -1929,6 +1929,7 @@ fn block_size_is_zero_or_intrinsic(size: &StyleSize, containing_block: &Containi
|
|||
lp.is_definitely_zero() ||
|
||||
(lp.0.has_percentage() && containing_block.block_size.is_auto())
|
||||
},
|
||||
StyleSize::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,13 +10,14 @@ use style::computed_values::overflow_x::T as ComputedOverflow;
|
|||
use style::computed_values::position::T as ComputedPosition;
|
||||
use style::logical_geometry::WritingMode;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::LengthPercentageOrAuto;
|
||||
use style::Zero;
|
||||
|
||||
use super::{BaseFragment, BaseFragmentInfo, CollapsedBlockMargins, Fragment};
|
||||
use crate::cell::ArcRefCell;
|
||||
use crate::formatting_contexts::Baselines;
|
||||
use crate::geom::{AuOrAuto, PhysicalPoint, PhysicalRect, PhysicalSides, ToLogical};
|
||||
use crate::geom::{
|
||||
AuOrAuto, LengthPercentageOrAuto, PhysicalPoint, PhysicalRect, PhysicalSides, ToLogical,
|
||||
};
|
||||
use crate::style_ext::ComputedValuesExt;
|
||||
|
||||
/// Describes how a [`BoxFragment`] paints its background.
|
||||
|
@ -277,7 +278,7 @@ impl BoxFragment {
|
|||
// the property is not over-constrained, then the resolved value is the
|
||||
// used value. Otherwise the resolved value is the computed value."
|
||||
// https://drafts.csswg.org/cssom/#resolved-values
|
||||
let insets = self.style.get_position();
|
||||
let insets = self.style.physical_box_offsets();
|
||||
let (cb_width, cb_height) = (containing_block.width(), containing_block.height());
|
||||
if position == ComputedPosition::Relative {
|
||||
let get_resolved_axis = |start: &LengthPercentageOrAuto,
|
||||
|
|
|
@ -708,6 +708,7 @@ impl From<StyleSize> for Size<LengthPercentage> {
|
|||
StyleSize::MaxContent => Size::MaxContent,
|
||||
StyleSize::FitContent => Size::FitContent,
|
||||
StyleSize::Stretch => Size::Stretch,
|
||||
StyleSize::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -721,6 +722,7 @@ impl From<StyleMaxSize> for Size<LengthPercentage> {
|
|||
StyleMaxSize::MaxContent => Size::MaxContent,
|
||||
StyleMaxSize::FitContent => Size::FitContent,
|
||||
StyleMaxSize::Stretch => Size::Stretch,
|
||||
StyleMaxSize::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use style::properties::ComputedValues;
|
|||
use style::servo::selector_parser::PseudoElement;
|
||||
use style::values::computed::basic_shape::ClipPath;
|
||||
use style::values::computed::image::Image as ComputedImageLayer;
|
||||
use style::values::computed::{AlignItems, BorderStyle, LengthPercentage};
|
||||
use style::values::computed::{AlignItems, BorderStyle, Inset, LengthPercentage, Margin};
|
||||
use style::values::generics::box_::Perspective;
|
||||
use style::values::generics::position::{GenericAspectRatio, PreferredRatio};
|
||||
use style::values::specified::align::AlignFlags;
|
||||
|
@ -180,6 +180,7 @@ impl AspectRatio {
|
|||
}
|
||||
|
||||
pub(crate) trait ComputedValuesExt {
|
||||
fn physical_box_offsets(&self) -> PhysicalSides<LengthPercentageOrAuto<'_>>;
|
||||
fn box_offsets(
|
||||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
|
@ -279,6 +280,7 @@ pub(crate) trait ComputedValuesExt {
|
|||
fn border_style(&self, containing_block_writing_mode: WritingMode)
|
||||
-> LogicalSides<BorderStyle>;
|
||||
fn border_width(&self, containing_block_writing_mode: WritingMode) -> LogicalSides<Au>;
|
||||
fn physical_margin(&self) -> PhysicalSides<LengthPercentageOrAuto<'_>>;
|
||||
fn margin(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
|
@ -314,18 +316,30 @@ pub(crate) trait ComputedValuesExt {
|
|||
}
|
||||
|
||||
impl ComputedValuesExt for ComputedValues {
|
||||
fn physical_box_offsets(&self) -> PhysicalSides<LengthPercentageOrAuto<'_>> {
|
||||
fn convert<'a>(inset: &'a Inset) -> LengthPercentageOrAuto<'a> {
|
||||
match inset {
|
||||
Inset::LengthPercentage(ref v) => LengthPercentageOrAuto::LengthPercentage(v),
|
||||
Inset::Auto => LengthPercentageOrAuto::Auto,
|
||||
Inset::AnchorFunction(_) => unreachable!("anchor() should be disabled"),
|
||||
Inset::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
|
||||
}
|
||||
}
|
||||
let position = self.get_position();
|
||||
PhysicalSides::new(
|
||||
convert(&position.top),
|
||||
convert(&position.right),
|
||||
convert(&position.bottom),
|
||||
convert(&position.left),
|
||||
)
|
||||
}
|
||||
|
||||
fn box_offsets(
|
||||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
) -> LogicalSides<LengthPercentageOrAuto<'_>> {
|
||||
let position = self.get_position();
|
||||
LogicalSides::from_physical(
|
||||
&PhysicalSides::new(
|
||||
position.top.as_ref(),
|
||||
position.right.as_ref(),
|
||||
position.bottom.as_ref(),
|
||||
position.left.as_ref(),
|
||||
),
|
||||
&self.physical_box_offsets(),
|
||||
containing_block.style.writing_mode,
|
||||
)
|
||||
}
|
||||
|
@ -681,20 +695,28 @@ impl ComputedValuesExt for ComputedValues {
|
|||
)
|
||||
}
|
||||
|
||||
fn physical_margin(&self) -> PhysicalSides<LengthPercentageOrAuto<'_>> {
|
||||
fn convert<'a>(inset: &'a Margin) -> LengthPercentageOrAuto<'a> {
|
||||
match inset {
|
||||
Margin::LengthPercentage(ref v) => LengthPercentageOrAuto::LengthPercentage(v),
|
||||
Margin::Auto => LengthPercentageOrAuto::Auto,
|
||||
Margin::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
|
||||
}
|
||||
}
|
||||
let margin = self.get_margin();
|
||||
PhysicalSides::new(
|
||||
convert(&margin.margin_top),
|
||||
convert(&margin.margin_right),
|
||||
convert(&margin.margin_bottom),
|
||||
convert(&margin.margin_left),
|
||||
)
|
||||
}
|
||||
|
||||
fn margin(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> LogicalSides<LengthPercentageOrAuto<'_>> {
|
||||
let margin = self.get_margin();
|
||||
LogicalSides::from_physical(
|
||||
&PhysicalSides::new(
|
||||
margin.margin_top.as_ref(),
|
||||
margin.margin_right.as_ref(),
|
||||
margin.margin_bottom.as_ref(),
|
||||
margin.margin_left.as_ref(),
|
||||
),
|
||||
containing_block_writing_mode,
|
||||
)
|
||||
LogicalSides::from_physical(&self.physical_margin(), containing_block_writing_mode)
|
||||
}
|
||||
|
||||
/// Returns true if this style has a transform, or perspective property set and
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue