diff options
author | Oriol Brufau <obrufau@igalia.com> | 2023-11-22 11:38:17 +0100 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-11-24 08:57:14 +0100 |
commit | 0fd2f08da19e1e33e7850c1b2e7c484f9011fbe5 (patch) | |
tree | 20a2747a195feb1659e8d59e8ba2622937e3c2b0 | |
parent | 7b4fb5dc22e1542be9d92ec0e88a266ad9b1da86 (diff) | |
download | servo-0fd2f08da19e1e33e7850c1b2e7c484f9011fbe5.tar.gz servo-0fd2f08da19e1e33e7850c1b2e7c484f9011fbe5.zip |
Further changes required by Servo
-rw-r--r-- | components/layout/construct.rs | 9 | ||||
-rw-r--r-- | components/layout/query.rs | 23 | ||||
-rw-r--r-- | components/layout_2020/display_list/mod.rs | 10 | ||||
-rw-r--r-- | components/layout_2020/display_list/stacking_context.rs | 3 | ||||
-rw-r--r-- | components/layout_2020/fragment_tree/fragment_tree.rs | 4 | ||||
-rw-r--r-- | components/layout_2020/style_ext.rs | 8 | ||||
-rw-r--r-- | components/style/servo/media_queries.rs | 7 |
7 files changed, 34 insertions, 30 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index ba6407f6bc0..c14c6b61b74 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -2208,14 +2208,15 @@ fn has_padding_or_border(values: &ComputedValues) -> bool { let padding = values.get_padding(); let border = values.get_border(); + use style::Zero; !padding.padding_top.is_definitely_zero() || !padding.padding_right.is_definitely_zero() || !padding.padding_bottom.is_definitely_zero() || !padding.padding_left.is_definitely_zero() || - border.border_top_width.px() != 0. || - border.border_right_width.px() != 0. || - border.border_bottom_width.px() != 0. || - border.border_left_width.px() != 0. + !border.border_top_width.is_zero() || + !border.border_right_width.is_zero() || + !border.border_bottom_width.is_zero() || + !border.border_left_width.is_zero() } /// Maintains a stack of anonymous boxes needed to ensure that the flow tree is *legal*. The tree diff --git a/components/layout/query.rs b/components/layout/query.rs index 27ee6c3b51a..6309ebb2784 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -477,14 +477,12 @@ impl FragmentBorderBoxIterator for FragmentClientRectQueryIterator { border_left_width: left_width, .. } = *fragment.style.get_border(); - let (left_width, right_width) = (left_width.px(), right_width.px()); - let (top_width, bottom_width) = (top_width.px(), bottom_width.px()); - self.client_rect.origin.y = top_width as i32; - self.client_rect.origin.x = left_width as i32; - self.client_rect.size.width = - (border_box.size.width.to_f32_px() - left_width - right_width) as i32; - self.client_rect.size.height = - (border_box.size.height.to_f32_px() - top_width - bottom_width) as i32; + let (left_width, right_width) = (left_width.to_px(), right_width.to_px()); + let (top_width, bottom_width) = (top_width.to_px(), bottom_width.to_px()); + self.client_rect.origin.y = top_width; + self.client_rect.origin.x = left_width; + self.client_rect.size.width = border_box.size.width.to_px() - left_width - right_width; + self.client_rect.size.height = border_box.size.height.to_px() - top_width - bottom_width; } fn should_process(&mut self, fragment: &Fragment) -> bool { @@ -507,11 +505,10 @@ impl FragmentBorderBoxIterator for UnioningFragmentScrollAreaIterator { border_left_width: left_border, .. } = *fragment.style.get_border(); - let (left_border, right_border) = (left_border.px(), right_border.px()); - let (top_border, bottom_border) = (top_border.px(), bottom_border.px()); - let right_padding = (border_box.size.width.to_f32_px() - right_border - left_border) as i32; - let bottom_padding = - (border_box.size.height.to_f32_px() - bottom_border - top_border) as i32; + let (left_border, right_border) = (left_border.to_px(), right_border.to_px()); + let (top_border, bottom_border) = (top_border.to_px(), bottom_border.to_px()); + let right_padding = border_box.size.width.to_px() - right_border - left_border; + let bottom_padding = border_box.size.height.to_px() - bottom_border - top_border; let top_padding = top_border as i32; let left_padding = left_border as i32; diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs index 57bc6100cd8..6b01f327b18 100644 --- a/components/layout_2020/display_list/mod.rs +++ b/components/layout_2020/display_list/mod.rs @@ -686,10 +686,10 @@ impl<'a> BuilderForBoxFragment<'a> { fn build_border(&mut self, builder: &mut DisplayListBuilder) { let border = self.fragment.style.get_border(); let widths = SideOffsets2D::new( - border.border_top_width.px(), - border.border_right_width.px(), - border.border_bottom_width.px(), - border.border_left_width.px(), + border.border_top_width.to_f32_px(), + border.border_right_width.to_f32_px(), + border.border_bottom_width.to_f32_px(), + border.border_left_width.to_f32_px(), ); if widths == SideOffsets2D::zero() { return; @@ -715,7 +715,7 @@ impl<'a> BuilderForBoxFragment<'a> { fn build_outline(&mut self, builder: &mut DisplayListBuilder) { let outline = self.fragment.style.get_outline(); - let width = outline.outline_width.px(); + let width = outline.outline_width.to_f32_px(); if width == 0.0 { return; } diff --git a/components/layout_2020/display_list/stacking_context.rs b/components/layout_2020/display_list/stacking_context.rs index 42d61f03c2f..22d7a5679e6 100644 --- a/components/layout_2020/display_list/stacking_context.rs +++ b/components/layout_2020/display_list/stacking_context.rs @@ -1052,7 +1052,8 @@ impl BoxFragment { containing_block: containing_block.rect, fragment: fragment.clone(), }); - if self.style.get_outline().outline_width.px() > 0.0 { + use style::Zero; + if !self.style.get_outline().outline_width.is_zero() { stacking_context .contents .push(StackingContextContent::Fragment { diff --git a/components/layout_2020/fragment_tree/fragment_tree.rs b/components/layout_2020/fragment_tree/fragment_tree.rs index f797f5644c6..8a10927ad3b 100644 --- a/components/layout_2020/fragment_tree/fragment_tree.rs +++ b/components/layout_2020/fragment_tree/fragment_tree.rs @@ -160,8 +160,8 @@ impl FragmentTree { let border = style.get_border(); Some(Rect::new( Point2D::new( - border.border_left_width.px() as i32, - border.border_top_width.px() as i32, + border.border_left_width.to_px(), + border.border_top_width.to_px(), ), Size2D::new( padding_rect.size.width.px() as i32, diff --git a/components/layout_2020/style_ext.rs b/components/layout_2020/style_ext.rs index 78f06625e06..0f8d4d245ad 100644 --- a/components/layout_2020/style_ext.rs +++ b/components/layout_2020/style_ext.rs @@ -320,10 +320,10 @@ impl ComputedValuesExt for ComputedValues { let border = self.get_border(); LogicalSides::from_physical( &PhysicalSides::new( - border.border_top_width.0, - border.border_right_width.0, - border.border_bottom_width.0, - border.border_left_width.0, + border.border_top_width.into(), + border.border_right_width.into(), + border.border_bottom_width.into(), + border.border_left_width.into(), ), containing_block_writing_mode, ) diff --git a/components/style/servo/media_queries.rs b/components/style/servo/media_queries.rs index 207a78fc8ef..11f3550a311 100644 --- a/components/style/servo/media_queries.rs +++ b/components/style/servo/media_queries.rs @@ -17,7 +17,7 @@ use crate::values::computed::Resolution; use crate::values::specified::font::FONT_MEDIUM_PX; use crate::values::specified::ViewportVariant; use crate::values::KeyframesName; -use app_units::Au; +use app_units::{Au, AU_PER_PX}; use euclid::default::Size2D as UntypedSize2D; use euclid::{Scale, SideOffsets2D, Size2D}; use mime::Mime; @@ -159,6 +159,11 @@ impl Device { self.used_viewport_units.load(Ordering::Relaxed) } + /// Returns the number of app units per device pixel we're using currently. + pub fn app_units_per_device_pixel(&self) -> i32 { + (AU_PER_PX as f32 / self.device_pixel_ratio.0) as i32 + } + /// Returns the device pixel ratio. pub fn device_pixel_ratio(&self) -> Scale<f32, CSSPixel, DevicePixel> { self.device_pixel_ratio |