mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
script: Wrapping unsafe code in unsafe
blocks for basic DOM types (#37997)
There is a new default cargo clippy lint, `unsafe_op_in_unsafe_fn`, which requires unsafe code to be wrapped in unsafe blocks, even inside functions marked as unsafe. The lint is disabled as much of our code doesn't fulfill this contract. The thing itself is pretty useful in order to gradually remove unsafety, so this change starts adding `unsafe` blocks so we can eventually enable this lint. Testing: This doesn't change behavior so existings tests should suffice. Fixes: This is part of #35955. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
a13cc1b25a
commit
2366a8bf9e
6 changed files with 51 additions and 30 deletions
|
@ -99,9 +99,11 @@ impl<'dom> ServoLayoutElement<'dom> {
|
|||
/// This function accesses and modifies the underlying DOM object and should
|
||||
/// not be used by more than a single thread at once.
|
||||
pub unsafe fn unset_snapshot_flags(&self) {
|
||||
self.as_node()
|
||||
.node
|
||||
.set_flag(NodeFlags::HAS_SNAPSHOT | NodeFlags::HANDLED_SNAPSHOT, false);
|
||||
unsafe {
|
||||
self.as_node()
|
||||
.node
|
||||
.set_flag(NodeFlags::HAS_SNAPSHOT | NodeFlags::HANDLED_SNAPSHOT, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// Unset the snapshot flags on the underlying DOM object for this element.
|
||||
|
@ -111,7 +113,9 @@ impl<'dom> ServoLayoutElement<'dom> {
|
|||
/// This function accesses and modifies the underlying DOM object and should
|
||||
/// not be used by more than a single thread at once.
|
||||
pub unsafe fn set_has_snapshot(&self) {
|
||||
self.as_node().node.set_flag(NodeFlags::HAS_SNAPSHOT, true);
|
||||
unsafe {
|
||||
self.as_node().node.set_flag(NodeFlags::HAS_SNAPSHOT, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if this element is the body child of an html element root element.
|
||||
|
@ -355,22 +359,28 @@ impl<'dom> style::dom::TElement for ServoLayoutElement<'dom> {
|
|||
}
|
||||
|
||||
unsafe fn set_handled_snapshot(&self) {
|
||||
self.as_node()
|
||||
.node
|
||||
.set_flag(NodeFlags::HANDLED_SNAPSHOT, true);
|
||||
unsafe {
|
||||
self.as_node()
|
||||
.node
|
||||
.set_flag(NodeFlags::HANDLED_SNAPSHOT, true);
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn set_dirty_descendants(&self) {
|
||||
debug_assert!(self.as_node().is_connected());
|
||||
self.as_node()
|
||||
.node
|
||||
.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, true)
|
||||
unsafe {
|
||||
self.as_node()
|
||||
.node
|
||||
.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, true)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn unset_dirty_descendants(&self) {
|
||||
self.as_node()
|
||||
.node
|
||||
.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, false)
|
||||
unsafe {
|
||||
self.as_node()
|
||||
.node
|
||||
.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, false)
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether this element should match user and content rules.
|
||||
|
@ -406,11 +416,13 @@ impl<'dom> style::dom::TElement for ServoLayoutElement<'dom> {
|
|||
}
|
||||
|
||||
unsafe fn clear_data(&self) {
|
||||
self.as_node().get_jsmanaged().clear_style_and_layout_data()
|
||||
unsafe { self.as_node().get_jsmanaged().clear_style_and_layout_data() }
|
||||
}
|
||||
|
||||
unsafe fn ensure_data(&self) -> AtomicRefMut<ElementData> {
|
||||
self.as_node().get_jsmanaged().initialize_style_data();
|
||||
unsafe {
|
||||
self.as_node().get_jsmanaged().initialize_style_data();
|
||||
};
|
||||
self.mutate_data().unwrap()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue