mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 17:25:36 +00:00
servo: Merge #2725 - Upgrade to latest Rust (from metajack:rustup-20140624)
Source-Repo: https://github.com/servo/servo Source-Revision: 52b5d2575c80d863e0c26143eefbce785cb0181a
This commit is contained in:
parent
7eeecb11b3
commit
8dd686694c
@ -1 +1 @@
|
||||
0935beba717bf6d3b54ad1b2eace359dea5dfca0/rust-0.11.0-pre
|
||||
9f8d2205f0518389993a9b5de6646ba8b14e5a12/rust-0.11.0-pre
|
||||
|
@ -2,7 +2,7 @@
|
||||
* 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 collections::hashmap::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use geom::size::Size2D;
|
||||
use layers::platform::surface::NativePaintingGraphicsContext;
|
||||
use servo_msg::compositor_msg::Tile;
|
||||
@ -26,7 +26,7 @@ pub struct BufferMap<T> {
|
||||
}
|
||||
|
||||
/// A key with which to store buffers. It is based on the size of the buffer.
|
||||
#[deriving(TotalEq)]
|
||||
#[deriving(Eq)]
|
||||
struct BufferKey([uint, ..2]);
|
||||
|
||||
impl Hash for BufferKey {
|
||||
@ -36,7 +36,7 @@ impl Hash for BufferKey {
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for BufferKey {
|
||||
impl PartialEq for BufferKey {
|
||||
fn eq(&self, other: &BufferKey) -> bool {
|
||||
let BufferKey(s) = *self;
|
||||
let BufferKey(o) = *other;
|
||||
|
@ -19,7 +19,7 @@ use render_context::RenderContext;
|
||||
use text::glyph::CharIndex;
|
||||
use text::TextRun;
|
||||
|
||||
use collections::deque::Deque;
|
||||
use std::collections::Deque;
|
||||
use collections::dlist::DList;
|
||||
use collections::dlist;
|
||||
use geom::{Point2D, Rect, SideOffsets2D, Size2D};
|
||||
@ -41,7 +41,7 @@ pub mod optimizer;
|
||||
/// Because the script task's GC does not trace layout, node data cannot be safely stored in layout
|
||||
/// data structures. Also, layout code tends to be faster when the DOM is not being accessed, for
|
||||
/// locality reasons. Using `OpaqueNode` enforces this invariant.
|
||||
#[deriving(Clone, Eq)]
|
||||
#[deriving(Clone, PartialEq)]
|
||||
pub struct OpaqueNode(pub uintptr_t);
|
||||
|
||||
impl OpaqueNode {
|
||||
@ -53,7 +53,7 @@ impl OpaqueNode {
|
||||
}
|
||||
|
||||
/// "Steps" as defined by CSS 2.1 § E.2.
|
||||
#[deriving(Clone, Eq)]
|
||||
#[deriving(Clone, PartialEq)]
|
||||
pub enum StackingLevel {
|
||||
/// The border and backgrounds for the root of this stacking context: steps 1 and 2.
|
||||
BackgroundAndBordersStackingLevel,
|
||||
|
@ -6,7 +6,7 @@ use display_list::{BorderDisplayItemClass, ClipDisplayItem, ClipDisplayItemClass
|
||||
use display_list::{DisplayList, ImageDisplayItemClass, LineDisplayItemClass};
|
||||
use display_list::{PseudoDisplayItemClass, SolidColorDisplayItemClass, TextDisplayItemClass};
|
||||
|
||||
use collections::deque::Deque;
|
||||
use std::collections::Deque;
|
||||
use collections::dlist::DList;
|
||||
use geom::rect::Rect;
|
||||
use servo_util::geometry::Au;
|
||||
|
@ -94,7 +94,7 @@ pub struct FontMetrics {
|
||||
// the instance's properties.
|
||||
//
|
||||
// For now, the cases are differentiated with a typedef
|
||||
#[deriving(Clone, Eq)]
|
||||
#[deriving(Clone, PartialEq)]
|
||||
pub struct FontStyle {
|
||||
pub pt_size: f64,
|
||||
pub weight: font_weight::T,
|
||||
@ -112,7 +112,7 @@ pub type UsedFontStyle = FontStyle;
|
||||
// It's used to swizzle/unswizzle gfx::Font instances when
|
||||
// communicating across tasks, such as the display list between layout
|
||||
// and render tasks.
|
||||
#[deriving(Clone, Eq)]
|
||||
#[deriving(Clone, PartialEq)]
|
||||
pub struct FontDescriptor {
|
||||
pub style: UsedFontStyle,
|
||||
pub selector: FontSelector,
|
||||
@ -128,7 +128,7 @@ impl FontDescriptor {
|
||||
}
|
||||
|
||||
// A FontSelector is a platform-specific strategy for serializing face names.
|
||||
#[deriving(Clone, Eq)]
|
||||
#[deriving(Clone, PartialEq)]
|
||||
pub enum FontSelector {
|
||||
SelectorPlatformIdentifier(String),
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use platform::font::FontHandle;
|
||||
use platform::font_context::FontContextHandle;
|
||||
|
||||
use azure::azure_hl::BackendType;
|
||||
use collections::hashmap::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use servo_util::cache::{Cache, LRUCache};
|
||||
use servo_util::time::TimeProfilerChan;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* 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 collections::hashmap::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use font::SpecifiedFontStyle;
|
||||
use gfx_font::FontHandleMethods;
|
||||
use platform::font::FontHandle;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#![feature(globs, macro_rules, phase)]
|
||||
|
||||
#![feature(phase)]
|
||||
#[phase(syntax, link)]
|
||||
#[phase(plugin, link)]
|
||||
extern crate log;
|
||||
|
||||
extern crate debug;
|
||||
@ -21,10 +21,10 @@ extern crate layers;
|
||||
extern crate libc;
|
||||
extern crate stb_image;
|
||||
extern crate png;
|
||||
#[phase(syntax)]
|
||||
#[phase(plugin)]
|
||||
extern crate servo_macros = "macros";
|
||||
extern crate servo_net = "net";
|
||||
#[phase(syntax, link)]
|
||||
#[phase(plugin, link)]
|
||||
extern crate servo_util = "util";
|
||||
extern crate servo_msg = "msg";
|
||||
extern crate style;
|
||||
|
@ -25,7 +25,7 @@ use font_list::{FontEntry, FontFamily, FontFamilyMap};
|
||||
use platform::font::FontHandle;
|
||||
use platform::font_context::FontContextHandle;
|
||||
|
||||
use collections::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use libc;
|
||||
use libc::{c_int, c_char};
|
||||
use std::ptr;
|
||||
|
@ -27,7 +27,7 @@ use font_list::{FontEntry, FontFamily, FontFamilyMap};
|
||||
use platform::font::FontHandle;
|
||||
use platform::font_context::FontContextHandle;
|
||||
|
||||
use collections::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use libc;
|
||||
use libc::{c_int, c_char};
|
||||
use std::ptr;
|
||||
|
@ -7,7 +7,7 @@ use font_list::{FontEntry, FontFamily, FontFamilyMap};
|
||||
use platform::macos::font::FontHandle;
|
||||
use platform::macos::font_context::FontContextHandle;
|
||||
|
||||
use collections::hashmap::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use core_foundation::base::TCFType;
|
||||
use core_foundation::string::{CFString, CFStringRef};
|
||||
use core_text::font_descriptor::{CTFontDescriptor, CTFontDescriptorRef};
|
||||
|
@ -7,7 +7,7 @@ use servo_util::range;
|
||||
use servo_util::range::{Range, RangeIndex, IntRangeIndex, EachIndex};
|
||||
use servo_util::geometry::Au;
|
||||
|
||||
use std::cmp::{Ord, Eq};
|
||||
use std::cmp::{PartialOrd, PartialEq};
|
||||
use std::num::{NumCast, Zero};
|
||||
use std::mem;
|
||||
use std::u16;
|
||||
@ -87,7 +87,7 @@ impl GlyphEntry {
|
||||
pub type GlyphId = u32;
|
||||
|
||||
// TODO: unify with bit flags?
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub enum BreakType {
|
||||
BreakTypeNone,
|
||||
BreakTypeNormal,
|
||||
@ -270,7 +270,7 @@ impl DetailedGlyph {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone, TotalEq)]
|
||||
#[deriving(PartialEq, Clone, Eq)]
|
||||
struct DetailedGlyphRecord {
|
||||
// source string offset/GlyphEntry offset in the TextRun
|
||||
entry_offset: CharIndex,
|
||||
@ -278,13 +278,13 @@ struct DetailedGlyphRecord {
|
||||
detail_offset: int,
|
||||
}
|
||||
|
||||
impl Ord for DetailedGlyphRecord {
|
||||
impl PartialOrd for DetailedGlyphRecord {
|
||||
fn lt(&self, other: &DetailedGlyphRecord) -> bool {
|
||||
self.entry_offset < other.entry_offset
|
||||
}
|
||||
}
|
||||
|
||||
impl TotalOrd for DetailedGlyphRecord {
|
||||
impl Ord for DetailedGlyphRecord {
|
||||
fn cmp(&self, other: &DetailedGlyphRecord) -> Ordering {
|
||||
self.entry_offset.cmp(&other.entry_offset)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use text::glyph::CharIndex;
|
||||
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub enum CompressionMode {
|
||||
CompressNone,
|
||||
CompressWhitespace,
|
||||
@ -82,7 +82,7 @@ pub fn transform_text(text: &str, mode: CompressionMode,
|
||||
}
|
||||
};
|
||||
|
||||
return (out_str.into_owned(), out_whitespace);
|
||||
return (out_str.into_string(), out_whitespace);
|
||||
|
||||
fn is_in_whitespace(ch: char, mode: CompressionMode) -> bool {
|
||||
match (ch, mode) {
|
||||
|
@ -61,14 +61,13 @@ macro_rules! lazy_init(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
extern crate collections;
|
||||
|
||||
use std::collections::hashmap::HashMap;
|
||||
lazy_init! {
|
||||
static ref NUMBER: uint = times_two(3);
|
||||
static ref VEC: [Box<uint>, ..3] = [box 1, box 2, box 3];
|
||||
static ref OWNED_STRING: String = "hello".to_string();
|
||||
static ref HASHMAP: collections::HashMap<uint, &'static str> = {
|
||||
let mut m = collections::HashMap::new();
|
||||
static ref HASHMAP: HashMap<uint, &'static str> = {
|
||||
let mut m = HashMap::new();
|
||||
m.insert(0u, "abc");
|
||||
m.insert(1, "def");
|
||||
m.insert(2, "ghi");
|
||||
|
@ -386,9 +386,10 @@ impl IOCompositor {
|
||||
|
||||
self.root_layer.remove_all_children();
|
||||
|
||||
let new_layer_id = new_layer.id;
|
||||
assert!(new_layer.add_child_if_necessary(self.root_layer.clone(),
|
||||
root_pipeline_id,
|
||||
new_layer.id,
|
||||
new_layer_id,
|
||||
layer_id,
|
||||
Rect(Point2D(0f32, 0f32), size),
|
||||
size,
|
||||
@ -414,13 +415,14 @@ impl IOCompositor {
|
||||
scroll_policy: ScrollPolicy) {
|
||||
match self.compositor_layer {
|
||||
Some(ref mut compositor_layer) => {
|
||||
let compositor_layer_id = compositor_layer.id;
|
||||
let page_size = compositor_layer.page_size.unwrap();
|
||||
assert!(compositor_layer.add_child_if_necessary(self.root_layer.clone(),
|
||||
pipeline_id,
|
||||
compositor_layer.id,
|
||||
compositor_layer_id,
|
||||
layer_id,
|
||||
rect,
|
||||
compositor_layer.page_size
|
||||
.unwrap(),
|
||||
page_size,
|
||||
scroll_policy))
|
||||
}
|
||||
None => fail!("Compositor: Received new layer without initialized pipeline"),
|
||||
|
@ -122,7 +122,7 @@ impl MaybeQuadtree {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum WantsScrollEventsFlag {
|
||||
WantsScrollEvents,
|
||||
DoesntWantScrollEvents,
|
||||
@ -345,8 +345,8 @@ impl CompositorLayer {
|
||||
if old_origin - self.scroll_offset == TypedPoint2D(0f32, 0f32) {
|
||||
return false
|
||||
}
|
||||
|
||||
self.scroll(self.scroll_offset)
|
||||
let offset = self.scroll_offset;
|
||||
self.scroll(offset)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
@ -616,8 +616,8 @@ impl CompositorLayer {
|
||||
if old_origin - self.scroll_offset == TypedPoint2D(0f32, 0f32) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.scroll(self.scroll_offset)
|
||||
let offset = self.scroll_offset;
|
||||
self.scroll(offset)
|
||||
}
|
||||
|
||||
// Returns whether the layer should be vertically flipped.
|
||||
|
@ -52,7 +52,7 @@ struct QuadtreeNode<T> {
|
||||
|
||||
/// The status of a QuadtreeNode. This determines the behavior of the node
|
||||
/// when querying for tile requests.
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub enum NodeStatus {
|
||||
/// If we have no valid tile, request one; otherwise, don't send a request.
|
||||
Normal,
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use compositing::{CompositorChan, LoadComplete, SetIds, SetLayerClipRect, ShutdownComplete};
|
||||
|
||||
use collections::hashmap::{HashMap, HashSet};
|
||||
use std::collections::hashmap::{HashMap, HashSet};
|
||||
use geom::rect::{Rect, TypedRect};
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use geom::size::TypedSize2D;
|
||||
|
@ -66,7 +66,7 @@ impl ApplicableDeclarationsCacheEntry {
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for ApplicableDeclarationsCacheEntry {
|
||||
impl PartialEq for ApplicableDeclarationsCacheEntry {
|
||||
fn eq(&self, other: &ApplicableDeclarationsCacheEntry) -> bool {
|
||||
let this_as_query = ApplicableDeclarationsCacheQuery::new(self.declarations.as_slice());
|
||||
this_as_query.equiv(other)
|
||||
@ -169,7 +169,7 @@ pub struct StyleSharingCandidate {
|
||||
pub class: Option<DOMString>,
|
||||
}
|
||||
|
||||
impl Eq for StyleSharingCandidate {
|
||||
impl PartialEq for StyleSharingCandidate {
|
||||
fn eq(&self, other: &StyleSharingCandidate) -> bool {
|
||||
arc_ptr_eq(&self.style, &other.style) &&
|
||||
arc_ptr_eq(&self.parent_style, &other.parent_style) &&
|
||||
|
@ -449,13 +449,13 @@ enum BlockType {
|
||||
FloatNonReplacedType,
|
||||
}
|
||||
|
||||
#[deriving(Clone, Eq)]
|
||||
#[deriving(Clone, PartialEq)]
|
||||
pub enum MarginsMayCollapseFlag {
|
||||
MarginsMayCollapse,
|
||||
MarginsMayNotCollapse,
|
||||
}
|
||||
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
enum FormattingContextType {
|
||||
NonformattingContext,
|
||||
BlockFormattingContext,
|
||||
|
@ -380,7 +380,7 @@ pub trait MutableOwnedFlowUtils {
|
||||
fn set_abs_descendants(&mut self, abs_descendants: AbsDescendants);
|
||||
}
|
||||
|
||||
#[deriving(Eq, Show)]
|
||||
#[deriving(PartialEq, Show)]
|
||||
pub enum FlowClass {
|
||||
BlockFlowClass,
|
||||
InlineFlowClass,
|
||||
|
@ -82,7 +82,7 @@ unsafe fn link_with_prev(mut next: FlowRef, prev: Option<FlowRef>) -> Link {
|
||||
Some(next)
|
||||
}
|
||||
|
||||
impl Container for FlowList {
|
||||
impl Collection for FlowList {
|
||||
/// O(1)
|
||||
#[inline]
|
||||
fn is_empty(&self) -> bool {
|
||||
|
@ -151,7 +151,7 @@ int_range_index! {
|
||||
/// A line index consists of two indices: a fragment index that refers to the
|
||||
/// index of a DOM fragment within a flattened inline element; and a glyph index
|
||||
/// where the 0th glyph refers to the first glyph of that fragment.
|
||||
#[deriving(Clone, Eq, Ord, TotalEq, TotalOrd, Zero)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Zero)]
|
||||
pub struct LineIndices {
|
||||
/// The index of a fragment into the flattened vector of DOM elements.
|
||||
///
|
||||
@ -1109,9 +1109,10 @@ impl Flow for InlineFlow {
|
||||
debug!("InlineFlow::assign_widths: floats in: {:?}", self.base.floats);
|
||||
|
||||
{
|
||||
let width = self.base.position.size.width;
|
||||
let this = &mut *self;
|
||||
for (fragment, context) in this.fragments.mut_iter() {
|
||||
fragment.assign_replaced_width_if_necessary(self.base.position.size.width,
|
||||
fragment.assign_replaced_width_if_necessary(width,
|
||||
Some(context))
|
||||
}
|
||||
}
|
||||
|
@ -895,7 +895,7 @@ impl LayoutTask {
|
||||
// to the script task, and ultimately cause the image to be
|
||||
// re-requested. We probably don't need to go all the way back to
|
||||
// the script task for this.
|
||||
fn make_on_image_available_cb(&self) -> Box<ImageResponder:Send> {
|
||||
fn make_on_image_available_cb(&self) -> Box<ImageResponder+Send> {
|
||||
// This has a crazy signature because the image cache needs to
|
||||
// make multiple copies of the callback, and the dom event
|
||||
// channel is not a copyable type, so this is actually a
|
||||
@ -903,7 +903,7 @@ impl LayoutTask {
|
||||
box LayoutImageResponder {
|
||||
id: self.id.clone(),
|
||||
script_chan: self.script_chan.clone(),
|
||||
} as Box<ImageResponder:Send>
|
||||
} as Box<ImageResponder+Send>
|
||||
}
|
||||
|
||||
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* task
|
||||
|
@ -219,7 +219,7 @@ impl TextRunScanner {
|
||||
let run = if clump.length() != CharIndex(0) && run_str.len() > 0 {
|
||||
Some(Arc::new(box TextRun::new(
|
||||
&mut *fontgroup.borrow().fonts.get(0).borrow_mut(),
|
||||
run_str.into_owned(), decoration)))
|
||||
run_str.to_string(), decoration)))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -150,7 +150,7 @@ impl<'ln> Clone for LayoutNode<'ln> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Eq for LayoutNode<'a> {
|
||||
impl<'a> PartialEq for LayoutNode<'a> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &LayoutNode) -> bool {
|
||||
self.node == other.node
|
||||
@ -407,7 +407,7 @@ fn get_content(content_list: &content::T) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum PseudoElementType {
|
||||
Normal,
|
||||
Before,
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#![feature(globs, macro_rules, phase, thread_local)]
|
||||
|
||||
#[phase(syntax, link)]
|
||||
#[phase(plugin, link)]
|
||||
extern crate log;
|
||||
|
||||
extern crate debug;
|
||||
@ -27,11 +27,11 @@ extern crate opengles;
|
||||
extern crate png;
|
||||
extern crate rustuv;
|
||||
extern crate script;
|
||||
#[phase(syntax)]
|
||||
#[phase(plugin)]
|
||||
extern crate servo_macros = "macros";
|
||||
extern crate servo_net = "net";
|
||||
extern crate servo_msg = "msg";
|
||||
#[phase(syntax, link)]
|
||||
#[phase(plugin, link)]
|
||||
extern crate servo_util = "util";
|
||||
extern crate style;
|
||||
extern crate sharegl;
|
||||
@ -41,6 +41,7 @@ extern crate collections;
|
||||
extern crate green;
|
||||
extern crate libc;
|
||||
extern crate native;
|
||||
extern crate rustrt;
|
||||
extern crate serialize;
|
||||
extern crate sync;
|
||||
extern crate time;
|
||||
@ -78,7 +79,7 @@ use std::os;
|
||||
#[cfg(not(test), target_os="android")]
|
||||
use std::str;
|
||||
#[cfg(not(test))]
|
||||
use std::task::TaskOpts;
|
||||
use rustrt::task::TaskOpts;
|
||||
#[cfg(not(test))]
|
||||
use url::Url;
|
||||
|
||||
|
@ -48,13 +48,13 @@ impl LayerBufferSet {
|
||||
}
|
||||
|
||||
/// The status of the renderer.
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum RenderState {
|
||||
IdleRenderState,
|
||||
RenderingRenderState,
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum ReadyState {
|
||||
/// Informs the compositor that nothing has been done yet. Used for setting status
|
||||
Blank,
|
||||
@ -67,7 +67,7 @@ pub enum ReadyState {
|
||||
}
|
||||
|
||||
/// A newtype struct for denoting the age of messages; prevents race conditions.
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub struct Epoch(pub uint);
|
||||
|
||||
impl Epoch {
|
||||
@ -77,7 +77,7 @@ impl Epoch {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, Eq)]
|
||||
#[deriving(Clone, PartialEq)]
|
||||
pub struct LayerId(pub uint, pub uint);
|
||||
|
||||
impl Show for LayerId {
|
||||
@ -95,7 +95,7 @@ impl LayerId {
|
||||
}
|
||||
|
||||
/// The scrolling policy of a layer.
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub enum ScrollPolicy {
|
||||
/// These layers scroll when the parent receives a scrolling message.
|
||||
Scrollable,
|
||||
|
@ -22,7 +22,7 @@ impl ConstellationChan {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub enum IFrameSandboxState {
|
||||
IFrameSandboxed,
|
||||
IFrameUnsandboxed
|
||||
@ -62,20 +62,20 @@ pub enum Msg {
|
||||
}
|
||||
|
||||
/// Represents the two different ways to which a page can be navigated
|
||||
#[deriving(Clone, Eq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Hash)]
|
||||
pub enum NavigationType {
|
||||
Load, // entered or clicked on a url
|
||||
Navigate, // browser forward/back buttons
|
||||
}
|
||||
|
||||
#[deriving(Clone, Eq, Hash)]
|
||||
#[deriving(Clone, PartialEq, Hash)]
|
||||
pub enum NavigationDirection {
|
||||
Forward,
|
||||
Back,
|
||||
}
|
||||
|
||||
#[deriving(Clone, Eq, TotalEq, Hash, Encodable)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Encodable)]
|
||||
pub struct PipelineId(pub uint);
|
||||
|
||||
#[deriving(Clone, Eq, TotalEq, Hash, Encodable)]
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Encodable)]
|
||||
pub struct SubpageId(pub uint);
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use resource_task::{Metadata, Payload, Done, LoadResponse, LoadData, LoaderTask, start_sending_opt};
|
||||
|
||||
use collections::hashmap::HashSet;
|
||||
use std::collections::hashmap::HashSet;
|
||||
use http::client::{RequestWriter, NetworkStream};
|
||||
use http::headers::HeaderEnum;
|
||||
use std::io::Reader;
|
||||
|
@ -55,7 +55,7 @@ pub enum ImageResponseMsg {
|
||||
ImageFailed
|
||||
}
|
||||
|
||||
impl Eq for ImageResponseMsg {
|
||||
impl PartialEq for ImageResponseMsg {
|
||||
fn eq(&self, other: &ImageResponseMsg) -> bool {
|
||||
match (self, other) {
|
||||
(&ImageReady(..), &ImageReady(..)) => fail!("unimplemented comparison"),
|
||||
|
@ -32,7 +32,7 @@ pub fn LocalImageCache(image_cache_task: ImageCacheTask) -> LocalImageCache {
|
||||
pub struct LocalImageCache {
|
||||
image_cache_task: ImageCacheTask,
|
||||
round_number: uint,
|
||||
on_image_available: Option<Box<ImageResponder:Send>>,
|
||||
on_image_available: Option<Box<ImageResponder+Send>>,
|
||||
state_map: UrlMap<ImageState>
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ struct ImageState {
|
||||
impl LocalImageCache {
|
||||
/// The local cache will only do a single remote request for a given
|
||||
/// URL in each 'round'. Layout should call this each time it begins
|
||||
pub fn next_round(&mut self, on_image_available: Box<ImageResponder:Send>) {
|
||||
pub fn next_round(&mut self, on_image_available: Box<ImageResponder+Send>) {
|
||||
self.round_number += 1;
|
||||
self.on_image_available = Some(on_image_available);
|
||||
}
|
||||
@ -80,12 +80,13 @@ impl LocalImageCache {
|
||||
// FIXME: Should return a Future
|
||||
pub fn get_image(&mut self, url: &Url) -> Receiver<ImageResponseMsg> {
|
||||
{
|
||||
let round_number = self.round_number;
|
||||
let state = self.get_state(url);
|
||||
|
||||
// Save the previous round number for comparison
|
||||
let last_round = state.last_request_round;
|
||||
// Set the current round number for this image
|
||||
state.last_request_round = self.round_number;
|
||||
state.last_request_round = round_number;
|
||||
|
||||
match state.last_response {
|
||||
ImageReady(ref image) => {
|
||||
@ -94,7 +95,7 @@ impl LocalImageCache {
|
||||
return port;
|
||||
}
|
||||
ImageNotReady => {
|
||||
if last_round == self.round_number {
|
||||
if last_round == round_number {
|
||||
let (chan, port) = channel();
|
||||
chan.send(ImageNotReady);
|
||||
return port;
|
||||
|
@ -14,7 +14,7 @@ extern crate collections;
|
||||
extern crate geom;
|
||||
extern crate http;
|
||||
extern crate png;
|
||||
#[phase(syntax, link)]
|
||||
#[phase(plugin, link)]
|
||||
extern crate log;
|
||||
extern crate serialize;
|
||||
extern crate servo_util = "util";
|
||||
|
@ -108,7 +108,7 @@ pub struct LoadResponse {
|
||||
}
|
||||
|
||||
/// Messages sent in response to a `Load` message
|
||||
#[deriving(Eq,Show)]
|
||||
#[deriving(PartialEq,Show)]
|
||||
pub enum ProgressMsg {
|
||||
/// Binary data - there may be multiple of these
|
||||
Payload(Vec<u8>),
|
||||
|
@ -22,7 +22,7 @@ pub enum AttrSettingType {
|
||||
ReplacedAttr,
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone, Encodable)]
|
||||
#[deriving(PartialEq, Clone, Encodable)]
|
||||
pub enum AttrValue {
|
||||
StringAttrValue(DOMString),
|
||||
TokenListAttrValue(DOMString, Vec<(uint, uint)>),
|
||||
|
@ -24,7 +24,7 @@ pub enum ExceptionHandling {
|
||||
RethrowExceptions
|
||||
}
|
||||
|
||||
#[deriving(Clone,Eq,Encodable)]
|
||||
#[deriving(Clone,PartialEq,Encodable)]
|
||||
pub struct CallbackFunction {
|
||||
object: CallbackObject
|
||||
}
|
||||
@ -39,13 +39,13 @@ impl CallbackFunction {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone,Eq,Encodable)]
|
||||
#[deriving(Clone,PartialEq,Encodable)]
|
||||
pub struct CallbackInterface {
|
||||
object: CallbackObject
|
||||
}
|
||||
|
||||
#[allow(raw_pointer_deriving)]
|
||||
#[deriving(Clone,Eq,Encodable)]
|
||||
#[deriving(Clone,PartialEq,Encodable)]
|
||||
struct CallbackObject {
|
||||
callback: Traceable<*mut JSObject>,
|
||||
}
|
||||
|
@ -2707,7 +2707,7 @@ use js::jsapi::JSContext;
|
||||
use js::jsval::JSVal;
|
||||
|
||||
#[repr(uint)]
|
||||
#[deriving(Encodable, Eq)]
|
||||
#[deriving(Encodable, PartialEq)]
|
||||
pub enum valuelist {
|
||||
%s
|
||||
}
|
||||
@ -4756,7 +4756,7 @@ class CGCallback(CGClass):
|
||||
bases=[ClassBase(baseName)],
|
||||
constructors=self.getConstructors(),
|
||||
methods=realMethods+getters+setters,
|
||||
decorators="#[deriving(Eq,Clone,Encodable)]")
|
||||
decorators="#[deriving(PartialEq,Clone,Encodable)]")
|
||||
|
||||
def getConstructors(self):
|
||||
return [ClassConstructor(
|
||||
@ -5262,7 +5262,7 @@ class GlobalGenRoots():
|
||||
return CGList([
|
||||
CGGeneric(AUTOGENERATED_WARNING_COMMENT),
|
||||
CGGeneric("pub static MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength),
|
||||
CGNamespacedEnum('id', 'ID', protos, [0], deriving="Eq"),
|
||||
CGNamespacedEnum('id', 'ID', protos, [0], deriving="PartialEq"),
|
||||
])
|
||||
|
||||
|
||||
|
@ -228,7 +228,7 @@ impl ToJSValConvertible for DOMString {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub enum StringificationBehavior {
|
||||
Default,
|
||||
Empty,
|
||||
|
@ -63,7 +63,7 @@ pub struct Temporary<T> {
|
||||
js_ptr: *mut JSObject,
|
||||
}
|
||||
|
||||
impl<T> Eq for Temporary<T> {
|
||||
impl<T> PartialEq for Temporary<T> {
|
||||
fn eq(&self, other: &Temporary<T>) -> bool {
|
||||
self.inner == other.inner
|
||||
}
|
||||
@ -106,7 +106,7 @@ pub struct JS<T> {
|
||||
ptr: *T
|
||||
}
|
||||
|
||||
impl<T> Eq for JS<T> {
|
||||
impl<T> PartialEq for JS<T> {
|
||||
fn eq(&self, other: &JS<T>) -> bool {
|
||||
self.ptr == other.ptr
|
||||
}
|
||||
@ -455,7 +455,7 @@ impl<'a, T> Clone for JSRef<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> Eq for JSRef<'a, T> {
|
||||
impl<'a, T> PartialEq for JSRef<'a, T> {
|
||||
fn eq(&self, other: &JSRef<T>) -> bool {
|
||||
self.ptr == other.ptr
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use std::hash::{Hash, sip};
|
||||
use std::path::BytesContainer;
|
||||
use std::str;
|
||||
|
||||
#[deriving(Encodable,Clone,TotalEq,Eq)]
|
||||
#[deriving(Encodable,Clone,Eq,PartialEq)]
|
||||
pub struct ByteString(Vec<u8>);
|
||||
|
||||
impl ByteString {
|
||||
@ -66,7 +66,7 @@ impl ByteString {
|
||||
|
||||
pub fn is_field_value(&self) -> bool {
|
||||
// Classifications of characters necessary for the [CRLF] (SP|HT) rule
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
enum PreviousCharacter {
|
||||
Other,
|
||||
CR,
|
||||
|
@ -116,7 +116,7 @@ impl<T> DerefMut<T> for Untraceable<T> {
|
||||
///
|
||||
/// We always prefer this, in case the contained type ever changes to something that should be traced.
|
||||
/// See more details: mozilla#2662.
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub struct Traceable<T> {
|
||||
inner: T
|
||||
}
|
||||
|
@ -11,12 +11,12 @@ use dom::browsercontext;
|
||||
use dom::window;
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
use collections::hashmap::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use libc;
|
||||
use libc::c_uint;
|
||||
use std::cell::Cell;
|
||||
use std::cmp::Eq;
|
||||
use std::mem;
|
||||
use std::cmp::PartialEq;
|
||||
use std::ptr;
|
||||
use std::ptr::null;
|
||||
use std::slice;
|
||||
@ -383,7 +383,7 @@ pub fn reflect_dom_object<T: Reflectable>
|
||||
}
|
||||
|
||||
#[allow(raw_pointer_deriving)]
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub struct Reflector {
|
||||
object: Cell<*mut JSObject>,
|
||||
}
|
||||
@ -608,7 +608,7 @@ pub fn cx_for_dom_object<T: Reflectable>(obj: &T) -> *mut JSContext {
|
||||
|
||||
/// Check if an element name is valid. See http://www.w3.org/TR/xml/#NT-Name
|
||||
/// for details.
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub enum XMLName {
|
||||
QName,
|
||||
Name,
|
||||
|
@ -46,13 +46,13 @@ use servo_util::namespace;
|
||||
use servo_util::namespace::{Namespace, Null};
|
||||
use servo_util::str::{DOMString, null_str_as_empty_ref};
|
||||
|
||||
use collections::hashmap::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use js::jsapi::JSContext;
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use url::{Url, from_str};
|
||||
|
||||
#[deriving(Eq,Encodable)]
|
||||
#[deriving(PartialEq,Encodable)]
|
||||
pub enum IsHTMLDocument {
|
||||
HTMLDocument,
|
||||
NonHTMLDocument,
|
||||
|
@ -64,7 +64,7 @@ impl Reflectable for Element {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq,Encodable)]
|
||||
#[deriving(PartialEq,Encodable)]
|
||||
pub enum ElementTypeId {
|
||||
HTMLElementTypeId,
|
||||
HTMLAnchorElementTypeId,
|
||||
@ -773,9 +773,9 @@ pub fn get_attribute_parts(name: DOMString) -> (Option<String>, String) {
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods:> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods+> {
|
||||
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
||||
Some(node as &VirtualMethods:)
|
||||
Some(node as &VirtualMethods+)
|
||||
}
|
||||
|
||||
fn after_set_attr(&self, name: DOMString, value: DOMString) {
|
||||
|
@ -35,7 +35,7 @@ pub enum EventPhase {
|
||||
PhaseBubbling = EventConstants::BUBBLING_PHASE,
|
||||
}
|
||||
|
||||
#[deriving(Eq, Encodable)]
|
||||
#[deriving(PartialEq, Encodable)]
|
||||
pub enum EventTypeId {
|
||||
CustomEventTypeId,
|
||||
HTMLEventTypeId,
|
||||
|
@ -22,22 +22,22 @@ use std::cell::RefCell;
|
||||
use std::ptr;
|
||||
use url::Url;
|
||||
|
||||
use collections::hashmap::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
|
||||
#[deriving(Eq,Encodable)]
|
||||
#[deriving(PartialEq,Encodable)]
|
||||
pub enum ListenerPhase {
|
||||
Capturing,
|
||||
Bubbling,
|
||||
}
|
||||
|
||||
#[deriving(Eq,Encodable)]
|
||||
#[deriving(PartialEq,Encodable)]
|
||||
pub enum EventTargetTypeId {
|
||||
NodeTargetTypeId(NodeTypeId),
|
||||
WindowTypeId,
|
||||
XMLHttpRequestTargetTypeId(XMLHttpRequestId)
|
||||
}
|
||||
|
||||
#[deriving(Eq, Encodable)]
|
||||
#[deriving(PartialEq, Encodable)]
|
||||
pub enum EventListenerType {
|
||||
Additive(EventListener),
|
||||
Inline(EventListener),
|
||||
@ -51,7 +51,7 @@ impl EventListenerType {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq,Encodable)]
|
||||
#[deriving(PartialEq,Encodable)]
|
||||
pub struct EventListenerEntry {
|
||||
pub phase: ListenerPhase,
|
||||
pub listener: EventListenerType
|
||||
@ -281,7 +281,7 @@ impl Reflectable for EventTarget {
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, EventTarget> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods:> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods+> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use dom::htmlformelement::HTMLFormElement;
|
||||
use dom::window::Window;
|
||||
use servo_util::str::DOMString;
|
||||
use std::cell::RefCell;
|
||||
use collections::hashmap::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
|
||||
#[deriving(Encodable, Clone)]
|
||||
pub enum FormDatum {
|
||||
@ -120,4 +120,4 @@ impl PrivateFormDataHelpers for FormData {
|
||||
let name = filename.unwrap_or(f.map(|inner| inner.name.clone()).unwrap_or("blob".to_string()));
|
||||
File::new(&*global, value, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,9 +68,9 @@ impl<'a> PrivateHTMLAnchorElementHelpers for JSRef<'a, HTMLAnchorElement> {
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLAnchorElement> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods:> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods+> {
|
||||
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self);
|
||||
Some(htmlelement as &VirtualMethods:)
|
||||
Some(htmlelement as &VirtualMethods+)
|
||||
}
|
||||
|
||||
fn handle_event(&self, event: &JSRef<Event>) {
|
||||
|
@ -59,9 +59,9 @@ impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> {
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods:> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods+> {
|
||||
let element: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self);
|
||||
Some(element as &VirtualMethods:)
|
||||
Some(element as &VirtualMethods+)
|
||||
}
|
||||
|
||||
fn after_set_attr(&self, name: DOMString, value: DOMString) {
|
||||
|
@ -135,10 +135,10 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
|
||||
Live(ref root, ref filter) => {
|
||||
let root = root.root();
|
||||
root.deref().traverse_preorder()
|
||||
.count(|child| {
|
||||
.filter(|&child| {
|
||||
let elem: Option<&JSRef<Element>> = ElementCast::to_ref(&child);
|
||||
elem.map_or(false, |elem| filter.filter(elem, &*root))
|
||||
}) as u32
|
||||
}).count() as u32
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,9 +93,9 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods:> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods+> {
|
||||
let element: &JSRef<Element> = ElementCast::from_ref(self);
|
||||
Some(element as &VirtualMethods:)
|
||||
Some(element as &VirtualMethods+)
|
||||
}
|
||||
|
||||
fn after_set_attr(&self, name: DOMString, value: DOMString) {
|
||||
|
@ -136,9 +136,9 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods:> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods+> {
|
||||
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self);
|
||||
Some(htmlelement as &VirtualMethods:)
|
||||
Some(htmlelement as &VirtualMethods+)
|
||||
}
|
||||
|
||||
fn after_set_attr(&self, name: DOMString, value: DOMString) {
|
||||
|
@ -240,9 +240,9 @@ impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> {
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods:> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods+> {
|
||||
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self);
|
||||
Some(htmlelement as &VirtualMethods:)
|
||||
Some(htmlelement as &VirtualMethods+)
|
||||
}
|
||||
|
||||
fn after_set_attr(&self, name: DOMString, value: DOMString) {
|
||||
|
@ -85,9 +85,9 @@ impl<'a> HTMLObjectElementMethods for JSRef<'a, HTMLObjectElement> {
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLObjectElement> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods:> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods+> {
|
||||
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self);
|
||||
Some(htmlelement as &VirtualMethods:)
|
||||
Some(htmlelement as &VirtualMethods+)
|
||||
}
|
||||
|
||||
fn after_set_attr(&self, name: DOMString, value: DOMString) {
|
||||
|
@ -22,9 +22,9 @@ use dom::text::Text;
|
||||
pub fn serialize(iterator: &mut NodeIterator) -> String {
|
||||
let mut html = String::new();
|
||||
let mut open_elements: Vec<String> = vec!();
|
||||
|
||||
let depth = iterator.depth;
|
||||
for node in *iterator {
|
||||
while open_elements.len() > iterator.depth {
|
||||
while open_elements.len() > depth {
|
||||
html.push_str("</");
|
||||
html.push_str(open_elements.pop().unwrap().as_slice());
|
||||
html.push_str(">");
|
||||
|
@ -65,9 +65,9 @@ impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLStyleElement> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods:> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods+> {
|
||||
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_ref(self);
|
||||
Some(htmlelement as &VirtualMethods:)
|
||||
Some(htmlelement as &VirtualMethods+)
|
||||
}
|
||||
|
||||
fn child_inserted(&self, child: &JSRef<Node>) {
|
||||
|
@ -172,12 +172,6 @@ impl LayoutDataRef {
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn from_data<T>(data: Box<T>) -> LayoutDataRef {
|
||||
LayoutDataRef {
|
||||
data_cell: RefCell::new(Some(mem::transmute(data))),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if there is layout data present.
|
||||
#[inline]
|
||||
pub fn is_present(&self) -> bool {
|
||||
@ -225,7 +219,7 @@ impl LayoutDataRef {
|
||||
pub trait TLayoutData {}
|
||||
|
||||
/// The different types of nodes.
|
||||
#[deriving(Eq,Encodable)]
|
||||
#[deriving(PartialEq,Encodable)]
|
||||
pub enum NodeTypeId {
|
||||
DoctypeNodeTypeId,
|
||||
DocumentFragmentNodeTypeId,
|
||||
@ -901,7 +895,7 @@ fn gather_abstract_nodes<'a>(cur: &JSRef<'a, Node>, refs: &mut Vec<JSRef<'a, Nod
|
||||
}
|
||||
|
||||
/// Specifies whether children must be recursively cloned or not.
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub enum CloneChildrenFlag {
|
||||
CloneChildren,
|
||||
DoNotCloneChildren
|
||||
@ -1024,13 +1018,13 @@ impl Node {
|
||||
if node.children().any(|c| c.is_text()) {
|
||||
return Err(HierarchyRequest);
|
||||
}
|
||||
match node.child_elements().len() {
|
||||
match node.child_elements().count() {
|
||||
0 => (),
|
||||
// Step 6.1.2
|
||||
1 => {
|
||||
// FIXME: change to empty() when https://github.com/mozilla/rust/issues/11218
|
||||
// will be fixed
|
||||
if parent.child_elements().len() > 0 {
|
||||
if parent.child_elements().count() > 0 {
|
||||
return Err(HierarchyRequest);
|
||||
}
|
||||
match child {
|
||||
@ -1049,7 +1043,7 @@ impl Node {
|
||||
ElementNodeTypeId(_) => {
|
||||
// FIXME: change to empty() when https://github.com/mozilla/rust/issues/11218
|
||||
// will be fixed
|
||||
if parent.child_elements().len() > 0 {
|
||||
if parent.child_elements().count() > 0 {
|
||||
return Err(HierarchyRequest);
|
||||
}
|
||||
match child {
|
||||
@ -1076,7 +1070,7 @@ impl Node {
|
||||
None => {
|
||||
// FIXME: change to empty() when https://github.com/mozilla/rust/issues/11218
|
||||
// will be fixed
|
||||
if parent.child_elements().len() > 0 {
|
||||
if parent.child_elements().count() > 0 {
|
||||
return Err(HierarchyRequest);
|
||||
}
|
||||
},
|
||||
@ -1649,7 +1643,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||
if node.children().any(|c| c.is_text()) {
|
||||
return Err(HierarchyRequest);
|
||||
}
|
||||
match node.child_elements().len() {
|
||||
match node.child_elements().count() {
|
||||
0 => (),
|
||||
// Step 6.1.2
|
||||
1 => {
|
||||
@ -1837,7 +1831,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||
}
|
||||
|
||||
// Step 5.
|
||||
if this.children().len() != node.children().len() {
|
||||
if this.children().count() != node.children().count() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1953,9 +1947,9 @@ pub fn window_from_node<T: NodeBase>(derived: &JSRef<T>) -> Temporary<Window> {
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, Node> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods:> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods+> {
|
||||
let eventtarget: &JSRef<EventTarget> = EventTargetCast::from_ref(self);
|
||||
Some(eventtarget as &VirtualMethods:)
|
||||
Some(eventtarget as &VirtualMethods+)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ impl<'a> NodeListMethods for JSRef<'a, NodeList> {
|
||||
Simple(ref elems) => elems.len() as u32,
|
||||
Children(ref node) => {
|
||||
let node = node.root();
|
||||
node.deref().children().len() as u32
|
||||
node.deref().children().count() as u32
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ use servo_util::str::DOMString;
|
||||
pub trait VirtualMethods {
|
||||
/// Returns self as the superclass of the implementation for this trait,
|
||||
/// if any.
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods:>;
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods+>;
|
||||
|
||||
/// Called when changing or adding attributes, after the attribute's value
|
||||
/// has been updated.
|
||||
@ -99,42 +99,42 @@ pub trait VirtualMethods {
|
||||
/// method call on the trait object will invoke the corresponding method on the
|
||||
/// concrete type, propagating up the parent hierarchy unless otherwise
|
||||
/// interrupted.
|
||||
pub fn vtable_for<'a>(node: &'a JSRef<Node>) -> &'a VirtualMethods: {
|
||||
pub fn vtable_for<'a>(node: &'a JSRef<Node>) -> &'a VirtualMethods+ {
|
||||
match node.type_id() {
|
||||
ElementNodeTypeId(HTMLAnchorElementTypeId) => {
|
||||
let element: &JSRef<HTMLAnchorElement> = HTMLAnchorElementCast::to_ref(node).unwrap();
|
||||
element as &VirtualMethods:
|
||||
element as &VirtualMethods+
|
||||
}
|
||||
ElementNodeTypeId(HTMLBodyElementTypeId) => {
|
||||
let element: &JSRef<HTMLBodyElement> = HTMLBodyElementCast::to_ref(node).unwrap();
|
||||
element as &VirtualMethods:
|
||||
element as &VirtualMethods+
|
||||
}
|
||||
ElementNodeTypeId(HTMLImageElementTypeId) => {
|
||||
let element: &JSRef<HTMLImageElement> = HTMLImageElementCast::to_ref(node).unwrap();
|
||||
element as &VirtualMethods:
|
||||
element as &VirtualMethods+
|
||||
}
|
||||
ElementNodeTypeId(HTMLIFrameElementTypeId) => {
|
||||
let element: &JSRef<HTMLIFrameElement> = HTMLIFrameElementCast::to_ref(node).unwrap();
|
||||
element as &VirtualMethods:
|
||||
element as &VirtualMethods+
|
||||
}
|
||||
ElementNodeTypeId(HTMLObjectElementTypeId) => {
|
||||
let element: &JSRef<HTMLObjectElement> = HTMLObjectElementCast::to_ref(node).unwrap();
|
||||
element as &VirtualMethods:
|
||||
element as &VirtualMethods+
|
||||
}
|
||||
ElementNodeTypeId(HTMLStyleElementTypeId) => {
|
||||
let element: &JSRef<HTMLStyleElement> = HTMLStyleElementCast::to_ref(node).unwrap();
|
||||
element as &VirtualMethods:
|
||||
element as &VirtualMethods+
|
||||
}
|
||||
ElementNodeTypeId(ElementTypeId) => {
|
||||
let element: &JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
||||
element as &VirtualMethods:
|
||||
element as &VirtualMethods+
|
||||
}
|
||||
ElementNodeTypeId(_) => {
|
||||
let element: &JSRef<HTMLElement> = HTMLElementCast::to_ref(node).unwrap();
|
||||
element as &VirtualMethods:
|
||||
element as &VirtualMethods+
|
||||
}
|
||||
_ => {
|
||||
node as &VirtualMethods:
|
||||
node as &VirtualMethods+
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ use js::jsapi::JSContext;
|
||||
use js::jsapi::{JS_GC, JS_GetRuntime};
|
||||
use js::jsval::JSVal;
|
||||
|
||||
use collections::hashmap::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::cmp;
|
||||
use std::comm::{channel, Sender};
|
||||
@ -43,7 +43,7 @@ use time;
|
||||
use serialize::{Encoder, Encodable};
|
||||
use url::Url;
|
||||
|
||||
#[deriving(Eq, Encodable, TotalEq)]
|
||||
#[deriving(PartialEq, Encodable, Eq)]
|
||||
pub struct TimerId(i32);
|
||||
|
||||
#[deriving(Encodable)]
|
||||
|
@ -61,13 +61,13 @@ use url::Url;
|
||||
// use SendParam = dom::bindings::codegen::UnionTypes::StringOrFormData;
|
||||
pub type SendParam = DOMString;
|
||||
|
||||
#[deriving(Eq,Encodable)]
|
||||
#[deriving(PartialEq,Encodable)]
|
||||
pub enum XMLHttpRequestId {
|
||||
XMLHttpRequestTypeId,
|
||||
XMLHttpRequestUploadTypeId
|
||||
}
|
||||
|
||||
#[deriving(Eq, Encodable)]
|
||||
#[deriving(PartialEq, Encodable)]
|
||||
enum XMLHttpRequestState {
|
||||
Unsent = 0u16,
|
||||
Opened = 1u16,
|
||||
@ -889,7 +889,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
|
||||
self.timer.deref().borrow_mut().oneshot(0);
|
||||
}
|
||||
fn text_response(&self) -> DOMString {
|
||||
let mut encoding = UTF_8 as &Encoding:Send;
|
||||
let mut encoding = UTF_8 as &Encoding+Send;
|
||||
match self.response_headers.deref().borrow().content_type {
|
||||
Some(ref x) => {
|
||||
for &(ref name, ref value) in x.parameters.iter() {
|
||||
|
@ -87,7 +87,7 @@ pub struct HitTestResponse(pub UntrustedNodeAddress);
|
||||
pub struct MouseOverResponse(pub Vec<UntrustedNodeAddress>);
|
||||
|
||||
/// Determines which part of the
|
||||
#[deriving(Eq, Ord, TotalEq, TotalOrd, Encodable)]
|
||||
#[deriving(PartialEq, PartialOrd, Eq, Ord, Encodable)]
|
||||
pub enum DocumentDamageLevel {
|
||||
/// Reflow, but do not perform CSS selector matching.
|
||||
ReflowDocumentDamage,
|
||||
@ -116,7 +116,7 @@ pub struct DocumentDamage {
|
||||
}
|
||||
|
||||
/// Why we're doing reflow.
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub enum ReflowGoal {
|
||||
/// We're reflowing in order to send a display list to the screen.
|
||||
ReflowForDisplay,
|
||||
|
@ -13,7 +13,10 @@
|
||||
#![feature(globs, macro_rules, struct_variant, phase)]
|
||||
|
||||
#![feature(phase)]
|
||||
#[phase(syntax, link)]
|
||||
|
||||
#![allow(non_snake_case_functions)]
|
||||
|
||||
#[phase(plugin, link)]
|
||||
extern crate log;
|
||||
|
||||
extern crate debug;
|
||||
@ -29,7 +32,7 @@ extern crate native;
|
||||
extern crate net;
|
||||
extern crate serialize;
|
||||
extern crate time;
|
||||
#[phase(syntax)]
|
||||
#[phase(plugin)]
|
||||
extern crate servo_macros = "macros";
|
||||
extern crate servo_net = "net";
|
||||
extern crate servo_util = "util";
|
||||
|
@ -36,7 +36,7 @@ pub enum MediaQueryType {
|
||||
MediaType(MediaType),
|
||||
}
|
||||
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
pub enum MediaType {
|
||||
Screen,
|
||||
Print,
|
||||
|
@ -3,7 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::ast::*;
|
||||
use collections::hashmap::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use servo_util::namespace::Namespace;
|
||||
use errors::log_css_error;
|
||||
|
||||
@ -36,7 +36,7 @@ pub fn parse_namespace_rule(rule: AtRule, namespaces: &mut NamespaceMap) {
|
||||
match component_value {
|
||||
Ident(value) => {
|
||||
if prefix.is_some() { syntax_error!() }
|
||||
prefix = Some(value.into_owned());
|
||||
prefix = Some(value.into_string());
|
||||
},
|
||||
URL(value) | String(value) => {
|
||||
if ns.is_some() { syntax_error!() }
|
||||
|
@ -205,7 +205,7 @@ pub mod computed {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum LengthOrPercentage {
|
||||
LP_Length(Au),
|
||||
LP_Percentage(CSSFloat),
|
||||
@ -218,7 +218,7 @@ pub mod computed {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum LengthOrPercentageOrAuto {
|
||||
LPA_Length(Au),
|
||||
LPA_Percentage(CSSFloat),
|
||||
@ -233,7 +233,7 @@ pub mod computed {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum LengthOrPercentageOrNone {
|
||||
LPN_Length(Au),
|
||||
LPN_Percentage(CSSFloat),
|
||||
|
@ -154,7 +154,7 @@ pub mod longhands {
|
||||
${caller.body()}
|
||||
pub mod computed_value {
|
||||
#[allow(non_camel_case_types)]
|
||||
#[deriving(Eq, Clone, FromPrimitive)]
|
||||
#[deriving(PartialEq, Clone, FromPrimitive)]
|
||||
pub enum T {
|
||||
% for value in values.split():
|
||||
${to_rust_ident(value)},
|
||||
@ -398,7 +398,7 @@ pub mod longhands {
|
||||
}
|
||||
pub mod computed_value {
|
||||
use super::super::{Au, CSSFloat};
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum T {
|
||||
Normal,
|
||||
Length(Au),
|
||||
@ -486,7 +486,7 @@ pub mod longhands {
|
||||
pub mod computed_value {
|
||||
use super::super::{Au, CSSFloat};
|
||||
#[allow(non_camel_case_types)]
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum T {
|
||||
% for keyword in vertical_align_keywords:
|
||||
${to_rust_ident(keyword)},
|
||||
@ -529,12 +529,12 @@ pub mod longhands {
|
||||
<%self:longhand name="content">
|
||||
pub use to_computed_value = super::computed_as_specified;
|
||||
pub mod computed_value {
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum Content {
|
||||
StringContent(String),
|
||||
}
|
||||
#[allow(non_camel_case_types)]
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum T {
|
||||
normal,
|
||||
none,
|
||||
@ -605,7 +605,7 @@ pub mod longhands {
|
||||
pub mod computed_value {
|
||||
use super::super::super::common_types::computed::LengthOrPercentage;
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub struct T {
|
||||
pub horizontal: LengthOrPercentage,
|
||||
pub vertical: LengthOrPercentage,
|
||||
@ -703,7 +703,7 @@ pub mod longhands {
|
||||
<%self:longhand name="font-family">
|
||||
pub use to_computed_value = super::computed_as_specified;
|
||||
pub mod computed_value {
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum FontFamily {
|
||||
FamilyName(String),
|
||||
// Generic
|
||||
@ -816,7 +816,7 @@ pub mod longhands {
|
||||
}
|
||||
}
|
||||
pub mod computed_value {
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum T {
|
||||
% for weight in range(100, 901, 100):
|
||||
Weight${weight},
|
||||
@ -905,7 +905,7 @@ pub mod longhands {
|
||||
|
||||
<%self:longhand name="text-decoration">
|
||||
pub use to_computed_value = super::computed_as_specified;
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub struct SpecifiedValue {
|
||||
pub underline: bool,
|
||||
pub overline: bool,
|
||||
@ -957,7 +957,7 @@ pub mod longhands {
|
||||
|
||||
pub use to_computed_value = super::computed_as_specified;
|
||||
|
||||
#[deriving(Clone, Eq)]
|
||||
#[deriving(Clone, PartialEq)]
|
||||
pub struct SpecifiedValue {
|
||||
pub underline: Option<RGBA>,
|
||||
pub overline: Option<RGBA>,
|
||||
@ -1562,7 +1562,7 @@ impl PropertyDeclaration {
|
||||
pub mod style_structs {
|
||||
use super::longhands;
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub struct ${style_struct.name} {
|
||||
% for longhand in style_struct.longhands:
|
||||
pub ${longhand.ident}: longhands::${longhand.ident}::computed_value::T,
|
||||
|
@ -2,11 +2,12 @@
|
||||
* 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 collections::hashmap::HashMap;
|
||||
use collections::hash::Writer;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::hash::Hash;
|
||||
use std::hash::sip::SipState;
|
||||
use num::div_rem;
|
||||
use std::num::div_rem;
|
||||
use sync::Arc;
|
||||
|
||||
use servo_util::namespace;
|
||||
@ -49,12 +50,12 @@ impl<'a> Hash for LowercaseAsciiString<'a> {
|
||||
// `Ascii` type's invariants by using `to_ascii_nocheck`, but it's OK as we simply
|
||||
// convert to a byte afterward.
|
||||
unsafe {
|
||||
state.write_u8(b.to_ascii_nocheck().to_lowercase().to_byte()).unwrap()
|
||||
state.write(&[b.to_ascii_nocheck().to_lowercase().to_byte()])
|
||||
};
|
||||
}
|
||||
// Terminate the string with a non-UTF-8 character, to match what the built-in string
|
||||
// `ToBytes` implementation does. (See `libstd/to_bytes.rs`.)
|
||||
state.write_u8(0xff).unwrap();
|
||||
state.write(&[0xff]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,7 +498,7 @@ impl MatchedProperty {
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for MatchedProperty {
|
||||
impl PartialEq for MatchedProperty {
|
||||
#[inline]
|
||||
fn eq(&self, other: &MatchedProperty) -> bool {
|
||||
let this_rank = (self.specificity, self.source_order);
|
||||
@ -506,7 +507,9 @@ impl Eq for MatchedProperty {
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for MatchedProperty {
|
||||
impl Eq for MatchedProperty {}
|
||||
|
||||
impl PartialOrd for MatchedProperty {
|
||||
#[inline]
|
||||
fn lt(&self, other: &MatchedProperty) -> bool {
|
||||
let this_rank = (self.specificity, self.source_order);
|
||||
@ -515,6 +518,15 @@ impl Ord for MatchedProperty {
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for MatchedProperty {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &MatchedProperty) -> Ordering {
|
||||
let this_rank = (self.specificity, self.source_order);
|
||||
let other_rank = (other.specificity, other.source_order);
|
||||
this_rank.cmp(&other_rank)
|
||||
}
|
||||
}
|
||||
|
||||
/// Determines whether the given element matches the given single or compound selector.
|
||||
///
|
||||
/// NB: If you add support for any new kinds of selectors to this routine, be sure to set
|
||||
|
@ -17,21 +17,21 @@ use namespaces::NamespaceMap;
|
||||
|
||||
|
||||
// Only used in tests
|
||||
impl Eq for Arc<CompoundSelector> {
|
||||
impl PartialEq for Arc<CompoundSelector> {
|
||||
fn eq(&self, other: &Arc<CompoundSelector>) -> bool {
|
||||
**self == **other
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub struct Selector {
|
||||
pub compound_selectors: Arc<CompoundSelector>,
|
||||
pub pseudo_element: Option<PseudoElement>,
|
||||
pub specificity: u32,
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum PseudoElement {
|
||||
Before,
|
||||
After,
|
||||
@ -40,13 +40,13 @@ pub enum PseudoElement {
|
||||
}
|
||||
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub struct CompoundSelector {
|
||||
pub simple_selectors: Vec<SimpleSelector>,
|
||||
pub next: Option<(Box<CompoundSelector>, Combinator)>, // c.next is left of c
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum Combinator {
|
||||
Child, // >
|
||||
Descendant, // space
|
||||
@ -54,7 +54,7 @@ pub enum Combinator {
|
||||
LaterSibling, // ~
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum SimpleSelector {
|
||||
IDSelector(String),
|
||||
ClassSelector(String),
|
||||
@ -90,14 +90,14 @@ pub enum SimpleSelector {
|
||||
// ...
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub struct AttrSelector {
|
||||
pub name: String,
|
||||
pub lower_name: String,
|
||||
pub namespace: NamespaceConstraint,
|
||||
}
|
||||
|
||||
#[deriving(Eq, Clone)]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
pub enum NamespaceConstraint {
|
||||
AnyNamespace,
|
||||
SpecificNamespace(Namespace),
|
||||
|
@ -13,7 +13,7 @@
|
||||
#![feature(globs, macro_rules)]
|
||||
|
||||
#![feature(phase)]
|
||||
#[phase(syntax, link)] extern crate log;
|
||||
#[phase(plugin, link)] extern crate log;
|
||||
|
||||
extern crate debug;
|
||||
extern crate collections;
|
||||
@ -25,7 +25,7 @@ extern crate url;
|
||||
extern crate cssparser;
|
||||
extern crate encoding;
|
||||
|
||||
#[phase(syntax)]
|
||||
#[phase(plugin)]
|
||||
extern crate servo_macros = "macros";
|
||||
extern crate servo_util = "util";
|
||||
|
||||
|
@ -2,16 +2,16 @@
|
||||
* 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 collections::HashMap;
|
||||
use rand;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use rand::Rng;
|
||||
use std::hash::{Hash, sip};
|
||||
use std::rand::task_rng;
|
||||
use std::slice::Items;
|
||||
|
||||
#[cfg(test)]
|
||||
use std::cell::Cell;
|
||||
|
||||
pub trait Cache<K: Eq, V: Clone> {
|
||||
pub trait Cache<K: PartialEq, V: Clone> {
|
||||
fn insert(&mut self, key: K, value: V);
|
||||
fn find(&mut self, key: &K) -> Option<V>;
|
||||
fn find_or_create(&mut self, key: &K, blk: |&K| -> V) -> V;
|
||||
@ -22,13 +22,13 @@ pub struct MonoCache<K, V> {
|
||||
entry: Option<(K,V)>,
|
||||
}
|
||||
|
||||
impl<K: Clone + Eq, V: Clone> MonoCache<K,V> {
|
||||
impl<K: Clone + PartialEq, V: Clone> MonoCache<K,V> {
|
||||
pub fn new(_size: uint) -> MonoCache<K,V> {
|
||||
MonoCache { entry: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + Eq, V: Clone> Cache<K,V> for MonoCache<K,V> {
|
||||
impl<K: Clone + PartialEq, V: Clone> Cache<K,V> for MonoCache<K,V> {
|
||||
fn insert(&mut self, key: K, value: V) {
|
||||
self.entry = Some((key, value));
|
||||
}
|
||||
@ -74,7 +74,7 @@ pub struct HashCache<K, V> {
|
||||
entries: HashMap<K, V>,
|
||||
}
|
||||
|
||||
impl<K: Clone + Eq + TotalEq + Hash, V: Clone> HashCache<K,V> {
|
||||
impl<K: Clone + PartialEq + Eq + Hash, V: Clone> HashCache<K,V> {
|
||||
pub fn new() -> HashCache<K, V> {
|
||||
HashCache {
|
||||
entries: HashMap::new(),
|
||||
@ -82,7 +82,7 @@ impl<K: Clone + Eq + TotalEq + Hash, V: Clone> HashCache<K,V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + Eq + TotalEq + Hash, V: Clone> Cache<K,V> for HashCache<K,V> {
|
||||
impl<K: Clone + PartialEq + Eq + Hash, V: Clone> Cache<K,V> for HashCache<K,V> {
|
||||
fn insert(&mut self, key: K, value: V) {
|
||||
self.entries.insert(key, value);
|
||||
}
|
||||
@ -123,7 +123,7 @@ pub struct LRUCache<K, V> {
|
||||
cache_size: uint,
|
||||
}
|
||||
|
||||
impl<K: Clone + Eq, V: Clone> LRUCache<K,V> {
|
||||
impl<K: Clone + PartialEq, V: Clone> LRUCache<K,V> {
|
||||
pub fn new(size: uint) -> LRUCache<K, V> {
|
||||
LRUCache {
|
||||
entries: vec!(),
|
||||
@ -146,7 +146,7 @@ impl<K: Clone + Eq, V: Clone> LRUCache<K,V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + Eq, V: Clone> Cache<K,V> for LRUCache<K,V> {
|
||||
impl<K: Clone + PartialEq, V: Clone> Cache<K,V> for LRUCache<K,V> {
|
||||
fn insert(&mut self, key: K, val: V) {
|
||||
if self.entries.len() == self.cache_size {
|
||||
self.entries.remove(0);
|
||||
@ -183,9 +183,9 @@ pub struct SimpleHashCache<K,V> {
|
||||
k1: u64,
|
||||
}
|
||||
|
||||
impl<K:Clone+Eq+Hash,V:Clone> SimpleHashCache<K,V> {
|
||||
impl<K:Clone+PartialEq+Hash,V:Clone> SimpleHashCache<K,V> {
|
||||
pub fn new(cache_size: uint) -> SimpleHashCache<K,V> {
|
||||
let mut r = rand::task_rng();
|
||||
let mut r = task_rng();
|
||||
SimpleHashCache {
|
||||
entries: Vec::from_elem(cache_size, None),
|
||||
k0: r.gen(),
|
||||
@ -213,7 +213,7 @@ impl<K:Clone+Eq+Hash,V:Clone> SimpleHashCache<K,V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K:Clone+Eq+Hash,V:Clone> Cache<K,V> for SimpleHashCache<K,V> {
|
||||
impl<K:Clone+PartialEq+Hash,V:Clone> Cache<K,V> for SimpleHashCache<K,V> {
|
||||
fn insert(&mut self, key: K, value: V) {
|
||||
let bucket_index = self.bucket_for_key(&key);
|
||||
*self.entries.get_mut(bucket_index) = Some((key, value));
|
||||
|
@ -64,7 +64,7 @@ pub enum PagePx {}
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=177805 for more info.
|
||||
//
|
||||
// FIXME: Implement Au using Length and ScaleFactor instead of a custom type.
|
||||
#[deriving(Clone, Eq, Ord, Zero)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Zero)]
|
||||
pub struct Au(pub i32);
|
||||
|
||||
impl Default for Au {
|
||||
@ -288,7 +288,7 @@ pub fn to_pt(au: Au) -> f64 {
|
||||
/// Returns true if the rect contains the given point. Points on the top or left sides of the rect
|
||||
/// are considered inside the rectangle, while points on the right or bottom sides of the rect are
|
||||
/// not considered inside the rectangle.
|
||||
pub fn rect_contains_point<T:Ord + Add<T,T>>(rect: Rect<T>, point: Point2D<T>) -> bool {
|
||||
pub fn rect_contains_point<T:PartialOrd + Add<T,T>>(rect: Rect<T>, point: Point2D<T>) -> bool {
|
||||
point.x >= rect.origin.x && point.x < rect.origin.x + rect.size.width &&
|
||||
point.y >= rect.origin.y && point.y < rect.origin.y + rect.size.height
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* 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/. */
|
||||
|
||||
#[deriving(Eq, Clone, Encodable)]
|
||||
#[deriving(PartialEq, Clone, Encodable)]
|
||||
pub enum Namespace {
|
||||
Null,
|
||||
HTML,
|
||||
|
@ -12,10 +12,10 @@ use std::num::{Bounded, Zero};
|
||||
pub trait RangeIndex: Copy
|
||||
+ Clone
|
||||
+ fmt::Show
|
||||
+ PartialEq
|
||||
+ PartialOrd
|
||||
+ Eq
|
||||
+ Ord
|
||||
+ TotalEq
|
||||
+ TotalOrd
|
||||
+ Add<Self, Self>
|
||||
+ Sub<Self, Self>
|
||||
+ Neg<Self>
|
||||
@ -40,7 +40,7 @@ impl IntRangeIndex<int> for int {
|
||||
#[macro_export]
|
||||
macro_rules! int_range_index {
|
||||
($(#[$attr:meta])* struct $Self:ident($T:ty)) => (
|
||||
#[deriving(Clone, Eq, Ord, TotalEq, TotalOrd, Show, Zero)]
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show, Zero)]
|
||||
$(#[$attr])*
|
||||
pub struct $Self(pub $T);
|
||||
|
||||
|
@ -11,7 +11,7 @@ use std::intrinsics;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::raw::Slice;
|
||||
use std::rt::local_heap;
|
||||
use rustrt::local_heap;
|
||||
use alloc::heap;
|
||||
|
||||
// Generic code for all small vectors
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
//! In-place sorting.
|
||||
|
||||
fn quicksort_helper<T:Ord + Eq>(arr: &mut [T], left: int, right: int) {
|
||||
fn quicksort_helper<T:Ord + Eq + PartialOrd + PartialEq>(arr: &mut [T], left: int, right: int) {
|
||||
if right <= left {
|
||||
return
|
||||
}
|
||||
@ -68,7 +68,7 @@ fn quicksort_helper<T:Ord + Eq>(arr: &mut [T], left: int, right: int) {
|
||||
///
|
||||
/// The algorithm is from Sedgewick and Bentley, "Quicksort is Optimal":
|
||||
/// http://www.cs.princeton.edu/~rs/talks/QuicksortIsOptimal.pdf
|
||||
pub fn quicksort<T:Ord + Eq>(arr: &mut [T]) {
|
||||
pub fn quicksort<T:Ord + Eq + PartialOrd + PartialEq>(arr: &mut [T]) {
|
||||
if arr.len() <= 1 {
|
||||
return
|
||||
}
|
||||
@ -79,8 +79,8 @@ pub fn quicksort<T:Ord + Eq>(arr: &mut [T]) {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
use rand;
|
||||
use rand::{Rng, task_rng};
|
||||
use std::rand;
|
||||
use std::rand::Rng;
|
||||
|
||||
use sort;
|
||||
|
||||
@ -89,7 +89,7 @@ pub mod test {
|
||||
let mut rng = rand::task_rng();
|
||||
for _ in range(0, 50000) {
|
||||
let len: uint = rng.gen();
|
||||
let mut v: Vec<int> = rng.gen_vec((len % 32) + 1).iter().map(|&x| x).collect();
|
||||
let mut v: Vec<int> = rng.gen_iter::<int>().take((len % 32) + 1).collect();
|
||||
sort::quicksort(v.as_mut_slice());
|
||||
for i in range(0, v.len() - 1) {
|
||||
assert!(v.get(i) <= v.get(i + 1))
|
||||
|
@ -33,7 +33,7 @@ pub enum TimeProfilerMsg {
|
||||
}
|
||||
|
||||
#[repr(u32)]
|
||||
#[deriving(Eq, Clone, Ord, TotalEq, TotalOrd)]
|
||||
#[deriving(PartialEq, Clone, PartialOrd, Eq, Ord)]
|
||||
pub enum TimeProfilerCategory {
|
||||
CompositingCategory,
|
||||
LayoutQueryCategory,
|
||||
|
@ -2,7 +2,7 @@
|
||||
* 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 collections::HashMap;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::os;
|
||||
use std_url;
|
||||
use std_url::Url;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#![feature(macro_rules)]
|
||||
|
||||
#![feature(phase)]
|
||||
#[phase(syntax, link)]
|
||||
#[phase(plugin, link)]
|
||||
extern crate log;
|
||||
|
||||
extern crate debug;
|
||||
@ -21,6 +21,7 @@ extern crate geom;
|
||||
extern crate getopts;
|
||||
extern crate native;
|
||||
extern crate rand;
|
||||
extern crate rustrt;
|
||||
extern crate serialize;
|
||||
extern crate sync;
|
||||
extern crate std_time = "time";
|
||||
|
@ -2,7 +2,7 @@
|
||||
* 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::cmp::{Ord, Eq};
|
||||
use std::cmp::{PartialOrd, PartialEq};
|
||||
|
||||
/// FIXME(pcwalton): Workaround for lack of unboxed closures. This is called in
|
||||
/// performance-critical code, so a closure is insufficient.
|
||||
@ -10,7 +10,7 @@ pub trait Comparator<K,T> {
|
||||
fn compare(&self, key: &K, value: &T) -> Ordering;
|
||||
}
|
||||
|
||||
pub trait BinarySearchMethods<'a, T: TotalOrd + Ord + Eq> {
|
||||
pub trait BinarySearchMethods<'a, T: Ord + PartialOrd + PartialEq> {
|
||||
fn binary_search(&self, key: &T) -> Option<&'a T>;
|
||||
fn binary_search_index(&self, key: &T) -> Option<uint>;
|
||||
}
|
||||
@ -19,7 +19,7 @@ pub trait FullBinarySearchMethods<T> {
|
||||
fn binary_search_index_by<K,C:Comparator<K,T>>(&self, key: &K, cmp: C) -> Option<uint>;
|
||||
}
|
||||
|
||||
impl<'a, T: TotalOrd + Ord + Eq> BinarySearchMethods<'a, T> for &'a [T] {
|
||||
impl<'a, T: Ord + PartialOrd + PartialEq> BinarySearchMethods<'a, T> for &'a [T] {
|
||||
fn binary_search(&self, key: &T) -> Option<&'a T> {
|
||||
self.binary_search_index(key).map(|i| &self[i])
|
||||
}
|
||||
@ -55,14 +55,14 @@ impl<'a, T> FullBinarySearchMethods<T> for &'a [T] {
|
||||
|
||||
struct DefaultComparator;
|
||||
|
||||
impl<T:Eq + Ord + TotalOrd> Comparator<T,T> for DefaultComparator {
|
||||
impl<T:PartialEq + PartialOrd + Ord> Comparator<T,T> for DefaultComparator {
|
||||
fn compare(&self, key: &T, value: &T) -> Ordering {
|
||||
(*key).cmp(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn test_find_all_elems<T: Eq + Ord + TotalEq + TotalOrd>(arr: &[T]) {
|
||||
fn test_find_all_elems<T: PartialEq + PartialOrd + Eq + Ord>(arr: &[T]) {
|
||||
let mut i = 0;
|
||||
while i < arr.len() {
|
||||
assert!(test_match(&arr[i], arr.binary_search(&arr[i])));
|
||||
@ -71,7 +71,7 @@ fn test_find_all_elems<T: Eq + Ord + TotalEq + TotalOrd>(arr: &[T]) {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn test_miss_all_elems<T: Eq + Ord + TotalEq + TotalOrd>(arr: &[T], misses: &[T]) {
|
||||
fn test_miss_all_elems<T: PartialEq + PartialOrd + Eq + Ord>(arr: &[T], misses: &[T]) {
|
||||
let mut i = 0;
|
||||
while i < misses.len() {
|
||||
let res = arr.binary_search(&misses[i]);
|
||||
@ -82,7 +82,7 @@ fn test_miss_all_elems<T: Eq + Ord + TotalEq + TotalOrd>(arr: &[T], misses: &[T]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn test_match<T: Eq>(b: &T, a: Option<&T>) -> bool {
|
||||
fn test_match<T: PartialEq>(b: &T, a: Option<&T>) -> bool {
|
||||
match a {
|
||||
None => false,
|
||||
Some(t) => t == b
|
||||
|
@ -8,12 +8,12 @@
|
||||
//! higher-level API on top of this could allow safe fork-join parallelism.
|
||||
|
||||
use native;
|
||||
use rand;
|
||||
use rand::{Rng, XorShiftRng};
|
||||
use std::mem;
|
||||
use std::rand::weak_rng;
|
||||
use std::sync::atomics::{AtomicUint, SeqCst};
|
||||
use std::sync::deque::{Abort, BufferPool, Data, Empty, Stealer, Worker};
|
||||
use std::task::TaskOpts;
|
||||
use rustrt::task::TaskOpts;
|
||||
|
||||
/// A unit of work.
|
||||
///
|
||||
@ -217,7 +217,7 @@ impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
||||
port: worker_port,
|
||||
chan: supervisor_chan.clone(),
|
||||
other_deques: vec!(),
|
||||
rng: rand::weak_rng(),
|
||||
rng: weak_rng(),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ extern crate getopts;
|
||||
extern crate regex;
|
||||
extern crate test;
|
||||
|
||||
use test::{TestOpts, run_tests_console, TestDesc, TestDescAndFn, DynTestFn, DynTestName};
|
||||
use test::{AutoColor, TestOpts, run_tests_console, TestDesc, TestDescAndFn, DynTestFn, DynTestName};
|
||||
use getopts::{getopts, reqopt};
|
||||
use std::{os, str};
|
||||
use std::io::fs;
|
||||
@ -63,7 +63,8 @@ fn test_options(config: Config) -> TestOpts {
|
||||
save_metrics: None,
|
||||
test_shard: None,
|
||||
logfile: None,
|
||||
nocapture: false
|
||||
nocapture: false,
|
||||
color: AutoColor
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ use std::io;
|
||||
use std::io::{File, Reader, Command};
|
||||
use std::io::process::ExitStatus;
|
||||
use std::os;
|
||||
use test::{DynTestName, DynTestFn, TestDesc, TestOpts, TestDescAndFn};
|
||||
use test::{AutoColor, DynTestName, DynTestFn, TestDesc, TestOpts, TestDescAndFn};
|
||||
use test::run_tests_console;
|
||||
use regex::Regex;
|
||||
|
||||
@ -45,6 +45,7 @@ fn main() {
|
||||
save_metrics: None,
|
||||
test_shard: None,
|
||||
nocapture: false,
|
||||
color: AutoColor
|
||||
};
|
||||
|
||||
match run_tests_console(&test_opts, tests) {
|
||||
@ -54,7 +55,7 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq)]
|
||||
#[deriving(PartialEq)]
|
||||
enum ReftestKind {
|
||||
Same,
|
||||
Different,
|
||||
|
Loading…
Reference in New Issue
Block a user