mirror of
https://github.com/servo/servo.git
synced 2025-09-27 23:30:08 +01:00
script: Chain up keyboard scrolling to parent <iframe>
s (#39469)
When an `<iframe>` cannot scroll because the size of the frame is greater than or equal to the size of page contents, chain up the keyboard scroll operation to the parent frame. Testing: A new Servo-only WPT tests is added, though needs to be manually run with `--product servodriver`. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
parent
75e32ba5a4
commit
ffdb7d3663
23 changed files with 406 additions and 132 deletions
|
@ -42,7 +42,7 @@ pub struct BoxTree {
|
|||
root: BlockFormattingContext,
|
||||
|
||||
/// Whether or not the viewport should be sensitive to scrolling input events in two axes
|
||||
viewport_scroll_sensitivity: AxesScrollSensitivity,
|
||||
pub(crate) viewport_overflow: AxesOverflow,
|
||||
}
|
||||
|
||||
impl BoxTree {
|
||||
|
@ -65,10 +65,7 @@ impl BoxTree {
|
|||
// From https://www.w3.org/TR/css-overflow-3/#overflow-propagation:
|
||||
// > If visible is applied to the viewport, it must be interpreted as auto.
|
||||
// > If clip is applied to the viewport, it must be interpreted as hidden.
|
||||
viewport_scroll_sensitivity: AxesScrollSensitivity {
|
||||
x: viewport_overflow.x.to_scrollable().into(),
|
||||
y: viewport_overflow.y.to_scrollable().into(),
|
||||
},
|
||||
viewport_overflow: viewport_overflow.to_scrollable(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,11 +263,16 @@ impl BoxTree {
|
|||
&mut root_fragments,
|
||||
);
|
||||
|
||||
let viewport_scroll_sensitivity = AxesScrollSensitivity {
|
||||
x: self.viewport_overflow.x.into(),
|
||||
y: self.viewport_overflow.y.into(),
|
||||
};
|
||||
|
||||
FragmentTree::new(
|
||||
layout_context,
|
||||
root_fragments,
|
||||
physical_containing_block,
|
||||
self.viewport_scroll_sensitivity,
|
||||
viewport_scroll_sensitivity,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -333,11 +333,17 @@ impl Layout for LayoutThread {
|
|||
#[servo_tracing::instrument(skip_all)]
|
||||
fn query_scroll_container(
|
||||
&self,
|
||||
node: TrustedNodeAddress,
|
||||
node: Option<TrustedNodeAddress>,
|
||||
flags: ScrollContainerQueryFlags,
|
||||
) -> Option<ScrollContainerResponse> {
|
||||
let node = unsafe { ServoLayoutNode::new(&node) };
|
||||
process_scroll_container_query(node, flags)
|
||||
let node = unsafe { node.as_ref().map(|node| ServoLayoutNode::new(node)) };
|
||||
let viewport_overflow = self
|
||||
.box_tree
|
||||
.borrow()
|
||||
.as_ref()
|
||||
.expect("Should have a BoxTree for all scroll container queries.")
|
||||
.viewport_overflow;
|
||||
process_scroll_container_query(node, flags, viewport_overflow)
|
||||
}
|
||||
|
||||
#[servo_tracing::instrument(skip_all)]
|
||||
|
|
|
@ -12,7 +12,7 @@ use euclid::{SideOffsets2D, Size2D};
|
|||
use itertools::Itertools;
|
||||
use layout_api::wrapper_traits::{LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
||||
use layout_api::{
|
||||
BoxAreaType, LayoutElementType, LayoutNodeType, OffsetParentResponse,
|
||||
AxesOverflow, BoxAreaType, LayoutElementType, LayoutNodeType, OffsetParentResponse,
|
||||
ScrollContainerQueryFlags, ScrollContainerResponse,
|
||||
};
|
||||
use script::layout_dom::{ServoLayoutNode, ServoThreadSafeLayoutNode};
|
||||
|
@ -676,9 +676,14 @@ pub fn process_offset_parent_query(
|
|||
///
|
||||
#[inline]
|
||||
pub(crate) fn process_scroll_container_query(
|
||||
node: ServoLayoutNode<'_>,
|
||||
node: Option<ServoLayoutNode<'_>>,
|
||||
query_flags: ScrollContainerQueryFlags,
|
||||
viewport_overflow: AxesOverflow,
|
||||
) -> Option<ScrollContainerResponse> {
|
||||
let Some(node) = node else {
|
||||
return Some(ScrollContainerResponse::Viewport(viewport_overflow));
|
||||
};
|
||||
|
||||
let layout_data = node.to_threadsafe().inner_layout_data()?;
|
||||
|
||||
// 1. If any of the following holds true, return null and terminate this algorithm:
|
||||
|
@ -776,7 +781,7 @@ pub(crate) fn process_scroll_container_query(
|
|||
|
||||
match current_position_value {
|
||||
Position::Fixed => None,
|
||||
_ => Some(ScrollContainerResponse::Viewport),
|
||||
_ => Some(ScrollContainerResponse::Viewport(viewport_overflow)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue