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

layout_2020: Use the containing block more when calculating scrolling overflow #26012

Merged
merged 1 commit into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/layout_2020/display_list/stacking_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,8 @@ impl BoxFragment {
builder.current_space_and_clip = builder.wr.define_scroll_frame(
&original_scroll_and_clip_info,
Some(external_id),
self.scrollable_overflow().to_webrender(),
self.scrollable_overflow(&containing_block_info.rect)
.to_webrender(),
padding_rect,
vec![], // complex_clips
None, // image_mask
Expand Down
2 changes: 1 addition & 1 deletion components/layout_2020/flow/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl BoxTreeRoot {
.fragments
.iter()
.fold(PhysicalRect::zero(), |acc, child| {
let child_overflow = child.scrollable_overflow();
let child_overflow = child.scrollable_overflow(&physical_containing_block);

// https://drafts.csswg.org/css-overflow/#scrolling-direction
// We want to clip scrollable overflow on box-start and inline-start
Expand Down
31 changes: 19 additions & 12 deletions components/layout_2020/fragments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ impl Fragment {
}
}

pub fn scrollable_overflow(&self) -> PhysicalRect<Length> {
// FIXME(mrobinson, bug 25564): We should be using the containing block
// here to properly convert scrollable overflow to physical geometry.
let containing_block = PhysicalRect::zero();
pub fn scrollable_overflow(
&self,
containing_block: &PhysicalRect<Length>,
) -> PhysicalRect<Length> {
match self {
Fragment::Box(fragment) => fragment.scrollable_overflow_for_parent(&containing_block),
Fragment::AbsoluteOrFixedPositioned(_) => PhysicalRect::zero(),
Expand Down Expand Up @@ -182,11 +182,14 @@ impl AnonymousFragment {
}

pub fn new(rect: Rect<Length>, children: Vec<Fragment>, mode: WritingMode) -> Self {
// FIXME(mrobinson, bug 25564): We should be using the containing block
// here to properly convert scrollable overflow to physical geometry.
let containing_block = PhysicalRect::zero();
let content_origin = rect.start_corner.to_physical(mode);
let scrollable_overflow = children.iter().fold(PhysicalRect::zero(), |acc, child| {
acc.union(
&child
.scrollable_overflow()
.scrollable_overflow(&containing_block)
.translate(content_origin.to_vector()),
)
});
Expand Down Expand Up @@ -226,9 +229,12 @@ impl BoxFragment {
block_margins_collapsed_with_children: CollapsedBlockMargins,
hoisted_fragment_id: Option<HoistedFragmentId>,
) -> BoxFragment {
// FIXME(mrobinson, bug 25564): We should be using the containing block
// here to properly convert scrollable overflow to physical geometry.
let containing_block = PhysicalRect::zero();
let scrollable_overflow_from_children =
children.iter().fold(PhysicalRect::zero(), |acc, child| {
acc.union(&child.scrollable_overflow())
acc.union(&child.scrollable_overflow(&containing_block))
});
BoxFragment {
tag,
Expand All @@ -245,12 +251,13 @@ impl BoxFragment {
}
}

pub fn scrollable_overflow(&self) -> PhysicalRect<Length> {
// FIXME(mrobinson, bug 25564): We should be using the containing block
// here to properly convert scrollable overflow to physical geometry.
pub fn scrollable_overflow(
&self,
containing_block: &PhysicalRect<Length>,
) -> PhysicalRect<Length> {
let physical_padding_rect = self
.padding_rect()
.to_physical(self.style.writing_mode, &PhysicalRect::zero());
.to_physical(self.style.writing_mode, containing_block);

let content_origin = self
.content_rect
Expand Down Expand Up @@ -284,7 +291,7 @@ impl BoxFragment {
self.content_rect,
self.padding_rect(),
self.border_rect(),
self.scrollable_overflow(),
self.scrollable_overflow(&PhysicalRect::zero()),
self.style.get_box().overflow_x,
self.style.get_box().overflow_y,
self.style,
Expand Down Expand Up @@ -313,7 +320,7 @@ impl BoxFragment {

// https://www.w3.org/TR/css-overflow-3/#scrollable
// Only include the scrollable overflow of a child box if it has overflow: visible.
let scrollable_overflow = self.scrollable_overflow();
let scrollable_overflow = self.scrollable_overflow(&containing_block);
let bottom_right = PhysicalPoint::new(
overflow.max_x().max(scrollable_overflow.max_x()),
overflow.max_y().max(scrollable_overflow.max_y()),
Expand Down