mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Bug 1364412: Simplify Servo_HasAuthorSpecifiedRules looking at the pseudo style. r=bholley
MozReview-Commit-ID: HpV92ttZGJz Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
84f5a90668
commit
737c7f1f63
2 changed files with 14 additions and 67 deletions
|
@ -1071,10 +1071,11 @@ impl StrongRuleNode {
|
|||
if !have_explicit_ua_inherit { break }
|
||||
|
||||
// Continue to the parent element and search for the inherited properties.
|
||||
element = match element.parent_element() {
|
||||
element = match element.inheritance_parent() {
|
||||
Some(parent) => parent,
|
||||
None => break
|
||||
};
|
||||
|
||||
let parent_data = element.mutate_data().unwrap();
|
||||
let parent_rule_node = parent_data.styles().primary.rules.clone();
|
||||
element_rule_node = Cow::Owned(parent_rule_node);
|
||||
|
|
|
@ -33,7 +33,6 @@ use style::gecko_bindings::bindings::{RawServoMediaList, RawServoMediaListBorrow
|
|||
use style::gecko_bindings::bindings::{RawServoMediaRule, RawServoMediaRuleBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoNamespaceRule, RawServoNamespaceRuleBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoPageRule, RawServoPageRuleBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoRuleNodeBorrowed, RawServoRuleNodeStrong};
|
||||
use style::gecko_bindings::bindings::{RawServoStyleSetBorrowed, RawServoStyleSetOwned};
|
||||
use style::gecko_bindings::bindings::{RawServoStyleSheetBorrowed, ServoComputedValuesBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedValuesStrong};
|
||||
|
@ -84,7 +83,7 @@ use style::properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
|
|||
use style::properties::animated_properties::{Animatable, AnimationValue, TransitionProperty};
|
||||
use style::properties::parse_one_declaration;
|
||||
use style::restyle_hints::{self, RestyleHint};
|
||||
use style::rule_tree::{StrongRuleNode, StyleSource};
|
||||
use style::rule_tree::StyleSource;
|
||||
use style::selector_parser::PseudoElementCascadeType;
|
||||
use style::sequential;
|
||||
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked};
|
||||
|
@ -990,42 +989,10 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
|||
.into_strong()
|
||||
}
|
||||
|
||||
// FIXME(emilio): Don't use pseudo_tag here, and pass the pseudo-element
|
||||
// directly.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ResolveRuleNode(element: RawGeckoElementBorrowed,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
raw_data: RawServoStyleSetBorrowed)
|
||||
-> RawServoRuleNodeStrong
|
||||
{
|
||||
let element = GeckoElement(element);
|
||||
let doc_data = PerDocumentStyleData::from_ffi(raw_data);
|
||||
let guard = (*GLOBAL_STYLE_DATA).shared_lock.read();
|
||||
|
||||
let data = element.mutate_data().unwrap();
|
||||
let styles = match data.get_styles() {
|
||||
Some(styles) => styles,
|
||||
None => {
|
||||
warn!("Calling Servo_ResolveRuleNode on unstyled element");
|
||||
return Strong::null()
|
||||
}
|
||||
};
|
||||
|
||||
let maybe_rules = if pseudo_tag.is_null() {
|
||||
Some(styles.primary.rules.clone())
|
||||
} else {
|
||||
get_pseudo_rule_node(&guard, element, pseudo_tag, styles, doc_data)
|
||||
};
|
||||
|
||||
match maybe_rules {
|
||||
Some(rule_node) => rule_node.into_strong(),
|
||||
None => Strong::null(),
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||
pseudo_tag: *mut nsIAtom, is_probe: bool,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
is_probe: bool,
|
||||
raw_data: RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong
|
||||
{
|
||||
|
@ -1055,44 +1022,23 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_HasAuthorSpecifiedRules(rule_node: RawServoRuleNodeBorrowed,
|
||||
element: RawGeckoElementBorrowed,
|
||||
pub extern "C" fn Servo_HasAuthorSpecifiedRules(element: RawGeckoElementBorrowed,
|
||||
rule_type_mask: u32,
|
||||
author_colors_allowed: bool)
|
||||
-> bool
|
||||
{
|
||||
let element = GeckoElement(element);
|
||||
|
||||
let data = element.borrow_data().unwrap();
|
||||
let primary_style = &data.styles().primary;
|
||||
|
||||
let guard = (*GLOBAL_STYLE_DATA).shared_lock.read();
|
||||
let guards = StylesheetGuards::same(&guard);
|
||||
|
||||
StrongRuleNode::from_ffi(&rule_node).has_author_specified_rules(element,
|
||||
&guards,
|
||||
rule_type_mask,
|
||||
author_colors_allowed)
|
||||
}
|
||||
|
||||
fn get_pseudo_rule_node(guard: &SharedRwLockReadGuard,
|
||||
element: GeckoElement,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
styles: &ElementStyles,
|
||||
doc_data: &PerDocumentStyleData)
|
||||
-> Option<StrongRuleNode>
|
||||
{
|
||||
let pseudo = PseudoElement::from_atom_unchecked(Atom::from(pseudo_tag), false);
|
||||
match pseudo.cascade_type() {
|
||||
PseudoElementCascadeType::Eager => styles.pseudos.get(&pseudo).map(|s| s.rules.clone()),
|
||||
PseudoElementCascadeType::Precomputed => unreachable!("No anonymous boxes"),
|
||||
PseudoElementCascadeType::Lazy => {
|
||||
let d = doc_data.borrow_mut();
|
||||
let guards = StylesheetGuards::same(guard);
|
||||
|
||||
// FIXME(emilio): We should get the pseudo state here!
|
||||
d.stylist.lazy_pseudo_rules(&guards,
|
||||
&element,
|
||||
&pseudo,
|
||||
ElementState::empty())
|
||||
},
|
||||
}
|
||||
primary_style.rules.has_author_specified_rules(element,
|
||||
&guards,
|
||||
rule_type_mask,
|
||||
author_colors_allowed)
|
||||
}
|
||||
|
||||
fn get_pseudo_style(guard: &SharedRwLockReadGuard,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue