aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/gecko
diff options
context:
space:
mode:
Diffstat (limited to 'components/style/gecko')
-rw-r--r--components/style/gecko/snapshot.rs10
-rw-r--r--components/style/gecko/snapshot_helpers.rs20
-rw-r--r--components/style/gecko/wrapper.rs28
3 files changed, 40 insertions, 18 deletions
diff --git a/components/style/gecko/snapshot.rs b/components/style/gecko/snapshot.rs
index cffb78d3e9e..02707682b4d 100644
--- a/components/style/gecko/snapshot.rs
+++ b/components/style/gecko/snapshot.rs
@@ -194,6 +194,16 @@ impl ElementSnapshot for GeckoElementSnapshot {
}
#[inline]
+ fn exported_part(&self, name: &Atom) -> Option<Atom> {
+ snapshot_helpers::exported_part(&*self.mAttrs, name)
+ }
+
+ #[inline]
+ fn imported_part(&self, name: &Atom) -> Option<Atom> {
+ snapshot_helpers::imported_part(&*self.mAttrs, name)
+ }
+
+ #[inline]
fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {
if !self.has_any(Flags::MaybeClass) {
return false;
diff --git a/components/style/gecko/snapshot_helpers.rs b/components/style/gecko/snapshot_helpers.rs
index b8b31bc87dd..24b3ebb1991 100644
--- a/components/style/gecko/snapshot_helpers.rs
+++ b/components/style/gecko/snapshot_helpers.rs
@@ -82,6 +82,26 @@ pub fn get_id(attrs: &[structs::AttrArray_InternalAttr]) -> Option<&WeakAtom> {
Some(unsafe { get_id_from_attr(find_attr(attrs, &atom!("id"))?) })
}
+#[inline(always)]
+pub(super) fn exported_part(attrs: &[structs::AttrArray_InternalAttr], name: &Atom) -> Option<Atom> {
+ let attr = find_attr(attrs, &atom!("exportparts"))?;
+ let atom = unsafe { bindings::Gecko_Element_ExportedPart(attr, name.as_ptr()) };
+ if atom.is_null() {
+ return None;
+ }
+ Some(unsafe { Atom::from_raw(atom) })
+}
+
+#[inline(always)]
+pub(super) fn imported_part(attrs: &[structs::AttrArray_InternalAttr], name: &Atom) -> Option<Atom> {
+ let attr = find_attr(attrs, &atom!("exportparts"))?;
+ let atom = unsafe { bindings::Gecko_Element_ImportedPart(attr, name.as_ptr()) };
+ if atom.is_null() {
+ return None;
+ }
+ Some(unsafe { Atom::from_raw(atom) })
+}
+
/// Given a class or part name, a case sensitivity, and an array of attributes,
/// returns whether the attribute has that name.
#[inline(always)]
diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs
index 2d1236ce698..ac47927744b 100644
--- a/components/style/gecko/wrapper.rs
+++ b/components/style/gecko/wrapper.rs
@@ -1244,8 +1244,12 @@ impl<'le> TElement for GeckoElement<'le> {
#[inline]
fn has_part_attr(&self) -> bool {
- self.as_node()
- .get_bool_flag(nsINode_BooleanFlag::ElementHasPart)
+ self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementHasPart)
+ }
+
+ #[inline]
+ fn exports_any_part(&self) -> bool {
+ snapshot_helpers::find_attr(self.attrs(), &atom!("exportparts")).is_some()
}
// FIXME(emilio): we should probably just return a reference to the Atom.
@@ -2217,25 +2221,13 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
}
#[inline]
- fn imported_part(&self, name: &Atom) -> Option<Atom> {
- let imported = unsafe {
- bindings::Gecko_Element_ImportedPart(self.0, name.as_ptr())
- };
- if imported.is_null() {
- return None;
- }
- Some(unsafe { Atom::from_raw(imported) })
+ fn exported_part(&self, name: &Atom) -> Option<Atom> {
+ snapshot_helpers::exported_part(self.attrs(), name)
}
#[inline]
- fn exported_part(&self, name: &Atom) -> Option<Atom> {
- let exported = unsafe {
- bindings::Gecko_Element_ExportedPart(self.0, name.as_ptr())
- };
- if exported.is_null() {
- return None;
- }
- Some(unsafe { Atom::from_raw(exported) })
+ fn imported_part(&self, name: &Atom) -> Option<Atom> {
+ snapshot_helpers::imported_part(self.attrs(), name)
}
#[inline(always)]