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

@ -2857,7 +2857,8 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
pseudo_type: CSSPseudoElementType,
rule_inclusion: StyleRuleInclusion,
snapshots: *const ServoElementSnapshotTable,
raw_data: RawServoStyleSetBorrowed)
raw_data: RawServoStyleSetBorrowed,
ignore_existing_styles: bool)
-> ServoStyleContextStrong
{
debug_assert!(!snapshots.is_null());
@ -2888,8 +2889,9 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
// In the common case we already have the style. Check that before setting
// up all the computation machinery. (Don't use it when we're getting
// default styles, though.)
if rule_inclusion == RuleInclusion::All {
// default styles or in a bfcached document (as indicated by
// ignore_existing_styles), though.)
if rule_inclusion == RuleInclusion::All && !ignore_existing_styles {
let styles = element.mutate_data().and_then(|d| {
if d.has_styles() {
Some(finish(&d.styles))
@ -2914,7 +2916,7 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
thread_local: &mut tlc,
};
let styles = resolve_style(&mut context, element, rule_inclusion);
let styles = resolve_style(&mut context, element, rule_inclusion, ignore_existing_styles);
finish(&styles).into()
}