diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-07-20 13:38:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-20 13:38:31 -0500 |
commit | 14aeccc33ab44d706df86fbce67339218efe710c (patch) | |
tree | 623b24534550a56755d440d48f5a89cff6171ded | |
parent | 46db988b906fbec0286fa07387bb34e76a5b3a94 (diff) | |
parent | 0b67b218d0c8dc48a5301227802296aff98af6d7 (diff) | |
download | servo-14aeccc33ab44d706df86fbce67339218efe710c.tar.gz servo-14aeccc33ab44d706df86fbce67339218efe710c.zip |
Auto merge of #12392 - emilio:test-animations, r=SimonSapin
style: Add support to test animations programatically.
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #12120
<!-- Either: -->
- [x] There are tests for these changes OR
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
r? @SimonSapin for the style changes, @Ms2ger or @jdm for the dom and test changes
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12392)
<!-- Reviewable:end -->
-rw-r--r-- | components/layout/Cargo.toml | 1 | ||||
-rw-r--r-- | components/layout/animation.rs | 9 | ||||
-rw-r--r-- | components/layout/lib.rs | 1 | ||||
-rw-r--r-- | components/layout_thread/lib.rs | 42 | ||||
-rw-r--r-- | components/script/dom/testbinding.rs | 4 | ||||
-rw-r--r-- | components/script/dom/webidls/TestBinding.webidl | 2 | ||||
-rw-r--r-- | components/script/dom/window.rs | 6 | ||||
-rw-r--r-- | components/script/script_thread.rs | 16 | ||||
-rw-r--r-- | components/script_layout_interface/message.rs | 5 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 32 | ||||
-rw-r--r-- | components/servo/Cargo.lock | 1 | ||||
-rw-r--r-- | components/style/animation.rs | 21 | ||||
-rw-r--r-- | components/style/context.rs | 5 | ||||
-rw-r--r-- | components/style/lib.rs | 1 | ||||
-rw-r--r-- | components/style/matching.rs | 3 | ||||
-rw-r--r-- | components/style/timer.rs | 58 | ||||
-rw-r--r-- | ports/cef/Cargo.lock | 1 | ||||
-rw-r--r-- | ports/geckolib/glue.rs | 2 | ||||
-rw-r--r-- | resources/prefs.json | 1 | ||||
-rw-r--r-- | tests/wpt/mozilla/meta/MANIFEST.json | 6 | ||||
-rw-r--r-- | tests/wpt/mozilla/meta/css/animations/__dir__.ini | 2 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/css/animations/basic-linear-width.html | 33 |
22 files changed, 216 insertions, 36 deletions
diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index 3add6b14976..9c83648128a 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -38,7 +38,6 @@ smallvec = "0.1" string_cache = {version = "0.2.20", features = ["heap_size"]} style = {path = "../style"} style_traits = {path = "../style_traits"} -time = "0.1" unicode-bidi = "0.2" unicode-script = {version = "0.1", features = ["harfbuzz"]} url = {version = "1.0.0", features = ["heap_size"]} diff --git a/components/layout/animation.rs b/components/layout/animation.rs index 4087479ed47..5a67b1af5bf 100644 --- a/components/layout/animation.rs +++ b/components/layout/animation.rs @@ -14,7 +14,7 @@ use script_traits::{AnimationState, LayoutMsg as ConstellationMsg}; use std::collections::HashMap; use std::sync::mpsc::Receiver; use style::animation::{Animation, update_style_for_animation}; -use time; +use style::timer::Timer; /// Processes any new animations that were discovered after style recalculation. /// Also expire any old animations that have completed, inserting them into @@ -23,7 +23,8 @@ pub fn update_animation_state(constellation_chan: &IpcSender<ConstellationMsg>, running_animations: &mut HashMap<OpaqueNode, Vec<Animation>>, expired_animations: &mut HashMap<OpaqueNode, Vec<Animation>>, new_animations_receiver: &Receiver<Animation>, - pipeline_id: PipelineId) { + pipeline_id: PipelineId, + timer: &Timer) { let mut new_running_animations = vec![]; while let Ok(animation) = new_animations_receiver.try_recv() { let mut should_push = true; @@ -37,7 +38,7 @@ pub fn update_animation_state(constellation_chan: &IpcSender<ConstellationMsg>, if let Animation::Keyframes(_, ref anim_name, ref mut anim_state) = *anim { if *name == *anim_name { debug!("update_animation_state: Found other animation {}", name); - anim_state.update_from_other(&state); + anim_state.update_from_other(&state, timer); should_push = false; break; } @@ -57,7 +58,7 @@ pub fn update_animation_state(constellation_chan: &IpcSender<ConstellationMsg>, return } - let now = time::precise_time_s(); + let now = timer.seconds(); // Expire old running animations. // // TODO: Do not expunge Keyframes animations, since we need that state if diff --git a/components/layout/lib.rs b/components/layout/lib.rs index f05b21c3628..b6f10c7fa89 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -50,7 +50,6 @@ extern crate smallvec; #[macro_use(atom, ns)] extern crate string_cache; extern crate style; extern crate style_traits; -extern crate time; extern crate unicode_bidi; extern crate unicode_script; extern crate url; diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 7fc12535ff7..592a6cda6a4 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -110,11 +110,13 @@ use style::refcell::RefCell; use style::selector_matching::Stylist; use style::servo_selector_impl::USER_OR_USER_AGENT_STYLESHEETS; use style::stylesheets::{Stylesheet, CSSRuleIteratorExt}; +use style::timer::Timer; use style::workqueue::WorkQueue; use url::Url; use util::geometry::MAX_RECT; use util::ipc::OptionalIpcSender; use util::opts; +use util::prefs::PREFS; use util::thread; use util::thread_state; @@ -226,6 +228,10 @@ pub struct LayoutThread { // Webrender interface, if enabled. webrender_api: Option<webrender_traits::RenderApi>, + + /// The timer object to control the timing of the animations. This should + /// only be a test-mode timer during testing for animations. + timer: Timer, } impl LayoutThreadFactory for LayoutThread { @@ -459,13 +465,20 @@ impl LayoutThread { offset_parent_response: OffsetParentResponse::empty(), margin_style_response: MarginStyleResponse::empty(), stacking_context_scroll_offsets: HashMap::new(), - })), - error_reporter: CSSErrorReporter { - pipelineid: id, - script_chan: Arc::new(Mutex::new(script_chan)), - }, - webrender_image_cache: - Arc::new(RwLock::new(HashMap::with_hasher(Default::default()))), + })), + error_reporter: CSSErrorReporter { + pipelineid: id, + script_chan: Arc::new(Mutex::new(script_chan)), + }, + webrender_image_cache: + Arc::new(RwLock::new(HashMap::with_hasher(Default::default()))), + timer: + if PREFS.get("layout.animations.test.enabled") + .as_boolean().unwrap_or(false) { + Timer::test_mode() + } else { + Timer::new() + }, } } @@ -501,6 +514,7 @@ impl LayoutThread { expired_animations: self.expired_animations.clone(), error_reporter: self.error_reporter.clone(), local_context_creation_data: Mutex::new(local_style_context_creation_data), + timer: self.timer.clone(), }, image_cache_thread: self.image_cache_thread.clone(), image_cache_sender: Mutex::new(self.image_cache_sender.clone()), @@ -653,6 +667,9 @@ impl LayoutThread { let _rw_data = possibly_locked_rw_data.lock(); sender.send(self.epoch).unwrap(); }, + Msg::AdvanceClockMs(how_many) => { + self.handle_advance_clock_ms(how_many, possibly_locked_rw_data); + } Msg::GetWebFontLoadState(sender) => { let _rw_data = possibly_locked_rw_data.lock(); let outstanding_web_fonts = self.outstanding_web_fonts.load(Ordering::SeqCst); @@ -795,6 +812,14 @@ impl LayoutThread { possibly_locked_rw_data.block(rw_data); } + /// Advances the animation clock of the document. + fn handle_advance_clock_ms<'a, 'b>(&mut self, + how_many_ms: i32, + possibly_locked_rw_data: &mut RwData<'a, 'b>) { + self.timer.increment(how_many_ms as f64 / 1000.0); + self.tick_all_animations(possibly_locked_rw_data); + } + /// Sets quirks mode for the document, causing the quirks mode stylesheet to be used. fn handle_set_quirks_mode<'a, 'b>(&self, possibly_locked_rw_data: &mut RwData<'a, 'b>) { let mut rw_data = possibly_locked_rw_data.lock(); @@ -1350,7 +1375,8 @@ impl LayoutThread { &mut *self.running_animations.write().unwrap(), &mut *self.expired_animations.write().unwrap(), &self.new_animations_receiver, - self.id); + self.id, + &self.timer); profile(time::ProfilerCategory::LayoutRestyleDamagePropagation, self.profiler_metadata(), diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 64fb6fb7578..8ee6dfe8025 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -581,6 +581,10 @@ impl TestBindingMethods for TestBinding { } } + fn AdvanceClock(&self, ms: i32) { + self.global().r().as_window().advance_animation_clock(ms); + } + fn Panic(&self) { panic!("explicit panic from script") } } diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl index 355141a4d92..48e647ee7bc 100644 --- a/components/script/dom/webidls/TestBinding.webidl +++ b/components/script/dom/webidls/TestBinding.webidl @@ -424,6 +424,8 @@ interface TestBinding { static void prefControlledStaticMethodDisabled(); [Pref="dom.testbinding.prefcontrolled.enabled"] const unsigned short prefControlledConstDisabled = 0; + [Pref="layout.animations.test.enabled"] + void advanceClock(long millis); [Pref="dom.testbinding.prefcontrolled2.enabled"] readonly attribute boolean prefControlledAttributeEnabled; diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 4878f33f994..07509a92e4a 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -1030,6 +1030,12 @@ impl Window { recv.recv().unwrap_or((Size2D::zero(), Point2D::zero())) } + /// Advances the layout animation clock by `delta` milliseconds, and then + /// forces a reflow. + pub fn advance_animation_clock(&self, delta: i32) { + self.layout_chan.send(Msg::AdvanceClockMs(delta)).unwrap(); + } + /// Reflows the page unconditionally if possible and not suppressed. This /// method will wait for the layout thread to complete (but see the `TODO` /// below). If there is no window size yet, the page is presumed invisible diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index ec2401d6f61..1a32477b999 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -886,22 +886,12 @@ impl ScriptThread { fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) { match msg { - ConstellationControlMsg::AttachLayout(_) => - panic!("should have handled AttachLayout already"), ConstellationControlMsg::Navigate(pipeline_id, subpage_id, load_data) => self.handle_navigate(pipeline_id, Some(subpage_id), load_data), ConstellationControlMsg::SendEvent(id, event) => self.handle_event(id, event), ConstellationControlMsg::ResizeInactive(id, new_size) => self.handle_resize_inactive_msg(id, new_size), - ConstellationControlMsg::Viewport(..) => - panic!("should have handled Viewport already"), - ConstellationControlMsg::SetScrollState(..) => - panic!("should have handled SetScrollState already"), - ConstellationControlMsg::Resize(..) => - panic!("should have handled Resize already"), - ConstellationControlMsg::ExitPipeline(..) => - panic!("should have handled ExitPipeline already"), ConstellationControlMsg::GetTitle(pipeline_id) => self.handle_get_title_msg(pipeline_id), ConstellationControlMsg::Freeze(pipeline_id) => @@ -943,6 +933,12 @@ impl ScriptThread { self.handle_css_error_reporting(pipeline_id, filename, line, column, msg), ConstellationControlMsg::Reload(pipeline_id) => self.handle_reload(pipeline_id), + msg @ ConstellationControlMsg::AttachLayout(..) | + msg @ ConstellationControlMsg::Viewport(..) | + msg @ ConstellationControlMsg::SetScrollState(..) | + msg @ ConstellationControlMsg::Resize(..) | + msg @ ConstellationControlMsg::ExitPipeline(..) => + panic!("should have handled {:?} already", msg), } } diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index 22370b043c3..ce97c805bb2 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -40,6 +40,11 @@ pub enum Msg { /// Requests that the layout thread render the next frame of all animations. TickAnimations, + /// Updates layout's timer for animation testing from script. + /// + /// The inner field is the number of *milliseconds* to advance. + AdvanceClockMs(i32), + /// Requests that the layout thread reflow with a newly-loaded Web font. ReflowWithNewlyLoadedWebFont, diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index f57ed29f43c..175cc0b82f2 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -61,6 +61,7 @@ use profile_traits::mem; use profile_traits::time as profile_time; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::collections::HashMap; +use std::fmt; use std::sync::mpsc::{Sender, Receiver}; use style_traits::{PagePx, ViewportPx}; use url::Url; @@ -207,6 +208,37 @@ pub enum ConstellationControlMsg { Reload(PipelineId), } +impl fmt::Debug for ConstellationControlMsg { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + use self::ConstellationControlMsg::*; + write!(formatter, "ConstellationMsg::{}", match *self { + AttachLayout(..) => "AttachLayout", + Resize(..) => "Resize", + ResizeInactive(..) => "ResizeInactive", + ExitPipeline(..) => "ExitPipeline", + SendEvent(..) => "SendEvent", + Viewport(..) => "Viewport", + SetScrollState(..) => "SetScrollState", + GetTitle(..) => "GetTitle", + Freeze(..) => "Freeze", + Thaw(..) => "Thaw", + ChangeFrameVisibilityStatus(..) => "ChangeFrameVisibilityStatus", + NotifyVisibilityChange(..) => "NotifyVisibilityChange", + Navigate(..) => "Navigate", + MozBrowserEvent(..) => "MozBrowserEvent", + UpdateSubpageId(..) => "UpdateSubpageId", + FocusIFrame(..) => "FocusIFrame", + WebDriverScriptCommand(..) => "WebDriverScriptCommand", + TickAllAnimations(..) => "TickAllAnimations", + WebFontLoaded(..) => "WebFontLoaded", + DispatchFrameLoadEvent { .. } => "DispatchFrameLoadEvent", + FramedContentChanged(..) => "FramedContentChanged", + ReportCSSError(..) => "ReportCSSError", + Reload(..) => "Reload", + }) + } +} + /// Used to determine if a script has any pending asynchronous activity. #[derive(Copy, Clone, Debug, PartialEq, Deserialize, Serialize)] pub enum DocumentState { diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 55a1d808087..d7eb68f237a 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -1136,7 +1136,6 @@ dependencies = [ "string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "style_traits 0.0.1", - "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/style/animation.rs b/components/style/animation.rs index c9529f7b99f..c36cde3caea 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -20,7 +20,7 @@ use selectors::matching::DeclarationBlock; use std::sync::Arc; use std::sync::mpsc::Sender; use string_cache::Atom; -use time; +use timer::Timer; use values::computed::Time; /// This structure represents a keyframes animation current iteration state. @@ -122,7 +122,9 @@ impl KeyframesAnimationState { /// /// There are some bits of state we can't just replace, over all taking in /// account times, so here's that logic. - pub fn update_from_other(&mut self, other: &Self) { + pub fn update_from_other(&mut self, + other: &Self, + timer: &Timer) { use self::KeyframesRunningState::*; debug!("KeyframesAnimationState::update_from_other({:?}, {:?})", self, other); @@ -146,11 +148,11 @@ impl KeyframesAnimationState { // If we're pausing the animation, compute the progress value. match (&mut self.running_state, old_running_state) { (&mut Running, Paused(progress)) - => new_started_at = time::precise_time_s() - (self.duration * progress), + => new_started_at = timer.seconds() - (self.duration * progress), (&mut Paused(ref mut new), Paused(old)) => *new = old, (&mut Paused(ref mut progress), Running) - => *progress = (time::precise_time_s() - old_started_at) / old_duration, + => *progress = (timer.seconds() - old_started_at) / old_duration, _ => {}, } @@ -341,7 +343,8 @@ impl PropertyAnimation { pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation>, node: OpaqueNode, old_style: &ComputedValues, - new_style: &mut Arc<ComputedValues>) + new_style: &mut Arc<ComputedValues>, + timer: &Timer) -> bool { let mut had_animations = false; for i in 0..new_style.get_box().transition_property_count() { @@ -355,7 +358,7 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation> // Kick off the animation. let box_style = new_style.get_box(); - let now = time::precise_time_s(); + let now = timer.seconds(); let start_time = now + (box_style.transition_delay_mod(i).seconds() as f64); new_animations_sender @@ -424,7 +427,7 @@ pub fn maybe_start_animations(context: &SharedStyleContext, } let delay = box_style.animation_delay_mod(i).seconds(); - let now = time::precise_time_s(); + let now = context.timer.seconds(); let animation_start = now + delay as f64; let duration = box_style.animation_duration_mod(i).seconds(); let iteration_state = match box_style.animation_iteration_count_mod(i) { @@ -497,7 +500,7 @@ where Damage: TRestyleDamage { match *animation { Animation::Transition(_, start_time, ref frame, _) => { debug!("update_style_for_animation: transition found"); - let now = time::precise_time_s(); + let now = context.timer.seconds(); let mut new_style = (*style).clone(); let updated_style = update_style_for_animation_frame(&mut new_style, now, start_time, @@ -516,7 +519,7 @@ where Damage: TRestyleDamage { let started_at = state.started_at; let now = match state.running_state { - KeyframesRunningState::Running => time::precise_time_s(), + KeyframesRunningState::Running => context.timer.seconds(), KeyframesRunningState::Paused(progress) => started_at + duration * progress, }; diff --git a/components/style/context.rs b/components/style/context.rs index 3515728b4cf..f1c5ac3f307 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -15,6 +15,7 @@ use std::cell::RefCell; use std::collections::HashMap; use std::sync::mpsc::Sender; use std::sync::{Arc, Mutex, RwLock}; +use timer::Timer; /// This structure is used to create a local style context from a shared one. pub struct LocalStyleContextCreationInfo { @@ -57,6 +58,10 @@ pub struct SharedStyleContext { /// Data needed to create the local style context from the shared one. pub local_context_creation_data: Mutex<LocalStyleContextCreationInfo>, + + /// The current timer for transitions and animations. This is needed to test + /// them. + pub timer: Timer, } pub struct LocalStyleContext { diff --git a/components/style/lib.rs b/components/style/lib.rs index 673e8311b02..1ad47061062 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -101,6 +101,7 @@ pub mod sink; pub mod str; pub mod stylesheets; mod tid; +pub mod timer; pub mod traversal; #[macro_use] #[allow(non_camel_case_types)] diff --git a/components/style/matching.rs b/components/style/matching.rs index 42320d2ecdd..2c4dfc990cd 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -435,7 +435,8 @@ trait PrivateMatchMethods: TNode new_animations_sender, this_opaque, &**style, - &mut this_style); + &mut this_style, + &shared_context.timer); } cacheable = cacheable && !animations_started diff --git a/components/style/timer.rs b/components/style/timer.rs new file mode 100644 index 00000000000..619e93e80f1 --- /dev/null +++ b/components/style/timer.rs @@ -0,0 +1,58 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use time; + +/// The `TimerMode` is used to determine what time should the `Timer` return, +/// either a fixed value (in the `Test` mode), or the actual time (in the +/// `Current` mode). +#[derive(Debug, Clone)] +enum TimerMode { + Test(f64), + Current, +} + +/// A `Timer` struct that takes care of giving the current time for animations. +/// +/// This is needed to be allowed to hook the time in the animations' test-mode. +#[derive(Debug, Clone)] +pub struct Timer { + mode: TimerMode, +} + +impl Timer { + /// Creates a new "normal" timer, i.e., a "Current" mode timer. + #[inline] + pub fn new() -> Self { + Timer { + mode: TimerMode::Current, + } + } + + /// Creates a new "test mode" timer, with initial time 0. + #[inline] + pub fn test_mode() -> Self { + Timer { + mode: TimerMode::Test(0.), + } + } + + /// Returns the current time, at least from the caller's perspective. In + /// test mode returns whatever the value is. + pub fn seconds(&self) -> f64 { + match self.mode { + TimerMode::Test(test_value) => test_value, + TimerMode::Current => time::precise_time_s(), + } + } + + /// Increments the current clock. Panics if the clock is not on test mode. + pub fn increment(&mut self, by: f64) { + match self.mode { + TimerMode::Test(ref mut val) + => *val += by, + TimerMode::Current + => panic!("Timer::increment called for a non-test mode timer. This is a bug."), + } + } +} diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index cc6112d0ef8..591371cbfc0 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -1045,7 +1045,6 @@ dependencies = [ "string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "style_traits 0.0.1", - "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 9d8e8ec5129..f1da1fe14b5 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -31,6 +31,7 @@ use style::properties::{ComputedValues, PropertyDeclarationBlock, parse_one_decl use style::selector_impl::{SelectorImplExt, PseudoElementCascadeType}; use style::sequential; use style::stylesheets::{Stylesheet, Origin}; +use style::timer::Timer; use traversal::RecalcStyleOnly; use url::Url; use wrapper::{DUMMY_BASE_URL, GeckoDocument, GeckoElement, GeckoNode, NonOpaqueStyleData}; @@ -106,6 +107,7 @@ fn restyle_subtree(node: GeckoNode, raw_data: *mut RawServoStyleSet) { expired_animations: per_doc_data.expired_animations.clone(), error_reporter: Box::new(StdoutErrorReporter), local_context_creation_data: Mutex::new(local_context_data), + timer: Timer::new(), }; if node.is_dirty() || node.has_dirty_descendants() { diff --git a/resources/prefs.json b/resources/prefs.json index 64ac5353cdb..35961dee0e2 100644 --- a/resources/prefs.json +++ b/resources/prefs.json @@ -45,6 +45,7 @@ "js.mem.gc.empty_chunk_count_max": 30, "js.mem.gc.zeal.level": 0, "js.mem.gc.zeal.frequency": 100, + "layout.animations.test.enabled": false, "layout.columns.enabled": false, "layout.column-width.enabled": false, "layout.column-count.enabled": false, diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index d11b5f3e1cc..3fedff120e5 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6120,6 +6120,12 @@ ] }, "testharness": { + "css/animations/basic-linear-width.html": [ + { + "path": "css/animations/basic-linear-width.html", + "url": "/_mozilla/css/animations/basic-linear-width.html" + } + ], "css/empty-keyframes.html": [ { "path": "css/empty-keyframes.html", diff --git a/tests/wpt/mozilla/meta/css/animations/__dir__.ini b/tests/wpt/mozilla/meta/css/animations/__dir__.ini new file mode 100644 index 00000000000..696581b4a4a --- /dev/null +++ b/tests/wpt/mozilla/meta/css/animations/__dir__.ini @@ -0,0 +1,2 @@ +prefs: ["layout.animations.test.enabled:true", + "dom.testbinding.enabled:true"] diff --git a/tests/wpt/mozilla/tests/css/animations/basic-linear-width.html b/tests/wpt/mozilla/tests/css/animations/basic-linear-width.html new file mode 100644 index 00000000000..634b09dca59 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/animations/basic-linear-width.html @@ -0,0 +1,33 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Animation test: Linear animation repeated infinitely.</title> +<style> + .animatable { + width: 50px; + height: 50px; + background: red; + animation: foo 1s infinite linear; + } + @keyframes foo { + from { width: 0; } + to { width: 500px; } + } +</style> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div class="animatable"></div> +<script> +var div = document.querySelector('.animatable'); +async_test(function(t) { + window.addEventListener('load', function() { + var test = new window.TestBinding(); + test.advanceClock(500); + assert_equals(getComputedStyle(div).getPropertyValue('width'), '250px'); + test.advanceClock(500); + assert_equals(getComputedStyle(div).getPropertyValue('width'), '500px'); + test.advanceClock(500); + assert_equals(getComputedStyle(div).getPropertyValue('width'), '250px'); + t.done(); + }) +}) +</script> |