Auto merge of #26048 - nox:layout-2020-transparent-data, r=jdm

Give a lifetime parameter to LayoutDom
This commit is contained in:
bors-servo 2020-03-28 13:37:31 -04:00 committed by GitHub
commit 15d8c6058b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 335 additions and 432 deletions

View file

@ -349,7 +349,7 @@ impl Drop for BoxSlot<'_> {
}
}
pub(crate) trait NodeExt<'dom>: 'dom + Copy + LayoutNode + Send + Sync {
pub(crate) trait NodeExt<'dom>: 'dom + Copy + LayoutNode<'dom> + Send + Sync {
fn is_element(self) -> bool;
fn as_text(self) -> Option<String>;
@ -372,7 +372,7 @@ pub(crate) trait NodeExt<'dom>: 'dom + Copy + LayoutNode + Send + Sync {
impl<'dom, T> NodeExt<'dom> for T
where
T: 'dom + Copy + LayoutNode + Send + Sync,
T: 'dom + Copy + LayoutNode<'dom> + Send + Sync,
{
fn is_element(self) -> bool {
self.to_threadsafe().as_element().is_some()

View file

@ -50,7 +50,7 @@ pub struct FragmentTreeRoot {
impl BoxTreeRoot {
pub fn construct<'dom, Node>(context: &LayoutContext, root_element: Node) -> Self
where
Node: 'dom + Copy + LayoutNode + Send + Sync,
Node: 'dom + Copy + LayoutNode<'dom> + Send + Sync,
{
let (contains_floats, boxes) = construct_for_root_element(&context, root_element);
Self(BlockFormattingContext {

View file

@ -192,9 +192,9 @@ pub fn process_node_geometry_request(
fragment_tree_root.get_border_dimensions_for_node(requested_node)
}
pub fn process_node_scroll_id_request<N: LayoutNode>(
pub fn process_node_scroll_id_request<'dom>(
id: PipelineId,
requested_node: N,
requested_node: impl LayoutNode<'dom>,
) -> ExternalScrollId {
let layout_node = requested_node.to_threadsafe();
layout_node.generate_scroll_id(id)
@ -207,15 +207,12 @@ pub fn process_node_scroll_area_request(_requested_node: OpaqueNode) -> Rect<i32
/// Return the resolved value of property for a given (pseudo)element.
/// <https://drafts.csswg.org/cssom/#resolved-value>
pub fn process_resolved_style_request<'a, N>(
pub fn process_resolved_style_request<'dom>(
_context: &LayoutContext,
_node: N,
_node: impl LayoutNode<'dom>,
_pseudo: &Option<PseudoElement>,
_property: &PropertyId,
) -> String
where
N: LayoutNode,
{
) -> String {
"".to_owned()
}
@ -223,12 +220,12 @@ pub fn process_offset_parent_query(_requested_node: OpaqueNode) -> OffsetParentR
OffsetParentResponse::empty()
}
pub fn process_style_query<N: LayoutNode>(_requested_node: N) -> StyleResponse {
pub fn process_style_query<'dom>(_requested_node: impl LayoutNode<'dom>) -> StyleResponse {
StyleResponse(None)
}
// https://html.spec.whatwg.org/multipage/#the-innertext-idl-attribute
pub fn process_element_inner_text_query<N: LayoutNode>(_node: N) -> String {
pub fn process_element_inner_text_query<'dom>(_node: impl LayoutNode<'dom>) -> String {
"".to_owned()
}

View file

@ -30,10 +30,10 @@ impl<'a> RecalcStyle<'a> {
}
#[allow(unsafe_code)]
impl<'a, E> DomTraversal<E> for RecalcStyle<'a>
impl<'a, 'dom, E> DomTraversal<E> for RecalcStyle<'a>
where
E: TElement,
E::ConcreteNode: LayoutNode,
E::ConcreteNode: LayoutNode<'dom>,
E::FontMetricsProvider: Send,
{
fn process_preorder<F>(

View file

@ -11,7 +11,10 @@ pub trait GetRawData {
fn get_raw_data(&self) -> Option<&StyleAndLayoutData>;
}
impl<T: GetLayoutData> GetRawData for T {
impl<'dom, T> GetRawData for T
where
T: GetLayoutData<'dom>,
{
fn get_raw_data(&self) -> Option<&StyleAndLayoutData> {
self.get_style_and_layout_data().map(|opaque| {
let container = opaque.ptr.as_ptr() as *mut StyleAndLayoutData;