mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
script: Use HTMLElement.scrollParent
to implement Element.scrollIntoView
(#39144)
To find scrolling ancestors, we need to walk up the flat tree and only consider the elements that are in the chain of containing block ancestors of an element. `scrollParent` now does this so we can use it to properly implement `scrollIntoView`. Testing: There are WPT tests for this change. --------- Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
286bbe6cb1
commit
9f4f598f44
9 changed files with 141 additions and 71 deletions
|
@ -56,8 +56,8 @@ use js::rust::{
|
|||
use layout_api::{
|
||||
BoxAreaType, ElementsFromPointFlags, ElementsFromPointResult, FragmentType, Layout,
|
||||
PendingImage, PendingImageState, PendingRasterizationImage, QueryMsg, ReflowGoal,
|
||||
ReflowPhasesRun, ReflowRequest, ReflowRequestRestyle, RestyleReason, ScrollParentResponse,
|
||||
TrustedNodeAddress, combine_id_with_fragment_type,
|
||||
ReflowPhasesRun, ReflowRequest, ReflowRequestRestyle, RestyleReason, ScrollContainerQueryType,
|
||||
ScrollContainerResponse, TrustedNodeAddress, combine_id_with_fragment_type,
|
||||
};
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
use media::WindowGLContext;
|
||||
|
@ -2599,21 +2599,15 @@ impl Window {
|
|||
(element, response.rect)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub(crate) fn scroll_parent_query(&self, node: &Node) -> Option<DomRoot<Element>> {
|
||||
pub(crate) fn scroll_container_query(
|
||||
&self,
|
||||
node: &Node,
|
||||
query_type: ScrollContainerQueryType,
|
||||
) -> Option<ScrollContainerResponse> {
|
||||
self.layout_reflow(QueryMsg::ScrollParentQuery);
|
||||
self.layout
|
||||
.borrow()
|
||||
.query_scroll_parent(node.to_trusted_node_address())
|
||||
.and_then(|response| match response {
|
||||
ScrollParentResponse::DocumentScrollingElement => {
|
||||
self.Document().GetScrollingElement()
|
||||
},
|
||||
ScrollParentResponse::Element(parent_node_address) => {
|
||||
let node = unsafe { from_untrusted_node_address(parent_node_address) };
|
||||
DomRoot::downcast(node)
|
||||
},
|
||||
})
|
||||
.query_scroll_container(node.to_trusted_node_address(), query_type)
|
||||
}
|
||||
|
||||
pub(crate) fn text_index_query(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue