mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Implement get_attr_for_layout that returns an AttrValue.
This commit is contained in:
parent
9951e0b4d6
commit
1b99fd7ecb
2 changed files with 16 additions and 0 deletions
|
@ -306,6 +306,7 @@ impl<'a> AttrHelpers<'a> for JSRef<'a, Attr> {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait AttrHelpersForLayout {
|
||||
unsafe fn value_forever(&self) -> &'static AttrValue;
|
||||
unsafe fn value_ref_forever(&self) -> &'static str;
|
||||
unsafe fn value_atom_forever(&self) -> Option<Atom>;
|
||||
unsafe fn value_tokens_forever(&self) -> Option<&'static [Atom]>;
|
||||
|
@ -314,6 +315,12 @@ pub trait AttrHelpersForLayout {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
impl AttrHelpersForLayout for Attr {
|
||||
#[inline]
|
||||
unsafe fn value_forever(&self) -> &'static AttrValue {
|
||||
// This transmute is used to cheat the lifetime restriction.
|
||||
mem::transmute::<&AttrValue, &AttrValue>(self.value.borrow_for_layout())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn value_ref_forever(&self) -> &'static str {
|
||||
// This transmute is used to cheat the lifetime restriction.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue