mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Auto merge of #26012 - mrobinson:scrolling-overflow-cb, r=nox
layout_2020: Use the containing block more when calculating scrolling overflow When calculating scrolling overflow calculation we cannot currently use the actual containing block in all cases. This change increases the amount that we do use the containing block. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because they should not change behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
8bd3429069
3 changed files with 22 additions and 14 deletions
|
@ -580,7 +580,8 @@ impl BoxFragment {
|
||||||
builder.current_space_and_clip = builder.wr.define_scroll_frame(
|
builder.current_space_and_clip = builder.wr.define_scroll_frame(
|
||||||
&original_scroll_and_clip_info,
|
&original_scroll_and_clip_info,
|
||||||
Some(external_id),
|
Some(external_id),
|
||||||
self.scrollable_overflow().to_webrender(),
|
self.scrollable_overflow(&containing_block_info.rect)
|
||||||
|
.to_webrender(),
|
||||||
padding_rect,
|
padding_rect,
|
||||||
vec![], // complex_clips
|
vec![], // complex_clips
|
||||||
None, // image_mask
|
None, // image_mask
|
||||||
|
|
|
@ -163,7 +163,7 @@ impl BoxTreeRoot {
|
||||||
.fragments
|
.fragments
|
||||||
.iter()
|
.iter()
|
||||||
.fold(PhysicalRect::zero(), |acc, child| {
|
.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
|
// https://drafts.csswg.org/css-overflow/#scrolling-direction
|
||||||
// We want to clip scrollable overflow on box-start and inline-start
|
// We want to clip scrollable overflow on box-start and inline-start
|
||||||
|
|
|
@ -132,10 +132,10 @@ impl Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scrollable_overflow(&self) -> PhysicalRect<Length> {
|
pub fn scrollable_overflow(
|
||||||
// FIXME(mrobinson, bug 25564): We should be using the containing block
|
&self,
|
||||||
// here to properly convert scrollable overflow to physical geometry.
|
containing_block: &PhysicalRect<Length>,
|
||||||
let containing_block = PhysicalRect::zero();
|
) -> PhysicalRect<Length> {
|
||||||
match self {
|
match self {
|
||||||
Fragment::Box(fragment) => fragment.scrollable_overflow_for_parent(&containing_block),
|
Fragment::Box(fragment) => fragment.scrollable_overflow_for_parent(&containing_block),
|
||||||
Fragment::AbsoluteOrFixedPositioned(_) => PhysicalRect::zero(),
|
Fragment::AbsoluteOrFixedPositioned(_) => PhysicalRect::zero(),
|
||||||
|
@ -182,11 +182,14 @@ impl AnonymousFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(rect: Rect<Length>, children: Vec<Fragment>, mode: WritingMode) -> Self {
|
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 content_origin = rect.start_corner.to_physical(mode);
|
||||||
let scrollable_overflow = children.iter().fold(PhysicalRect::zero(), |acc, child| {
|
let scrollable_overflow = children.iter().fold(PhysicalRect::zero(), |acc, child| {
|
||||||
acc.union(
|
acc.union(
|
||||||
&child
|
&child
|
||||||
.scrollable_overflow()
|
.scrollable_overflow(&containing_block)
|
||||||
.translate(content_origin.to_vector()),
|
.translate(content_origin.to_vector()),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -226,9 +229,12 @@ impl BoxFragment {
|
||||||
block_margins_collapsed_with_children: CollapsedBlockMargins,
|
block_margins_collapsed_with_children: CollapsedBlockMargins,
|
||||||
hoisted_fragment_id: Option<HoistedFragmentId>,
|
hoisted_fragment_id: Option<HoistedFragmentId>,
|
||||||
) -> BoxFragment {
|
) -> 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 =
|
let scrollable_overflow_from_children =
|
||||||
children.iter().fold(PhysicalRect::zero(), |acc, child| {
|
children.iter().fold(PhysicalRect::zero(), |acc, child| {
|
||||||
acc.union(&child.scrollable_overflow())
|
acc.union(&child.scrollable_overflow(&containing_block))
|
||||||
});
|
});
|
||||||
BoxFragment {
|
BoxFragment {
|
||||||
tag,
|
tag,
|
||||||
|
@ -245,12 +251,13 @@ impl BoxFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scrollable_overflow(&self) -> PhysicalRect<Length> {
|
pub fn scrollable_overflow(
|
||||||
// FIXME(mrobinson, bug 25564): We should be using the containing block
|
&self,
|
||||||
// here to properly convert scrollable overflow to physical geometry.
|
containing_block: &PhysicalRect<Length>,
|
||||||
|
) -> PhysicalRect<Length> {
|
||||||
let physical_padding_rect = self
|
let physical_padding_rect = self
|
||||||
.padding_rect()
|
.padding_rect()
|
||||||
.to_physical(self.style.writing_mode, &PhysicalRect::zero());
|
.to_physical(self.style.writing_mode, containing_block);
|
||||||
|
|
||||||
let content_origin = self
|
let content_origin = self
|
||||||
.content_rect
|
.content_rect
|
||||||
|
@ -284,7 +291,7 @@ impl BoxFragment {
|
||||||
self.content_rect,
|
self.content_rect,
|
||||||
self.padding_rect(),
|
self.padding_rect(),
|
||||||
self.border_rect(),
|
self.border_rect(),
|
||||||
self.scrollable_overflow(),
|
self.scrollable_overflow(&PhysicalRect::zero()),
|
||||||
self.style.get_box().overflow_x,
|
self.style.get_box().overflow_x,
|
||||||
self.style.get_box().overflow_y,
|
self.style.get_box().overflow_y,
|
||||||
self.style,
|
self.style,
|
||||||
|
@ -313,7 +320,7 @@ impl BoxFragment {
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-overflow-3/#scrollable
|
// https://www.w3.org/TR/css-overflow-3/#scrollable
|
||||||
// Only include the scrollable overflow of a child box if it has overflow: visible.
|
// 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(
|
let bottom_right = PhysicalPoint::new(
|
||||||
overflow.max_x().max(scrollable_overflow.max_x()),
|
overflow.max_x().max(scrollable_overflow.max_x()),
|
||||||
overflow.max_y().max(scrollable_overflow.max_y()),
|
overflow.max_y().max(scrollable_overflow.max_y()),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue