aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorAnthony Ramine <nox@nox.paris>2020-03-13 12:22:32 +0100
committerPatrick Walton <pcwalton@mimiga.net>2020-03-17 11:15:17 -0700
commitc3932185ec649c3063096ca0c545b62c3ddbfd5b (patch)
tree45d29b8a3c46d8473084e65ff00f769765273893 /components
parent7ade924683c22f1f990c4b9fa09ef1b38dc6b027 (diff)
downloadservo-c3932185ec649c3063096ca0c545b62c3ddbfd5b.tar.gz
servo-c3932185ec649c3063096ca0c545b62c3ddbfd5b.zip
Make AbsolutelyPositionedBox be 'static
Diffstat (limited to 'components')
-rw-r--r--components/layout_2020/flow/construct.rs8
-rw-r--r--components/layout_2020/flow/inline.rs10
-rw-r--r--components/layout_2020/flow/mod.rs32
-rw-r--r--components/layout_2020/flow/root.rs4
-rw-r--r--components/layout_2020/formatting_contexts.rs4
-rw-r--r--components/layout_2020/lib.rs1
-rw-r--r--components/layout_2020/positioned.rs31
7 files changed, 42 insertions, 48 deletions
diff --git a/components/layout_2020/flow/construct.rs b/components/layout_2020/flow/construct.rs
index cff3fa281a6..6eee3675a8e 100644
--- a/components/layout_2020/flow/construct.rs
+++ b/components/layout_2020/flow/construct.rs
@@ -525,7 +525,7 @@ where
kind,
});
} else {
- let box_ = Arc::new(InlineLevelBox::OutOfFlowAbsolutelyPositionedBox(
+ let box_ = Arc::new(InlineLevelBox::OutOfFlowAbsolutelyPositionedBox(Arc::new(
AbsolutelyPositionedBox::construct(
self.context,
node,
@@ -533,7 +533,7 @@ where
display_inside,
contents,
),
- ));
+ )));
self.current_inline_level_boxes().push(box_.clone());
box_slot.set(LayoutBox::InlineLevel(box_))
}
@@ -687,13 +687,13 @@ where
contents,
} => {
let block_level_box = Arc::new(BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(
- AbsolutelyPositionedBox::construct(
+ Arc::new(AbsolutelyPositionedBox::construct(
context,
node,
style,
display_inside,
contents,
- ),
+ )),
));
(block_level_box, ContainsFloats::No)
},
diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs
index bd8f5bc784f..8e1587568c0 100644
--- a/components/layout_2020/flow/inline.rs
+++ b/components/layout_2020/flow/inline.rs
@@ -34,7 +34,7 @@ pub(crate) struct InlineFormattingContext {
pub(crate) enum InlineLevelBox {
InlineBox(InlineBox),
TextRun(TextRun),
- OutOfFlowAbsolutelyPositionedBox(AbsolutelyPositionedBox),
+ OutOfFlowAbsolutelyPositionedBox(Arc<AbsolutelyPositionedBox>),
OutOfFlowFloatBox(FloatBox),
Atomic(IndependentFormattingContext),
}
@@ -77,7 +77,7 @@ struct PartialInlineBoxFragment<'box_tree> {
}
struct InlineFormattingContextState<'box_tree, 'a, 'b> {
- positioning_context: &'a mut PositioningContext<'box_tree>,
+ positioning_context: &'a mut PositioningContext,
containing_block: &'b ContainingBlock<'b>,
lines: Lines,
inline_position: Length,
@@ -204,10 +204,10 @@ impl InlineFormattingContext {
computation.paragraph
}
- pub(super) fn layout<'a>(
- &'a self,
+ pub(super) fn layout(
+ &self,
layout_context: &LayoutContext,
- positioning_context: &mut PositioningContext<'a>,
+ positioning_context: &mut PositioningContext,
containing_block: &ContainingBlock,
tree_rank: usize,
) -> FlowLayout {
diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs
index e15947f52b0..1f6d6db49df 100644
--- a/components/layout_2020/flow/mod.rs
+++ b/components/layout_2020/flow/mod.rs
@@ -50,7 +50,7 @@ pub(crate) enum BlockLevelBox {
style: Arc<ComputedValues>,
contents: BlockContainer,
},
- OutOfFlowAbsolutelyPositionedBox(AbsolutelyPositionedBox),
+ OutOfFlowAbsolutelyPositionedBox(Arc<AbsolutelyPositionedBox>),
OutOfFlowFloatBox(FloatBox),
Independent(IndependentFormattingContext),
}
@@ -65,10 +65,10 @@ struct FlowLayout {
struct CollapsibleWithParentStartMargin(bool);
impl BlockFormattingContext {
- pub(super) fn layout<'a>(
- &'a self,
+ pub(super) fn layout(
+ &self,
layout_context: &LayoutContext,
- positioning_context: &mut PositioningContext<'a>,
+ positioning_context: &mut PositioningContext,
containing_block: &ContainingBlock,
tree_rank: usize,
) -> IndependentLayout {
@@ -101,10 +101,10 @@ impl BlockFormattingContext {
}
impl BlockContainer {
- fn layout<'a>(
- &'a self,
+ fn layout(
+ &self,
layout_context: &LayoutContext,
- positioning_context: &mut PositioningContext<'a>,
+ positioning_context: &mut PositioningContext,
containing_block: &ContainingBlock,
tree_rank: usize,
float_context: Option<&mut FloatContext>,
@@ -130,10 +130,10 @@ impl BlockContainer {
}
}
-fn layout_block_level_children<'a>(
+fn layout_block_level_children(
layout_context: &LayoutContext,
- positioning_context: &mut PositioningContext<'a>,
- child_boxes: &'a [Arc<BlockLevelBox>],
+ positioning_context: &mut PositioningContext,
+ child_boxes: &[Arc<BlockLevelBox>],
containing_block: &ContainingBlock,
tree_rank: usize,
mut float_context: Option<&mut FloatContext>,
@@ -256,10 +256,10 @@ fn layout_block_level_children<'a>(
}
impl BlockLevelBox {
- fn layout<'a>(
- &'a self,
+ fn layout(
+ &self,
layout_context: &LayoutContext,
- positioning_context: &mut PositioningContext<'a>,
+ positioning_context: &mut PositioningContext,
containing_block: &ContainingBlock,
tree_rank: usize,
float_context: Option<&mut FloatContext>,
@@ -338,13 +338,13 @@ enum NonReplacedContents<'a> {
/// https://drafts.csswg.org/css2/visudet.html#blockwidth
/// https://drafts.csswg.org/css2/visudet.html#normal-block
-fn layout_in_flow_non_replaced_block_level<'a>(
+fn layout_in_flow_non_replaced_block_level(
layout_context: &LayoutContext,
- positioning_context: &mut PositioningContext<'a>,
+ positioning_context: &mut PositioningContext,
containing_block: &ContainingBlock,
tag: OpaqueNode,
style: &Arc<ComputedValues>,
- block_level_kind: NonReplacedContents<'a>,
+ block_level_kind: NonReplacedContents,
tree_rank: usize,
float_context: Option<&mut FloatContext>,
) -> BoxFragment {
diff --git a/components/layout_2020/flow/root.rs b/components/layout_2020/flow/root.rs
index 0b93701b01b..63ca58ead1d 100644
--- a/components/layout_2020/flow/root.rs
+++ b/components/layout_2020/flow/root.rs
@@ -84,13 +84,13 @@ fn construct_for_root_element<'dom>(
(
ContainsFloats::No,
vec![Arc::new(BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(
- AbsolutelyPositionedBox::construct(
+ Arc::new(AbsolutelyPositionedBox::construct(
context,
root_element,
style,
display_inside,
contents,
- ),
+ )),
))],
)
} else if box_style.float.is_floating() {
diff --git a/components/layout_2020/formatting_contexts.rs b/components/layout_2020/formatting_contexts.rs
index e4baf169476..100ef4a7c4b 100644
--- a/components/layout_2020/formatting_contexts.rs
+++ b/components/layout_2020/formatting_contexts.rs
@@ -104,11 +104,11 @@ impl IndependentFormattingContext {
}
}
-impl<'a> NonReplacedIFC<'a> {
+impl NonReplacedIFC<'_> {
pub fn layout(
&self,
layout_context: &LayoutContext,
- positioning_context: &mut PositioningContext<'a>,
+ positioning_context: &mut PositioningContext,
containing_block: &ContainingBlock,
tree_rank: usize,
) -> IndependentLayout {
diff --git a/components/layout_2020/lib.rs b/components/layout_2020/lib.rs
index 610c5306f53..c7d260f0f89 100644
--- a/components/layout_2020/lib.rs
+++ b/components/layout_2020/lib.rs
@@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![deny(unsafe_code)]
+#![feature(arbitrary_self_types)]
#![feature(exact_size_is_empty)]
#[macro_use]
diff --git a/components/layout_2020/positioned.rs b/components/layout_2020/positioned.rs
index b40a3b8b1ab..b909ae2d471 100644
--- a/components/layout_2020/positioned.rs
+++ b/components/layout_2020/positioned.rs
@@ -36,19 +36,18 @@ pub(crate) struct AbsolutelyPositionedBox {
pub contents: IndependentFormattingContext,
}
-pub(crate) struct PositioningContext<'box_tree> {
- for_nearest_positioned_ancestor: Option<Vec<HoistedAbsolutelyPositionedBox<'box_tree>>>,
+pub(crate) struct PositioningContext {
+ for_nearest_positioned_ancestor: Option<Vec<HoistedAbsolutelyPositionedBox>>,
// For nearest `containing block for all descendants` as defined by the CSS transforms
// spec.
// https://www.w3.org/TR/css-transforms-1/#containing-block-for-all-descendants
- for_nearest_containing_block_for_all_descendants:
- Vec<HoistedAbsolutelyPositionedBox<'box_tree>>,
+ for_nearest_containing_block_for_all_descendants: Vec<HoistedAbsolutelyPositionedBox>,
}
#[derive(Debug)]
-pub(crate) struct HoistedAbsolutelyPositionedBox<'box_tree> {
- absolutely_positioned_box: &'box_tree AbsolutelyPositionedBox,
+pub(crate) struct HoistedAbsolutelyPositionedBox {
+ absolutely_positioned_box: Arc<AbsolutelyPositionedBox>,
/// The rank of the child from which this absolutely positioned fragment
/// came from, when doing the layout of a block container. Used to compute
@@ -110,7 +109,7 @@ impl AbsolutelyPositionedBox {
}
pub(crate) fn to_hoisted(
- &self,
+ self: Arc<Self>,
initial_start_corner: Vec2<Length>,
tree_rank: usize,
) -> HoistedAbsolutelyPositionedBox {
@@ -150,7 +149,7 @@ impl AbsolutelyPositionedBox {
}
}
-impl<'box_tree> PositioningContext<'box_tree> {
+impl PositioningContext {
pub(crate) fn new_for_containing_block_for_all_descendants() -> Self {
Self {
for_nearest_positioned_ancestor: None,
@@ -220,9 +219,7 @@ impl<'box_tree> PositioningContext<'box_tree> {
fn create_and_layout_positioned(
layout_context: &LayoutContext,
style: &ComputedValues,
- for_nearest_containing_block_for_all_descendants: &mut Vec<
- HoistedAbsolutelyPositionedBox<'box_tree>,
- >,
+ for_nearest_containing_block_for_all_descendants: &mut Vec<HoistedAbsolutelyPositionedBox>,
fragment_layout_fn: impl FnOnce(&mut Self) -> BoxFragment,
) -> BoxFragment {
if style.establishes_containing_block_for_all_descendants() {
@@ -296,7 +293,7 @@ impl<'box_tree> PositioningContext<'box_tree> {
new_fragment
}
- pub(crate) fn push(&mut self, box_: HoistedAbsolutelyPositionedBox<'box_tree>) {
+ pub(crate) fn push(&mut self, box_: HoistedAbsolutelyPositionedBox) {
if let Some(nearest) = &mut self.for_nearest_positioned_ancestor {
match box_
.absolutely_positioned_box
@@ -412,14 +409,12 @@ impl<'box_tree> PositioningContext<'box_tree> {
}
}
-impl<'box_tree> HoistedAbsolutelyPositionedBox<'box_tree> {
+impl HoistedAbsolutelyPositionedBox {
pub(crate) fn layout_many(
layout_context: &LayoutContext,
boxes: &[Self],
fragments: &mut Vec<Fragment>,
- for_nearest_containing_block_for_all_descendants: &mut Vec<
- HoistedAbsolutelyPositionedBox<'box_tree>,
- >,
+ for_nearest_containing_block_for_all_descendants: &mut Vec<HoistedAbsolutelyPositionedBox>,
containing_block: &DefiniteContainingBlock,
) {
if layout_context.use_rayon {
@@ -449,9 +444,7 @@ impl<'box_tree> HoistedAbsolutelyPositionedBox<'box_tree> {
pub(crate) fn layout(
&self,
layout_context: &LayoutContext,
- for_nearest_containing_block_for_all_descendants: &mut Vec<
- HoistedAbsolutelyPositionedBox<'box_tree>,
- >,
+ for_nearest_containing_block_for_all_descendants: &mut Vec<HoistedAbsolutelyPositionedBox>,
containing_block: &DefiniteContainingBlock,
) -> BoxFragment {
let style = &self.absolutely_positioned_box.contents.style;