aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/style/gecko/data.rs10
-rw-r--r--components/style/gecko/media_queries.rs9
-rw-r--r--ports/geckolib/glue.rs14
3 files changed, 20 insertions, 13 deletions
diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs
index 6a4b1f8c896..3ca07ff8ae1 100644
--- a/components/style/gecko/data.rs
+++ b/components/style/gecko/data.rs
@@ -9,7 +9,6 @@ use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use dom::TElement;
use fnv::FnvHashMap;
use gecko::rules::{CounterStyleRule, FontFaceRule};
-use gecko::wrapper::GeckoElement;
use gecko_bindings::bindings::RawServoStyleSet;
use gecko_bindings::structs::RawGeckoPresContextOwned;
use gecko_bindings::structs::nsIDocument;
@@ -70,15 +69,6 @@ impl PerDocumentStyleData {
}
impl PerDocumentStyleDataImpl {
- /// Reset the device state because it may have changed.
- ///
- /// Implies also a stylesheet flush.
- pub fn reset_device(&mut self, guard: &SharedRwLockReadGuard) {
- self.stylist.device_mut().reset();
- self.stylesheets.force_dirty();
- self.flush_stylesheets::<GeckoElement>(guard, None);
- }
-
/// Recreate the style data if the stylesheets have changed.
pub fn flush_stylesheets<E>(&mut self,
guard: &SharedRwLockReadGuard,
diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs
index 3cfdc7a798c..0b60a502df9 100644
--- a/components/style/gecko/media_queries.rs
+++ b/components/style/gecko/media_queries.rs
@@ -99,6 +99,13 @@ impl Device {
self.root_font_size.store(size.0 as isize, Ordering::Relaxed)
}
+ /// Recreates the default computed values.
+ pub fn reset_computed_values(&mut self) {
+ // NB: A following stylesheet flush will populate this if appropriate.
+ self.viewport_override = None;
+ self.default_values = ComputedValues::default_values(unsafe { &*self.pres_context });
+ }
+
/// Recreates all the temporary state that the `Device` stores.
///
/// This includes the viewport override from `@viewport` rules, and also the
@@ -106,7 +113,7 @@ impl Device {
pub fn reset(&mut self) {
// NB: A following stylesheet flush will populate this if appropriate.
self.viewport_override = None;
- self.default_values = ComputedValues::default_values(unsafe { &*self.pres_context });
+ self.reset_computed_values();
}
/// Returns the current media type of the device.
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index 9f76b35d92d..6383a2f3fba 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -758,7 +758,15 @@ pub extern "C" fn Servo_StyleSet_MediumFeaturesChanged(
// it's up to date.
//
// In case it isn't we would trigger a rebuild + restyle as needed too.
- let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
+ //
+ // We need to ensure the default computed values are up to date though,
+ // because those can influence the result of media query evaluation.
+ //
+ // FIXME(emilio, bug 1369984): do the computation conditionally, to do it
+ // less often.
+ let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
+
+ data.stylist.device_mut().reset_computed_values();
data.stylist.media_features_change_changed_style(
data.stylesheets.iter(),
&guard,
@@ -1428,7 +1436,9 @@ pub extern "C" fn Servo_StyleSet_RebuildData(raw_data: RawServoStyleSetBorrowed)
let guard = global_style_data.shared_lock.read();
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
- data.reset_device(&guard);
+ data.stylist.device_mut().reset();
+ data.stylesheets.force_dirty();
+ data.flush_stylesheets::<GeckoElement>(&guard, None);
}
#[no_mangle]