mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Bug 1364377: Fix inheritance of NAC, and selector-matching of pseudo-implementing NAC. r=bholley
MozReview-Commit-ID: DjSyaWHq1Xj Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
58253f545b
commit
2ffffcfdce
3 changed files with 59 additions and 8 deletions
|
@ -33,8 +33,10 @@ use stylist::ApplicableDeclarationBlock;
|
|||
|
||||
/// The way a style should be inherited.
|
||||
enum InheritMode {
|
||||
/// Inherit from the parent element, as normal CSS dictates.
|
||||
FromParentElement,
|
||||
/// Inherit from the parent element, as normal CSS dictates, _or_ from the
|
||||
/// closest non-Native Anonymous element in case this is Native Anonymous
|
||||
/// Content.
|
||||
Normal,
|
||||
/// Inherit from the primary style, this is used while computing eager
|
||||
/// pseudos, like ::before and ::after when we're traversing the parent.
|
||||
FromPrimaryStyle,
|
||||
|
@ -423,8 +425,8 @@ trait PrivateMatchMethods: TElement {
|
|||
let parent_el;
|
||||
let parent_data;
|
||||
let style_to_inherit_from = match inherit_mode {
|
||||
InheritMode::FromParentElement => {
|
||||
parent_el = self.parent_element();
|
||||
InheritMode::Normal => {
|
||||
parent_el = self.inheritance_parent();
|
||||
parent_data = parent_el.as_ref().and_then(|e| e.borrow_data());
|
||||
let parent_values = parent_data.as_ref().map(|d| {
|
||||
// Sometimes Gecko eagerly styles things without processing
|
||||
|
@ -500,7 +502,7 @@ trait PrivateMatchMethods: TElement {
|
|||
let inherit_mode = if eager_pseudo_style.is_some() {
|
||||
InheritMode::FromPrimaryStyle
|
||||
} else {
|
||||
InheritMode::FromParentElement
|
||||
InheritMode::Normal
|
||||
};
|
||||
|
||||
self.cascade_with_rules(context.shared,
|
||||
|
@ -623,7 +625,7 @@ trait PrivateMatchMethods: TElement {
|
|||
&context.thread_local.font_metrics_provider,
|
||||
&without_transition_rules,
|
||||
primary_style,
|
||||
InheritMode::FromParentElement))
|
||||
InheritMode::Normal))
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -1002,8 +1004,16 @@ pub trait MatchMethods : TElement {
|
|||
self.apply_selector_flags(map, element, flags);
|
||||
};
|
||||
|
||||
let selector_matching_target = match implemented_pseudo {
|
||||
Some(..) => {
|
||||
self.closest_non_native_anonymous_ancestor()
|
||||
.expect("Pseudo-element without non-NAC parent?")
|
||||
},
|
||||
None => *self,
|
||||
};
|
||||
|
||||
// Compute the primary rule node.
|
||||
*relations = stylist.push_applicable_declarations(self,
|
||||
*relations = stylist.push_applicable_declarations(&selector_matching_target,
|
||||
Some(bloom),
|
||||
style_attribute,
|
||||
smil_override,
|
||||
|
@ -1448,7 +1458,7 @@ pub trait MatchMethods : TElement {
|
|||
font_metrics_provider,
|
||||
&without_animation_rules,
|
||||
primary_style,
|
||||
InheritMode::FromParentElement)
|
||||
InheritMode::Normal)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue