Auto merge of #17758 - emilio:extended-slots, r=heycam

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

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17758)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-17 14:25:51 -07:00 committed by GitHub
commit 3459748134
3 changed files with 2701 additions and 2265 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

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 {