mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Allow adjusting box offsets
This commit is contained in:
parent
fc71345114
commit
96c0c50874
2 changed files with 22 additions and 0 deletions
|
@ -352,6 +352,9 @@ impl BlockLevelBox {
|
||||||
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => {
|
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => {
|
||||||
let hoisted_box = AbsolutelyPositionedBox::to_hoisted(
|
let hoisted_box = AbsolutelyPositionedBox::to_hoisted(
|
||||||
box_.clone(),
|
box_.clone(),
|
||||||
|
// This is incorrect, however we do not know the
|
||||||
|
// correct positioning until later, in place_block_level_fragment,
|
||||||
|
// and this value will be adjusted there
|
||||||
Vec2::zero(),
|
Vec2::zero(),
|
||||||
tree_rank,
|
tree_rank,
|
||||||
containing_block,
|
containing_block,
|
||||||
|
|
|
@ -49,6 +49,16 @@ pub(crate) struct HoistedAbsolutelyPositionedBox {
|
||||||
pub fragment: ArcRefCell<Option<ArcRefCell<Fragment>>>,
|
pub fragment: ArcRefCell<Option<ArcRefCell<Fragment>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl HoistedAbsolutelyPositionedBox {
|
||||||
|
/// In some cases `inset: auto`-positioned elements do not know their precise
|
||||||
|
/// position until after they're hoisted. This lets us adjust auto values
|
||||||
|
/// after the fact.
|
||||||
|
pub(crate) fn adjust_offsets(&mut self, offsets: Vec2<Length>) {
|
||||||
|
self.box_offsets.inline.adjust_offset(offsets.inline);
|
||||||
|
self.box_offsets.block.adjust_offset(offsets.block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) enum AbsoluteBoxOffsets {
|
pub(crate) enum AbsoluteBoxOffsets {
|
||||||
StaticStart {
|
StaticStart {
|
||||||
|
@ -66,6 +76,15 @@ pub(crate) enum AbsoluteBoxOffsets {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AbsoluteBoxOffsets {
|
||||||
|
fn adjust_offset(&mut self, new_offset: Length) {
|
||||||
|
match *self {
|
||||||
|
AbsoluteBoxOffsets::StaticStart {ref mut start} => *start = new_offset,
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AbsolutelyPositionedBox {
|
impl AbsolutelyPositionedBox {
|
||||||
pub fn construct<'dom>(
|
pub fn construct<'dom>(
|
||||||
context: &LayoutContext,
|
context: &LayoutContext,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue