aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2024-10-20 21:53:38 +0200
committerGitHub <noreply@github.com>2024-10-20 19:53:38 +0000
commitc75f6627ba0e314d5fb4c4c9230e93cbb1b188e3 (patch)
treee6ebec7e4fa425f36b02d89587020012ff7a05ee /components
parent65c866285f69d4c26ae46e604bcc05dda1641df7 (diff)
downloadservo-c75f6627ba0e314d5fb4c4c9230e93cbb1b188e3.tar.gz
servo-c75f6627ba0e314d5fb4c4c9230e93cbb1b188e3.zip
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>
Diffstat (limited to 'components')
-rw-r--r--components/layout/block.rs34
-rw-r--r--components/layout/flex.rs4
-rw-r--r--components/layout/fragment.rs30
-rw-r--r--components/layout/model.rs33
-rw-r--r--components/layout_2020/display_list/mod.rs19
-rw-r--r--components/layout_2020/display_list/stacking_context.rs12
-rw-r--r--components/layout_2020/flow/mod.rs1
-rw-r--r--components/layout_2020/fragment_tree/box_fragment.rs7
-rw-r--r--components/layout_2020/geom.rs2
-rw-r--r--components/layout_2020/style_ext.rs58
-rw-r--r--components/script/dom/cssrule.rs1
11 files changed, 125 insertions, 76 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs
index bceb82b572d..31f6acd243c 100644
--- a/components/layout/block.rs
+++ b/components/layout/block.rs
@@ -46,7 +46,7 @@ use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode};
use style::properties::ComputedValues;
use style::servo::restyle_damage::ServoRestyleDamage;
-use style::values::computed::{LengthPercentageOrAuto, MaxSize, Size};
+use style::values::computed::{Margin, MaxSize, Size};
use crate::context::LayoutContext;
use crate::display_list::items::DisplayListSection;
@@ -1408,8 +1408,8 @@ impl BlockFlow {
let (block_start, block_end) = {
let position = self.fragment.style().logical_position();
(
- MaybeAuto::from_style(position.block_start, container_size),
- MaybeAuto::from_style(position.block_end, container_size),
+ MaybeAuto::from_inset(position.block_start, container_size),
+ MaybeAuto::from_inset(position.block_end, container_size),
)
};
@@ -1422,11 +1422,11 @@ impl BlockFlow {
// calculated during assign-inline-size.
let margin = self.fragment.style().logical_margin();
let margin_block_start = match margin.block_start {
- LengthPercentageOrAuto::Auto => MaybeAuto::Auto,
+ Margin::Auto => MaybeAuto::Auto,
_ => MaybeAuto::Specified(self.fragment.margin.block_start),
};
let margin_block_end = match margin.block_end {
- LengthPercentageOrAuto::Auto => MaybeAuto::Auto,
+ Margin::Auto => MaybeAuto::Auto,
_ => MaybeAuto::Specified(self.fragment.margin.block_end),
};
@@ -1456,11 +1456,11 @@ impl BlockFlow {
// calculated during assign-inline-size.
let margin = self.fragment.style().logical_margin();
let margin_block_start = match margin.block_start {
- LengthPercentageOrAuto::Auto => MaybeAuto::Auto,
+ Margin::Auto => MaybeAuto::Auto,
_ => MaybeAuto::Specified(self.fragment.margin.block_start),
};
let margin_block_end = match margin.block_end {
- LengthPercentageOrAuto::Auto => MaybeAuto::Auto,
+ Margin::Auto => MaybeAuto::Auto,
_ => MaybeAuto::Specified(self.fragment.margin.block_end),
};
@@ -1469,8 +1469,8 @@ impl BlockFlow {
{
let position = self.fragment.style().logical_position();
block_start =
- MaybeAuto::from_style(position.block_start, containing_block_block_size);
- block_end = MaybeAuto::from_style(position.block_end, containing_block_block_size);
+ MaybeAuto::from_inset(position.block_start, containing_block_block_size);
+ block_end = MaybeAuto::from_inset(position.block_end, containing_block_block_size);
}
let available_block_size =
@@ -2117,10 +2117,10 @@ impl BlockFlow {
let offsets = self.fragment.style().logical_position();
let as_margins = LogicalMargin::new(
writing_mode,
- MaybeAuto::from_style(offsets.block_start, containing_block_size.inline),
- MaybeAuto::from_style(offsets.inline_end, containing_block_size.inline),
- MaybeAuto::from_style(offsets.block_end, containing_block_size.inline),
- MaybeAuto::from_style(offsets.inline_start, containing_block_size.inline),
+ MaybeAuto::from_inset(offsets.block_start, containing_block_size.inline),
+ MaybeAuto::from_inset(offsets.inline_end, containing_block_size.inline),
+ MaybeAuto::from_inset(offsets.block_end, containing_block_size.inline),
+ MaybeAuto::from_inset(offsets.inline_start, containing_block_size.inline),
);
as_margins.to_physical(writing_mode)
}
@@ -2789,10 +2789,10 @@ pub trait ISizeAndMarginsComputer {
containing_block_inline_size - block.fragment.border_padding.inline_start_end();
ISizeConstraintInput::new(
computed_inline_size,
- MaybeAuto::from_style(margin.inline_start, containing_block_inline_size),
- MaybeAuto::from_style(margin.inline_end, containing_block_inline_size),
- MaybeAuto::from_style(position.inline_start, containing_block_inline_size),
- MaybeAuto::from_style(position.inline_end, containing_block_inline_size),
+ MaybeAuto::from_margin(margin.inline_start, containing_block_inline_size),
+ MaybeAuto::from_margin(margin.inline_end, containing_block_inline_size),
+ MaybeAuto::from_inset(position.inline_start, containing_block_inline_size),
+ MaybeAuto::from_inset(position.inline_end, containing_block_inline_size),
available_inline_size,
)
}
diff --git a/components/layout/flex.rs b/components/layout/flex.rs
index f2aa96a0ec9..87408ad66f1 100644
--- a/components/layout/flex.rs
+++ b/components/layout/flex.rs
@@ -671,9 +671,9 @@ impl FlexFlow {
} else {
line.free_space / line.auto_margin_count
};
- let margin_inline_start = MaybeAuto::from_style(margin.inline_start, inline_size)
+ let margin_inline_start = MaybeAuto::from_margin(margin.inline_start, inline_size)
.specified_or_default(auto_len);
- let margin_inline_end = MaybeAuto::from_style(margin.inline_end, inline_size)
+ let margin_inline_end = MaybeAuto::from_margin(margin.inline_end, inline_size)
.specified_or_default(auto_len);
let item_inline_size = item.main_size -
block.fragment.box_sizing_boundary(self.main_mode) +
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index 1cb25cefc7a..01004e47438 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -962,8 +962,8 @@ impl Fragment {
QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_MARGINS,
) {
let margin = style.logical_margin();
- MaybeAuto::from_style(margin.inline_start, Au(0)).specified_or_zero() +
- MaybeAuto::from_style(margin.inline_end, Au(0)).specified_or_zero()
+ MaybeAuto::from_margin(margin.inline_start, Au(0)).specified_or_zero() +
+ MaybeAuto::from_margin(margin.inline_end, Au(0)).specified_or_zero()
} else {
Au(0)
};
@@ -1274,10 +1274,10 @@ impl Fragment {
let logical_padding = self.style.logical_padding();
let border_width = self.border_width();
SpeculatedInlineContentEdgeOffsets {
- start: MaybeAuto::from_style(logical_margin.inline_start, Au(0)).specified_or_zero() +
+ start: MaybeAuto::from_margin(logical_margin.inline_start, Au(0)).specified_or_zero() +
logical_padding.inline_start.to_used_value(Au(0)) +
border_width.inline_start,
- end: MaybeAuto::from_style(logical_margin.inline_end, Au(0)).specified_or_zero() +
+ end: MaybeAuto::from_margin(logical_margin.inline_end, Au(0)).specified_or_zero() +
logical_padding.inline_end.to_used_value(Au(0)) +
border_width.inline_end,
}
@@ -1349,9 +1349,9 @@ impl Fragment {
let (inline_start, inline_end) = {
let margin = self.style().logical_margin();
(
- MaybeAuto::from_style(margin.inline_start, containing_block_inline_size)
+ MaybeAuto::from_margin(margin.inline_start, containing_block_inline_size)
.specified_or_zero(),
- MaybeAuto::from_style(margin.inline_end, containing_block_inline_size)
+ MaybeAuto::from_margin(margin.inline_end, containing_block_inline_size)
.specified_or_zero(),
)
};
@@ -1369,7 +1369,7 @@ impl Fragment {
{
Au(0)
} else {
- MaybeAuto::from_style(margin.inline_start, containing_block_inline_size)
+ MaybeAuto::from_margin(margin.inline_start, containing_block_inline_size)
.specified_or_zero()
};
let this_inline_end_margin = if !node
@@ -1378,7 +1378,7 @@ impl Fragment {
{
Au(0)
} else {
- MaybeAuto::from_style(margin.inline_end, containing_block_inline_size)
+ MaybeAuto::from_margin(margin.inline_end, containing_block_inline_size)
.specified_or_zero()
};
@@ -1408,9 +1408,9 @@ impl Fragment {
let (block_start, block_end) = {
let margin = self.style().logical_margin();
(
- MaybeAuto::from_style(margin.block_start, containing_block_inline_size)
+ MaybeAuto::from_margin(margin.block_start, containing_block_inline_size)
.specified_or_zero(),
- MaybeAuto::from_style(margin.block_end, containing_block_inline_size)
+ MaybeAuto::from_margin(margin.block_end, containing_block_inline_size)
.specified_or_zero(),
)
};
@@ -1484,16 +1484,16 @@ impl Fragment {
fn from_style(style: &ComputedValues, container_size: &LogicalSize<Au>) -> LogicalSize<Au> {
let offsets = style.logical_position();
let offset_i = if !offsets.inline_start.is_auto() {
- MaybeAuto::from_style(offsets.inline_start, container_size.inline)
+ MaybeAuto::from_inset(offsets.inline_start, container_size.inline)
.specified_or_zero()
} else {
- -MaybeAuto::from_style(offsets.inline_end, container_size.inline)
+ -MaybeAuto::from_inset(offsets.inline_end, container_size.inline)
.specified_or_zero()
};
- let offset_b = if !offsets.block_start.is_auto() {
- MaybeAuto::from_style(offsets.block_start, container_size.block).specified_or_zero()
+ let offset_b = if offsets.block_start.is_auto() {
+ MaybeAuto::from_inset(offsets.block_start, container_size.block).specified_or_zero()
} else {
- -MaybeAuto::from_style(offsets.block_end, container_size.block).specified_or_zero()
+ -MaybeAuto::from_inset(offsets.block_end, container_size.block).specified_or_zero()
};
LogicalSize::new(style.writing_mode, offset_i, offset_b)
}
diff --git a/components/layout/model.rs b/components/layout/model.rs
index 83b3e3a8879..9aadc7083f8 100644
--- a/components/layout/model.rs
+++ b/components/layout/model.rs
@@ -12,7 +12,7 @@ use euclid::SideOffsets2D;
use serde::Serialize;
use style::logical_geometry::{LogicalMargin, WritingMode};
use style::properties::ComputedValues;
-use style::values::computed::{LengthPercentageOrAuto, MaxSize, Size};
+use style::values::computed::{Inset, LengthPercentageOrAuto, Margin, MaxSize, Size};
use crate::fragment::Fragment;
@@ -468,6 +468,29 @@ impl MaybeAuto {
}
#[inline]
+ pub fn from_inset(length: &Inset, containing_length: Au) -> MaybeAuto {
+ match length {
+ Inset::Auto => MaybeAuto::Auto,
+ Inset::LengthPercentage(ref lp) => {
+ MaybeAuto::Specified(lp.to_used_value(containing_length))
+ },
+ Inset::AnchorFunction(_) => unreachable!("anchor() should be disabled"),
+ Inset::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
+ }
+ }
+
+ #[inline]
+ pub fn from_margin(length: &Margin, containing_length: Au) -> MaybeAuto {
+ match length {
+ Margin::Auto => MaybeAuto::Auto,
+ Margin::LengthPercentage(ref lp) => {
+ MaybeAuto::Specified(lp.to_used_value(containing_length))
+ },
+ Margin::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
+ }
+ }
+
+ #[inline]
pub fn from_option(au: Option<Au>) -> MaybeAuto {
match au {
Some(l) => MaybeAuto::Specified(l),
@@ -562,10 +585,10 @@ pub fn specified_margin_from_style(
LogicalMargin::from_physical(
writing_mode,
SideOffsets2D::new(
- MaybeAuto::from_style(&margin_style.margin_top, Au(0)).specified_or_zero(),
- MaybeAuto::from_style(&margin_style.margin_right, Au(0)).specified_or_zero(),
- MaybeAuto::from_style(&margin_style.margin_bottom, Au(0)).specified_or_zero(),
- MaybeAuto::from_style(&margin_style.margin_left, Au(0)).specified_or_zero(),
+ MaybeAuto::from_margin(&margin_style.margin_top, Au(0)).specified_or_zero(),
+ MaybeAuto::from_margin(&margin_style.margin_right, Au(0)).specified_or_zero(),
+ MaybeAuto::from_margin(&margin_style.margin_bottom, Au(0)).specified_or_zero(),
+ MaybeAuto::from_margin(&margin_style.margin_left, Au(0)).specified_or_zero(),
),
)
}
diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs
index 3e9105035f4..1aed24e70eb 100644
--- a/components/layout_2020/display_list/mod.rs
+++ b/components/layout_2020/display_list/mod.rs
@@ -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()),
),
}
}
diff --git a/components/layout_2020/display_list/stacking_context.rs b/components/layout_2020/display_list/stacking_context.rs
index c6645949f19..1571dd999ca 100644
--- a/components/layout_2020/display_list/stacking_context.rs
+++ b/components/layout_2020/display_list/stacking_context.rs
@@ -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);
diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs
index 80dcba20b66..2187a15c7f5 100644
--- a/components/layout_2020/flow/mod.rs
+++ b/components/layout_2020/flow/mod.rs
@@ -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"),
}
}
diff --git a/components/layout_2020/fragment_tree/box_fragment.rs b/components/layout_2020/fragment_tree/box_fragment.rs
index 594fb56aa14..6e1039200e2 100644
--- a/components/layout_2020/fragment_tree/box_fragment.rs
+++ b/components/layout_2020/fragment_tree/box_fragment.rs
@@ -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,
diff --git a/components/layout_2020/geom.rs b/components/layout_2020/geom.rs
index baa2c541415..515ec7fa979 100644
--- a/components/layout_2020/geom.rs
+++ b/components/layout_2020/geom.rs
@@ -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"),
}
}
}
diff --git a/components/layout_2020/style_ext.rs b/components/layout_2020/style_ext.rs
index 16cecbf22c0..b1ea1110857 100644
--- a/components/layout_2020/style_ext.rs
+++ b/components/layout_2020/style_ext.rs
@@ -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
diff --git a/components/script/dom/cssrule.rs b/components/script/dom/cssrule.rs
index 465dcce7aa2..de648ca849b 100644
--- a/components/script/dom/cssrule.rs
+++ b/components/script/dom/cssrule.rs
@@ -120,6 +120,7 @@ impl CSSRule {
StyleCssRule::Scope(_) => unimplemented!(), // TODO
StyleCssRule::StartingStyle(_) => unimplemented!(), // TODO
StyleCssRule::PositionTry(_) => unimplemented!(), // TODO
+ StyleCssRule::NestedDeclarations(_) => unimplemented!(), // TODO
}
}