mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
use au in HoistedSharedFragment (#32288)
This commit is contained in:
parent
c89fb1f381
commit
903c516fb5
3 changed files with 11 additions and 11 deletions
|
@ -1762,9 +1762,8 @@ impl PlacementState {
|
||||||
},
|
},
|
||||||
Fragment::AbsoluteOrFixedPositioned(fragment) => {
|
Fragment::AbsoluteOrFixedPositioned(fragment) => {
|
||||||
let offset = LogicalVec2 {
|
let offset = LogicalVec2 {
|
||||||
block: (self.current_margin.solve() + self.current_block_direction_position)
|
block: (self.current_margin.solve() + self.current_block_direction_position),
|
||||||
.into(),
|
inline: Au::zero(),
|
||||||
inline: Length::new(0.),
|
|
||||||
};
|
};
|
||||||
fragment.borrow_mut().adjust_offsets(offset);
|
fragment.borrow_mut().adjust_offsets(offset);
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use app_units::Au;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use style::values::computed::{Length, LengthPercentage};
|
use style::values::computed::LengthPercentage;
|
||||||
|
|
||||||
use super::Fragment;
|
use super::Fragment;
|
||||||
use crate::cell::ArcRefCell;
|
use crate::cell::ArcRefCell;
|
||||||
|
@ -31,7 +32,7 @@ impl HoistedSharedFragment {
|
||||||
/// In some cases `inset: auto`-positioned elements do not know their precise
|
/// In some cases `inset: auto`-positioned elements do not know their precise
|
||||||
/// position until after they're hoisted. This lets us adjust auto values
|
/// position until after they're hoisted. This lets us adjust auto values
|
||||||
/// after the fact.
|
/// after the fact.
|
||||||
pub(crate) fn adjust_offsets(&mut self, offsets: LogicalVec2<Length>) {
|
pub(crate) fn adjust_offsets(&mut self, offsets: LogicalVec2<Au>) {
|
||||||
self.box_offsets.inline.adjust_offset(offsets.inline);
|
self.box_offsets.inline.adjust_offset(offsets.inline);
|
||||||
self.box_offsets.block.adjust_offset(offsets.block);
|
self.box_offsets.block.adjust_offset(offsets.block);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +41,7 @@ impl HoistedSharedFragment {
|
||||||
#[derive(Clone, Debug, Serialize)]
|
#[derive(Clone, Debug, Serialize)]
|
||||||
pub(crate) enum AbsoluteBoxOffsets {
|
pub(crate) enum AbsoluteBoxOffsets {
|
||||||
StaticStart {
|
StaticStart {
|
||||||
start: Length,
|
start: Au,
|
||||||
},
|
},
|
||||||
Start {
|
Start {
|
||||||
start: LengthPercentage,
|
start: LengthPercentage,
|
||||||
|
@ -59,7 +60,7 @@ impl AbsoluteBoxOffsets {
|
||||||
matches!(self, AbsoluteBoxOffsets::Both { .. })
|
matches!(self, AbsoluteBoxOffsets::Both { .. })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn adjust_offset(&mut self, new_offset: Length) {
|
pub(crate) fn adjust_offset(&mut self, new_offset: Au) {
|
||||||
if let AbsoluteBoxOffsets::StaticStart { ref mut start } = *self {
|
if let AbsoluteBoxOffsets::StaticStart { ref mut start } = *self {
|
||||||
*start = new_offset
|
*start = new_offset
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ impl AbsolutelyPositionedBox {
|
||||||
) -> AbsoluteBoxOffsets {
|
) -> AbsoluteBoxOffsets {
|
||||||
match (start.non_auto(), end.non_auto()) {
|
match (start.non_auto(), end.non_auto()) {
|
||||||
(None, None) => AbsoluteBoxOffsets::StaticStart {
|
(None, None) => AbsoluteBoxOffsets::StaticStart {
|
||||||
start: initial_static_start,
|
start: initial_static_start.into(),
|
||||||
},
|
},
|
||||||
(Some(start), Some(end)) => AbsoluteBoxOffsets::Both {
|
(Some(start), Some(end)) => AbsoluteBoxOffsets::Both {
|
||||||
start: start.clone(),
|
start: start.clone(),
|
||||||
|
@ -196,10 +196,10 @@ impl PositioningContext {
|
||||||
let update_fragment_if_needed = |hoisted_fragment: &mut HoistedAbsolutelyPositionedBox| {
|
let update_fragment_if_needed = |hoisted_fragment: &mut HoistedAbsolutelyPositionedBox| {
|
||||||
let mut fragment = hoisted_fragment.fragment.borrow_mut();
|
let mut fragment = hoisted_fragment.fragment.borrow_mut();
|
||||||
if let AbsoluteBoxOffsets::StaticStart { start } = &mut fragment.box_offsets.inline {
|
if let AbsoluteBoxOffsets::StaticStart { start } = &mut fragment.box_offsets.inline {
|
||||||
*start += start_offset.inline;
|
*start += start_offset.inline.into();
|
||||||
}
|
}
|
||||||
if let AbsoluteBoxOffsets::StaticStart { start } = &mut fragment.box_offsets.block {
|
if let AbsoluteBoxOffsets::StaticStart { start } = &mut fragment.box_offsets.block {
|
||||||
*start += start_offset.block;
|
*start += start_offset.block.into();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -773,7 +773,7 @@ impl<'a> AbsoluteAxisSolver<'a> {
|
||||||
fn solve_for_size(&self, computed_size: AuOrAuto) -> AxisResult {
|
fn solve_for_size(&self, computed_size: AuOrAuto) -> AxisResult {
|
||||||
match self.box_offsets {
|
match self.box_offsets {
|
||||||
AbsoluteBoxOffsets::StaticStart { start } => AxisResult {
|
AbsoluteBoxOffsets::StaticStart { start } => AxisResult {
|
||||||
anchor: Anchor::Start((*start).into()),
|
anchor: Anchor::Start(*start),
|
||||||
size: computed_size,
|
size: computed_size,
|
||||||
margin_start: self.computed_margin_start.auto_is(Au::zero),
|
margin_start: self.computed_margin_start.auto_is(Au::zero),
|
||||||
margin_end: self.computed_margin_end.auto_is(Au::zero),
|
margin_end: self.computed_margin_end.auto_is(Au::zero),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue