mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
layout: Use overflow: visible
if overflow
was propagated to viewport (#38598)
The `overflow-*` values of either the root element or the `<body>` get propagated to the viewport. However, we were missing this part: > The element from which the value is propagated must then have a used `overflow` value of `visible`. See https://drafts.csswg.org/css-overflow/#overflow-propagation Testing: - `css/cssom-view/scrolling-quirks-vs-nonquirks.html` - `css/css-overflow/overflow-body-propagation-007.html` - `css/css-overflow/overflow-body-propagation-008.html` - `css/css-overflow/overflow-body-propagation-009.html` - `css/css-overflow/scrollable-overflow-with-nested-elements-001.html` - `css/css-overflow/scrollable-overflow-with-nested-elements-002.html` - `css/css-overflow/scrollable-overflow-with-nested-elements-003.html` - `css/css-overflow/scrollable-overflow-with-nested-elements-004.html` - `css/css-overflow/scrollbar-gutter-scroll-into-view.html` Failures: - `css/css-overflow/overflow-body-propagation-010.html` Failing because of missing support for `contain: paint`. - `css/css-overflow/scrollable-overflow-with-nested-elements-005.html` Failing because of wrong `data-expected-height`, but correct `data-expected-scroll-height` which is core of this PR. `data-expected-height` can be dealt separately. Fixes: #38248 --------- Signed-off-by: Shubham Gupta <shubham13297@gmail.com> Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
37088aa4c3
commit
d8ff9c7a08
22 changed files with 373 additions and 72 deletions
|
@ -26,7 +26,7 @@ use crate::flow::float::FloatBox;
|
|||
use crate::flow::inline::InlineItem;
|
||||
use crate::flow::{BlockContainer, BlockFormattingContext, BlockLevelBox};
|
||||
use crate::formatting_contexts::IndependentFormattingContext;
|
||||
use crate::fragment_tree::FragmentTree;
|
||||
use crate::fragment_tree::{FragmentFlags, FragmentTree};
|
||||
use crate::geom::{LogicalVec2, PhysicalSize};
|
||||
use crate::positioned::{AbsolutelyPositionedBox, PositioningContext};
|
||||
use crate::replaced::ReplacedContents;
|
||||
|
@ -48,10 +48,6 @@ impl BoxTree {
|
|||
#[servo_tracing::instrument(name = "Box Tree Construction", skip_all)]
|
||||
pub(crate) fn construct(context: &LayoutContext, root_element: ServoLayoutNode<'_>) -> Self {
|
||||
let root_element = root_element.to_threadsafe();
|
||||
let boxes = construct_for_root_element(context, root_element);
|
||||
|
||||
// Zero box for `:root { display: none }`, one for the root element otherwise.
|
||||
assert!(boxes.len() <= 1);
|
||||
|
||||
// From https://www.w3.org/TR/css-overflow-3/#overflow-propagation:
|
||||
// > UAs must apply the overflow-* values set on the root element to the viewport when the
|
||||
|
@ -65,6 +61,7 @@ impl BoxTree {
|
|||
|
||||
let mut viewport_overflow_x = root_style.clone_overflow_x();
|
||||
let mut viewport_overflow_y = root_style.clone_overflow_y();
|
||||
let mut element_propagating_overflow = root_element;
|
||||
if viewport_overflow_x == Overflow::Visible &&
|
||||
viewport_overflow_y == Overflow::Visible &&
|
||||
!root_style.get_box().display.is_none()
|
||||
|
@ -81,12 +78,28 @@ impl BoxTree {
|
|||
if !style.get_box().display.is_none() {
|
||||
viewport_overflow_x = style.clone_overflow_x();
|
||||
viewport_overflow_y = style.clone_overflow_y();
|
||||
element_propagating_overflow = child;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let boxes = construct_for_root_element(context, root_element);
|
||||
|
||||
// Zero box for `:root { display: none }`, one for the root element otherwise.
|
||||
assert!(boxes.len() <= 1);
|
||||
|
||||
if let Some(layout_data) = element_propagating_overflow.inner_layout_data() {
|
||||
if let Some(ref mut layout_box) = *layout_data.self_box.borrow_mut() {
|
||||
layout_box.with_base_mut(|base| {
|
||||
base.base_fragment_info
|
||||
.flags
|
||||
.insert(FragmentFlags::PROPAGATED_OVERFLOW_TO_VIEWPORT)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let contents = BlockContainer::BlockLevelBoxes(boxes);
|
||||
let contains_floats = contents.contains_floats();
|
||||
Self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue