diff options
Diffstat (limited to 'components/layout_thread/lib.rs')
-rw-r--r-- | components/layout_thread/lib.rs | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index b063aa0bca6..a51cdb7ac1a 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -33,6 +33,7 @@ extern crate script_layout_interface; extern crate script_traits; extern crate selectors; extern crate serde_json; +extern crate servo_atoms; extern crate servo_config; extern crate servo_geometry; extern crate servo_url; @@ -53,6 +54,7 @@ use ipc_channel::router::ROUTER; use layout::animation; use layout::construct::ConstructionResult; use layout::context::LayoutContext; +use layout::context::RegisteredPainter; use layout::context::heap_size_of_persistent_local_context; use layout::display_list_builder::ToGfxColor; use layout::flow::{self, Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUtils}; @@ -87,8 +89,8 @@ use script_layout_interface::rpc::TextIndexResponse; use script_layout_interface::wrapper_traits::LayoutNode; use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg}; use script_traits::{ScrollState, UntrustedNodeAddress}; -use script_traits::PaintWorkletExecutor; use selectors::Element; +use servo_atoms::Atom; use servo_config::opts; use servo_config::prefs::PREFS; use servo_config::resource_files::read_resource_file; @@ -114,6 +116,7 @@ use style::error_reporting::{NullReporter, RustLogReporter}; use style::invalidation::element::restyle_hints::RestyleHint; use style::logical_geometry::LogicalPoint; use style::media_queries::{Device, MediaList, MediaType}; +use style::properties::PropertyId; use style::selector_parser::SnapshotMap; use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW}; use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards}; @@ -123,6 +126,7 @@ use style::stylist::{ExtraStyleData, Stylist}; use style::thread_state; use style::timer::Timer; use style::traversal::{DomTraversal, TraversalDriver, TraversalFlags}; +use style::values::CompactCowStr; /// Information needed by the layout thread. pub struct LayoutThread { @@ -223,7 +227,7 @@ pub struct LayoutThread { WebRenderImageInfo>>>, /// The executor for paint worklets. /// Will be None if the script thread hasn't added any paint worklet modules. - paint_worklet_executor: Option<Arc<PaintWorkletExecutor>>, + registered_painters: Arc<RwLock<FnvHashMap<Atom, RegisteredPainter>>>, /// Webrender interface. webrender_api: webrender_traits::RenderApi, @@ -491,7 +495,7 @@ impl LayoutThread { constellation_chan: constellation_chan.clone(), time_profiler_chan: time_profiler_chan, mem_profiler_chan: mem_profiler_chan, - paint_worklet_executor: None, + registered_painters: Arc::new(RwLock::new(FnvHashMap::default())), image_cache: image_cache.clone(), font_cache_thread: font_cache_thread, first_reflow: Cell::new(true), @@ -584,7 +588,7 @@ impl LayoutThread { webrender_image_cache: self.webrender_image_cache.clone(), pending_images: if script_initiated_layout { Some(Mutex::new(vec![])) } else { None }, newly_transitioning_nodes: if script_initiated_layout { Some(Mutex::new(vec![])) } else { None }, - paint_worklet_executor: self.paint_worklet_executor.clone(), + registered_painters: self.registered_painters.clone(), } } @@ -700,10 +704,19 @@ impl LayoutThread { Msg::SetFinalUrl(final_url) => { self.url = final_url; }, - Msg::SetPaintWorkletExecutor(executor) => { - debug!("Setting the paint worklet executor"); - debug_assert!(self.paint_worklet_executor.is_none()); - self.paint_worklet_executor = Some(executor); + Msg::RegisterPaint(name, mut properties, painter) => { + debug!("Registering the painter"); + let properties = properties.drain(..) + .filter_map(|name| PropertyId::parse(CompactCowStr::from(&*name)).ok().map(|id| (name.clone(), id))) + .filter(|&(_, ref id)| id.as_shorthand().is_err()) + .collect(); + let registered_painter = RegisteredPainter { + name: name.clone(), + properties: properties, + painter: painter, + }; + self.registered_painters.write() + .insert(name, registered_painter); }, Msg::PrepareToExit(response_chan) => { self.prepare_to_exit(response_chan); |