servo: Merge #17471 - stylo: Fix pseudo element matching for rules in XBL stylesheets (from 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

Source-Repo: https://github.com/servo/servo
Source-Revision: 6342a4b455e7714d42b9f8379eec7eec6262abb6

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 4de3e9b28adcb16412f6804bdc02a9a632d93132
This commit is contained in:
Ting-Yu Lin 2017-06-22 19:53:37 -07:00
Родитель ee15089976
Коммит 3b03bef29f
3 изменённых файлов: 22 добавлений и 21 удалений

Просмотреть файл

@ -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>,

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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 {