зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1577171 - Remove duplicated logic from Stylo's Gecko wrapper. r=emilio
Stylo's Gecko wrapper duplicated some logic from the C++ side so that the Rust compiler would be able to optimize better. Now that we have xLTO, this kind of manual inlining should not be neccessary anymore. Differential Revision: https://phabricator.services.mozilla.com/D43765 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1cb6343d9b
Коммит
77f7095cb5
|
@ -153,6 +153,10 @@ const Element* Gecko_GetMarkerPseudo(const Element* aElement) {
|
|||
return nsLayoutUtils::GetMarkerPseudo(aElement);
|
||||
}
|
||||
|
||||
bool Gecko_IsInAnonymousSubtree(const Element* aElement) {
|
||||
return aElement->IsInAnonymousSubtree();
|
||||
}
|
||||
|
||||
nsTArray<nsIContent*>* Gecko_GetAnonymousContentForElement(
|
||||
const Element* aElement) {
|
||||
nsIAnonymousContentCreator* ac = do_QueryFrame(aElement->GetPrimaryFrame());
|
||||
|
|
|
@ -81,6 +81,8 @@ const mozilla::dom::Element* Gecko_GetBeforeOrAfterPseudo(
|
|||
const mozilla::dom::Element* Gecko_GetMarkerPseudo(
|
||||
const mozilla::dom::Element*);
|
||||
|
||||
bool Gecko_IsInAnonymousSubtree(const mozilla::dom::Element*);
|
||||
|
||||
nsTArray<nsIContent*>* Gecko_GetAnonymousContentForElement(
|
||||
const mozilla::dom::Element*);
|
||||
void Gecko_DestroyAnonymousContentList(nsTArray<nsIContent*>* anon_content);
|
||||
|
|
|
@ -706,44 +706,6 @@ impl<'le> GeckoElement<'le> {
|
|||
!self.xbl_binding_with_content().is_none()
|
||||
}
|
||||
|
||||
/// This duplicates the logic in Gecko's virtual nsINode::GetBindingParent
|
||||
/// function, which only has two implementations: one for XUL elements, and
|
||||
/// one for other elements.
|
||||
///
|
||||
/// We just hard code in our knowledge of those two implementations here.
|
||||
fn xbl_binding_parent(&self) -> Option<Self> {
|
||||
if self.is_xul_element() {
|
||||
// FIXME(heycam): Having trouble with bindgen on nsXULElement,
|
||||
// where the binding parent is stored in a member variable
|
||||
// rather than in slots. So just get it through FFI for now.
|
||||
unsafe {
|
||||
bindings::Gecko_GetBindingParent(self.0)
|
||||
.as_ref()
|
||||
.map(GeckoElement)
|
||||
}
|
||||
} else {
|
||||
let binding_parent =
|
||||
unsafe { self.non_xul_xbl_binding_parent().as_ref() }.map(GeckoElement);
|
||||
|
||||
debug_assert!(
|
||||
binding_parent ==
|
||||
unsafe {
|
||||
bindings::Gecko_GetBindingParent(self.0)
|
||||
.as_ref()
|
||||
.map(GeckoElement)
|
||||
}
|
||||
);
|
||||
binding_parent
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn non_xul_xbl_binding_parent(&self) -> *mut RawGeckoElement {
|
||||
debug_assert!(!self.is_xul_element());
|
||||
self.extended_slots()
|
||||
.map_or(ptr::null_mut(), |slots| slots._base.mBindingParent.mRawPtr)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn namespace_id(&self) -> i32 {
|
||||
self.as_node().node_info().mInner.mNamespaceID
|
||||
|
@ -865,19 +827,11 @@ impl<'le> GeckoElement<'le> {
|
|||
return self.flags() & (NODE_IS_NATIVE_ANONYMOUS_ROOT as u32) != 0;
|
||||
}
|
||||
|
||||
/// This logic is duplicated in Gecko's nsIContent::IsInAnonymousSubtree.
|
||||
#[inline]
|
||||
fn is_in_anonymous_subtree(&self) -> bool {
|
||||
if self.is_in_native_anonymous_subtree() {
|
||||
return true;
|
||||
unsafe {
|
||||
bindings::Gecko_IsInAnonymousSubtree(self.0)
|
||||
}
|
||||
|
||||
let binding_parent = match self.xbl_binding_parent() {
|
||||
Some(p) => p,
|
||||
None => return false,
|
||||
};
|
||||
|
||||
binding_parent.shadow_root().is_none()
|
||||
}
|
||||
|
||||
/// Returns true if this node is the shadow root of an use-element shadow tree.
|
||||
|
|
Загрузка…
Ссылка в новой задаче