mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Make AttrHelpersForLayout methods be safe
The unsafety isn't there, it's in the creation of the LayoutDom<T> values.
This commit is contained in:
parent
f9e7c6b9dc
commit
4c16729a01
1 changed files with 10 additions and 10 deletions
|
@ -234,26 +234,26 @@ impl Attr {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub trait AttrHelpersForLayout<'dom> {
|
pub trait AttrHelpersForLayout<'dom> {
|
||||||
unsafe fn value(self) -> &'dom AttrValue;
|
fn value(self) -> &'dom AttrValue;
|
||||||
unsafe fn value_ref_forever(self) -> &'dom str;
|
fn value_ref_forever(self) -> &'dom str;
|
||||||
unsafe fn value_tokens(self) -> Option<&'dom [Atom]>;
|
fn value_tokens(self) -> Option<&'dom [Atom]>;
|
||||||
unsafe fn local_name_atom(self) -> LocalName;
|
fn local_name_atom(self) -> LocalName;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
impl<'dom> AttrHelpersForLayout<'dom> for LayoutDom<'dom, Attr> {
|
impl<'dom> AttrHelpersForLayout<'dom> for LayoutDom<'dom, Attr> {
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn value(self) -> &'dom AttrValue {
|
fn value(self) -> &'dom AttrValue {
|
||||||
(*self.unsafe_get()).value.borrow_for_layout()
|
unsafe { self.unsafe_get().value.borrow_for_layout() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn value_ref_forever(self) -> &'dom str {
|
fn value_ref_forever(self) -> &'dom str {
|
||||||
&**self.value()
|
&**self.value()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn value_tokens(self) -> Option<&'dom [Atom]> {
|
fn value_tokens(self) -> Option<&'dom [Atom]> {
|
||||||
// This transmute is used to cheat the lifetime restriction.
|
// This transmute is used to cheat the lifetime restriction.
|
||||||
match *self.value() {
|
match *self.value() {
|
||||||
AttrValue::TokenList(_, ref tokens) => Some(tokens),
|
AttrValue::TokenList(_, ref tokens) => Some(tokens),
|
||||||
|
@ -262,7 +262,7 @@ impl<'dom> AttrHelpersForLayout<'dom> for LayoutDom<'dom, Attr> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn local_name_atom(self) -> LocalName {
|
fn local_name_atom(self) -> LocalName {
|
||||||
(*self.unsafe_get()).identifier.local_name.clone()
|
unsafe { self.unsafe_get().identifier.local_name.clone() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue