mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Make LayoutNodeHelpers::composed_parent_node_ref be safe
For clarity, I introduce <LayoutDom<Element>>::parent_node_ref to contain the remaining unsafety bits out of composed_parent_node_ref which is more complex than just a field access.
This commit is contained in:
parent
f712b0bcf8
commit
fc07a5147c
4 changed files with 44 additions and 50 deletions
|
@ -203,11 +203,9 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
|||
type ConcreteShadowRoot = ServoShadowRoot<'ln>;
|
||||
|
||||
fn parent_node(&self) -> Option<Self> {
|
||||
unsafe {
|
||||
self.node
|
||||
.composed_parent_node_ref()
|
||||
.map(Self::from_layout_js)
|
||||
}
|
||||
self.node
|
||||
.composed_parent_node_ref()
|
||||
.map(Self::from_layout_js)
|
||||
}
|
||||
|
||||
fn first_child(&self) -> Option<Self> {
|
||||
|
@ -745,12 +743,10 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
|||
}
|
||||
|
||||
fn parent_element(&self) -> Option<ServoLayoutElement<'le>> {
|
||||
unsafe {
|
||||
self.element
|
||||
.upcast()
|
||||
.composed_parent_node_ref()
|
||||
.and_then(as_element)
|
||||
}
|
||||
self.element
|
||||
.upcast()
|
||||
.composed_parent_node_ref()
|
||||
.and_then(as_element)
|
||||
}
|
||||
|
||||
fn parent_node_is_shadow_root(&self) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue