aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorAnthony Ramine <nox@nox.paris>2020-03-31 21:24:07 +0200
committerAnthony Ramine <nox@nox.paris>2020-03-31 21:39:45 +0200
commit72c0771299151ce93f8178c84b1eb1d13c29a49c (patch)
treeaf51fa70be20e608b821f89471568e90719031c9 /components
parente56191106693f5cbfd1978ead55d410cc43663a0 (diff)
downloadservo-72c0771299151ce93f8178c84b1eb1d13c29a49c.tar.gz
servo-72c0771299151ce93f8178c84b1eb1d13c29a49c.zip
Make a bunch of LayoutDocumentHelpers be safe
The other methods are actually unsafe.
Diffstat (limited to 'components')
-rw-r--r--components/layout_thread/dom_wrapper.rs4
-rw-r--r--components/layout_thread_2020/dom_wrapper.rs4
-rw-r--r--components/script/dom/document.rs40
3 files changed, 27 insertions, 21 deletions
diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs
index 2528a474211..7d3ad1e5c5a 100644
--- a/components/layout_thread/dom_wrapper.rs
+++ b/components/layout_thread/dom_wrapper.rs
@@ -345,11 +345,11 @@ impl<'ld> TDocument for ServoLayoutDocument<'ld> {
}
fn quirks_mode(&self) -> QuirksMode {
- unsafe { self.document.quirks_mode() }
+ self.document.quirks_mode()
}
fn is_html_document(&self) -> bool {
- unsafe { self.document.is_html_document_for_layout() }
+ self.document.is_html_document_for_layout()
}
}
diff --git a/components/layout_thread_2020/dom_wrapper.rs b/components/layout_thread_2020/dom_wrapper.rs
index dea364d1723..4516a6c20d5 100644
--- a/components/layout_thread_2020/dom_wrapper.rs
+++ b/components/layout_thread_2020/dom_wrapper.rs
@@ -352,11 +352,11 @@ impl<'ld> TDocument for ServoLayoutDocument<'ld> {
}
fn quirks_mode(&self) -> QuirksMode {
- unsafe { self.document.quirks_mode() }
+ self.document.quirks_mode()
}
fn is_html_document(&self) -> bool {
- unsafe { self.document.is_html_document_for_layout() }
+ self.document.is_html_document_for_layout()
}
}
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 1e60b3b79fc..c3c64babfef 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -2606,21 +2606,21 @@ pub enum DocumentSource {
#[allow(unsafe_code)]
pub trait LayoutDocumentHelpers<'dom> {
- unsafe fn is_html_document_for_layout(self) -> bool;
+ fn is_html_document_for_layout(self) -> bool;
unsafe fn needs_paint_from_layout(self);
unsafe fn will_paint(self);
- unsafe fn quirks_mode(self) -> QuirksMode;
+ fn quirks_mode(self) -> QuirksMode;
unsafe fn style_shared_lock(self) -> &'dom StyleSharedRwLock;
- unsafe fn shadow_roots(self) -> Vec<LayoutDom<'dom, ShadowRoot>>;
- unsafe fn shadow_roots_styles_changed(self) -> bool;
+ fn shadow_roots(self) -> Vec<LayoutDom<'dom, ShadowRoot>>;
+ fn shadow_roots_styles_changed(self) -> bool;
unsafe fn flush_shadow_roots_stylesheets(self);
}
#[allow(unsafe_code)]
impl<'dom> LayoutDocumentHelpers<'dom> for LayoutDom<'dom, Document> {
#[inline]
- unsafe fn is_html_document_for_layout(self) -> bool {
- (*self.unsafe_get()).is_html_document
+ fn is_html_document_for_layout(self) -> bool {
+ unsafe { self.unsafe_get().is_html_document }
}
#[inline]
@@ -2634,8 +2634,8 @@ impl<'dom> LayoutDocumentHelpers<'dom> for LayoutDom<'dom, Document> {
}
#[inline]
- unsafe fn quirks_mode(self) -> QuirksMode {
- (*self.unsafe_get()).quirks_mode()
+ fn quirks_mode(self) -> QuirksMode {
+ unsafe { self.unsafe_get().quirks_mode.get() }
}
#[inline]
@@ -2644,18 +2644,24 @@ impl<'dom> LayoutDocumentHelpers<'dom> for LayoutDom<'dom, Document> {
}
#[inline]
- unsafe fn shadow_roots(self) -> Vec<LayoutDom<'dom, ShadowRoot>> {
- (*self.unsafe_get())
- .shadow_roots
- .borrow_for_layout()
- .iter()
- .map(|sr| sr.to_layout())
- .collect()
+ fn shadow_roots(self) -> Vec<LayoutDom<'dom, ShadowRoot>> {
+ // FIXME(nox): We should just return a
+ // &'dom HashSet<LayoutDom<'dom, ShadowRoot>> here but not until
+ // I rework the ToLayout trait as mentioned in
+ // LayoutDom::to_layout_slice.
+ unsafe {
+ self.unsafe_get()
+ .shadow_roots
+ .borrow_for_layout()
+ .iter()
+ .map(|sr| sr.to_layout())
+ .collect()
+ }
}
#[inline]
- unsafe fn shadow_roots_styles_changed(self) -> bool {
- (*self.unsafe_get()).shadow_roots_styles_changed()
+ fn shadow_roots_styles_changed(self) -> bool {
+ unsafe { self.unsafe_get().shadow_roots_styles_changed.get() }
}
#[inline]