diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index 070e2698e94..babefa95ebb 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -42,7 +42,6 @@ pub struct Device { /// here is fine. pres_context: RawGeckoPresContextOwned, default_values: Arc, - viewport_override: Option, /// The font size of the root element /// This is set when computing the style of the root /// element, and used for rem units in other elements. @@ -70,7 +69,6 @@ impl Device { Device { pres_context: pres_context, default_values: ComputedValues::default_values(unsafe { &*pres_context }), - viewport_override: None, root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious? used_root_font_size: AtomicBool::new(false), used_viewport_size: AtomicBool::new(false), @@ -79,9 +77,11 @@ impl Device { /// Tells the device that a new viewport rule has been found, and stores the /// relevant viewport constraints. - pub fn account_for_viewport_rule(&mut self, - constraints: &ViewportConstraints) { - self.viewport_override = Some(constraints.clone()); + pub fn account_for_viewport_rule( + &mut self, + _constraints: &ViewportConstraints + ) { + unreachable!("Gecko doesn't support @viewport"); } /// Returns the default computed values as a reference, in order to match @@ -113,9 +113,12 @@ impl Device { /// 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(self.pres_context()); + } + + /// Rebuild all the cached data. + pub fn rebuild_cached_data(&mut self) { + self.reset_computed_values(); self.used_root_font_size.store(false, Ordering::Relaxed); self.used_viewport_size.store(false, Ordering::Relaxed); } @@ -130,8 +133,6 @@ impl Device { /// This includes the viewport override from `@viewport` rules, and also the /// default computed values. pub fn reset(&mut self) { - // NB: A following stylesheet flush will populate this if appropriate. - self.viewport_override = None; self.reset_computed_values(); } @@ -153,14 +154,11 @@ impl Device { /// Returns the current viewport size in app units. pub fn au_viewport_size(&self) -> Size2D { self.used_viewport_size.store(true, Ordering::Relaxed); - self.viewport_override.as_ref().map(|v| { - Size2D::new(Au::from_f32_px(v.size.width), - Au::from_f32_px(v.size.height)) - }).unwrap_or_else(|| unsafe { + unsafe { // TODO(emilio): Need to take into account scrollbars. let area = &self.pres_context().mVisibleArea; Size2D::new(Au(area.width), Au(area.height)) - }) + } } /// Returns whether we ever looked up the viewport size of the Device. diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 724b00eb939..367d24ff87b 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -850,8 +850,8 @@ pub extern "C" fn Servo_StyleSet_AppendStyleSheet( #[no_mangle] pub extern "C" fn Servo_StyleSet_MediumFeaturesChanged( raw_data: RawServoStyleSetBorrowed, - viewport_changed: bool, -) -> nsRestyleHint { + viewport_units_used: *mut bool, +) -> bool { let global_style_data = &*GLOBAL_STYLE_DATA; let guard = global_style_data.shared_lock.read(); @@ -867,19 +867,16 @@ pub extern "C" fn Servo_StyleSet_MediumFeaturesChanged( // less often. let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); - let viewport_units_used = data.stylist.device().used_viewport_size(); + unsafe { + *viewport_units_used = data.stylist.device().used_viewport_size(); + } data.stylist.device_mut().reset_computed_values(); let rules_changed = data.stylist.media_features_change_changed_style( data.stylesheets.iter(), &guard, ); - if rules_changed { - structs::nsRestyleHint_eRestyle_Subtree - } else if viewport_changed && viewport_units_used { - structs::nsRestyleHint_eRestyle_ForceDescendants - } else { - nsRestyleHint(0) - } + + rules_changed } #[no_mangle] @@ -1852,14 +1849,9 @@ pub extern "C" fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextOwned) } #[no_mangle] -pub extern "C" fn Servo_StyleSet_RebuildData(raw_data: RawServoStyleSetBorrowed) { - let global_style_data = &*GLOBAL_STYLE_DATA; - let guard = global_style_data.shared_lock.read(); - +pub extern "C" fn Servo_StyleSet_RebuildCachedData(raw_data: RawServoStyleSetBorrowed) { let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); - data.stylist.device_mut().reset(); - data.stylesheets.force_dirty(); - data.flush_stylesheets::(&guard, None); + data.stylist.device_mut().rebuild_cached_data(); } #[no_mangle]