diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-06-22 19:53:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-22 19:53:37 -0700 |
commit | 6342a4b455e7714d42b9f8379eec7eec6262abb6 (patch) | |
tree | 06dd3db753d95a4f83f6ebd3686aa2d956a8c803 | |
parent | daed0a51839112054036f220ba1a6f03a8325b9b (diff) | |
parent | 1795af5e57582325fb3e727d53607aa860915033 (diff) | |
download | servo-6342a4b455e7714d42b9f8379eec7eec6262abb6.tar.gz servo-6342a4b455e7714d42b9f8379eec7eec6262abb6.zip |
Auto merge of #17471 - aethanyc:fix-pseudo-element-matching-xbl, r=emilio
stylo: Fix pseudo element matching for rules in XBL stylesheets
This change was reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1372876
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17471)
<!-- Reviewable:end -->
-rw-r--r-- | components/style/dom.rs | 15 | ||||
-rw-r--r-- | components/style/gecko/wrapper.rs | 4 | ||||
-rw-r--r-- | components/style/stylist.rs | 24 |
3 files changed, 22 insertions, 21 deletions
diff --git a/components/style/dom.rs b/components/style/dom.rs index f4031c1d6f7..de736e291c6 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -602,6 +602,21 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone + None } + /// Returns the rule hash target given an element. + fn rule_hash_target(&self) -> Self { + let is_implemented_pseudo = + self.implemented_pseudo_element().is_some(); + + // NB: This causes use to rule has pseudo selectors based on the + // properties of the originating element (which is fine, given the + // find_first_from_right usage). + if is_implemented_pseudo { + self.closest_non_native_anonymous_ancestor().unwrap() + } else { + *self + } + } + /// Gets declarations from XBL bindings from the element. Only gecko element could have this. fn get_declarations_from_xbl_bindings<V>(&self, _pseudo_element: Option<&PseudoElement>, diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index b97a7fc1081..9f2169028ca 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1019,7 +1019,9 @@ impl<'le> TElement for GeckoElement<'le> { where V: Push<ApplicableDeclarationBlock> + VecLike<ApplicableDeclarationBlock> { // Walk the binding scope chain, starting with the binding attached to our content, up // till we run out of scopes or we get cut off. - let mut current = Some(*self); + + // If we are NAC, we want to get rules from our rule_hash_target. + let mut current = Some(self.rule_hash_target()); while let Some(element) = current { if let Some(binding) = element.get_xbl_binding() { diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 80a15c14081..2825e6c1088 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -957,22 +957,6 @@ impl Stylist { } } - /// Returns the rule hash target given an element. - fn rule_hash_target<E>(&self, element: E) -> E - where E: TElement - { - let is_implemented_pseudo = - element.implemented_pseudo_element().is_some(); - - // NB: This causes use to rule has pseudo selectors based on the - // properties of the originating element (which is fine, given the - // find_first_from_right usage). - if is_implemented_pseudo { - element.closest_non_native_anonymous_ancestor().unwrap() - } else { - element - } - } /// Returns the applicable CSS declarations for the given element by /// treating us as an XBL stylesheet-only stylist. @@ -991,7 +975,7 @@ impl Stylist { Some(map) => map, None => return, }; - let rule_hash_target = self.rule_hash_target(*element); + let rule_hash_target = element.rule_hash_target(); // nsXBLPrototypeResources::ComputeServoStyleSet() added XBL stylesheets under author // (doc) level. @@ -1037,7 +1021,7 @@ impl Stylist { Some(map) => map, None => return, }; - let rule_hash_target = self.rule_hash_target(*element); + let rule_hash_target = element.rule_hash_target(); debug!("Determining if style is shareable: pseudo: {}", pseudo_element.is_some()); @@ -1099,8 +1083,8 @@ impl Stylist { // Step 3b: XBL rules. let cut_off_inheritance = - rule_hash_target.get_declarations_from_xbl_bindings(pseudo_element, - applicable_declarations); + element.get_declarations_from_xbl_bindings(pseudo_element, + applicable_declarations); debug!("XBL: {:?}", context.relations); if rule_hash_target.matches_user_and_author_rules() && !only_default_rules { |