mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #16146 - mrobinson:containing-block-scrolling, r=glennw
Fix scroll root of absolutely positioned elements Absolutely positioned elements should be given the scroll root of their containing block and not necessarily the scroll root of their parent. This fixes several CSS tests, though others are still failing pending a similar fix for inherited clipping rectangles. Fixes #13530. <!-- 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: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16146) <!-- Reviewable:end -->
This commit is contained in:
commit
9f5b17202f
8 changed files with 22 additions and 22 deletions
|
@ -157,6 +157,11 @@ pub struct DisplayListBuildState<'a> {
|
|||
/// recursively building and processing the display list.
|
||||
pub current_scroll_root_id: ScrollRootId,
|
||||
|
||||
/// The scroll root id of the first ancestor which defines a containing block.
|
||||
/// This is necessary because absolutely positioned items should be clipped
|
||||
/// by their containing block's scroll root.
|
||||
pub containing_block_scroll_root_id: ScrollRootId,
|
||||
|
||||
/// Vector containing iframe sizes, used to inform the constellation about
|
||||
/// new iframe sizes
|
||||
pub iframe_sizes: Vec<(PipelineId, TypedSize2D<f32, CSSPixel>)>,
|
||||
|
@ -173,6 +178,7 @@ impl<'a> DisplayListBuildState<'a> {
|
|||
processing_scroll_root_element: false,
|
||||
current_stacking_context_id: StackingContextId::root(),
|
||||
current_scroll_root_id: ScrollRootId::root(),
|
||||
containing_block_scroll_root_id: ScrollRootId::root(),
|
||||
iframe_sizes: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
@ -1907,6 +1913,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
|||
state.current_stacking_context_id = self.base.stacking_context_id;
|
||||
|
||||
let original_scroll_root_id = state.current_scroll_root_id;
|
||||
let original_containing_block_scroll_root = state.containing_block_scroll_root_id;
|
||||
|
||||
// We are getting the id of the scroll root that contains us here, not the id of
|
||||
// any scroll root that we create. If we create a scroll root, its id will be
|
||||
|
@ -1931,12 +1938,19 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
|||
}
|
||||
|
||||
state.current_scroll_root_id = original_scroll_root_id;
|
||||
state.containing_block_scroll_root_id = original_containing_block_scroll_root;
|
||||
state.current_stacking_context_id = parent_stacking_context_id;
|
||||
}
|
||||
|
||||
fn setup_scroll_root_for_block(&mut self, state: &mut DisplayListBuildState) -> ScrollRootId {
|
||||
let containing_scroll_root_id = state.current_scroll_root_id;
|
||||
// If this block is absolutely positioned, we should be clipped and positioned by
|
||||
// the scroll root of our nearest ancestor that establishes a containing block.
|
||||
let containing_scroll_root_id = match self.positioning() {
|
||||
position::T::absolute => state.containing_block_scroll_root_id,
|
||||
_ => state.current_scroll_root_id,
|
||||
};
|
||||
self.base.scroll_root_id = containing_scroll_root_id;
|
||||
state.current_scroll_root_id = containing_scroll_root_id;
|
||||
|
||||
if !self.style_permits_scrolling_overflow() {
|
||||
return containing_scroll_root_id;
|
||||
|
@ -1977,6 +1991,13 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
|||
|
||||
self.base.scroll_root_id = new_scroll_root_id;
|
||||
state.current_scroll_root_id = new_scroll_root_id;
|
||||
|
||||
match self.positioning() {
|
||||
position::T::absolute | position::T::relative | position::T::fixed =>
|
||||
state.containing_block_scroll_root_id = new_scroll_root_id,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
containing_scroll_root_id
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue