Bug 1466406: Work around a bindgen bug on Android. r?xidorn
MozReview-Commit-ID: 2lltjH7IoZu
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -62,16 +62,17 @@
#include "mozilla/SystemGroup.h"
#include "mozilla/ServoTraversalStatistics.h"
#include "mozilla/Telemetry.h"
#include "mozilla/RWLock.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ElementInlines.h"
#include "mozilla/dom/HTMLTableCellElement.h"
#include "mozilla/dom/HTMLBodyElement.h"
+#include "mozilla/dom/HTMLSlotElement.h"
#include "mozilla/dom/MediaList.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/URLExtraData.h"
#include "mozilla/dom/CSSMozDocumentRule.h"
#if defined(MOZ_MEMORY)
# include "mozmemory.h"
#endif
@@ -177,16 +178,23 @@ Gecko_GetAnonymousContentForElement(RawG
void
Gecko_DestroyAnonymousContentList(nsTArray<nsIContent*>* aAnonContent)
{
MOZ_ASSERT(aAnonContent);
delete aAnonContent;
}
+const nsTArray<RefPtr<nsINode>>*
+Gecko_GetAssignedNodes(RawGeckoElementBorrowed aElement)
+{
+ MOZ_ASSERT(HTMLSlotElement::FromNode(aElement));
+ return &static_cast<const HTMLSlotElement*>(aElement)->AssignedNodes();
+}
+
void
Gecko_ComputedStyle_Init(
mozilla::ComputedStyle* aStyle,
const mozilla::ComputedStyle* aParentContext,
RawGeckoPresContextBorrowed aPresContext,
const ServoComputedData* aValues,
mozilla::CSSPseudoElementType aPseudoType,
nsAtom* aPseudoTag)
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -139,16 +139,17 @@ struct MediumFeaturesChangedResult {
bool mUsesViewportUnits;
};
bool Gecko_IsSignificantChild(RawGeckoNodeBorrowed node, bool whitespace_is_significant);
RawGeckoNodeBorrowedOrNull Gecko_GetLastChild(RawGeckoNodeBorrowed node);
RawGeckoNodeBorrowedOrNull Gecko_GetFlattenedTreeParentNode(RawGeckoNodeBorrowed node);
RawGeckoElementBorrowedOrNull Gecko_GetBeforeOrAfterPseudo(RawGeckoElementBorrowed element, bool is_before);
nsTArray<nsIContent*>* Gecko_GetAnonymousContentForElement(RawGeckoElementBorrowed element);
+const nsTArray<RefPtr<nsINode>>* Gecko_GetAssignedNodes(RawGeckoElementBorrowed element);
void Gecko_DestroyAnonymousContentList(nsTArray<nsIContent*>* anon_content);
void Gecko_ComputedStyle_Init(mozilla::ComputedStyle* context,
ComputedStyleBorrowedOrNull parent_context,
RawGeckoPresContextBorrowed pres_context, ServoComputedDataBorrowed values,
mozilla::CSSPseudoElementType pseudo_type, nsAtom* pseudo_tag);
void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle* context);
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -464,16 +464,17 @@ structs-types = [
"mozilla::FontStretch",
"mozilla::FontSlantStyle",
"mozilla::FontWeight",
"mozilla::MallocSizeOf",
"mozilla::OriginFlags",
"mozilla::UniquePtr",
"ServoRawOffsetArc",
"nsIContent",
+ "nsINode",
"nsIDocument",
"nsIDocument_DocumentTheme",
"nsSimpleContentList",
"MediumFeaturesChangedResult",
"RawGeckoAnimationPropertySegment",
"RawGeckoComputedTiming",
"RawGeckoCSSPropertyIDList",
"RawGeckoDocument",
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -1108,17 +1108,27 @@ impl<'le> TElement for GeckoElement<'le>
let slot: &structs::HTMLSlotElement = unsafe { mem::transmute(self.0) };
if cfg!(debug_assertions) {
let base: &RawGeckoElement = &slot._base._base._base._base;
assert_eq!(base as *const _, self.0 as *const _, "Bad cast");
}
- let assigned_nodes: &[structs::RefPtr<structs::nsINode>] = &*slot.mAssignedNodes;
+ let assigned_nodes: &[structs::RefPtr<structs::nsINode>] =
+ if !cfg!(target_os = "android") {
+ debug_assert_eq!(
+ unsafe { bindings::Gecko_GetAssignedNodes(self.0) },
+ &slot.mAssignedNodes as *const _,
+ );
+
+ &*slot.mAssignedNodes
+ } else {
+ unsafe { &**bindings::Gecko_GetAssignedNodes(self.0) }
+ };
debug_assert_eq!(
mem::size_of::<structs::RefPtr<structs::nsINode>>(),
mem::size_of::<Self::ConcreteNode>(),
"Bad cast!"
);
unsafe { mem::transmute(assigned_nodes) }