servo: Merge #11930 - Remove some util stuff (from nox:die-util-die); r=SimonSapin
authorAnthony Ramine <n.oxyde@gmail.com>
Wed, 29 Jun 2016 15:37:42 -0500
changeset 339157 dcee600d9b26c9d8993aa9f78b75c9b3d9db1045
parent 339156 d3f459d197f5e26eaa73ba6954cc78472870810d
child 339158 dc8cc3ec4670f4842b57d095f18c02ef7d00e8bb
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersSimonSapin
servo: Merge #11930 - Remove some util stuff (from nox:die-util-die); r=SimonSapin Source-Repo: https://github.com/servo/servo Source-Revision: dcc4697dde3ba8af32e233b302a16bea76af378a
servo/components/compositing/delayed_composition.rs
servo/components/layout/construct.rs
servo/components/layout/lib.rs
servo/components/layout/linked_list.rs
servo/components/layout/text.rs
servo/components/profile/mem.rs
servo/components/profile/time.rs
servo/components/util/lib.rs
servo/components/util/linked_list.rs
servo/components/util/time.rs
--- a/servo/components/compositing/delayed_composition.rs
+++ b/servo/components/compositing/delayed_composition.rs
@@ -5,18 +5,19 @@
 //! A timer thread that composites near the end of the frame.
 //!
 //! This is useful when we need to composite next frame but we want to opportunistically give the
 //! painting thread time to paint if it can.
 
 use compositor_thread::{CompositorProxy, Msg};
 use std::sync::mpsc::{Receiver, Sender, channel};
 use std::thread::{self, Builder};
+use std::time::Duration;
+use std::u32;
 use time;
-use util::time::duration_from_nanoseconds;
 
 /// The amount of time in nanoseconds that we give to the painting thread to paint. When this
 /// expires, we give up and composite anyway.
 static TIMEOUT: u64 = 12_000_000;
 
 pub struct DelayedCompositionTimerProxy {
     sender: Sender<ToDelayedCompositionTimerMsg>,
 }
@@ -87,8 +88,20 @@ impl DelayedCompositionTimer {
                 let delta_ns = target - now;
                 thread::sleep(duration_from_nanoseconds(delta_ns));
             }
             self.compositor_proxy.send(Msg::DelayedCompositionTimeout(timestamp));
         }
     }
 }
 
+fn duration_from_nanoseconds(nanos: u64) -> Duration {
+    pub const NANOS_PER_SEC: u32 = 1_000_000_000;
+
+    // Get number of seconds.
+    let secs = nanos / NANOS_PER_SEC as u64;
+
+    // Get number of extra nanoseconds. This should always fit in a u32, but check anyway.
+    let subsec_nanos = nanos % NANOS_PER_SEC as u64;
+    assert!(subsec_nanos <= u32::MAX as u64);
+
+    Duration::new(secs, subsec_nanos as u32)
+}
--- a/servo/components/layout/construct.rs
+++ b/servo/components/layout/construct.rs
@@ -25,16 +25,17 @@ use flow_ref::{self, FlowRef};
 use fragment::WhitespaceStrippingResult;
 use fragment::{CanvasFragmentInfo, ImageFragmentInfo, InlineAbsoluteFragmentInfo};
 use fragment::{Fragment, GeneratedContentInfo, IframeFragmentInfo};
 use fragment::{InlineAbsoluteHypotheticalFragmentInfo, TableColumnFragmentInfo};
 use fragment::{InlineBlockFragmentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
 use gfx::display_list::OpaqueNode;
 use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, InlineFragmentNodeFlags};
 use inline::{InlineFragmentNodeInfo, LAST_FRAGMENT_OF_ELEMENT};
+use linked_list::prepend_from;
 use list_item::{ListItemFlow, ListStyleTypeContent};
 use multicol::{MulticolFlow, MulticolColumnFlow};
 use parallel;
 use script_layout_interface::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW, RestyleDamage};
 use script_layout_interface::wrapper_traits::{ThreadSafeLayoutNode, PseudoElementType, ThreadSafeLayoutElement};
 use script_layout_interface::{LayoutNodeType, LayoutElementType, is_image_data};
 use std::borrow::ToOwned;
 use std::collections::LinkedList;
@@ -52,17 +53,16 @@ use table_caption::TableCaptionFlow;
 use table_cell::TableCellFlow;
 use table_colgroup::TableColGroupFlow;
 use table_row::TableRowFlow;
 use table_rowgroup::TableRowGroupFlow;
 use table_wrapper::TableWrapperFlow;
 use text::TextRunScanner;
 use traversal::PostorderNodeMutTraversal;
 use url::Url;
-use util::linked_list;
 use util::opts;
 use wrapper::{TextContent, ThreadSafeLayoutNodeHelpers};
 
 /// The results of flow construction for a DOM node.
 #[derive(Clone)]
 pub enum ConstructionResult {
     /// This node contributes nothing at all (`display: none`). Alternately, this is what newly
     /// created nodes have their `ConstructionResult` set to.
@@ -1800,18 +1800,17 @@ pub fn strip_ignorable_whitespace_from_s
             WhitespaceStrippingResult::FragmentContainedOnlyWhitespace => {
                 let removed_fragment = this.pop_front().unwrap();
                 if let Some(ref mut remaining_fragment) = this.front_mut() {
                     remaining_fragment.meld_with_prev_inline_fragment(&removed_fragment);
                 }
             }
         }
     }
-    linked_list::prepend_from(this,
-                              &mut leading_fragments_consisting_of_solely_bidi_control_characters);
+    prepend_from(this, &mut leading_fragments_consisting_of_solely_bidi_control_characters);
 }
 
 /// Strips ignorable whitespace from the end of a list of fragments.
 pub fn strip_ignorable_whitespace_from_end(this: &mut LinkedList<Fragment>) {
     if this.is_empty() {
         return
     }
 
--- a/servo/components/layout/lib.rs
+++ b/servo/components/layout/lib.rs
@@ -70,16 +70,17 @@ mod flex;
 mod floats;
 pub mod flow;
 mod flow_list;
 pub mod flow_ref;
 mod fragment;
 mod generated_content;
 pub mod incremental;
 mod inline;
+mod linked_list;
 mod list_item;
 mod model;
 mod multicol;
 mod opaque_node;
 pub mod parallel;
 mod persistent_list;
 pub mod query;
 pub mod sequential;
rename from servo/components/util/linked_list.rs
rename to servo/components/layout/linked_list.rs
--- a/servo/components/layout/text.rs
+++ b/servo/components/layout/text.rs
@@ -11,29 +11,29 @@ use fragment::{Fragment, REQUIRES_LINE_B
 use fragment::{ScannedTextFragmentInfo, SELECTED, SpecificFragmentInfo, UnscannedTextFragmentInfo};
 use gfx::font::{DISABLE_KERNING_SHAPING_FLAG, FontMetrics, IGNORE_LIGATURES_SHAPING_FLAG};
 use gfx::font::{RTL_FLAG, RunMetrics, ShapingFlags, ShapingOptions};
 use gfx::font_context::FontContext;
 use gfx::text::glyph::ByteIndex;
 use gfx::text::text_run::TextRun;
 use gfx::text::util::{self, CompressionMode};
 use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFragments, LAST_FRAGMENT_OF_ELEMENT};
+use linked_list::split_off_head;
 use range::Range;
 use std::borrow::ToOwned;
 use std::collections::LinkedList;
 use std::mem;
 use std::sync::Arc;
 use style::computed_values::white_space;
 use style::computed_values::{line_height, text_orientation, text_rendering, text_transform};
 use style::logical_geometry::{LogicalSize, WritingMode};
 use style::properties::style_structs::ServoFont;
 use style::properties::{ComputedValues, ServoComputedValues};
 use unicode_bidi::{is_rtl, process_text};
 use unicode_script::{get_script, Script};
-use util::linked_list::split_off_head;
 
 /// Returns the concatenated text of a list of unscanned text fragments.
 fn text(fragments: &LinkedList<Fragment>) -> String {
     // FIXME: Some of this work is later duplicated in split_first_fragment_at_newline_if_necessary
     // and transform_text.  This code should be refactored so that the all the scanning for
     // newlines is done in a single pass.
 
     let mut text = String::new();
--- a/servo/components/profile/mem.rs
+++ b/servo/components/profile/mem.rs
@@ -7,18 +7,18 @@
 use ipc_channel::ipc::{self, IpcReceiver};
 use ipc_channel::router::ROUTER;
 use profile_traits::mem::ReportsChan;
 use profile_traits::mem::{ProfilerChan, ProfilerMsg, ReportKind, Reporter, ReporterRequest};
 use std::borrow::ToOwned;
 use std::cmp::Ordering;
 use std::collections::HashMap;
 use std::thread;
+use time::duration_from_seconds;
 use util::thread::spawn_named;
-use util::time::duration_from_seconds;
 
 pub struct Profiler {
     /// The port through which messages are received.
     pub port: IpcReceiver<ProfilerMsg>,
 
     /// Registered memory reporters.
     reporters: HashMap<String, Reporter>,
 }
--- a/servo/components/profile/time.rs
+++ b/servo/components/profile/time.rs
@@ -14,22 +14,21 @@ use std::cmp::Ordering;
 use std::collections::BTreeMap;
 use std::error::Error;
 use std::fs;
 use std::fs::File;
 use std::io::{self, Write};
 use std::path;
 use std::path::Path;
 use std::time::Duration;
-use std::{thread, f64};
+use std::{f64, thread, u32, u64};
 use std_time::precise_time_ns;
 use trace_dump::TraceDump;
 use util::opts::OutputOptions;
 use util::thread::spawn_named;
-use util::time::duration_from_seconds;
 
 pub trait Formattable {
     fn format(&self, output: &Option<OutputOptions>) -> String;
 }
 
 impl Formattable for Option<TimerMetadata> {
     fn format(&self, output: &Option<OutputOptions>) -> String {
         match *self {
@@ -403,8 +402,22 @@ fn enforce_range<T>(min: T, max: T, valu
         Ordering::Less => {
             match value.cmp(&min) {
                 Ordering::Equal | Ordering::Less => min,
                 Ordering::Greater => value,
             }
         },
     }
 }
+
+pub fn duration_from_seconds(secs: f64) -> Duration {
+    pub const NANOS_PER_SEC: u32 = 1_000_000_000;
+
+    // Get number of seconds and check that it fits in a u64.
+    let whole_secs = secs.trunc();
+    assert!(whole_secs >= 0.0 && whole_secs <= u64::MAX as f64);
+
+    // Get number of nanoseconds. This should always fit in a u32, but check anyway.
+    let nanos = (secs.fract() * (NANOS_PER_SEC as f64)).trunc();
+    assert!(nanos >= 0.0 && nanos <= u32::MAX as f64);
+
+    Duration::new(whole_secs as u64, nanos as u32)
+}
--- a/servo/components/util/lib.rs
+++ b/servo/components/util/lib.rs
@@ -34,27 +34,25 @@ extern crate xdg;
 
 use std::sync::Arc;
 
 pub mod basedir;
 pub mod cache;
 #[allow(unsafe_code)] pub mod debug_utils;
 pub mod geometry;
 #[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod ipc;
-#[cfg(feature = "servo")] pub mod linked_list;
 #[allow(unsafe_code)] pub mod opts;
 #[cfg(feature = "servo")] pub mod panicking;
 pub mod prefs;
 #[cfg(feature = "servo")] pub mod print_tree;
 pub mod resource_files;
 pub mod str;
 pub mod thread;
 pub mod thread_state;
 pub mod tid;
-#[cfg(feature = "servo")] pub mod time;
 pub mod vec;
 #[allow(unsafe_code)] pub mod workqueue;
 
 #[cfg(feature = "servo")]
 #[allow(unsafe_code)]
 pub fn breakpoint() {
     unsafe { ::std::intrinsics::breakpoint() };
 }
deleted file mode 100644
--- a/servo/components/util/time.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-/* 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 std::time::Duration;
-use std::{u32, u64};
-
-pub const NANOS_PER_SEC: u32 = 1_000_000_000;
-
-pub fn duration_from_seconds(secs: f64) -> Duration {
-    // Get number of seconds and check that it fits in a u64.
-    let whole_secs = secs.trunc();
-    assert!(whole_secs >= 0.0 && whole_secs <= u64::MAX as f64);
-
-    // Get number of nanoseconds. This should always fit in a u32, but check anyway.
-    let nanos = (secs.fract() * (NANOS_PER_SEC as f64)).trunc();
-    assert!(nanos >= 0.0 && nanos <= u32::MAX as f64);
-
-    Duration::new(whole_secs as u64, nanos as u32)
-}
-
-pub fn duration_from_nanoseconds(nanos: u64) -> Duration {
-    // Get number of seconds.
-    let secs = nanos / NANOS_PER_SEC as u64;
-
-    // Get number of extra nanoseconds. This should always fit in a u32, but check anyway.
-    let subsec_nanos = nanos % NANOS_PER_SEC as u64;
-    assert!(subsec_nanos <= u32::MAX as u64);
-
-    Duration::new(secs, subsec_nanos as u32)
-}