mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Move util::range into its own crate
This commit is contained in:
parent
455ed0ae6d
commit
205336bf2e
21 changed files with 96 additions and 26 deletions
|
@ -52,6 +52,9 @@ path = "../msg"
|
|||
[dependencies.profile_traits]
|
||||
path = "../profile_traits"
|
||||
|
||||
[dependencies.range]
|
||||
path = "../range"
|
||||
|
||||
[dependencies.style]
|
||||
path = "../style"
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ use msg::constellation_msg::PipelineId;
|
|||
use net_traits::image::base::Image;
|
||||
use paint_context::PaintContext;
|
||||
use paint_thread::{PaintLayerContents, PaintLayer};
|
||||
use range::Range;
|
||||
use self::DisplayItem::*;
|
||||
use smallvec::SmallVec;
|
||||
use std::cmp::Ordering;
|
||||
|
@ -44,7 +45,6 @@ use util::geometry::MAX_RECT;
|
|||
use util::linked_list::prepend_from;
|
||||
use util::opts;
|
||||
use util::print_tree::PrintTree;
|
||||
use util::range::Range;
|
||||
use webrender_traits::WebGLContextId;
|
||||
|
||||
pub use style::dom::OpaqueNode;
|
||||
|
|
|
@ -59,6 +59,8 @@ extern crate net_traits;
|
|||
#[macro_use]
|
||||
extern crate profile_traits;
|
||||
extern crate rand;
|
||||
#[macro_use]
|
||||
extern crate range;
|
||||
extern crate rustc_serialize;
|
||||
extern crate serde;
|
||||
|
||||
|
@ -73,7 +75,6 @@ extern crate style_traits;
|
|||
extern crate time;
|
||||
extern crate unicode_script;
|
||||
extern crate url;
|
||||
#[macro_use]
|
||||
extern crate util;
|
||||
extern crate webrender_traits;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ use filters;
|
|||
use font_context::FontContext;
|
||||
use gfx_traits::{color, LayerKind};
|
||||
use net_traits::image::base::{Image, PixelFormat};
|
||||
use range::Range;
|
||||
use std::default::Default;
|
||||
use std::sync::Arc;
|
||||
use std::{f32, mem, ptr};
|
||||
|
@ -36,7 +37,6 @@ use text::TextRun;
|
|||
use text::glyph::CharIndex;
|
||||
use util::geometry::{self, MAX_RECT, PagePx, ScreenPx};
|
||||
use util::opts;
|
||||
use util::range::Range;
|
||||
|
||||
pub struct PaintContext<'a> {
|
||||
pub draw_target: DrawTarget,
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
use app_units::Au;
|
||||
use euclid::point::Point2D;
|
||||
use range::{self, EachIndex, Range, RangeIndex};
|
||||
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
|
||||
use simd::u32x4;
|
||||
use std::cmp::{Ordering, PartialOrd};
|
||||
use std::vec::Vec;
|
||||
use std::{fmt, mem, u16};
|
||||
use util::range::{self, EachIndex, Range, RangeIndex};
|
||||
use util::vec::*;
|
||||
|
||||
/// GlyphEntry is a port of Gecko's CompressedGlyph scheme for storing glyph data compactly.
|
||||
|
|
|
@ -34,11 +34,11 @@ use harfbuzz::{hb_glyph_position_t};
|
|||
use harfbuzz::{hb_position_t, hb_tag_t};
|
||||
use libc::{c_char, c_int, c_uint, c_void};
|
||||
use platform::font::FontTable;
|
||||
use range::Range;
|
||||
use std::{char, cmp, ptr};
|
||||
use text::glyph::{CharIndex, GlyphData, GlyphId, GlyphStore};
|
||||
use text::shaping::ShaperMethods;
|
||||
use text::util::{fixed_to_float, float_to_fixed, is_bidi_control};
|
||||
use util::range::Range;
|
||||
|
||||
macro_rules! hb_tag {
|
||||
($t1:expr, $t2:expr, $t3:expr, $t4:expr) => (
|
||||
|
|
|
@ -6,12 +6,12 @@ use app_units::Au;
|
|||
use font::{Font, FontHandleMethods, FontMetrics, IS_WHITESPACE_SHAPING_FLAG, RunMetrics};
|
||||
use font::{ShapingOptions};
|
||||
use platform::font_template::FontTemplateData;
|
||||
use range::Range;
|
||||
use std::cell::Cell;
|
||||
use std::cmp::{Ordering, max};
|
||||
use std::slice::Iter;
|
||||
use std::sync::Arc;
|
||||
use text::glyph::{CharIndex, GlyphStore};
|
||||
use util::range::Range;
|
||||
use util::vec::{Comparator, FullBinarySearchMethods};
|
||||
use webrender_traits;
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@ path = "../script"
|
|||
[dependencies.layout_traits]
|
||||
path = "../layout_traits"
|
||||
|
||||
[dependencies.range]
|
||||
path = "../range"
|
||||
|
||||
[dependencies.script_traits]
|
||||
path = "../script_traits"
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ use list_item::ListItemFlow;
|
|||
use model::{self, MaybeAuto, ToGfxMatrix};
|
||||
use net_traits::image::base::{Image, PixelFormat};
|
||||
use net_traits::image_cache_thread::UsePlaceholder;
|
||||
use range::Range;
|
||||
use std::default::Default;
|
||||
use std::sync::Arc;
|
||||
use std::{cmp, f32};
|
||||
|
@ -57,7 +58,6 @@ use style_traits::cursor::Cursor;
|
|||
use table_cell::CollapsedBordersForCell;
|
||||
use url::Url;
|
||||
use util::opts;
|
||||
use util::range::Range;
|
||||
|
||||
/// The logical width of an insertion point: at the moment, a one-pixel-wide line.
|
||||
const INSERTION_POINT_LOGICAL_WIDTH: Au = Au(1 * AU_PER_PX);
|
||||
|
|
|
@ -27,6 +27,7 @@ use model::{self, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, speci
|
|||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::image::base::{Image, ImageMetadata};
|
||||
use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
|
||||
use range::*;
|
||||
use rustc_serialize::{Encodable, Encoder};
|
||||
use script::dom::htmlcanvaselement::HTMLCanvasData;
|
||||
use std::borrow::ToOwned;
|
||||
|
@ -48,7 +49,6 @@ use text;
|
|||
use text::TextRunScanner;
|
||||
use url::Url;
|
||||
use util;
|
||||
use util::range::*;
|
||||
use util::str::slice_chars;
|
||||
use wrapper::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ use gfx::font_context::FontContext;
|
|||
use incremental::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, RESOLVE_GENERATED_CONTENT};
|
||||
use layout_debug;
|
||||
use model::IntrinsicISizesContribution;
|
||||
use range::{Range, RangeIndex};
|
||||
use std::cmp::max;
|
||||
use std::collections::VecDeque;
|
||||
use std::sync::Arc;
|
||||
|
@ -34,7 +35,6 @@ use text;
|
|||
use unicode_bidi;
|
||||
use util;
|
||||
use util::print_tree::PrintTree;
|
||||
use util::range::{Range, RangeIndex};
|
||||
use wrapper::PseudoElementType;
|
||||
|
||||
// From gfxFontConstants.h in Firefox
|
||||
|
|
|
@ -43,6 +43,8 @@ extern crate net_traits;
|
|||
extern crate plugins as servo_plugins;
|
||||
#[macro_use]
|
||||
extern crate profile_traits;
|
||||
#[macro_use]
|
||||
extern crate range;
|
||||
extern crate rustc_serialize;
|
||||
extern crate script;
|
||||
extern crate script_traits;
|
||||
|
@ -57,7 +59,6 @@ extern crate time;
|
|||
extern crate unicode_bidi;
|
||||
extern crate unicode_script;
|
||||
extern crate url;
|
||||
#[macro_use]
|
||||
extern crate util;
|
||||
extern crate webrender_traits;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ use gfx::text::glyph::CharIndex;
|
|||
use gfx::text::text_run::TextRun;
|
||||
use gfx::text::util::{self, CompressionMode};
|
||||
use inline::InlineFragments;
|
||||
use range::{Range, RangeIndex};
|
||||
use std::borrow::ToOwned;
|
||||
use std::collections::LinkedList;
|
||||
use std::mem;
|
||||
|
@ -27,7 +28,6 @@ use style::properties::style_structs::Font as FontStyle;
|
|||
use unicode_bidi::{is_rtl, process_text};
|
||||
use unicode_script::{get_script, Script};
|
||||
use util::linked_list::split_off_head;
|
||||
use util::range::{Range, RangeIndex};
|
||||
|
||||
/// Returns the concatenated text of a list of unscanned text fragments.
|
||||
fn text(fragments: &LinkedList<Fragment>) -> String {
|
||||
|
|
17
components/range/Cargo.toml
Normal file
17
components/range/Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
|||
[package]
|
||||
|
||||
name = "range"
|
||||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
|
||||
[lib]
|
||||
name = "range"
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
heapsize = "0.3.0"
|
||||
heapsize_plugin = "0.1.2"
|
||||
num = "0.1.24"
|
||||
rustc-serialize = "0.3"
|
||||
serde = "0.6"
|
||||
serde_macros = "0.6"
|
|
@ -2,7 +2,19 @@
|
|||
* 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 num_lib;
|
||||
#![feature(custom_derive)]
|
||||
#![feature(plugin)]
|
||||
#![feature(step_trait)]
|
||||
#![feature(zero_one)]
|
||||
|
||||
#![plugin(heapsize_plugin)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate heapsize;
|
||||
extern crate num as num_lib;
|
||||
extern crate rustc_serialize;
|
||||
extern crate serde;
|
||||
|
||||
use std::cmp::{self, max, min};
|
||||
use std::fmt;
|
||||
use std::iter;
|
||||
|
@ -95,15 +107,15 @@ macro_rules! int_range_index {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::range::Int for $Self_ {
|
||||
impl $crate::Int for $Self_ {
|
||||
#[inline]
|
||||
fn zero() -> $Self_ { $Self_($crate::range::Int::zero()) }
|
||||
fn zero() -> $Self_ { $Self_($crate::Int::zero()) }
|
||||
#[inline]
|
||||
fn one() -> $Self_ { $Self_($crate::range::Int::one()) }
|
||||
fn one() -> $Self_ { $Self_($crate::Int::one()) }
|
||||
#[inline]
|
||||
fn max_value() -> $Self_ { $Self_($crate::range::Int::max_value()) }
|
||||
fn max_value() -> $Self_ { $Self_($crate::Int::max_value()) }
|
||||
#[inline]
|
||||
fn from_usize(n: usize) -> Option<$Self_> { $crate::range::Int::from_usize(n).map($Self_) }
|
||||
fn from_usize(n: usize) -> Option<$Self_> { $crate::Int::from_usize(n).map($Self_) }
|
||||
}
|
||||
|
||||
impl ::std::ops::Add<$Self_> for $Self_ {
|
15
components/servo/Cargo.lock
generated
15
components/servo/Cargo.lock
generated
|
@ -676,6 +676,7 @@ dependencies = [
|
|||
"plugins 0.0.1",
|
||||
"profile_traits 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"range 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1017,6 +1018,7 @@ dependencies = [
|
|||
"net_traits 0.0.1",
|
||||
"plugins 0.0.1",
|
||||
"profile_traits 0.0.1",
|
||||
"range 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
|
@ -1560,6 +1562,18 @@ dependencies = [
|
|||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "range"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heapsize_plugin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref_slice"
|
||||
version = "0.1.0"
|
||||
|
@ -2104,7 +2118,6 @@ dependencies = [
|
|||
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -38,7 +38,6 @@ heapsize_plugin = "0.1.2"
|
|||
lazy_static = "0.1"
|
||||
libc = "0.2"
|
||||
log = "0.3"
|
||||
num = "0.1.24"
|
||||
num_cpus = "0.2.2"
|
||||
rand = "0.3"
|
||||
rustc-serialize = "0.3"
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#![feature(plugin)]
|
||||
#![feature(reflect_marker)]
|
||||
#![feature(step_by)]
|
||||
#![feature(step_trait)]
|
||||
#![feature(zero_one)]
|
||||
|
||||
#![plugin(heapsize_plugin, plugins, serde_macros)]
|
||||
|
||||
|
@ -35,7 +33,6 @@ extern crate lazy_static;
|
|||
extern crate libc;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate num as num_lib;
|
||||
extern crate num_cpus;
|
||||
extern crate rand;
|
||||
extern crate rustc_serialize;
|
||||
|
@ -58,7 +55,6 @@ pub mod non_geckolib;
|
|||
pub mod opts;
|
||||
pub mod prefs;
|
||||
pub mod print_tree;
|
||||
pub mod range;
|
||||
pub mod resource_files;
|
||||
pub mod str;
|
||||
pub mod thread;
|
||||
|
|
15
ports/cef/Cargo.lock
generated
15
ports/cef/Cargo.lock
generated
|
@ -615,6 +615,7 @@ dependencies = [
|
|||
"plugins 0.0.1",
|
||||
"profile_traits 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"range 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -947,6 +948,7 @@ dependencies = [
|
|||
"net_traits 0.0.1",
|
||||
"plugins 0.0.1",
|
||||
"profile_traits 0.0.1",
|
||||
"range 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
|
@ -1446,6 +1448,18 @@ dependencies = [
|
|||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "range"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heapsize_plugin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref_slice"
|
||||
version = "0.1.0"
|
||||
|
@ -2001,7 +2015,6 @@ dependencies = [
|
|||
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
1
ports/geckolib/Cargo.lock
generated
1
ports/geckolib/Cargo.lock
generated
|
@ -541,7 +541,6 @@ dependencies = [
|
|||
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
15
ports/gonk/Cargo.lock
generated
15
ports/gonk/Cargo.lock
generated
|
@ -617,6 +617,7 @@ dependencies = [
|
|||
"plugins 0.0.1",
|
||||
"profile_traits 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"range 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -928,6 +929,7 @@ dependencies = [
|
|||
"net_traits 0.0.1",
|
||||
"plugins 0.0.1",
|
||||
"profile_traits 0.0.1",
|
||||
"range 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
|
@ -1427,6 +1429,18 @@ dependencies = [
|
|||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "range"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"heapsize_plugin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref_slice"
|
||||
version = "0.1.0"
|
||||
|
@ -1980,7 +1994,6 @@ dependencies = [
|
|||
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue