mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Make AbsolutelyPositionedBox be 'static
This commit is contained in:
parent
7ade924683
commit
c3932185ec
7 changed files with 42 additions and 48 deletions
|
@ -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)
|
||||
},
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue