mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Fix broken viewport percentage length units after a viewport resize.
When a viewport is resized, the computed values for a style containing viewport percentage length units become stale. However, there's no way for those styles to be invalidated after a resize. As a solution, this commit invalidates the computed values cache after a resize has occurred, which is probably over-kill. A better solution would probably be to track under what conditions computed values remain valid, and invalidate them as indicated.
This commit is contained in:
parent
09c36de8f1
commit
fafc357308
3 changed files with 19 additions and 5 deletions
|
@ -41,6 +41,10 @@ fn create_or_get_local_context(shared_layout_context: &SharedLayoutContext) -> *
|
||||||
style_sharing_candidate_cache: StyleSharingCandidateCache::new(),
|
style_sharing_candidate_cache: StyleSharingCandidateCache::new(),
|
||||||
};
|
};
|
||||||
r.set(unsafe { boxed::into_raw(context) });
|
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()
|
r.get()
|
||||||
|
@ -54,6 +58,9 @@ pub struct SharedLayoutContext {
|
||||||
/// The current screen size.
|
/// The current screen size.
|
||||||
pub screen_size: Size2D<Au>,
|
pub screen_size: Size2D<Au>,
|
||||||
|
|
||||||
|
/// Screen sized changed?
|
||||||
|
pub screen_size_changed: bool,
|
||||||
|
|
||||||
/// A channel up to the constellation.
|
/// A channel up to the constellation.
|
||||||
pub constellation_chan: ConstellationChan,
|
pub constellation_chan: ConstellationChan,
|
||||||
|
|
||||||
|
|
|
@ -153,6 +153,10 @@ impl ApplicableDeclarationsCache {
|
||||||
fn insert(&mut self, declarations: Vec<DeclarationBlock>, style: Arc<ComputedValues>) {
|
fn insert(&mut self, declarations: Vec<DeclarationBlock>, style: Arc<ComputedValues>) {
|
||||||
self.cache.insert(ApplicableDeclarationsCacheEntry::new(declarations), style)
|
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.
|
/// An LRU cache of the last few nodes seen, so that we can aggressively try to reuse their styles.
|
||||||
|
|
|
@ -311,12 +311,14 @@ impl LayoutTask {
|
||||||
// Create a layout context for use in building display lists, hit testing, &c.
|
// Create a layout context for use in building display lists, hit testing, &c.
|
||||||
fn build_shared_layout_context(&self,
|
fn build_shared_layout_context(&self,
|
||||||
rw_data: &LayoutTaskData,
|
rw_data: &LayoutTaskData,
|
||||||
|
screen_size_changed: bool,
|
||||||
reflow_root: &LayoutNode,
|
reflow_root: &LayoutNode,
|
||||||
url: &Url)
|
url: &Url)
|
||||||
-> SharedLayoutContext {
|
-> SharedLayoutContext {
|
||||||
SharedLayoutContext {
|
SharedLayoutContext {
|
||||||
image_cache: rw_data.local_image_cache.clone(),
|
image_cache: rw_data.local_image_cache.clone(),
|
||||||
screen_size: rw_data.screen_size.clone(),
|
screen_size: rw_data.screen_size.clone(),
|
||||||
|
screen_size_changed: screen_size_changed,
|
||||||
constellation_chan: rw_data.constellation_chan.clone(),
|
constellation_chan: rw_data.constellation_chan.clone(),
|
||||||
layout_chan: self.chan.clone(),
|
layout_chan: self.chan.clone(),
|
||||||
font_cache_task: self.font_cache_task.clone(),
|
font_cache_task: self.font_cache_task.clone(),
|
||||||
|
@ -774,11 +776,6 @@ impl LayoutTask {
|
||||||
Au::from_frac32_px(viewport_size.height.get()));
|
Au::from_frac32_px(viewport_size.height.get()));
|
||||||
rw_data.screen_size = current_screen_size;
|
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.
|
// Handle conditions where the entire flow tree is invalid.
|
||||||
let screen_size_changed = current_screen_size != old_screen_size;
|
let screen_size_changed = current_screen_size != old_screen_size;
|
||||||
|
|
||||||
|
@ -803,6 +800,12 @@ impl LayoutTask {
|
||||||
|mut flow| LayoutTask::reflow_all_nodes(&mut *flow));
|
|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,
|
let mut layout_root = profile(TimeProfilerCategory::LayoutStyleRecalc,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(data),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue