diff options
-rw-r--r-- | components/compositing/compositor.rs | 26 | ||||
-rw-r--r-- | components/compositing/compositor_task.rs | 6 | ||||
-rw-r--r-- | components/compositing/constellation.rs | 4 | ||||
-rw-r--r-- | components/compositing/headless.rs | 2 | ||||
-rw-r--r-- | components/layout/construct.rs | 7 | ||||
-rw-r--r-- | components/layout/layout_task.rs | 11 | ||||
-rw-r--r-- | components/layout/util.rs | 6 | ||||
-rw-r--r-- | components/script/dom/node.rs | 47 | ||||
-rw-r--r-- | components/script/layout_interface.rs | 4 | ||||
-rw-r--r-- | components/util/memory.rs | 3 | ||||
-rw-r--r-- | python/servo/post_build_commands.py | 19 | ||||
-rw-r--r-- | tests/ref/basic.list | 1 | ||||
-rw-r--r-- | tests/ref/iframe/hide_and_show.html | 20 | ||||
-rw-r--r-- | tests/ref/iframe/hide_and_show_ref.html | 13 |
14 files changed, 110 insertions, 59 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 3ed89b37604..cf303102ba3 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -288,6 +288,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { response_chan, new_constellation_chan); self.send_viewport_rects_for_all_layers(); + self.get_title_for_main_frame(); } (Msg::ChangeLayerPipelineAndRemoveChildren(old_pipeline, new_pipeline, response_channel), @@ -315,9 +316,9 @@ impl<Window: WindowMethods> IOCompositor<Window> { chan.send(Some(self.window.native_metadata())).unwrap(); } - (Msg::SetLayerOrigin(pipeline_id, layer_id, origin), + (Msg::SetLayerRect(pipeline_id, layer_id, rect), ShutdownState::NotShuttingDown) => { - self.set_layer_origin(pipeline_id, layer_id, origin); + self.set_layer_rect(pipeline_id, layer_id, &rect); } (Msg::AssignPaintedBuffers(pipeline_id, epoch, replies), ShutdownState::NotShuttingDown) => { @@ -431,8 +432,13 @@ impl<Window: WindowMethods> IOCompositor<Window> { } } - fn change_page_title(&mut self, _: PipelineId, title: Option<String>) { - self.window.set_page_title(title); + fn change_page_title(&mut self, pipeline_id: PipelineId, title: Option<String>) { + let set_title = self.root_pipeline.as_ref().map_or(false, |root_pipeline| { + root_pipeline.id == pipeline_id + }); + if set_title { + self.window.set_page_title(title); + } } fn change_page_load_data(&mut self, _: FrameId, load_data: LoadData) { @@ -721,15 +727,15 @@ impl<Window: WindowMethods> IOCompositor<Window> { self.composition_request = CompositionRequest::CompositeOnScrollTimeout(timestamp); } - fn set_layer_origin(&mut self, - pipeline_id: PipelineId, - layer_id: LayerId, - new_origin: Point2D<f32>) { + fn set_layer_rect(&mut self, + pipeline_id: PipelineId, + layer_id: LayerId, + new_rect: &Rect<f32>) { match self.find_layer_with_pipeline_and_layer_id(pipeline_id, layer_id) { Some(ref layer) => { - layer.bounds.borrow_mut().origin = Point2D::from_untyped(&new_origin) + *layer.bounds.borrow_mut() = Rect::from_untyped(new_rect) } - None => panic!("Compositor received SetLayerOrigin for nonexistent \ + None => panic!("Compositor received SetLayerRect for nonexistent \ layer: {:?}", pipeline_id), }; diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs index f3504aa6704..e3c1a5102d1 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_task.rs @@ -188,8 +188,8 @@ pub enum Msg { /// Tells the compositor to create a descendant layer for a pipeline if necessary (i.e. if no /// layer with that ID exists). CreateOrUpdateDescendantLayer(LayerProperties), - /// Alerts the compositor that the specified layer's origin has changed. - SetLayerOrigin(PipelineId, LayerId, Point2D<f32>), + /// Alerts the compositor that the specified layer's rect has changed. + SetLayerRect(PipelineId, LayerId, Rect<f32>), /// Scroll a page in a window ScrollFragmentPoint(PipelineId, LayerId, Point2D<f32>), /// Requests that the compositor assign the painted buffers to the given layers. @@ -231,7 +231,7 @@ impl Debug for Msg { Msg::GetGraphicsMetadata(..) => write!(f, "GetGraphicsMetadata"), Msg::CreateOrUpdateBaseLayer(..) => write!(f, "CreateOrUpdateBaseLayer"), Msg::CreateOrUpdateDescendantLayer(..) => write!(f, "CreateOrUpdateDescendantLayer"), - Msg::SetLayerOrigin(..) => write!(f, "SetLayerOrigin"), + Msg::SetLayerRect(..) => write!(f, "SetLayerRect"), Msg::ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"), Msg::AssignPaintedBuffers(..) => write!(f, "AssignPaintedBuffers"), Msg::ChangeReadyState(..) => write!(f, "ChangeReadyState"), diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index daf2cb2503d..2d370eca4e5 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -681,10 +681,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { initial_viewport: rect.size * ScaleFactor(1.0), device_pixel_ratio: device_pixel_ratio, })).unwrap(); - compositor_proxy.send(CompositorMsg::SetLayerOrigin( + compositor_proxy.send(CompositorMsg::SetLayerRect( pipeline.id, LayerId::null(), - rect.to_untyped().origin)); + rect.to_untyped())); } else { already_sent.insert(pipeline.id); } diff --git a/components/compositing/headless.rs b/components/compositing/headless.rs index 3c57b0e3b82..0c38846d1d0 100644 --- a/components/compositing/headless.rs +++ b/components/compositing/headless.rs @@ -104,7 +104,7 @@ impl CompositorEventListener for NullCompositor { Msg::CreateOrUpdateBaseLayer(..) | Msg::CreateOrUpdateDescendantLayer(..) | - Msg::SetLayerOrigin(..) | + Msg::SetLayerRect(..) | Msg::AssignPaintedBuffers(..) | Msg::ChangeReadyState(..) | Msg::ChangePaintState(..) | diff --git a/components/layout/construct.rs b/components/layout/construct.rs index aa6a50f0545..b2ea8090ea6 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -1329,6 +1329,13 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> { let mut layout_data_ref = self.mutate_layout_data(); let layout_data = layout_data_ref.as_mut().expect("no layout data"); + match result { + ConstructionResult::None => { + layout_data.clear(); + } + _ => {} + } + let dst = self.get_construction_result(layout_data); *dst = result; diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 1b043c3d26b..ca321f23526 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -35,7 +35,7 @@ use gfx::paint_task::Msg as PaintMsg; use layout_traits::{LayoutControlMsg, LayoutTaskFactory}; use log; use script::dom::bindings::js::LayoutJS; -use script::dom::node::{LayoutDataRef, Node, NodeTypeId}; +use script::dom::node::{LayoutData, Node, NodeTypeId}; use script::dom::element::ElementTypeId; use script::dom::htmlelement::HTMLElementTypeId; use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse}; @@ -937,11 +937,10 @@ impl LayoutTask { } /// Handles a message to destroy layout data. Layout data must be destroyed on *this* task - /// because it contains local managed pointers. - unsafe fn handle_reap_layout_data(layout_data: LayoutDataRef) { - let mut layout_data_ref = layout_data.borrow_mut(); - let _: Option<LayoutDataWrapper> = mem::transmute( - mem::replace(&mut *layout_data_ref, None)); + /// because the struct type is transmuted to a different type on the script side. + unsafe fn handle_reap_layout_data(layout_data: LayoutData) { + let layout_data_wrapper: LayoutDataWrapper = mem::transmute(layout_data); + layout_data_wrapper.clear(); } /// Returns profiling information which is passed to the time profiler. diff --git a/components/layout/util.rs b/components/layout/util.rs index fca6fabb3ed..8d4d72e7466 100644 --- a/components/layout/util.rs +++ b/components/layout/util.rs @@ -78,6 +78,12 @@ pub struct LayoutDataWrapper { pub data: Box<PrivateLayoutData>, } +impl LayoutDataWrapper { + pub fn clear(&self) { + // TODO: Clear items related to this node, e.g. compositor layers + } +} + #[allow(dead_code)] fn static_assertion(x: Option<LayoutDataWrapper>) { unsafe { diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 18910764188..a7b5e5484d6 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -177,9 +177,7 @@ impl NodeFlags { impl Drop for Node { #[allow(unsafe_blocks)] fn drop(&mut self) { - unsafe { - self.reap_layout_data(); - } + self.layout_data.dispose(); } } @@ -205,6 +203,8 @@ pub struct LayoutData { _data: NonZero<*const ()>, } +unsafe impl Send for LayoutData {} + pub struct LayoutDataRef { pub data_cell: RefCell<Option<LayoutData>>, } @@ -218,18 +218,17 @@ impl LayoutDataRef { } } - /// Returns true if there is layout data present. - #[inline] - pub fn is_present(&self) -> bool { - self.data_cell.borrow().is_some() - } - - /// Take the chan out of the layout data if it is present. - pub fn take_chan(&self) -> Option<LayoutChan> { - let mut layout_data = self.data_cell.borrow_mut(); - match &mut *layout_data { - &mut None => None, - &mut Some(ref mut layout_data) => Some(layout_data.chan.take().unwrap()), + /// Sends layout data, if any, back to the layout task to be destroyed. + pub fn dispose(&self) { + if let Some(mut layout_data) = mem::replace(&mut *self.borrow_mut(), None) { + let layout_chan = layout_data.chan.take(); + match layout_chan { + None => {} + Some(chan) => { + let LayoutChan(chan) = chan; + chan.send(Msg::ReapLayoutData(layout_data)).unwrap() + } + } } } @@ -258,8 +257,6 @@ impl LayoutDataRef { } } -unsafe impl Send for LayoutDataRef {} - /// The different types of nodes. #[derive(Copy, PartialEq, Debug)] #[jstraceable] @@ -302,6 +299,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> { for node in self.traverse_preorder() { vtable_for(&node).unbind_from_tree(parent_in_doc); } + self.layout_data.dispose(); } // @@ -1648,21 +1646,6 @@ impl Node { Temporary::from_rooted(copy.r()) } - /// Sends layout data, if any, back to the layout task to be destroyed. - unsafe fn reap_layout_data(&mut self) { - if self.layout_data.is_present() { - let layout_data = mem::replace(&mut self.layout_data, LayoutDataRef::new()); - let layout_chan = layout_data.take_chan(); - match layout_chan { - None => {} - Some(chan) => { - let LayoutChan(chan) = chan; - chan.send(Msg::ReapLayoutData(layout_data)).unwrap() - }, - } - } - } - pub fn collect_text_contents<'a, T: Iterator<Item=JSRef<'a, Node>>>(iterator: T) -> String { let mut content = String::new(); for node in iterator { diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index c82370207cf..5b83c471b73 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -6,7 +6,7 @@ //! interface helps reduce coupling between these two components, and enables //! the DOM to be placed in a separate crate from layout. -use dom::node::LayoutDataRef; +use dom::node::LayoutData; use geom::point::Point2D; use geom::rect::Rect; @@ -41,7 +41,7 @@ pub enum Msg { /// Destroys layout data associated with a DOM node. /// /// TODO(pcwalton): Maybe think about batching to avoid message traffic. - ReapLayoutData(LayoutDataRef), + ReapLayoutData(LayoutData), /// Requests that the layout task enter a quiescent state in which no more messages are /// accepted except `ExitMsg`. A response message will be sent on the supplied channel when diff --git a/components/util/memory.rs b/components/util/memory.rs index e5e20d4cc94..c309cdbb4ed 100644 --- a/components/util/memory.rs +++ b/components/util/memory.rs @@ -7,6 +7,7 @@ use libc::{c_char,c_int,c_void,size_t}; use std::borrow::ToOwned; use std::ffi::CString; +use std::iter::AdditiveIterator; use std::old_io::timer::sleep; #[cfg(target_os="linux")] use std::old_io::File; @@ -380,7 +381,7 @@ fn get_resident_segments() -> Vec<(String, u64)> { // from the "resident" measurement obtained via /proc/<pid>/statm in // get_resident(). It's unclear why this difference occurs; for some // processes the measurements match, but for Servo they do not. - let total = segs.iter().fold(0u64, |total, &(_, size)| total + size); + let total = segs.iter().map(|&(_, size)| size).sum(); segs.push(("resident-according-to-smaps".to_owned(), total)); // Sort by size; the total will be first. diff --git a/python/servo/post_build_commands.py b/python/servo/post_build_commands.py index b28ef968091..495348c8269 100644 --- a/python/servo/post_build_commands.py +++ b/python/servo/post_build_commands.py @@ -8,6 +8,7 @@ import subprocess import SimpleHTTPServer import SocketServer import mozdebug +import sys from shutil import copytree, rmtree, ignore_patterns, copy2 from mach.registrar import Registrar @@ -33,8 +34,22 @@ class MachCommands(CommandBase): def get_binary_path(self, release): base_path = path.join("components", "servo", "target") - if release: - return path.join(base_path, "release", "servo") + release_path= path.join(base_path, "release", "servo") + + if not release: + if not os.path.exists(release_path): + if not os.path.exists(base_path): + print("Servo Binary cannot be found, please run './mach build'" + "and try again!") + sys.exit() + print("Running Debug Build") + return path.join(base_path, "servo") + else: + if os.path.exists(base_path): + print("You have multiple binaries present." + " Please specify which binary is to be run") + sys.exit() + return path.join(release_path, "servo") return path.join(base_path, "servo") @Command('run', diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 306a66950a8..0d83cc16d1f 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -138,6 +138,7 @@ fragment=top != ../html/acid2.html acid2_ref.html == iframe/multiple_external.html iframe/multiple_external_ref.html == iframe/overflow.html iframe/overflow_ref.html == iframe/positioning_margin.html iframe/positioning_margin_ref.html +== iframe/hide_and_show.html iframe/hide_and_show_ref.html == floated_generated_content_a.html floated_generated_content_b.html == inline_block_margin_a.html inline_block_margin_ref.html diff --git a/tests/ref/iframe/hide_and_show.html b/tests/ref/iframe/hide_and_show.html new file mode 100644 index 00000000000..29ab83dfe2a --- /dev/null +++ b/tests/ref/iframe/hide_and_show.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html class="reftest-wait"> + <style type="text/css"> + .hidden { + display: none; + } + iframe { + border: 0; + } + </style> + <body id="container"> + <iframe id="iframe" class="hidden" src="data:text/html,%3Cbody%20style%3D%22background%3Agreen%3B%20%22%3E"></iframe> + </body> + <script type="text/javascript"> + window.onload = function() { + document.getElementById("iframe").classList.remove("hidden"); + document.documentElement.classList.remove("reftest-wait"); + } + </script> +</html> diff --git a/tests/ref/iframe/hide_and_show_ref.html b/tests/ref/iframe/hide_and_show_ref.html new file mode 100644 index 00000000000..1580b58858c --- /dev/null +++ b/tests/ref/iframe/hide_and_show_ref.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html> + <style type="text/css"> + div { + width: 300px; + height: 150px; + background-color: green; + } + </style> + <body> + <div></div> + </body> +</html> |