Bug 1377993: Make node slots less memory hungry in common cases.

This commit is contained in:
Emilio Cobos Álvarez 2017-07-17 22:48:11 +02:00
parent 602ef8bce1
commit c606ec13e2
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -505,7 +505,7 @@ impl<'le> GeckoElement<'le> {
/// Returns true if this element has a shadow root. /// Returns true if this element has a shadow root.
fn has_shadow_root(&self) -> bool { fn has_shadow_root(&self) -> bool {
self.get_dom_slots().map_or(false, |slots| !slots.mShadowRoot.mRawPtr.is_null()) self.get_extended_slots().map_or(false, |slots| !slots.mShadowRoot.mRawPtr.is_null())
} }
/// Returns a reference to the DOM slots for this Element, if they exist. /// Returns a reference to the DOM slots for this Element, if they exist.
@ -514,6 +514,13 @@ impl<'le> GeckoElement<'le> {
unsafe { slots.as_ref() } unsafe { slots.as_ref() }
} }
/// Returns a reference to the extended DOM slots for this Element.
fn get_extended_slots(&self) -> Option<&structs::FragmentOrElement_nsExtendedDOMSlots> {
self.get_dom_slots().and_then(|s| {
unsafe { s.mExtendedSlots.mPtr.as_ref() }
})
}
#[inline] #[inline]
fn get_xbl_binding(&self) -> Option<GeckoXBLBinding> { fn get_xbl_binding(&self) -> Option<GeckoXBLBinding> {
if self.flags() & (structs::NODE_MAY_BE_IN_BINDING_MNGR as u32) == 0 { if self.flags() & (structs::NODE_MAY_BE_IN_BINDING_MNGR as u32) == 0 {
@ -556,10 +563,9 @@ impl<'le> GeckoElement<'le> {
fn get_non_xul_xbl_binding_parent_raw_content(&self) -> *mut nsIContent { fn get_non_xul_xbl_binding_parent_raw_content(&self) -> *mut nsIContent {
debug_assert!(!self.is_xul_element()); debug_assert!(!self.is_xul_element());
match self.get_dom_slots() { self.get_extended_slots().map_or(ptr::null_mut(), |slots| {
Some(slots) => unsafe { *slots.__bindgen_anon_1.mBindingParent.as_ref() }, slots.mBindingParent
None => ptr::null_mut(), })
}
} }
fn has_xbl_binding_parent(&self) -> bool { fn has_xbl_binding_parent(&self) -> bool {