зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #5180 - Fix broken viewport percentage length units after a viewport resize (from luniv:viewport-length-cached-values-invalidation); r=SimonSapin
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. Source-Repo: https://github.com/servo/servo Source-Revision: a50807051b0ff9a46ce6f76189617534b8294276
This commit is contained in:
Родитель
afc3b1285b
Коммит
8a3700f42f
|
@ -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,
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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(),
|
||||
|
|
Загрузка…
Ссылка в новой задаче