mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
servo: Update for Eq trait with explicit self
This commit is contained in:
parent
29e46273f9
commit
b04c68091d
11 changed files with 57 additions and 46 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 05de2b7203ece02c28b39242e572ee50c94a7aa0
|
Subproject commit 0578eb42ae1ef2f303918c4197a09ef69e8a07c7
|
|
@ -1 +1 @@
|
||||||
Subproject commit 06cff4a8b761e07a6b8f0a74e3c2feb40358ec6b
|
Subproject commit 9dddb337cc9dea2f4f871b34f9766608cd07cb83
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2f3c63579c01f9e3cb07f03fd172a7a812da7285
|
Subproject commit 9421b6c7353a0ae109faf44163b437f2787f52af
|
|
@ -108,10 +108,8 @@ enum CSSFontWeight {
|
||||||
FontWeight900,
|
FontWeight900,
|
||||||
}
|
}
|
||||||
pub impl CSSFontWeight : cmp::Eq {
|
pub impl CSSFontWeight : cmp::Eq {
|
||||||
pure fn eq(other: &CSSFontWeight) -> bool {
|
pure fn eq(&self, other: &CSSFontWeight) -> bool { (*self as uint) == (*other as uint) }
|
||||||
(self as uint) == (*other as uint)
|
pure fn ne(&self, other: &CSSFontWeight) -> bool { !(*self).eq(other) }
|
||||||
}
|
|
||||||
pure fn ne(other: &CSSFontWeight) -> bool { !self.eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl CSSFontWeight {
|
pub impl CSSFontWeight {
|
||||||
|
@ -140,7 +138,7 @@ pub struct FontStyle {
|
||||||
|
|
||||||
// TODO(Issue #181): use deriving for trivial cmp::Eq implementations
|
// TODO(Issue #181): use deriving for trivial cmp::Eq implementations
|
||||||
pub impl FontStyle : cmp::Eq {
|
pub impl FontStyle : cmp::Eq {
|
||||||
pure fn eq(other: &FontStyle) -> bool {
|
pure fn eq(&self, other: &FontStyle) -> bool {
|
||||||
use std::cmp::FuzzyEq;
|
use std::cmp::FuzzyEq;
|
||||||
|
|
||||||
self.pt_size.fuzzy_eq(&other.pt_size) &&
|
self.pt_size.fuzzy_eq(&other.pt_size) &&
|
||||||
|
@ -149,7 +147,7 @@ pub impl FontStyle : cmp::Eq {
|
||||||
self.oblique == other.oblique &&
|
self.oblique == other.oblique &&
|
||||||
self.families == other.families
|
self.families == other.families
|
||||||
}
|
}
|
||||||
pure fn ne(other: &FontStyle) -> bool { !self.eq(other) }
|
pure fn ne(&self, other: &FontStyle) -> bool { !(*self).eq(other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type SpecifiedFontStyle = FontStyle;
|
pub type SpecifiedFontStyle = FontStyle;
|
||||||
|
@ -175,11 +173,11 @@ pub struct FontDescriptor {
|
||||||
|
|
||||||
// TODO(Issue #181): use deriving for trivial cmp::Eq implementations
|
// TODO(Issue #181): use deriving for trivial cmp::Eq implementations
|
||||||
pub impl FontDescriptor : cmp::Eq {
|
pub impl FontDescriptor : cmp::Eq {
|
||||||
pure fn eq(other: &FontDescriptor) -> bool {
|
pure fn eq(&self, other: &FontDescriptor) -> bool {
|
||||||
self.style == other.style &&
|
self.style == other.style &&
|
||||||
self.selector == other.selector
|
self.selector == other.selector
|
||||||
}
|
}
|
||||||
pure fn ne(other: &FontDescriptor) -> bool { !self.eq(other) }
|
pure fn ne(&self, other: &FontDescriptor) -> bool { !(*self).eq(other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl FontDescriptor {
|
pub impl FontDescriptor {
|
||||||
|
@ -199,14 +197,14 @@ pub enum FontSelector {
|
||||||
|
|
||||||
// TODO(Issue #181): use deriving for trivial cmp::Eq implementations
|
// TODO(Issue #181): use deriving for trivial cmp::Eq implementations
|
||||||
pub impl FontSelector : cmp::Eq {
|
pub impl FontSelector : cmp::Eq {
|
||||||
pure fn eq(other: &FontSelector) -> bool {
|
pure fn eq(&self, other: &FontSelector) -> bool {
|
||||||
match (&self, other) {
|
match (self, other) {
|
||||||
(&SelectorPlatformIdentifier(a), &SelectorPlatformIdentifier(b)) => a == b,
|
(&SelectorPlatformIdentifier(a), &SelectorPlatformIdentifier(b)) => a == b,
|
||||||
(&SelectorStubDummy, &SelectorStubDummy) => true,
|
(&SelectorStubDummy, &SelectorStubDummy) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pure fn ne(other: &FontSelector) -> bool { !self.eq(other) }
|
pure fn ne(&self, other: &FontSelector) -> bool { !(*self).eq(other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// This struct is the result of mapping a specified FontStyle into the
|
// This struct is the result of mapping a specified FontStyle into the
|
||||||
|
|
|
@ -21,15 +21,15 @@ impl Au : Num {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Au : cmp::Ord {
|
impl Au : cmp::Ord {
|
||||||
pure fn lt(other: &Au) -> bool { *self < **other }
|
pure fn lt(&self, other: &Au) -> bool { **self < **other }
|
||||||
pure fn le(other: &Au) -> bool { *self <= **other }
|
pure fn le(&self, other: &Au) -> bool { **self <= **other }
|
||||||
pure fn ge(other: &Au) -> bool { *self >= **other }
|
pure fn ge(&self, other: &Au) -> bool { **self >= **other }
|
||||||
pure fn gt(other: &Au) -> bool { *self > **other }
|
pure fn gt(&self, other: &Au) -> bool { **self > **other }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Au : cmp::Eq {
|
impl Au : cmp::Eq {
|
||||||
pure fn eq(other: &Au) -> bool { *self == **other }
|
pure fn eq(&self, other: &Au) -> bool { **self == **other }
|
||||||
pure fn ne(other: &Au) -> bool { *self != **other }
|
pure fn ne(&self, other: &Au) -> bool { **self != **other }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub pure fn min(x: Au, y: Au) -> Au { if x < y { x } else { y } }
|
pub pure fn min(x: Au, y: Au) -> Au { if x < y { x } else { y } }
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl ImageResponseMsg {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImageResponseMsg: cmp::Eq {
|
impl ImageResponseMsg: cmp::Eq {
|
||||||
pure fn eq(other: &ImageResponseMsg) -> bool {
|
pure fn eq(&self, other: &ImageResponseMsg) -> bool {
|
||||||
// FIXME: Bad copies
|
// FIXME: Bad copies
|
||||||
match (self.clone(), other.clone()) {
|
match (self.clone(), other.clone()) {
|
||||||
(ImageReady(*), ImageReady(*)) => fail ~"unimplemented comparison",
|
(ImageReady(*), ImageReady(*)) => fail ~"unimplemented comparison",
|
||||||
|
@ -70,8 +70,8 @@ impl ImageResponseMsg: cmp::Eq {
|
||||||
| (ImageFailed, _) => false
|
| (ImageFailed, _) => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pure fn ne(other: &ImageResponseMsg) -> bool {
|
pure fn ne(&self, other: &ImageResponseMsg) -> bool {
|
||||||
return !self.eq(other);
|
return !(*self).eq(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,9 @@ pub enum ProgressMsg {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProgressMsg: cmp::Eq {
|
impl ProgressMsg: cmp::Eq {
|
||||||
pure fn eq(other: &ProgressMsg) -> bool {
|
pure fn eq(&self, other: &ProgressMsg) -> bool {
|
||||||
match (copy self, copy *other) {
|
// FIXME: Bad copies
|
||||||
|
match (copy *self, copy *other) {
|
||||||
(Payload(a), Payload(b)) => a == b,
|
(Payload(a), Payload(b)) => a == b,
|
||||||
(Done(a), Done(b)) => a == b,
|
(Done(a), Done(b)) => a == b,
|
||||||
|
|
||||||
|
@ -33,8 +34,8 @@ impl ProgressMsg: cmp::Eq {
|
||||||
| (Done(*), _) => false
|
| (Done(*), _) => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pure fn ne(other: &ProgressMsg) -> bool {
|
pure fn ne(&self, other: &ProgressMsg) -> bool {
|
||||||
return !self.eq(other);
|
return !(*self).eq(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,12 @@ pub enum format {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl format: cmp::Eq {
|
impl format: cmp::Eq {
|
||||||
pure fn eq(other: &format) -> bool {
|
pure fn eq(&self, other: &format) -> bool {
|
||||||
match (self, *other) {
|
match (*self, *other) {
|
||||||
(fo_rgba_8888, fo_rgba_8888) => true,
|
(fo_rgba_8888, fo_rgba_8888) => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pure fn ne(other: &format) -> bool {
|
pure fn ne(&self, other: &format) -> bool {
|
||||||
return !self.eq(other);
|
return !self.eq(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,16 +39,16 @@ enum BreakType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BreakType : Eq {
|
impl BreakType : Eq {
|
||||||
pure fn eq(other: &BreakType) -> bool {
|
pure fn eq(&self, other: &BreakType) -> bool {
|
||||||
match (self, *other) {
|
match (*self, *other) {
|
||||||
(BreakTypeNone, BreakTypeNone) => true,
|
(BreakTypeNone, BreakTypeNone) => true,
|
||||||
(BreakTypeNormal, BreakTypeNormal) => true,
|
(BreakTypeNormal, BreakTypeNormal) => true,
|
||||||
(BreakTypeHyphen, BreakTypeHyphen) => true,
|
(BreakTypeHyphen, BreakTypeHyphen) => true,
|
||||||
(_,_) => false,
|
(_,_) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pure fn ne(other: &BreakType) -> bool {
|
pure fn ne(&self, other: &BreakType) -> bool {
|
||||||
!self.eq(other)
|
!(*self).eq(other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,15 +288,27 @@ struct DetailedGlyphRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DetailedGlyphRecord : Ord {
|
impl DetailedGlyphRecord : Ord {
|
||||||
pure fn lt(other: &DetailedGlyphRecord) -> bool { self.entry_offset < other.entry_offset }
|
pure fn lt(&self, other: &DetailedGlyphRecord) -> bool {
|
||||||
pure fn le(other: &DetailedGlyphRecord) -> bool { self.entry_offset <= other.entry_offset }
|
self.entry_offset < other.entry_offset
|
||||||
pure fn ge(other: &DetailedGlyphRecord) -> bool { self.entry_offset >= other.entry_offset }
|
}
|
||||||
pure fn gt(other: &DetailedGlyphRecord) -> bool { self.entry_offset > other.entry_offset }
|
pure fn le(&self, other: &DetailedGlyphRecord) -> bool {
|
||||||
|
self.entry_offset <= other.entry_offset
|
||||||
|
}
|
||||||
|
pure fn ge(&self, other: &DetailedGlyphRecord) -> bool {
|
||||||
|
self.entry_offset >= other.entry_offset
|
||||||
|
}
|
||||||
|
pure fn gt(&self, other: &DetailedGlyphRecord) -> bool {
|
||||||
|
self.entry_offset > other.entry_offset
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DetailedGlyphRecord : Eq {
|
impl DetailedGlyphRecord : Eq {
|
||||||
pure fn eq(other : &DetailedGlyphRecord) -> bool { self.entry_offset == other.entry_offset }
|
pure fn eq(&self, other : &DetailedGlyphRecord) -> bool {
|
||||||
pure fn ne(other : &DetailedGlyphRecord) -> bool { self.entry_offset != other.entry_offset }
|
self.entry_offset == other.entry_offset
|
||||||
|
}
|
||||||
|
pure fn ne(&self, other : &DetailedGlyphRecord) -> bool {
|
||||||
|
self.entry_offset != other.entry_offset
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manages the lookup table for detailed glyphs. Sorting is deferred
|
// Manages the lookup table for detailed glyphs. Sorting is deferred
|
||||||
|
|
|
@ -6,8 +6,8 @@ enum CompressionMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompressionMode : cmp::Eq {
|
impl CompressionMode : cmp::Eq {
|
||||||
pure fn eq(other: &CompressionMode) -> bool {
|
pure fn eq(&self, other: &CompressionMode) -> bool {
|
||||||
match (self, *other) {
|
match (*self, *other) {
|
||||||
(CompressNone, CompressNone) => true,
|
(CompressNone, CompressNone) => true,
|
||||||
(CompressWhitespace, CompressWhitespace) => true,
|
(CompressWhitespace, CompressWhitespace) => true,
|
||||||
(CompressWhitespaceNewline, CompressWhitespaceNewline) => true,
|
(CompressWhitespaceNewline, CompressWhitespaceNewline) => true,
|
||||||
|
@ -15,8 +15,8 @@ impl CompressionMode : cmp::Eq {
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pure fn ne(other: &CompressionMode) -> bool {
|
pure fn ne(&self, other: &CompressionMode) -> bool {
|
||||||
!self.eq(other)
|
!(*self).eq(other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,8 +134,8 @@ impl<T:Send,A> Handle<T,A> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <T: Send,A> Handle<T,A> : cmp::Eq {
|
impl <T: Send,A> Handle<T,A> : cmp::Eq {
|
||||||
pure fn eq(other: &Handle<T,A>) -> bool { *self == **other }
|
pure fn eq(&self, other: &Handle<T,A>) -> bool { **self == **other }
|
||||||
pure fn ne(other: &Handle<T,A>) -> bool { *self != **other }
|
pure fn ne(&self, other: &Handle<T,A>) -> bool { **self != **other }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private methods
|
// Private methods
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue