Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some more boring stuff to change how we compute content sizes #26852

Merged
merged 5 commits into from Jun 15, 2020
Next

Rename contents to context in AbsolutelyPositionedBox

  • Loading branch information
nox committed Jun 15, 2020
commit b66dd66403f990db1a287ea70841194aa388a519
@@ -294,7 +294,7 @@ impl InlineFormattingContext {
InlineLevelBox::TextRun(run) => run.layout(layout_context, &mut ifc),
InlineLevelBox::Atomic(a) => layout_atomic(layout_context, &mut ifc, a),
InlineLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => {
let style = AtomicRef::map(box_.borrow(), |box_| &box_.contents.style);
let style = AtomicRef::map(box_.borrow(), |box_| &box_.context.style);
let initial_start_corner =
match Display::from(style.get_box().original_display) {
Display::GeneratingBox(DisplayGeneratingBox::OutsideInside {
@@ -326,7 +326,7 @@ impl BlockLevelBox {
positioning_context.push(hoisted_box);
Fragment::AbsoluteOrFixedPositioned(AbsoluteOrFixedPositionedFragment {
hoisted_fragment,
position: box_.borrow().contents.style.clone_position(),
position: box_.borrow().context.style.clone_position(),
})
},
BlockLevelBox::OutOfFlowFloatBox(_box_) => {
@@ -22,7 +22,7 @@ use style::Zero;

#[derive(Debug, Serialize)]
pub(crate) struct AbsolutelyPositionedBox {
pub contents: IndependentFormattingContext,

This comment has been minimized.

Copy link
@SimonSapin

SimonSapin Jun 15, 2020

Member

I’m not thrilled about this one (layout_context and style_content are groupings of transient data used "on the side" during layout, rather than the "object" of what we’re doing), but I don’t have a better suggestion.

pub context: IndependentFormattingContext,
}

pub(crate) struct PositioningContext {
@@ -84,7 +84,7 @@ impl AbsolutelyPositionedBox {
!node_info.style.inline_box_offsets_are_both_non_auto(),
);
Self {
contents: IndependentFormattingContext::construct(
context: IndependentFormattingContext::construct(
context,
node_info,
display_inside,
@@ -124,7 +124,7 @@ impl AbsolutelyPositionedBox {

let box_offsets = {
let box_ = self_.borrow();
let box_offsets = box_.contents.style.box_offsets(containing_block);
let box_offsets = box_.context.style.box_offsets(containing_block);
Vec2 {
inline: absolute_box_offsets(
initial_start_corner.inline,
@@ -288,7 +288,7 @@ impl PositioningContext {
let position = box_
.absolutely_positioned_box
.borrow()
.contents
.context
.style
.clone_position();
match position {
@@ -417,12 +417,12 @@ impl HoistedAbsolutelyPositionedBox {
let cbis = containing_block.size.inline;
let cbbs = containing_block.size.block;
let absolutely_positioned_box = self.absolutely_positioned_box.borrow_mut();
let style = &absolutely_positioned_box.contents.style;
let style = &absolutely_positioned_box.context.style;
let pbm = style.padding_border_margin(&containing_block.into());

let size;
let replaced_used_size;
match absolutely_positioned_box.contents.as_replaced() {
match absolutely_positioned_box.context.as_replaced() {
Ok(replaced) => {
// https://drafts.csswg.org/css2/visudet.html#abs-replaced-width
// https://drafts.csswg.org/css2/visudet.html#abs-replaced-height
@@ -474,11 +474,11 @@ impl HoistedAbsolutelyPositionedBox {
|positioning_context| {
let size;
let fragments;
match absolutely_positioned_box.contents.as_replaced() {
match absolutely_positioned_box.context.as_replaced() {
Ok(replaced) => {
// https://drafts.csswg.org/css2/visudet.html#abs-replaced-width
// https://drafts.csswg.org/css2/visudet.html#abs-replaced-height
let style = &absolutely_positioned_box.contents.style;
let style = &absolutely_positioned_box.context.style;
size = replaced_used_size.unwrap();
fragments = replaced.make_fragments(style, size.clone());
},
@@ -495,7 +495,7 @@ impl HoistedAbsolutelyPositionedBox {
pbm.padding_border_sums.inline -
margin.inline_sum();
absolutely_positioned_box
.contents
.context
.content_sizes
.shrink_to_fit(available_size)
});
@@ -550,7 +550,7 @@ impl HoistedAbsolutelyPositionedBox {
};

BoxFragment::new(
absolutely_positioned_box.contents.tag,
absolutely_positioned_box.context.tag,
style.clone(),
fragments,
content_rect,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.