Auto merge of #7918 - nox:partialeq-font, r=mbrubeck

Derive PartialEq on the style Font structure

We check the hash first.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7918)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-10-10 12:26:07 -06:00
commit 0f8493a566
2 changed files with 17 additions and 6 deletions

View file

@ -321,12 +321,7 @@ struct LayoutFontGroupCacheKey {
impl PartialEq for LayoutFontGroupCacheKey {
fn eq(&self, other: &LayoutFontGroupCacheKey) -> bool {
self.pointer.font_family == other.pointer.font_family &&
self.pointer.font_stretch == other.pointer.font_stretch &&
self.pointer.font_style == other.pointer.font_style &&
self.pointer.font_weight as u16 == other.pointer.font_weight as u16 &&
self.pointer.font_variant == other.pointer.font_variant &&
self.size == other.size
self.pointer == other.pointer && self.size == other.size
}
}

View file

@ -6031,7 +6031,11 @@ pub mod style_structs {
use super::longhands;
% for style_struct in STYLE_STRUCTS:
% if style_struct.name == "Font":
#[derive(Clone, HeapSizeOf)]
% else:
#[derive(PartialEq, Clone, HeapSizeOf)]
% endif
pub struct ${style_struct.name} {
% for longhand in style_struct.longhands:
pub ${longhand.ident}: longhands::${longhand.ident}::computed_value::T,
@ -6040,6 +6044,18 @@ pub mod style_structs {
pub hash: u64,
% endif
}
% if style_struct.name == "Font":
impl PartialEq for ${style_struct.name} {
fn eq(&self, other: &${style_struct.name}) -> bool {
self.hash == other.hash
% for longhand in style_struct.longhands:
&& self.${longhand.ident} == other.${longhand.ident}
% endfor
}
}
% endif
% endfor
}