aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/layout/context.rs7
-rw-r--r--components/layout/css/matching.rs4
-rw-r--r--components/layout/layout_task.rs13
3 files changed, 19 insertions, 5 deletions
diff --git a/components/layout/context.rs b/components/layout/context.rs
index 00d9f2139b1..7420a29fa9c 100644
--- a/components/layout/context.rs
+++ b/components/layout/context.rs
@@ -41,6 +41,10 @@ fn create_or_get_local_context(shared_layout_context: &SharedLayoutContext) -> *
style_sharing_candidate_cache: StyleSharingCandidateCache::new(),
};
r.set(unsafe { boxed::into_raw(context) });
+ } else if shared_layout_context.screen_size_changed {
+ unsafe {
+ (*r.get()).applicable_declarations_cache.evict_all();
+ }
}
r.get()
@@ -54,6 +58,9 @@ pub struct SharedLayoutContext {
/// The current screen size.
pub screen_size: Size2D<Au>,
+ /// Screen sized changed?
+ pub screen_size_changed: bool,
+
/// A channel up to the constellation.
pub constellation_chan: ConstellationChan,
diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs
index f688be2cda5..b474e55e120 100644
--- a/components/layout/css/matching.rs
+++ b/components/layout/css/matching.rs
@@ -153,6 +153,10 @@ impl ApplicableDeclarationsCache {
fn insert(&mut self, declarations: Vec<DeclarationBlock>, style: Arc<ComputedValues>) {
self.cache.insert(ApplicableDeclarationsCacheEntry::new(declarations), style)
}
+
+ pub fn evict_all(&mut self) {
+ self.cache.evict_all();
+ }
}
/// An LRU cache of the last few nodes seen, so that we can aggressively try to reuse their styles.
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs
index 793bc083723..970594c7fa2 100644
--- a/components/layout/layout_task.rs
+++ b/components/layout/layout_task.rs
@@ -311,12 +311,14 @@ impl LayoutTask {
// Create a layout context for use in building display lists, hit testing, &c.
fn build_shared_layout_context(&self,
rw_data: &LayoutTaskData,
+ screen_size_changed: bool,
reflow_root: &LayoutNode,
url: &Url)
-> SharedLayoutContext {
SharedLayoutContext {
image_cache: rw_data.local_image_cache.clone(),
screen_size: rw_data.screen_size.clone(),
+ screen_size_changed: screen_size_changed,
constellation_chan: rw_data.constellation_chan.clone(),
layout_chan: self.chan.clone(),
font_cache_task: self.font_cache_task.clone(),
@@ -774,11 +776,6 @@ impl LayoutTask {
Au::from_frac32_px(viewport_size.height.get()));
rw_data.screen_size = current_screen_size;
- // Create a layout context for use throughout the following passes.
- let mut shared_layout_context = self.build_shared_layout_context(&*rw_data,
- node,
- &data.url);
-
// Handle conditions where the entire flow tree is invalid.
let screen_size_changed = current_screen_size != old_screen_size;
@@ -803,6 +800,12 @@ impl LayoutTask {
|mut flow| LayoutTask::reflow_all_nodes(&mut *flow));
}
+ // Create a layout context for use throughout the following passes.
+ let mut shared_layout_context = self.build_shared_layout_context(&*rw_data,
+ screen_size_changed,
+ node,
+ &data.url);
+
let mut layout_root = profile(TimeProfilerCategory::LayoutStyleRecalc,
self.profiler_metadata(data),
self.time_profiler_chan.clone(),