mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
layout: Implement overflow scroll support for different axes (#35414)
* layout: Add AxesScrollSensitivity to enable control of scroll in axis Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout_2013: Be compatible with AxesScrollSensitivity Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: update struct AxesScrollSensitivity to euclid::Vector2D Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * display_list: implement From<Overflow> for ScrollSensitivity Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: simplify and reuse scroll related logic Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout_2013: simplify and reuse scroll related logic Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout, layout_2013: revert AxesScrollSensitivity to pair struct Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: Reimport ComputedOverflow as #35103 depends on it Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: Add AxesOverflow to replace PhysicalVec Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: implement scroll of viewport for different axes Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * layout: explicitly handle overflow match Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * Update components/shared/webrender/Cargo.toml Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
9b3e23633d
commit
03fc54e682
12 changed files with 111 additions and 63 deletions
|
@ -36,7 +36,7 @@ use webrender_api::{
|
|||
ImageRendering, NinePatchBorder, NinePatchBorderSource,
|
||||
};
|
||||
use webrender_traits::display_list::{
|
||||
CompositorDisplayListInfo, ScrollSensitivity, ScrollTreeNodeId,
|
||||
AxesScrollSensitivity, CompositorDisplayListInfo, ScrollTreeNodeId,
|
||||
};
|
||||
use wr::units::LayoutVector2D;
|
||||
|
||||
|
@ -101,7 +101,7 @@ impl DisplayList {
|
|||
content_size: units::LayoutSize,
|
||||
pipeline_id: wr::PipelineId,
|
||||
epoch: wr::Epoch,
|
||||
root_scroll_sensitivity: ScrollSensitivity,
|
||||
root_scroll_sensitivity: AxesScrollSensitivity,
|
||||
) -> Self {
|
||||
Self {
|
||||
wr: wr::DisplayListBuilder::new(pipeline_id),
|
||||
|
|
|
@ -26,7 +26,7 @@ use style::values::specified::box_::DisplayOutside;
|
|||
use style::Zero;
|
||||
use webrender_api::units::{LayoutPoint, LayoutRect, LayoutTransform, LayoutVector2D};
|
||||
use webrender_api::{self as wr, BorderRadius};
|
||||
use webrender_traits::display_list::{ScrollSensitivity, ScrollTreeNodeId, ScrollableNodeInfo};
|
||||
use webrender_traits::display_list::{AxesScrollSensitivity, ScrollTreeNodeId, ScrollableNodeInfo};
|
||||
use wr::units::{LayoutPixel, LayoutSize};
|
||||
use wr::{ClipChainId, SpatialTreeItemKey, StickyOffsetBounds};
|
||||
|
||||
|
@ -38,8 +38,8 @@ use crate::fragment_tree::{
|
|||
BoxFragment, ContainingBlockManager, Fragment, FragmentFlags, FragmentTree,
|
||||
PositioningFragment, SpecificLayoutInfo,
|
||||
};
|
||||
use crate::geom::{AuOrAuto, PhysicalRect, PhysicalSides, PhysicalVec};
|
||||
use crate::style_ext::ComputedValuesExt;
|
||||
use crate::geom::{AuOrAuto, PhysicalRect, PhysicalSides};
|
||||
use crate::style_ext::{AxesOverflow, ComputedValuesExt};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct ContainingBlock {
|
||||
|
@ -212,7 +212,7 @@ impl DisplayList {
|
|||
external_id: wr::ExternalScrollId,
|
||||
content_rect: LayoutRect,
|
||||
clip_rect: LayoutRect,
|
||||
scroll_sensitivity: ScrollSensitivity,
|
||||
scroll_sensitivity: AxesScrollSensitivity,
|
||||
) -> ScrollTreeNodeId {
|
||||
let spatial_tree_item_key = self.get_next_spatial_tree_item_key();
|
||||
|
||||
|
@ -1373,7 +1373,7 @@ impl BoxFragment {
|
|||
}
|
||||
|
||||
// TODO: merge this function with style.effective_overflow()
|
||||
fn used_overflow(&self) -> PhysicalVec<ComputedOverflow> {
|
||||
fn used_overflow(&self) -> AxesOverflow {
|
||||
let mut overflow = self.style.effective_overflow();
|
||||
let is_replaced_element = self.base.flags.contains(FragmentFlags::IS_REPLACED);
|
||||
|
||||
|
@ -1483,12 +1483,12 @@ impl BoxFragment {
|
|||
display_list.wr.pipeline_id,
|
||||
);
|
||||
|
||||
let sensitivity =
|
||||
if ComputedOverflow::Hidden == overflow.x && ComputedOverflow::Hidden == overflow.y {
|
||||
ScrollSensitivity::Script
|
||||
} else {
|
||||
ScrollSensitivity::ScriptAndInputEvents
|
||||
};
|
||||
let overflow = self.style.effective_overflow();
|
||||
|
||||
let sensitivity = AxesScrollSensitivity {
|
||||
x: overflow.x.into(),
|
||||
y: overflow.y.into(),
|
||||
};
|
||||
|
||||
let content_rect = self.scrollable_overflow().to_webrender();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue