diff options
author | Martin Robinson <mrobinson@igalia.com> | 2020-05-05 13:36:57 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2020-05-05 20:08:44 +0200 |
commit | 3a74013abcec241d67d2685e52a031409dc59dd4 (patch) | |
tree | 0fc6791d087797120dd960aa0fb1e0a9a6ebce92 /components/layout_thread/lib.rs | |
parent | b585ce5b1f181996b2f8109a4e045eb6f5b3e2a0 (diff) | |
download | servo-3a74013abcec241d67d2685e52a031409dc59dd4.tar.gz servo-3a74013abcec241d67d2685e52a031409dc59dd4.zip |
Start having animations conform to the HTML spec
This is a small step toward fixing #19242. The main idea is that the
clock for animations should advance as the event loop ticks. We
accomplish this by moving the clock from layout and naming it the
"animation timeline" which is the spec language. This should fix
flakiness with animations and transitions tests where a reflow could
move animations forward while script was running.
This change also starts to break out transition and animation events
into their own data structure, because it's quite likely that the next
step in fixing #19242 is to no longer send these events through a
channel.
Diffstat (limited to 'components/layout_thread/lib.rs')
-rw-r--r-- | components/layout_thread/lib.rs | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 38982fa826b..dfc3a2966df 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -87,7 +87,6 @@ use script_traits::{ScrollState, UntrustedNodeAddress, WindowSizeData}; use servo_arc::Arc as ServoArc; use servo_atoms::Atom; use servo_config::opts; -use servo_config::pref; use servo_url::{ImmutableOrigin, ServoUrl}; use std::borrow::ToOwned; use std::cell::{Cell, RefCell}; @@ -117,7 +116,6 @@ use style::stylesheets::{ }; use style::stylist::Stylist; use style::thread_state::{self, ThreadState}; -use style::timer::Timer; use style::traversal::DomTraversal; use style::traversal_flags::TraversalFlags; use style_traits::CSSPixel; @@ -220,10 +218,6 @@ pub struct LayoutThread { /// Webrender document. webrender_document: webrender_api::DocumentId, - /// The timer object to control the timing of the animations. This should - /// only be a test-mode timer during testing for animations. - timer: Timer, - /// Paint time metrics. paint_time_metrics: PaintTimeMetrics, @@ -583,11 +577,6 @@ impl LayoutThread { inner_window_dimensions_response: None, })), webrender_image_cache: Arc::new(RwLock::new(FnvHashMap::default())), - timer: if pref!(layout.animations.test.enabled) { - Timer::test_mode() - } else { - Timer::new() - }, paint_time_metrics: paint_time_metrics, layout_query_waiting_time: Histogram::new(), last_iframe_sizes: Default::default(), @@ -623,6 +612,7 @@ impl LayoutThread { guards: StylesheetGuards<'a>, snapshot_map: &'a SnapshotMap, origin: ImmutableOrigin, + animation_timeline_value: f64, ) -> LayoutContext<'a> { LayoutContext { id: self.id, @@ -634,7 +624,7 @@ impl LayoutThread { visited_styles_enabled: false, animation_states: self.animation_states.clone(), registered_speculative_painters: &self.registered_painters, - current_time_for_animations: self.timer.seconds(), + current_time_for_animations: animation_timeline_value, traversal_flags: TraversalFlags::empty(), snapshot_map: snapshot_map, }, @@ -1306,12 +1296,6 @@ impl LayoutThread { let device = Device::new(MediaType::screen(), initial_viewport, device_pixel_ratio); let sheet_origins_affected_by_device_change = self.stylist.set_device(device, &guards); - if pref!(layout.animations.test.enabled) { - if let Some(delta) = data.advance_clock_delta { - self.timer.increment(delta as f64 / 1000.0); - } - } - self.stylist .force_stylesheet_origins_dirty(sheet_origins_affected_by_device_change); self.viewport_size = @@ -1429,7 +1413,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(), &map, origin); + let mut layout_context = + self.build_layout_context(guards.clone(), &map, origin, data.animation_timeline_value); let pool; let (thread_pool, num_threads) = if self.parallel_flag { |