mirror of
https://github.com/servo/servo.git
synced 2025-06-08 00:23:30 +00:00
In the scrollable overflow calcutation, apply CSS transforms to boxes and scrollable overflow of the descendant. Clip unreachable scrollable overflow according to it's block start and inline start scrolling direction. And, renamed `Fragment::scrolling_overflow` to `Fragment::scrolling_overflow_for_parent` as it was calculating the scrolling overflow contribution from a child. Add several WPT tests, testing the transform interaction `rotate`, `scale`, and `skew` with scrollable overflow. There are several WPT test that are testing the interaction that not expected from current browsers implementation according to the spec. Testing: Existing and new WPT. Fixes: #36031 --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
95 lines
3.3 KiB
Rust
95 lines
3.3 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
use app_units::Au;
|
|
use base::print_tree::PrintTree;
|
|
use malloc_size_of_derive::MallocSizeOf;
|
|
use servo_arc::Arc as ServoArc;
|
|
use style::properties::ComputedValues;
|
|
|
|
use super::{BaseFragment, BaseFragmentInfo, Fragment};
|
|
use crate::cell::ArcRefCell;
|
|
use crate::geom::PhysicalRect;
|
|
|
|
/// Can contain child fragments with relative coordinates, but does not contribute to painting
|
|
/// itself. [`PositioningFragment`]s may be completely anonymous, or just non-painting Fragments
|
|
/// generated by boxes.
|
|
#[derive(MallocSizeOf)]
|
|
pub(crate) struct PositioningFragment {
|
|
pub base: BaseFragment,
|
|
pub rect: PhysicalRect<Au>,
|
|
pub children: Vec<Fragment>,
|
|
|
|
/// The scrollable overflow of this anonymous fragment's children.
|
|
pub scrollable_overflow: PhysicalRect<Au>,
|
|
|
|
/// If this fragment was created with a style, the style of the fragment.
|
|
#[conditional_malloc_size_of]
|
|
pub style: Option<ServoArc<ComputedValues>>,
|
|
|
|
/// This [`PositioningFragment`]'s containing block rectangle in coordinates relative to
|
|
/// the initial containing block, but not taking into account any transforms.
|
|
pub cumulative_containing_block_rect: PhysicalRect<Au>,
|
|
}
|
|
|
|
impl PositioningFragment {
|
|
pub fn new_anonymous(rect: PhysicalRect<Au>, children: Vec<Fragment>) -> ArcRefCell<Self> {
|
|
Self::new_with_base_fragment(BaseFragment::anonymous(), None, rect, children)
|
|
}
|
|
|
|
pub fn new_empty(
|
|
base_fragment_info: BaseFragmentInfo,
|
|
rect: PhysicalRect<Au>,
|
|
style: ServoArc<ComputedValues>,
|
|
) -> ArcRefCell<Self> {
|
|
Self::new_with_base_fragment(base_fragment_info.into(), Some(style), rect, Vec::new())
|
|
}
|
|
|
|
fn new_with_base_fragment(
|
|
base: BaseFragment,
|
|
style: Option<ServoArc<ComputedValues>>,
|
|
rect: PhysicalRect<Au>,
|
|
children: Vec<Fragment>,
|
|
) -> ArcRefCell<Self> {
|
|
let content_origin = rect.origin;
|
|
let scrollable_overflow = children.iter().fold(PhysicalRect::zero(), |acc, child| {
|
|
acc.union(
|
|
&child
|
|
.scrollable_overflow_for_parent()
|
|
.translate(content_origin.to_vector()),
|
|
)
|
|
});
|
|
ArcRefCell::new(PositioningFragment {
|
|
base,
|
|
style,
|
|
rect,
|
|
children,
|
|
scrollable_overflow,
|
|
cumulative_containing_block_rect: PhysicalRect::zero(),
|
|
})
|
|
}
|
|
|
|
pub(crate) fn set_containing_block(&mut self, containing_block: &PhysicalRect<Au>) {
|
|
self.cumulative_containing_block_rect = *containing_block;
|
|
}
|
|
|
|
pub fn offset_by_containing_block(&self, rect: &PhysicalRect<Au>) -> PhysicalRect<Au> {
|
|
rect.translate(self.cumulative_containing_block_rect.origin.to_vector())
|
|
}
|
|
|
|
pub fn print(&self, tree: &mut PrintTree) {
|
|
tree.new_level(format!(
|
|
"PositioningFragment\
|
|
\nbase={:?}\
|
|
\nrect={:?}\
|
|
\nscrollable_overflow={:?}",
|
|
self.base, self.rect, self.scrollable_overflow
|
|
));
|
|
|
|
for child in &self.children {
|
|
child.print(tree);
|
|
}
|
|
tree.end_level();
|
|
}
|
|
}
|