style: Allow styles to be computed ignoring existing element data.

This commit is contained in:
Cameron McCormack 2017-08-04 19:33:07 +10:00
parent 4f525f6fa0
commit bb44c0a6bc
6 changed files with 17 additions and 12 deletions

View file

@ -702,7 +702,7 @@ pub fn process_resolved_style_request<'a, N>(context: &LayoutContext,
thread_local: &mut tlc,
};
let styles = resolve_style(&mut context, element, RuleInclusion::All);
let styles = resolve_style(&mut context, element, RuleInclusion::All, false);
let style = styles.primary();
let longhand_id = match *property {
PropertyId::Longhand(id) => id,

View file

@ -2810,7 +2810,8 @@ extern "C" {
rule_inclusion: StyleRuleInclusion,
snapshots:
*const ServoElementSnapshotTable,
set: RawServoStyleSetBorrowed)
set: RawServoStyleSetBorrowed,
ignore_existing_styles: bool)
-> ServoStyleContextStrong;
}
extern "C" {

View file

@ -388,6 +388,7 @@ pub fn resolve_style<E>(
context: &mut StyleContext<E>,
element: E,
rule_inclusion: RuleInclusion,
ignore_existing_style: bool,
) -> ElementStyles
where
E: TElement,
@ -395,6 +396,7 @@ where
use style_resolver::StyleResolverForElement;
debug_assert!(rule_inclusion == RuleInclusion::DefaultOnly ||
ignore_existing_style ||
element.borrow_data().map_or(true, |d| !d.has_styles()),
"Why are we here?");
let mut ancestors_requiring_style_resolution = SmallVec::<[E; 16]>::new();
@ -405,7 +407,7 @@ where
let mut style = None;
let mut ancestor = element.traversal_parent();
while let Some(current) = ancestor {
if rule_inclusion == RuleInclusion::All {
if rule_inclusion == RuleInclusion::All && !ignore_existing_style {
if let Some(data) = current.borrow_data() {
if let Some(ancestor_style) = data.styles.get_primary() {
style = Some(ancestor_style.clone());