diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-04-03 10:41:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-03 08:41:19 +0000 |
commit | 18b37e676bcd50f754cd189444080fc547c9d48a (patch) | |
tree | ca2e235d13b6f9b19cff9172810b0c6f08265f3b /components/script/dom/htmlinputelement.rs | |
parent | 8aaff613342568c13e9141758b770788694d2f84 (diff) | |
download | servo-18b37e676bcd50f754cd189444080fc547c9d48a.tar.gz servo-18b37e676bcd50f754cd189444080fc547c9d48a.zip |
script: Reduce the use of `unsafe` in LayoutDom (#31979)
Remove the use of unsafe code in the layout wrappers of the DOM. The
main change here is that `unsafe_get()` no longer needs to be an unsafe
method, which allows us to transitively remove or reduce unsafe blocks
from callers. The function itself is not renamed, because it's still
a bit dangerous to start removing the layers of abstraction from actual
DOM nodes.
In addition `init_style_and_opaque_layout_data` can be merged into
`initialize_data`, which removes one more unsafe method.
Finally, a "Safety" section is added to some unsafe methods.
Diffstat (limited to 'components/script/dom/htmlinputelement.rs')
-rwxr-xr-x | components/script/dom/htmlinputelement.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 5ebd9c2cdc0..44669e7f875 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -1000,7 +1000,7 @@ impl<'dom> LayoutDom<'dom, HTMLInputElement> { } fn input_type(self) -> InputType { - unsafe { self.unsafe_get().input_type.get() } + self.unsafe_get().input_type.get() } fn textinput_sorted_selection_offsets_range(self) -> Range<UTF8Bytes> { @@ -1054,9 +1054,8 @@ impl<'dom> LayoutHTMLInputElementHelpers<'dom> for LayoutDom<'dom, HTMLInputElem } } - #[allow(unsafe_code)] fn size_for_layout(self) -> u32 { - unsafe { self.unsafe_get().size.get() } + self.unsafe_get().size.get() } fn selection_for_layout(self) -> Option<Range<usize>> { |