From 72a9fa3730ae64d4fbe8f78f082b0e6702d9b9be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 11 Jun 2019 17:42:49 +0000 Subject: [PATCH] Bug 1505489 - Implement GeckoElement::each_part. r=heycam This should make all the pieces come together. Note that we don't need to look at the snapshot for ::part() for now (other than when selector-matching normally) because I decided to just restyle the element for now when the part attribute changes. ::part() can't affect descendants anyway (as long as we don't do the forwarding stuff), and eager pseudo-elements are handled during the normal element restyle, so it seems to me that adding all the complexity that we have for classes to part may not be worth it at least yet. Depends on D32647 Differential Revision: https://phabricator.services.mozilla.com/D32648 --HG-- extra : moz-landing-system : lando --- servo/components/style/gecko/snapshot.rs | 2 +- servo/components/style/gecko/snapshot_helpers.rs | 4 ++-- servo/components/style/gecko/wrapper.rs | 14 +++++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/servo/components/style/gecko/snapshot.rs b/servo/components/style/gecko/snapshot.rs index d294939baeb8..cffb78d3e9e0 100644 --- a/servo/components/style/gecko/snapshot.rs +++ b/servo/components/style/gecko/snapshot.rs @@ -211,7 +211,7 @@ impl ElementSnapshot for GeckoElementSnapshot { return; } - snapshot_helpers::each_class(&self.mClass, callback) + snapshot_helpers::each_class_or_part(&self.mClass, callback) } #[inline] diff --git a/servo/components/style/gecko/snapshot_helpers.rs b/servo/components/style/gecko/snapshot_helpers.rs index aaa2254dbd76..b8b31bc87dd3 100644 --- a/servo/components/style/gecko/snapshot_helpers.rs +++ b/servo/components/style/gecko/snapshot_helpers.rs @@ -107,9 +107,9 @@ pub fn has_class_or_part( } /// Given an item, a callback, and a getter, execute `callback` for each class -/// this `item` has. +/// or part name this `item` has. #[inline(always)] -pub fn each_class(attr: &structs::nsAttrValue, mut callback: F) +pub fn each_class_or_part(attr: &structs::nsAttrValue, mut callback: F) where F: FnMut(&Atom), { diff --git a/servo/components/style/gecko/wrapper.rs b/servo/components/style/gecko/wrapper.rs index 17c1cfaf35db..ba2951f6f25b 100644 --- a/servo/components/style/gecko/wrapper.rs +++ b/servo/components/style/gecko/wrapper.rs @@ -1372,7 +1372,19 @@ impl<'le> TElement for GeckoElement<'le> { None => return, }; - snapshot_helpers::each_class(attr, callback) + snapshot_helpers::each_class_or_part(attr, callback) + } + + fn each_part(&self, callback: F) + where + F: FnMut(&Atom), + { + let attr = match self.get_part_attr() { + Some(c) => c, + None => return, + }; + + snapshot_helpers::each_class_or_part(attr, callback) } #[inline]