From 040379208e5cc648cf7ebde30b2a42e70c15e602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 17 Dec 2017 14:44:53 +0100 Subject: [PATCH] style: Implement GeckoElement::assigned_slot. This allows to selector-match ::slotted, though we still don't parse it. Bug: 1425755 Reviewed-by: heycam MozReview-Commit-ID: ItELHkf2PMl --- components/style/gecko/wrapper.rs | 10 ++++++++++ .../style/invalidation/element/element_wrapper.rs | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 66b7f538dd6..ff0f9634afb 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1795,11 +1795,21 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { parent_node.and_then(|n| n.as_element()) } + #[inline] fn pseudo_element_originating_element(&self) -> Option { debug_assert!(self.implemented_pseudo_element().is_some()); self.closest_non_native_anonymous_ancestor() } + #[inline] + fn assigned_slot(&self) -> Option { + let slot = self.get_extended_slots()?._base.mAssignedSlot.mRawPtr; + + unsafe { + Some(GeckoElement(&slot.as_ref()?._base._base._base._base)) + } + } + #[inline] fn first_child_element(&self) -> Option { let mut child = self.as_node().first_child(); diff --git a/components/style/invalidation/element/element_wrapper.rs b/components/style/invalidation/element/element_wrapper.rs index 4ef5f5cad86..65f3ea89c19 100644 --- a/components/style/invalidation/element/element_wrapper.rs +++ b/components/style/invalidation/element/element_wrapper.rs @@ -351,6 +351,11 @@ impl<'a, E> Element for ElementWrapper<'a, E> .map(|e| ElementWrapper::new(e, self.snapshot_map)) } + fn assigned_slot(&self) -> Option { + self.element.assigned_slot() + .map(|e| ElementWrapper::new(e, self.snapshot_map)) + } + fn blocks_ancestor_combinators(&self) -> bool { self.element.blocks_ancestor_combinators() }