aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/layout_dom/element.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-10-16 01:11:31 -0700
committerGitHub <noreply@github.com>2024-10-16 08:11:31 +0000
commit30abb99287790c2653821cc469ecd891b89ab57c (patch)
tree9d9187cd6a0ca7133096315044b24dcf75871a65 /components/script/layout_dom/element.rs
parented959d7a1a2a584803f689ce8d92f7d0c3c0d48b (diff)
downloadservo-30abb99287790c2653821cc469ecd891b89ab57c.tar.gz
servo-30abb99287790c2653821cc469ecd891b89ab57c.zip
clippy: Add safety documentation and clean up unsafe methods (#33748)
This change: 1. Adds safety documentation where it was missing. 2. Limits the scope of unsafe code in some cases to where it is actually unsafe. 3. Converts some free functions to associated functions and methods, thereby making them more likely to be called safely. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/script/layout_dom/element.rs')
-rw-r--r--components/script/layout_dom/element.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/components/script/layout_dom/element.rs b/components/script/layout_dom/element.rs
index 4ecd3ca2de1..05349205c82 100644
--- a/components/script/layout_dom/element.rs
+++ b/components/script/layout_dom/element.rs
@@ -89,12 +89,24 @@ impl<'dom> ServoLayoutElement<'dom> {
self.as_node().style_data()
}
+ /// Unset the snapshot flags on the underlying DOM object for this element.
+ ///
+ /// # Safety
+ ///
+ /// 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);
}
+ /// Unset the snapshot flags on the underlying DOM object for this element.
+ ///
+ /// # Safety
+ ///
+ /// 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);
}