From 13c49606a497673d830c1a1cac33481574b1d173 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Tue, 28 Mar 2017 15:32:35 +0800 Subject: [PATCH] stylo: Add argument to Servo_ResolveStyle to allow stale styles to be returned. --- components/style/gecko_bindings/bindings.rs | 3 ++- ports/geckolib/glue.rs | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index dd5196defa6..cc79d32bcf4 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -1812,7 +1812,8 @@ extern "C" { } extern "C" { pub fn Servo_ResolveStyle(element: RawGeckoElementBorrowed, - set: RawServoStyleSetBorrowed) + set: RawServoStyleSetBorrowed, + allow_stale: bool) -> ServoComputedValuesStrong; } extern "C" { diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 3ac1fdb8690..6b9c7288481 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1473,15 +1473,22 @@ pub extern "C" fn Servo_TakeChangeHint(element: RawGeckoElementBorrowed) -> nsCh #[no_mangle] pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed, - raw_data: RawServoStyleSetBorrowed) + raw_data: RawServoStyleSetBorrowed, + allow_stale: bool) -> ServoComputedValuesStrong { let element = GeckoElement(element); debug!("Servo_ResolveStyle: {:?}", element); let data = unsafe { element.ensure_data() }.borrow_mut(); - if !data.has_current_styles() { - warn!("Resolving style on unstyled element with lazy computation forbidden."); + let valid_styles = if allow_stale { + data.has_styles() + } else { + data.has_current_styles() + }; + + if !valid_styles { + warn!("Resolving style on element without current styles with lazy computation forbidden."); let per_doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow(); return per_doc_data.default_computed_values().clone().into_strong(); }