mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Derive PartialEq on the style Font structure
We check the hash first.
This commit is contained in:
parent
217c7da413
commit
6d6dbf0129
2 changed files with 17 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6029,7 +6029,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,
|
||||
|
@ -6038,6 +6042,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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue