mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Give a lifetime parameter to LayoutDom
This commit is contained in:
parent
60ca98b753
commit
dba6a635e5
26 changed files with 145 additions and 235 deletions
|
@ -70,7 +70,6 @@ use servo_url::ServoUrl;
|
|||
use std::fmt;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::marker::PhantomData;
|
||||
use std::ptr::NonNull;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc as StdArc;
|
||||
|
@ -100,12 +99,9 @@ pub unsafe fn drop_style_and_layout_data(data: OpaqueStyleAndLayoutData) {
|
|||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ServoLayoutNode<'a> {
|
||||
pub struct ServoLayoutNode<'dom> {
|
||||
/// The wrapped node.
|
||||
node: LayoutDom<Node>,
|
||||
|
||||
/// Being chained to a PhantomData prevents `LayoutNode`s from escaping.
|
||||
chain: PhantomData<&'a ()>,
|
||||
node: LayoutDom<'dom, Node>,
|
||||
}
|
||||
|
||||
impl<'ln> Debug for ServoLayoutNode<'ln> {
|
||||
|
@ -130,25 +126,14 @@ impl<'a> PartialEq for ServoLayoutNode<'a> {
|
|||
}
|
||||
|
||||
impl<'ln> ServoLayoutNode<'ln> {
|
||||
fn from_layout_js(n: LayoutDom<Node>) -> ServoLayoutNode<'ln> {
|
||||
ServoLayoutNode {
|
||||
node: n,
|
||||
chain: PhantomData,
|
||||
}
|
||||
fn from_layout_js(n: LayoutDom<'ln, Node>) -> Self {
|
||||
ServoLayoutNode { node: n }
|
||||
}
|
||||
|
||||
pub unsafe fn new(address: &TrustedNodeAddress) -> Self {
|
||||
ServoLayoutNode::from_layout_js(LayoutDom::from_trusted_node_address(*address))
|
||||
}
|
||||
|
||||
/// Creates a new layout node with the same lifetime as this layout node.
|
||||
pub unsafe fn new_with_this_lifetime(&self, node: &LayoutDom<Node>) -> ServoLayoutNode<'ln> {
|
||||
ServoLayoutNode {
|
||||
node: *node,
|
||||
chain: self.chain,
|
||||
}
|
||||
}
|
||||
|
||||
fn script_type_id(&self) -> NodeTypeId {
|
||||
unsafe { self.node.type_id_for_layout() }
|
||||
}
|
||||
|
@ -166,12 +151,9 @@ impl<'ln> NodeInfo for ServoLayoutNode<'ln> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub struct ServoShadowRoot<'a> {
|
||||
pub struct ServoShadowRoot<'dom> {
|
||||
/// The wrapped shadow root.
|
||||
shadow_root: LayoutDom<ShadowRoot>,
|
||||
|
||||
/// Being chained to a PhantomData prevents `ShadowRoot`s from escaping.
|
||||
chain: PhantomData<&'a ()>,
|
||||
shadow_root: LayoutDom<'dom, ShadowRoot>,
|
||||
}
|
||||
|
||||
impl<'lr> Debug for ServoShadowRoot<'lr> {
|
||||
|
@ -205,11 +187,8 @@ impl<'lr> TShadowRoot for ServoShadowRoot<'lr> {
|
|||
}
|
||||
|
||||
impl<'lr> ServoShadowRoot<'lr> {
|
||||
fn from_layout_js(shadow_root: LayoutDom<ShadowRoot>) -> ServoShadowRoot<'lr> {
|
||||
ServoShadowRoot {
|
||||
shadow_root,
|
||||
chain: PhantomData,
|
||||
}
|
||||
fn from_layout_js(shadow_root: LayoutDom<'lr, ShadowRoot>) -> Self {
|
||||
ServoShadowRoot { shadow_root }
|
||||
}
|
||||
|
||||
pub unsafe fn flush_stylesheets(
|
||||
|
@ -232,40 +211,24 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
|||
unsafe {
|
||||
self.node
|
||||
.composed_parent_node_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
.map(Self::from_layout_js)
|
||||
}
|
||||
}
|
||||
|
||||
fn first_child(&self) -> Option<Self> {
|
||||
unsafe {
|
||||
self.node
|
||||
.first_child_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
}
|
||||
unsafe { self.node.first_child_ref().map(Self::from_layout_js) }
|
||||
}
|
||||
|
||||
fn last_child(&self) -> Option<Self> {
|
||||
unsafe {
|
||||
self.node
|
||||
.last_child_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
}
|
||||
unsafe { self.node.last_child_ref().map(Self::from_layout_js) }
|
||||
}
|
||||
|
||||
fn prev_sibling(&self) -> Option<Self> {
|
||||
unsafe {
|
||||
self.node
|
||||
.prev_sibling_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
}
|
||||
unsafe { self.node.prev_sibling_ref().map(Self::from_layout_js) }
|
||||
}
|
||||
|
||||
fn next_sibling(&self) -> Option<Self> {
|
||||
unsafe {
|
||||
self.node
|
||||
.next_sibling_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
}
|
||||
unsafe { self.node.next_sibling_ref().map(Self::from_layout_js) }
|
||||
}
|
||||
|
||||
fn owner_doc(&self) -> Self::ConcreteDocument {
|
||||
|
@ -311,7 +274,7 @@ impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> {
|
|||
type ConcreteThreadSafeLayoutNode = ServoThreadSafeLayoutNode<'ln>;
|
||||
|
||||
fn to_threadsafe(&self) -> Self::ConcreteThreadSafeLayoutNode {
|
||||
ServoThreadSafeLayoutNode::new(self)
|
||||
ServoThreadSafeLayoutNode::new(*self)
|
||||
}
|
||||
|
||||
fn type_id(&self) -> LayoutNodeType {
|
||||
|
@ -368,16 +331,15 @@ impl<'le> GetLayoutData<'le> for ServoThreadSafeLayoutElement<'le> {
|
|||
impl<'ln> ServoLayoutNode<'ln> {
|
||||
/// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to
|
||||
/// call and as such is marked `unsafe`.
|
||||
pub unsafe fn get_jsmanaged(&self) -> &LayoutDom<Node> {
|
||||
&self.node
|
||||
pub unsafe fn get_jsmanaged(&self) -> LayoutDom<'ln, Node> {
|
||||
self.node
|
||||
}
|
||||
}
|
||||
|
||||
// A wrapper around documents that ensures ayout can only ever access safe properties.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ServoLayoutDocument<'ld> {
|
||||
document: LayoutDom<Document>,
|
||||
chain: PhantomData<&'ld ()>,
|
||||
pub struct ServoLayoutDocument<'dom> {
|
||||
document: LayoutDom<'dom, Document>,
|
||||
}
|
||||
|
||||
impl<'ld> TDocument for ServoLayoutDocument<'ld> {
|
||||
|
@ -446,19 +408,15 @@ impl<'ld> ServoLayoutDocument<'ld> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn from_layout_js(doc: LayoutDom<Document>) -> ServoLayoutDocument<'ld> {
|
||||
ServoLayoutDocument {
|
||||
document: doc,
|
||||
chain: PhantomData,
|
||||
}
|
||||
pub fn from_layout_js(doc: LayoutDom<'ld, Document>) -> Self {
|
||||
ServoLayoutDocument { document: doc }
|
||||
}
|
||||
}
|
||||
|
||||
/// A wrapper around elements that ensures layout can only ever access safe properties.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ServoLayoutElement<'le> {
|
||||
element: LayoutDom<Element>,
|
||||
chain: PhantomData<&'le ()>,
|
||||
pub struct ServoLayoutElement<'dom> {
|
||||
element: LayoutDom<'dom, Element>,
|
||||
}
|
||||
|
||||
impl<'le> fmt::Debug for ServoLayoutElement<'le> {
|
||||
|
@ -739,11 +697,8 @@ impl<'le> Hash for ServoLayoutElement<'le> {
|
|||
impl<'le> Eq for ServoLayoutElement<'le> {}
|
||||
|
||||
impl<'le> ServoLayoutElement<'le> {
|
||||
fn from_layout_js(el: LayoutDom<Element>) -> ServoLayoutElement<'le> {
|
||||
ServoLayoutElement {
|
||||
element: el,
|
||||
chain: PhantomData,
|
||||
}
|
||||
fn from_layout_js(el: LayoutDom<'le, Element>) -> Self {
|
||||
ServoLayoutElement { element: el }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -789,7 +744,7 @@ impl<'le> ServoLayoutElement<'le> {
|
|||
}
|
||||
}
|
||||
|
||||
fn as_element<'le>(node: LayoutDom<Node>) -> Option<ServoLayoutElement<'le>> {
|
||||
fn as_element<'dom>(node: LayoutDom<'dom, Node>) -> Option<ServoLayoutElement<'dom>> {
|
||||
node.downcast().map(ServoLayoutElement::from_layout_js)
|
||||
}
|
||||
|
||||
|
@ -1044,29 +999,20 @@ impl<'ln> DangerousThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln>
|
|||
unsafe fn dangerous_first_child(&self) -> Option<Self> {
|
||||
self.get_jsmanaged()
|
||||
.first_child_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
.map(ServoLayoutNode::from_layout_js)
|
||||
.map(Self::new)
|
||||
}
|
||||
unsafe fn dangerous_next_sibling(&self) -> Option<Self> {
|
||||
self.get_jsmanaged()
|
||||
.next_sibling_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
.map(ServoLayoutNode::from_layout_js)
|
||||
.map(Self::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> ServoThreadSafeLayoutNode<'ln> {
|
||||
/// Creates a new layout node with the same lifetime as this layout node.
|
||||
pub unsafe fn new_with_this_lifetime(
|
||||
&self,
|
||||
node: &LayoutDom<Node>,
|
||||
) -> ServoThreadSafeLayoutNode<'ln> {
|
||||
ServoThreadSafeLayoutNode {
|
||||
node: self.node.new_with_this_lifetime(node),
|
||||
pseudo: PseudoElementType::Normal,
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new `ServoThreadSafeLayoutNode` from the given `ServoLayoutNode`.
|
||||
pub fn new<'a>(node: &ServoLayoutNode<'a>) -> ServoThreadSafeLayoutNode<'a> {
|
||||
pub fn new(node: ServoLayoutNode<'ln>) -> Self {
|
||||
ServoThreadSafeLayoutNode {
|
||||
node: node.clone(),
|
||||
pseudo: PseudoElementType::Normal,
|
||||
|
@ -1075,7 +1021,7 @@ impl<'ln> ServoThreadSafeLayoutNode<'ln> {
|
|||
|
||||
/// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to
|
||||
/// call and as such is marked `unsafe`.
|
||||
unsafe fn get_jsmanaged(&self) -> &LayoutDom<Node> {
|
||||
unsafe fn get_jsmanaged(&self) -> LayoutDom<'ln, Node> {
|
||||
self.node.get_jsmanaged()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ use servo_url::ServoUrl;
|
|||
use std::fmt;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::marker::PhantomData;
|
||||
use std::ptr::NonNull;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc as StdArc;
|
||||
|
@ -100,12 +99,9 @@ pub unsafe fn drop_style_and_layout_data(data: OpaqueStyleAndLayoutData) {
|
|||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ServoLayoutNode<'a> {
|
||||
pub struct ServoLayoutNode<'dom> {
|
||||
/// The wrapped node.
|
||||
node: LayoutDom<Node>,
|
||||
|
||||
/// Being chained to a PhantomData prevents `LayoutNode`s from escaping.
|
||||
chain: PhantomData<&'a ()>,
|
||||
node: LayoutDom<'dom, Node>,
|
||||
}
|
||||
|
||||
// Those are supposed to be sound, but they aren't because the entire system
|
||||
|
@ -137,25 +133,14 @@ impl<'a> PartialEq for ServoLayoutNode<'a> {
|
|||
}
|
||||
|
||||
impl<'ln> ServoLayoutNode<'ln> {
|
||||
fn from_layout_js(n: LayoutDom<Node>) -> ServoLayoutNode<'ln> {
|
||||
ServoLayoutNode {
|
||||
node: n,
|
||||
chain: PhantomData,
|
||||
}
|
||||
fn from_layout_js(n: LayoutDom<'ln, Node>) -> Self {
|
||||
ServoLayoutNode { node: n }
|
||||
}
|
||||
|
||||
pub unsafe fn new(address: &TrustedNodeAddress) -> Self {
|
||||
ServoLayoutNode::from_layout_js(LayoutDom::from_trusted_node_address(*address))
|
||||
}
|
||||
|
||||
/// Creates a new layout node with the same lifetime as this layout node.
|
||||
pub unsafe fn new_with_this_lifetime(&self, node: &LayoutDom<Node>) -> ServoLayoutNode<'ln> {
|
||||
ServoLayoutNode {
|
||||
node: *node,
|
||||
chain: self.chain,
|
||||
}
|
||||
}
|
||||
|
||||
fn script_type_id(&self) -> NodeTypeId {
|
||||
unsafe { self.node.type_id_for_layout() }
|
||||
}
|
||||
|
@ -173,12 +158,9 @@ impl<'ln> NodeInfo for ServoLayoutNode<'ln> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub struct ServoShadowRoot<'a> {
|
||||
pub struct ServoShadowRoot<'dom> {
|
||||
/// The wrapped shadow root.
|
||||
shadow_root: LayoutDom<ShadowRoot>,
|
||||
|
||||
/// Being chained to a PhantomData prevents `ShadowRoot`s from escaping.
|
||||
chain: PhantomData<&'a ()>,
|
||||
shadow_root: LayoutDom<'dom, ShadowRoot>,
|
||||
}
|
||||
|
||||
impl<'lr> Debug for ServoShadowRoot<'lr> {
|
||||
|
@ -212,11 +194,8 @@ impl<'lr> TShadowRoot for ServoShadowRoot<'lr> {
|
|||
}
|
||||
|
||||
impl<'lr> ServoShadowRoot<'lr> {
|
||||
fn from_layout_js(shadow_root: LayoutDom<ShadowRoot>) -> ServoShadowRoot<'lr> {
|
||||
ServoShadowRoot {
|
||||
shadow_root,
|
||||
chain: PhantomData,
|
||||
}
|
||||
fn from_layout_js(shadow_root: LayoutDom<'lr, ShadowRoot>) -> Self {
|
||||
ServoShadowRoot { shadow_root }
|
||||
}
|
||||
|
||||
pub unsafe fn flush_stylesheets(
|
||||
|
@ -239,40 +218,24 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
|||
unsafe {
|
||||
self.node
|
||||
.composed_parent_node_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
.map(Self::from_layout_js)
|
||||
}
|
||||
}
|
||||
|
||||
fn first_child(&self) -> Option<Self> {
|
||||
unsafe {
|
||||
self.node
|
||||
.first_child_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
}
|
||||
unsafe { self.node.first_child_ref().map(Self::from_layout_js) }
|
||||
}
|
||||
|
||||
fn last_child(&self) -> Option<Self> {
|
||||
unsafe {
|
||||
self.node
|
||||
.last_child_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
}
|
||||
unsafe { self.node.last_child_ref().map(Self::from_layout_js) }
|
||||
}
|
||||
|
||||
fn prev_sibling(&self) -> Option<Self> {
|
||||
unsafe {
|
||||
self.node
|
||||
.prev_sibling_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
}
|
||||
unsafe { self.node.prev_sibling_ref().map(Self::from_layout_js) }
|
||||
}
|
||||
|
||||
fn next_sibling(&self) -> Option<Self> {
|
||||
unsafe {
|
||||
self.node
|
||||
.next_sibling_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
}
|
||||
unsafe { self.node.next_sibling_ref().map(Self::from_layout_js) }
|
||||
}
|
||||
|
||||
fn owner_doc(&self) -> Self::ConcreteDocument {
|
||||
|
@ -318,7 +281,7 @@ impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> {
|
|||
type ConcreteThreadSafeLayoutNode = ServoThreadSafeLayoutNode<'ln>;
|
||||
|
||||
fn to_threadsafe(&self) -> Self::ConcreteThreadSafeLayoutNode {
|
||||
ServoThreadSafeLayoutNode::new(self)
|
||||
ServoThreadSafeLayoutNode::new(*self)
|
||||
}
|
||||
|
||||
fn type_id(&self) -> LayoutNodeType {
|
||||
|
@ -375,16 +338,15 @@ impl<'le> GetLayoutData<'le> for ServoThreadSafeLayoutElement<'le> {
|
|||
impl<'ln> ServoLayoutNode<'ln> {
|
||||
/// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to
|
||||
/// call and as such is marked `unsafe`.
|
||||
pub unsafe fn get_jsmanaged(&self) -> &LayoutDom<Node> {
|
||||
&self.node
|
||||
pub unsafe fn get_jsmanaged(&self) -> LayoutDom<'ln, Node> {
|
||||
self.node
|
||||
}
|
||||
}
|
||||
|
||||
// A wrapper around documents that ensures ayout can only ever access safe properties.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ServoLayoutDocument<'ld> {
|
||||
document: LayoutDom<Document>,
|
||||
chain: PhantomData<&'ld ()>,
|
||||
pub struct ServoLayoutDocument<'dom> {
|
||||
document: LayoutDom<'dom, Document>,
|
||||
}
|
||||
|
||||
impl<'ld> TDocument for ServoLayoutDocument<'ld> {
|
||||
|
@ -453,19 +415,15 @@ impl<'ld> ServoLayoutDocument<'ld> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn from_layout_js(doc: LayoutDom<Document>) -> ServoLayoutDocument<'ld> {
|
||||
ServoLayoutDocument {
|
||||
document: doc,
|
||||
chain: PhantomData,
|
||||
}
|
||||
pub fn from_layout_js(doc: LayoutDom<'ld, Document>) -> Self {
|
||||
ServoLayoutDocument { document: doc }
|
||||
}
|
||||
}
|
||||
|
||||
/// A wrapper around elements that ensures layout can only ever access safe properties.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ServoLayoutElement<'le> {
|
||||
element: LayoutDom<Element>,
|
||||
chain: PhantomData<&'le ()>,
|
||||
pub struct ServoLayoutElement<'dom> {
|
||||
element: LayoutDom<'dom, Element>,
|
||||
}
|
||||
|
||||
impl<'le> fmt::Debug for ServoLayoutElement<'le> {
|
||||
|
@ -746,11 +704,8 @@ impl<'le> Hash for ServoLayoutElement<'le> {
|
|||
impl<'le> Eq for ServoLayoutElement<'le> {}
|
||||
|
||||
impl<'le> ServoLayoutElement<'le> {
|
||||
fn from_layout_js(el: LayoutDom<Element>) -> ServoLayoutElement<'le> {
|
||||
ServoLayoutElement {
|
||||
element: el,
|
||||
chain: PhantomData,
|
||||
}
|
||||
fn from_layout_js(el: LayoutDom<'le, Element>) -> Self {
|
||||
ServoLayoutElement { element: el }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -796,7 +751,7 @@ impl<'le> ServoLayoutElement<'le> {
|
|||
}
|
||||
}
|
||||
|
||||
fn as_element<'le>(node: LayoutDom<Node>) -> Option<ServoLayoutElement<'le>> {
|
||||
fn as_element<'dom>(node: LayoutDom<'dom, Node>) -> Option<ServoLayoutElement<'dom>> {
|
||||
node.downcast().map(ServoLayoutElement::from_layout_js)
|
||||
}
|
||||
|
||||
|
@ -1051,29 +1006,20 @@ impl<'ln> DangerousThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln>
|
|||
unsafe fn dangerous_first_child(&self) -> Option<Self> {
|
||||
self.get_jsmanaged()
|
||||
.first_child_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
.map(ServoLayoutNode::from_layout_js)
|
||||
.map(Self::new)
|
||||
}
|
||||
unsafe fn dangerous_next_sibling(&self) -> Option<Self> {
|
||||
self.get_jsmanaged()
|
||||
.next_sibling_ref()
|
||||
.map(|node| self.new_with_this_lifetime(&node))
|
||||
.map(ServoLayoutNode::from_layout_js)
|
||||
.map(Self::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> ServoThreadSafeLayoutNode<'ln> {
|
||||
/// Creates a new layout node with the same lifetime as this layout node.
|
||||
pub unsafe fn new_with_this_lifetime(
|
||||
&self,
|
||||
node: &LayoutDom<Node>,
|
||||
) -> ServoThreadSafeLayoutNode<'ln> {
|
||||
ServoThreadSafeLayoutNode {
|
||||
node: self.node.new_with_this_lifetime(node),
|
||||
pseudo: PseudoElementType::Normal,
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new `ServoThreadSafeLayoutNode` from the given `ServoLayoutNode`.
|
||||
pub fn new<'a>(node: &ServoLayoutNode<'a>) -> ServoThreadSafeLayoutNode<'a> {
|
||||
pub fn new(node: ServoLayoutNode<'ln>) -> Self {
|
||||
ServoThreadSafeLayoutNode {
|
||||
node: node.clone(),
|
||||
pseudo: PseudoElementType::Normal,
|
||||
|
@ -1082,7 +1028,7 @@ impl<'ln> ServoThreadSafeLayoutNode<'ln> {
|
|||
|
||||
/// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to
|
||||
/// call and as such is marked `unsafe`.
|
||||
unsafe fn get_jsmanaged(&self) -> &LayoutDom<Node> {
|
||||
unsafe fn get_jsmanaged(&self) -> LayoutDom<'ln, Node> {
|
||||
self.node.get_jsmanaged()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ pub trait AttrHelpersForLayout {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl AttrHelpersForLayout for LayoutDom<Attr> {
|
||||
impl AttrHelpersForLayout for LayoutDom<'_, Attr> {
|
||||
#[inline]
|
||||
unsafe fn value_forever(&self) -> &'static AttrValue {
|
||||
// This transmute is used to cheat the lifetime restriction.
|
||||
|
|
|
@ -331,6 +331,7 @@ impl<T> Dom<T> {
|
|||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutDom {
|
||||
ptr: self.ptr.clone(),
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -413,13 +414,17 @@ where
|
|||
/// An unrooted reference to a DOM object for use in layout. `Layout*Helpers`
|
||||
/// traits must be implemented on this.
|
||||
#[unrooted_must_root_lint::allow_unrooted_interior]
|
||||
pub struct LayoutDom<T> {
|
||||
pub struct LayoutDom<'dom, T> {
|
||||
ptr: ptr::NonNull<T>,
|
||||
marker: PhantomData<&'dom T>,
|
||||
}
|
||||
|
||||
impl<T: Castable> LayoutDom<T> {
|
||||
impl<'dom, T> LayoutDom<'dom, T>
|
||||
where
|
||||
T: Castable,
|
||||
{
|
||||
/// Cast a DOM object root upwards to one of the interfaces it derives from.
|
||||
pub fn upcast<U>(&self) -> LayoutDom<U>
|
||||
pub fn upcast<U>(&self) -> LayoutDom<'dom, U>
|
||||
where
|
||||
U: Castable,
|
||||
T: DerivedFrom<U>,
|
||||
|
@ -428,11 +433,12 @@ impl<T: Castable> LayoutDom<T> {
|
|||
let ptr: *mut T = self.ptr.as_ptr();
|
||||
LayoutDom {
|
||||
ptr: unsafe { ptr::NonNull::new_unchecked(ptr as *mut U) },
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Cast a DOM object downwards to one of the interfaces it might implement.
|
||||
pub fn downcast<U>(&self) -> Option<LayoutDom<U>>
|
||||
pub fn downcast<U>(&self) -> Option<LayoutDom<'dom, U>>
|
||||
where
|
||||
U: DerivedFrom<T>,
|
||||
{
|
||||
|
@ -442,6 +448,7 @@ impl<T: Castable> LayoutDom<T> {
|
|||
let ptr: *mut T = self.ptr.as_ptr();
|
||||
Some(LayoutDom {
|
||||
ptr: ptr::NonNull::new_unchecked(ptr as *mut U),
|
||||
marker: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
@ -450,7 +457,10 @@ impl<T: Castable> LayoutDom<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject> LayoutDom<T> {
|
||||
impl<T> LayoutDom<'_, T>
|
||||
where
|
||||
T: DomObject,
|
||||
{
|
||||
/// Get the reflector.
|
||||
pub unsafe fn get_jsobject(&self) -> *mut JSObject {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
|
@ -458,7 +468,7 @@ impl<T: DomObject> LayoutDom<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Copy for LayoutDom<T> {}
|
||||
impl<T> Copy for LayoutDom<'_, T> {}
|
||||
|
||||
impl<T> PartialEq for Dom<T> {
|
||||
fn eq(&self, other: &Dom<T>) -> bool {
|
||||
|
@ -474,13 +484,13 @@ impl<'a, T: DomObject> PartialEq<&'a T> for Dom<T> {
|
|||
|
||||
impl<T> Eq for Dom<T> {}
|
||||
|
||||
impl<T> PartialEq for LayoutDom<T> {
|
||||
fn eq(&self, other: &LayoutDom<T>) -> bool {
|
||||
impl<T> PartialEq for LayoutDom<'_, T> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.ptr.as_ptr() == other.ptr.as_ptr()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Eq for LayoutDom<T> {}
|
||||
impl<T> Eq for LayoutDom<'_, T> {}
|
||||
|
||||
impl<T> Hash for Dom<T> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
|
@ -488,7 +498,7 @@ impl<T> Hash for Dom<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Hash for LayoutDom<T> {
|
||||
impl<T> Hash for LayoutDom<'_, T> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.ptr.as_ptr().hash(state)
|
||||
}
|
||||
|
@ -497,7 +507,7 @@ impl<T> Hash for LayoutDom<T> {
|
|||
impl<T> Clone for Dom<T> {
|
||||
#[inline]
|
||||
#[allow(unrooted_must_root)]
|
||||
fn clone(&self) -> Dom<T> {
|
||||
fn clone(&self) -> Self {
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
Dom {
|
||||
ptr: self.ptr.clone(),
|
||||
|
@ -505,24 +515,26 @@ impl<T> Clone for Dom<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Clone for LayoutDom<T> {
|
||||
impl<T> Clone for LayoutDom<'_, T> {
|
||||
#[inline]
|
||||
fn clone(&self) -> LayoutDom<T> {
|
||||
fn clone(&self) -> Self {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutDom {
|
||||
ptr: self.ptr.clone(),
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LayoutDom<Node> {
|
||||
impl LayoutDom<'_, Node> {
|
||||
/// Create a new JS-owned value wrapped from an address known to be a
|
||||
/// `Node` pointer.
|
||||
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutDom<Node> {
|
||||
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> Self {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
let TrustedNodeAddress(addr) = inner;
|
||||
LayoutDom {
|
||||
ptr: ptr::NonNull::new_unchecked(addr as *const Node as *mut Node),
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -624,7 +636,7 @@ impl<T: DomObject> MutNullableDom<T> {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<T>> {
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
ptr::read(self.ptr.get()).map(|js| js.to_layout())
|
||||
(*self.ptr.get()).as_ref().map(|js| js.to_layout())
|
||||
}
|
||||
|
||||
/// Get a rooted value out of this object
|
||||
|
@ -732,7 +744,10 @@ unsafe impl<T: DomObject> JSTraceable for DomOnceCell<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: DomObject> LayoutDom<T> {
|
||||
impl<'dom, T> LayoutDom<'dom, T>
|
||||
where
|
||||
T: 'dom + DomObject,
|
||||
{
|
||||
/// Returns an unsafe pointer to the interior of this JS object. This is
|
||||
/// the only method that be safely accessed from layout. (The fact that
|
||||
/// this is unsafe is what necessitates the layout wrappers.)
|
||||
|
|
|
@ -157,7 +157,7 @@ pub trait LayoutCanvasRenderingContext2DHelpers {
|
|||
unsafe fn get_canvas_id(&self) -> CanvasId;
|
||||
}
|
||||
|
||||
impl LayoutCanvasRenderingContext2DHelpers for LayoutDom<CanvasRenderingContext2D> {
|
||||
impl LayoutCanvasRenderingContext2DHelpers for LayoutDom<'_, CanvasRenderingContext2D> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg> {
|
||||
(*self.unsafe_get())
|
||||
|
|
|
@ -286,7 +286,7 @@ pub trait LayoutCharacterDataHelpers {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl LayoutCharacterDataHelpers for LayoutDom<CharacterData> {
|
||||
impl LayoutCharacterDataHelpers for LayoutDom<'_, CharacterData> {
|
||||
#[inline]
|
||||
unsafe fn data_for_layout(&self) -> &str {
|
||||
&(*self.unsafe_get()).data.borrow_for_layout()
|
||||
|
|
|
@ -2617,7 +2617,7 @@ pub trait LayoutDocumentHelpers {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl LayoutDocumentHelpers for LayoutDom<Document> {
|
||||
impl LayoutDocumentHelpers for LayoutDom<'_, Document> {
|
||||
#[inline]
|
||||
unsafe fn is_html_document_for_layout(&self) -> bool {
|
||||
(*self.unsafe_get()).is_html_document
|
||||
|
|
|
@ -567,11 +567,11 @@ pub trait RawLayoutElementHelpers {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn get_attr_for_layout<'a>(
|
||||
elem: &'a Element,
|
||||
pub unsafe fn get_attr_for_layout<'dom>(
|
||||
elem: &'dom Element,
|
||||
namespace: &Namespace,
|
||||
name: &LocalName,
|
||||
) -> Option<LayoutDom<Attr>> {
|
||||
) -> Option<LayoutDom<'dom, Attr>> {
|
||||
// cast to point to T in RefCell<T> directly
|
||||
let attrs = elem.attrs.borrow_for_layout();
|
||||
attrs
|
||||
|
@ -620,7 +620,7 @@ impl RawLayoutElementHelpers for Element {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait LayoutElementHelpers {
|
||||
pub trait LayoutElementHelpers<'dom> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn has_class_for_layout(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool;
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -646,10 +646,10 @@ pub trait LayoutElementHelpers {
|
|||
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool;
|
||||
/// The shadow root this element is a host of.
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>>;
|
||||
unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
||||
}
|
||||
|
||||
impl LayoutElementHelpers for LayoutDom<Element> {
|
||||
impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
||||
#[allow(unsafe_code)]
|
||||
#[inline]
|
||||
unsafe fn has_class_for_layout(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
|
||||
|
@ -1095,7 +1095,7 @@ impl LayoutElementHelpers for LayoutDom<Element> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>> {
|
||||
unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
||||
(*self.unsafe_get())
|
||||
.rare_data_for_layout()
|
||||
.as_ref()?
|
||||
|
|
|
@ -99,7 +99,7 @@ pub trait HTMLBodyElementLayoutHelpers {
|
|||
fn get_background(&self) -> Option<ServoUrl>;
|
||||
}
|
||||
|
||||
impl HTMLBodyElementLayoutHelpers for LayoutDom<HTMLBodyElement> {
|
||||
impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
|
|
|
@ -120,7 +120,7 @@ pub trait LayoutHTMLCanvasElementHelpers {
|
|||
fn get_canvas_id_for_layout(&self) -> CanvasId;
|
||||
}
|
||||
|
||||
impl LayoutHTMLCanvasElementHelpers for LayoutDom<HTMLCanvasElement> {
|
||||
impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn data(&self) -> HTMLCanvasData {
|
||||
unsafe {
|
||||
|
|
|
@ -106,7 +106,7 @@ pub trait HTMLFontElementLayoutHelpers {
|
|||
fn get_size(&self) -> Option<u32>;
|
||||
}
|
||||
|
||||
impl HTMLFontElementLayoutHelpers for LayoutDom<HTMLFontElement> {
|
||||
impl HTMLFontElementLayoutHelpers for LayoutDom<'_, HTMLFontElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
|
|
|
@ -70,7 +70,7 @@ pub trait HTMLHRLayoutHelpers {
|
|||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl HTMLHRLayoutHelpers for LayoutDom<HTMLHRElement> {
|
||||
impl HTMLHRLayoutHelpers for LayoutDom<'_, HTMLHRElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
|
|
|
@ -486,7 +486,7 @@ pub trait HTMLIFrameElementLayoutMethods {
|
|||
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl HTMLIFrameElementLayoutMethods for LayoutDom<HTMLIFrameElement> {
|
||||
impl HTMLIFrameElementLayoutMethods for LayoutDom<'_, HTMLIFrameElement> {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
fn pipeline_id(&self) -> Option<PipelineId> {
|
||||
|
|
|
@ -1382,7 +1382,7 @@ pub trait LayoutHTMLImageElementHelpers {
|
|||
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl LayoutHTMLImageElementHelpers for LayoutDom<HTMLImageElement> {
|
||||
impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image(&self) -> Option<Arc<Image>> {
|
||||
(*self.unsafe_get())
|
||||
|
|
|
@ -726,11 +726,14 @@ unsafe fn get_raw_textinput_value(input: LayoutDom<HTMLInputElement>) -> DOMStri
|
|||
.get_content()
|
||||
}
|
||||
|
||||
impl LayoutHTMLInputElementHelpers for LayoutDom<HTMLInputElement> {
|
||||
impl LayoutHTMLInputElementHelpers for LayoutDom<'_, HTMLInputElement> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn value_for_layout(self) -> String {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_raw_attr_value(input: LayoutDom<HTMLInputElement>, default: &str) -> String {
|
||||
unsafe fn get_raw_attr_value(
|
||||
input: LayoutDom<'_, HTMLInputElement>,
|
||||
default: &str,
|
||||
) -> String {
|
||||
let elem = input.upcast::<Element>();
|
||||
let value = (*elem.unsafe_get())
|
||||
.get_attr_val_for_layout(&ns!(), &local_name!("value"))
|
||||
|
|
|
@ -2447,7 +2447,7 @@ pub trait LayoutHTMLMediaElementHelpers {
|
|||
fn data(&self) -> HTMLMediaData;
|
||||
}
|
||||
|
||||
impl LayoutHTMLMediaElementHelpers for LayoutDom<HTMLMediaElement> {
|
||||
impl LayoutHTMLMediaElementHelpers for LayoutDom<'_, HTMLMediaElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn data(&self) -> HTMLMediaData {
|
||||
let media = unsafe { &*self.unsafe_get() };
|
||||
|
|
|
@ -105,7 +105,7 @@ pub trait HTMLTableCellElementLayoutHelpers {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl HTMLTableCellElementLayoutHelpers for LayoutDom<HTMLTableCellElement> {
|
||||
impl HTMLTableCellElementLayoutHelpers for LayoutDom<'_, HTMLTableCellElement> {
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
|
|
|
@ -412,7 +412,7 @@ pub trait HTMLTableElementLayoutHelpers {
|
|||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl HTMLTableElementLayoutHelpers for LayoutDom<HTMLTableElement> {
|
||||
impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
|
|
|
@ -150,7 +150,7 @@ pub trait HTMLTableRowElementLayoutHelpers {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl HTMLTableRowElementLayoutHelpers for LayoutDom<HTMLTableRowElement> {
|
||||
impl HTMLTableRowElementLayoutHelpers for LayoutDom<'_, HTMLTableRowElement> {
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
|
|
|
@ -88,7 +88,7 @@ pub trait HTMLTableSectionElementLayoutHelpers {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl HTMLTableSectionElementLayoutHelpers for LayoutDom<HTMLTableSectionElement> {
|
||||
impl HTMLTableSectionElementLayoutHelpers for LayoutDom<'_, HTMLTableSectionElement> {
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
unsafe {
|
||||
(&*self.upcast::<Element>().unsafe_get())
|
||||
|
|
|
@ -66,7 +66,7 @@ pub trait LayoutHTMLTextAreaElementHelpers {
|
|||
fn get_rows(self) -> u32;
|
||||
}
|
||||
|
||||
impl LayoutHTMLTextAreaElementHelpers for LayoutDom<HTMLTextAreaElement> {
|
||||
impl LayoutHTMLTextAreaElementHelpers for LayoutDom<'_, HTMLTextAreaElement> {
|
||||
#[allow(unrooted_must_root)]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn value_for_layout(self) -> String {
|
||||
|
|
|
@ -1304,17 +1304,17 @@ pub unsafe fn from_untrusted_node_address(
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait LayoutNodeHelpers {
|
||||
pub trait LayoutNodeHelpers<'dom> {
|
||||
unsafe fn type_id_for_layout(&self) -> NodeTypeId;
|
||||
|
||||
unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<Node>>;
|
||||
unsafe fn first_child_ref(&self) -> Option<LayoutDom<Node>>;
|
||||
unsafe fn last_child_ref(&self) -> Option<LayoutDom<Node>>;
|
||||
unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<Node>>;
|
||||
unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<Node>>;
|
||||
unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<'dom, Node>>;
|
||||
unsafe fn first_child_ref(&self) -> Option<LayoutDom<'dom, Node>>;
|
||||
unsafe fn last_child_ref(&self) -> Option<LayoutDom<'dom, Node>>;
|
||||
unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>>;
|
||||
unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>>;
|
||||
|
||||
unsafe fn owner_doc_for_layout(&self) -> LayoutDom<Document>;
|
||||
unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>>;
|
||||
unsafe fn owner_doc_for_layout(&self) -> LayoutDom<'dom, Document>;
|
||||
unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
||||
|
||||
unsafe fn is_element_for_layout(&self) -> bool;
|
||||
unsafe fn get_flag(&self, flag: NodeFlags) -> bool;
|
||||
|
@ -1339,7 +1339,7 @@ pub trait LayoutNodeHelpers {
|
|||
fn opaque(&self) -> OpaqueNode;
|
||||
}
|
||||
|
||||
impl LayoutNodeHelpers for LayoutDom<Node> {
|
||||
impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn type_id_for_layout(&self) -> NodeTypeId {
|
||||
|
@ -1354,7 +1354,7 @@ impl LayoutNodeHelpers for LayoutDom<Node> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<Node>> {
|
||||
unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<'dom, Node>> {
|
||||
let parent = (*self.unsafe_get()).parent_node.get_inner_as_layout();
|
||||
if let Some(ref parent) = parent {
|
||||
if let Some(shadow_root) = parent.downcast::<ShadowRoot>() {
|
||||
|
@ -1366,31 +1366,31 @@ impl LayoutNodeHelpers for LayoutDom<Node> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn first_child_ref(&self) -> Option<LayoutDom<Node>> {
|
||||
unsafe fn first_child_ref(&self) -> Option<LayoutDom<'dom, Node>> {
|
||||
(*self.unsafe_get()).first_child.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn last_child_ref(&self) -> Option<LayoutDom<Node>> {
|
||||
unsafe fn last_child_ref(&self) -> Option<LayoutDom<'dom, Node>> {
|
||||
(*self.unsafe_get()).last_child.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<Node>> {
|
||||
unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>> {
|
||||
(*self.unsafe_get()).prev_sibling.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<Node>> {
|
||||
unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>> {
|
||||
(*self.unsafe_get()).next_sibling.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn owner_doc_for_layout(&self) -> LayoutDom<Document> {
|
||||
unsafe fn owner_doc_for_layout(&self) -> LayoutDom<'dom, Document> {
|
||||
(*self.unsafe_get())
|
||||
.owner_doc
|
||||
.get_inner_as_layout()
|
||||
|
@ -1399,7 +1399,7 @@ impl LayoutNodeHelpers for LayoutDom<Node> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>> {
|
||||
unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
||||
(*self.unsafe_get())
|
||||
.rare_data_for_layout()
|
||||
.as_ref()?
|
||||
|
|
|
@ -239,8 +239,8 @@ impl ShadowRootMethods for ShadowRoot {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait LayoutShadowRootHelpers {
|
||||
unsafe fn get_host_for_layout(&self) -> LayoutDom<Element>;
|
||||
pub trait LayoutShadowRootHelpers<'dom> {
|
||||
unsafe fn get_host_for_layout(&self) -> LayoutDom<'dom, Element>;
|
||||
unsafe fn get_style_data_for_layout<'a, E: TElement>(
|
||||
&self,
|
||||
) -> &'a AuthorStyles<StyleSheetInDocument>;
|
||||
|
@ -252,10 +252,10 @@ pub trait LayoutShadowRootHelpers {
|
|||
);
|
||||
}
|
||||
|
||||
impl LayoutShadowRootHelpers for LayoutDom<ShadowRoot> {
|
||||
impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_host_for_layout(&self) -> LayoutDom<Element> {
|
||||
unsafe fn get_host_for_layout(&self) -> LayoutDom<'dom, Element> {
|
||||
(*self.unsafe_get())
|
||||
.host
|
||||
.get_inner_as_layout()
|
||||
|
|
|
@ -52,7 +52,7 @@ pub trait LayoutSVGSVGElementHelpers {
|
|||
fn data(&self) -> SVGSVGData;
|
||||
}
|
||||
|
||||
impl LayoutSVGSVGElementHelpers for LayoutDom<SVGSVGElement> {
|
||||
impl LayoutSVGSVGElementHelpers for LayoutDom<'_, SVGSVGElement> {
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
fn data(&self) -> SVGSVGData {
|
||||
unsafe {
|
||||
|
|
|
@ -3884,7 +3884,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
}
|
||||
}
|
||||
|
||||
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<WebGL2RenderingContext> {
|
||||
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<'_, WebGL2RenderingContext> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource {
|
||||
let this = &*self.unsafe_get();
|
||||
|
|
|
@ -4450,7 +4450,7 @@ pub trait LayoutCanvasWebGLRenderingContextHelpers {
|
|||
unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource;
|
||||
}
|
||||
|
||||
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<WebGLRenderingContext> {
|
||||
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<'_, WebGLRenderingContext> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource {
|
||||
(*self.unsafe_get()).layout_handle()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue