mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
Auto merge of #11930 - nox:die-util-die, r=SimonSapin
Remove some util stuff <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11930) <!-- Reviewable:end -->
This commit is contained in:
commit
dcc4697dde
9 changed files with 34 additions and 41 deletions
|
@ -10,8 +10,9 @@
|
|||
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.
|
||||
|
@ -92,3 +93,15 @@ impl DelayedCompositionTimer {
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ use fragment::{InlineBlockFragmentInfo, SpecificFragmentInfo, UnscannedTextFragm
|
|||
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;
|
||||
|
@ -57,7 +58,6 @@ use table_wrapper::TableWrapperFlow;
|
|||
use text::TextRunScanner;
|
||||
use traversal::PostorderNodeMutTraversal;
|
||||
use url::Url;
|
||||
use util::linked_list;
|
||||
use util::opts;
|
||||
use wrapper::{TextContent, ThreadSafeLayoutNodeHelpers};
|
||||
|
||||
|
@ -1805,8 +1805,7 @@ pub fn strip_ignorable_whitespace_from_start(this: &mut LinkedList<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.
|
||||
|
|
|
@ -75,6 +75,7 @@ mod fragment;
|
|||
mod generated_content;
|
||||
pub mod incremental;
|
||||
mod inline;
|
||||
mod linked_list;
|
||||
mod list_item;
|
||||
mod model;
|
||||
mod multicol;
|
||||
|
|
|
@ -16,6 +16,7 @@ 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;
|
||||
|
@ -28,7 +29,6 @@ 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 {
|
||||
|
|
|
@ -12,8 +12,8 @@ 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.
|
||||
|
|
|
@ -19,12 +19,11 @@ 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;
|
||||
|
@ -408,3 +407,17 @@ fn enforce_range<T>(min: T, max: T, value: T) -> T where T: Ord {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ 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;
|
||||
|
@ -49,7 +48,6 @@ 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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue