diff --git a/components/layout_2020/display_list/stacking_context.rs b/components/layout_2020/display_list/stacking_context.rs index 371b20e25ac..8dfda0fe65f 100644 --- a/components/layout_2020/display_list/stacking_context.rs +++ b/components/layout_2020/display_list/stacking_context.rs @@ -916,7 +916,7 @@ impl AbsoluteOrFixedPositionedFragment { stacking_context: &mut StackingContext, ) { let hoisted_fragment = self.hoisted_fragment.borrow(); - let fragment_ref = match hoisted_fragment.as_ref() { + let fragment_ref = match hoisted_fragment.fragment.as_ref() { Some(fragment_ref) => fragment_ref, None => unreachable!("Found hoisted box with missing fragment."), }; diff --git a/components/layout_2020/fragments.rs b/components/layout_2020/fragments.rs index b0111f517bb..f780ff50d58 100644 --- a/components/layout_2020/fragments.rs +++ b/components/layout_2020/fragments.rs @@ -8,6 +8,7 @@ use crate::geom::flow_relative::{Rect, Sides}; use crate::geom::{PhysicalPoint, PhysicalRect}; #[cfg(debug_assertions)] use crate::layout_debug; +use crate::positioned::HoistedSharedFragment; use gfx::font::FontMetrics as GfxFontMetrics; use gfx::text::glyph::GlyphStore; use gfx_traits::print_tree::PrintTree; @@ -74,7 +75,7 @@ pub(crate) enum Fragment { #[derive(Serialize)] pub(crate) struct AbsoluteOrFixedPositionedFragment { pub position: ComputedPosition, - pub hoisted_fragment: ArcRefCell>>, + pub hoisted_fragment: ArcRefCell, } #[derive(Serialize)] diff --git a/components/layout_2020/positioned.rs b/components/layout_2020/positioned.rs index eb455eb4990..f1a84660303 100644 --- a/components/layout_2020/positioned.rs +++ b/components/layout_2020/positioned.rs @@ -46,7 +46,21 @@ pub(crate) struct HoistedAbsolutelyPositionedBox { /// A reference to a Fragment which is shared between this `HoistedAbsolutelyPositionedBox` /// and its placeholder `AbsoluteOrFixedPositionedFragment` in the original tree position. /// This will be used later in order to paint this hoisted box in tree order. - pub fragment: ArcRefCell>>, + pub fragment: ArcRefCell, +} + +/// A reference to a Fragment which is shared between `HoistedAbsolutelyPositionedBox` +/// and its placeholder `AbsoluteOrFixedPositionedFragment` in the original tree position. +/// This will be used later in order to paint this hoisted box in tree order. +#[derive(Serialize)] +pub(crate) struct HoistedSharedFragment { + pub fragment: Option>, +} + +impl HoistedSharedFragment { + pub(crate) fn new() -> Self { + HoistedSharedFragment { fragment: None } + } } impl HoistedAbsolutelyPositionedBox { @@ -79,8 +93,8 @@ pub(crate) enum AbsoluteBoxOffsets { impl AbsoluteBoxOffsets { fn adjust_offset(&mut self, new_offset: Length) { match *self { - AbsoluteBoxOffsets::StaticStart {ref mut start} => *start = new_offset, - _ => () + AbsoluteBoxOffsets::StaticStart { ref mut start } => *start = new_offset, + _ => (), } } } @@ -149,7 +163,7 @@ impl AbsolutelyPositionedBox { HoistedAbsolutelyPositionedBox { tree_rank, box_offsets, - fragment: ArcRefCell::new(None), + fragment: ArcRefCell::new(HoistedSharedFragment::new()), absolutely_positioned_box: self_, } } @@ -376,7 +390,7 @@ impl HoistedAbsolutelyPositionedBox { containing_block, ))); - *box_.fragment.borrow_mut() = Some(new_fragment.clone()); + box_.fragment.borrow_mut().fragment = Some(new_fragment.clone()); new_fragment }, Vec::new, @@ -389,7 +403,7 @@ impl HoistedAbsolutelyPositionedBox { for_nearest_containing_block_for_all_descendants, containing_block, ))); - *box_.fragment.borrow_mut() = Some(new_fragment.clone()); + box_.fragment.borrow_mut().fragment = Some(new_fragment.clone()); new_fragment })) }