New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Take origin from current window instead of creating a new one in event of reflow #25777
Changes from 1 commit
File filter...
Jump to…
Take origin from window instead of creating a new one in case of reflow
Everytime a new LayoutContext was created, it created a new origin which caused endless stream of image loads to occur in case of reflow. The reason for this was that the existing image, although cached successfully, was not used because the entry in hashmap did not match because of different(new) origin. This is solved by storing the origin of a window in enum ScriptReflow and used in creating new LayoutContext in case of reflow.
- Loading branch information
Verified
| @@ -93,7 +93,7 @@ use servo_atoms::Atom; | ||
| use servo_config::opts; | ||
| use servo_config::pref; | ||
| use servo_geometry::MaxRect; | ||
| use servo_url::ServoUrl; | ||
| use servo_url::{ImmutableOrigin, ServoUrl}; | ||
| use std::borrow::ToOwned; | ||
| use std::cell::{Cell, RefCell}; | ||
| use std::collections::HashMap; | ||
| @@ -644,13 +644,18 @@ impl LayoutThread { | ||
| guards: StylesheetGuards<'a>, | ||
| script_initiated_layout: bool, | ||
| snapshot_map: &'a SnapshotMap, | ||
| origin: Option<ImmutableOrigin>, | ||
| ) -> LayoutContext<'a> { | ||
| let thread_local_style_context_creation_data = | ||
| ThreadLocalStyleContextCreationInfo::new(self.new_animations_sender.clone()); | ||
|
|
||
| LayoutContext { | ||
| id: self.id, | ||
| origin: self.url.origin(), | ||
| origin: if let Some(origin) = origin { | ||
| origin | ||
| } else { | ||
| self.url.origin() | ||
| }, | ||
| style_context: SharedStyleContext { | ||
| stylist: &self.stylist, | ||
| options: GLOBAL_STYLE_DATA.options.clone(), | ||
| @@ -1341,6 +1346,8 @@ impl LayoutThread { | ||
| Au::from_f32_px(initial_viewport.height), | ||
| ); | ||
|
|
||
| let origin = data.origin.clone(); | ||
|
|
||
| // Calculate the actual viewport as per DEVICE-ADAPT § 6 | ||
| // If the entire flow tree is invalid, then it will be reflowed anyhow. | ||
| let document_shared_lock = document.style_shared_lock(); | ||
| @@ -1482,7 +1489,8 @@ impl LayoutThread { | ||
| self.stylist.flush(&guards, Some(element), Some(&map)); | ||
|
|
||
| // Create a layout context for use throughout the following passes. | ||
| let mut layout_context = self.build_layout_context(guards.clone(), true, &map); | ||
| let mut layout_context = | ||
| self.build_layout_context(guards.clone(), true, &map, Some(origin)); | ||
|
|
||
| let pool; | ||
| let (thread_pool, num_threads) = if self.parallel_flag { | ||
| @@ -1738,7 +1746,7 @@ impl LayoutThread { | ||
| ua_or_user: &ua_or_user_guard, | ||
| }; | ||
| let snapshots = SnapshotMap::new(); | ||
| let mut layout_context = self.build_layout_context(guards, false, &snapshots); | ||
| let mut layout_context = self.build_layout_context(guards, false, &snapshots, None); | ||
kunalmohan
Author
Collaborator
|
||
|
|
||
| let invalid_nodes = { | ||
| // Perform an abbreviated style recalc that operates without access to the DOM. | ||
Here you might be able to receive the origin as part of the
LayoutControlMsg::TickAnimations.It is sent from
servo/components/constellation/constellation.rs
Line 3231 in a5b43b7
So there you have the
Pipelineavailable, so you could to change the below:servo/components/constellation/constellation.rs
Line 3233 in a5b43b7
into something like