diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-03-31 10:39:56 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-03-31 10:39:56 -0600 |
commit | ebdf1d494b6c986e6dfcb7d8fd3f0ffa126523ed (patch) | |
tree | 79a21066baec2b2b00dcc0f48419c8f1ce0ced5b /components/script | |
parent | 52cc63a2622a77ee317f1b320be8ae7e478b2a43 (diff) | |
parent | 66dd8c8a6c5368f3b4d063e25d7a3cbaa4393cb4 (diff) | |
download | servo-ebdf1d494b6c986e6dfcb7d8fd3f0ffa126523ed.tar.gz servo-ebdf1d494b6c986e6dfcb7d8fd3f0ffa126523ed.zip |
auto merge of #5400 : pcwalton/servo/transitions-redux, r=glennw
Transition events are not yet supported, and the only animatable
properties are `top`, `right`, `bottom`, and `left`. However, all other
features of transitions are supported. There are no automated tests at
present because I'm not sure how best to test it, but three manual tests
are included.
r? @glennw
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/webidls/CSSStyleDeclaration.webidl | 6 | ||||
-rw-r--r-- | components/script/dom/window.rs | 14 | ||||
-rw-r--r-- | components/script/layout_interface.rs | 48 |
3 files changed, 56 insertions, 12 deletions
diff --git a/components/script/dom/webidls/CSSStyleDeclaration.webidl b/components/script/dom/webidls/CSSStyleDeclaration.webidl index 3be5abe1099..1da7946338b 100644 --- a/components/script/dom/webidls/CSSStyleDeclaration.webidl +++ b/components/script/dom/webidls/CSSStyleDeclaration.webidl @@ -186,4 +186,10 @@ partial interface CSSStyleDeclaration { [TreatNullAs=EmptyString] attribute DOMString zIndex; [TreatNullAs=EmptyString] attribute DOMString imageRendering; + + [TreatNullAs=EmptyString] attribute DOMString transition; + [TreatNullAs=EmptyString] attribute DOMString transitionDuration; + [TreatNullAs=EmptyString] attribute DOMString transitionTimingFunction; + [TreatNullAs=EmptyString] attribute DOMString transitionProperty; + [TreatNullAs=EmptyString] attribute DOMString transitionDelay; }; diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 675af64d5cb..08e526df282 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -27,7 +27,7 @@ use dom::performance::Performance; use dom::screen::Screen; use dom::storage::Storage; use layout_interface::{ReflowGoal, ReflowQueryType, LayoutRPC, LayoutChan, Reflow, Msg}; -use layout_interface::{ContentBoxResponse, ContentBoxesResponse}; +use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ScriptReflow}; use page::Page; use script_task::{TimerSource, ScriptChan}; use script_task::ScriptMsg; @@ -564,17 +564,19 @@ impl<'a> WindowHelpers for JSRef<'a, Window> { } // Send new document and relevant styles to layout. - let reflow = box Reflow { + let reflow = box ScriptReflow { + reflow_info: Reflow { + goal: goal, + url: self.get_url(), + iframe: self.parent_info.is_some(), + page_clip_rect: self.page_clip_rect.get(), + }, document_root: root.to_trusted_node_address(), - url: self.get_url(), - iframe: self.parent_info.is_some(), - goal: goal, window_size: window_size, script_chan: self.control_chan.clone(), script_join_chan: join_chan, id: last_reflow_id.get(), query_type: query_type, - page_clip_rect: self.page_clip_rect.get(), }; let LayoutChan(ref chan) = self.layout_chan; diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index 9b7e3a292ea..a0062a287b6 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -10,14 +10,16 @@ use dom::node::LayoutData; use geom::point::Point2D; use geom::rect::Rect; +use libc::uintptr_t; use msg::constellation_msg::{PipelineExitType, WindowSizeData}; use profile::mem::{Reporter, ReportsChan}; use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel, UntrustedNodeAddress}; use std::any::Any; use std::sync::mpsc::{channel, Receiver, Sender}; use std::boxed::BoxAny; -use style::stylesheets::Stylesheet; +use style::animation::PropertyAnimation; use style::media_queries::MediaQueryList; +use style::stylesheets::Stylesheet; use url::Url; use util::geometry::Au; @@ -35,11 +37,14 @@ pub enum Msg { SetQuirksMode, /// Requests a reflow. - Reflow(Box<Reflow>), + Reflow(Box<ScriptReflow>), /// Get an RPC interface. GetRPC(Sender<Box<LayoutRPC + Send>>), + /// Requests that the layout task render the next frame of all animations. + TickAnimations, + /// Destroys layout data associated with a DOM node. /// /// TODO(pcwalton): Maybe think about batching to avoid message traffic. @@ -100,14 +105,22 @@ pub enum ReflowQueryType { /// Information needed for a reflow. pub struct Reflow { - /// The document node. - pub document_root: TrustedNodeAddress, /// The goal of reflow: either to render to the screen or to flush layout info for script. pub goal: ReflowGoal, /// The URL of the page. pub url: Url, /// Is the current reflow of an iframe, as opposed to a root window? pub iframe: bool, + /// A clipping rectangle for the page, an enlarged rectangle containing the viewport. + pub page_clip_rect: Rect<Au>, +} + +/// Information needed for a script-initiated reflow. +pub struct ScriptReflow { + /// General reflow data. + pub reflow_info: Reflow, + /// The document node. + pub document_root: TrustedNodeAddress, /// The channel through which messages can be sent back to the script task. pub script_chan: ScriptControlChan, /// The current window size. @@ -118,8 +131,6 @@ pub struct Reflow { pub id: u32, /// The type of query if any to perform during this reflow. pub query_type: ReflowQueryType, - /// A clipping rectangle for the page, an enlarged rectangle containing the viewport. - pub page_clip_rect: Rect<Au>, } /// Encapsulates a channel to the layout task. @@ -165,3 +176,28 @@ impl ScriptLayoutChan for OpaqueScriptLayoutChannel { *receiver.downcast::<Receiver<Msg>>().unwrap() } } + +/// Type of an opaque node. +pub type OpaqueNode = uintptr_t; + +/// State relating to an animation. +#[derive(Copy, Clone)] +pub struct Animation { + /// An opaque reference to the DOM node participating in the animation. + pub node: OpaqueNode, + /// A description of the property animation that is occurring. + pub property_animation: PropertyAnimation, + /// The start time of the animation, as returned by `time::precise_time_s()`. + pub start_time: f64, + /// The end time of the animation, as returned by `time::precise_time_s()`. + pub end_time: f64, +} + +impl Animation { + /// Returns the duration of this animation in seconds. + #[inline] + pub fn duration(&self) -> f64 { + self.end_time - self.start_time + } +} + |