mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
auto merge of #4588 : Ms2ger/servo/layout-cleanup, r=larsbergstrom
This commit is contained in:
commit
43e34d6d10
2 changed files with 10 additions and 14 deletions
|
@ -99,24 +99,24 @@ impl<'a> LayoutContext<'a> {
|
|||
#[inline(always)]
|
||||
pub fn font_context<'a>(&'a self) -> &'a mut FontContext {
|
||||
unsafe {
|
||||
let cached_context = &*self.cached_local_layout_context;
|
||||
mem::transmute(&cached_context.font_context)
|
||||
let cached_context = &mut *self.cached_local_layout_context;
|
||||
&mut cached_context.font_context
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn applicable_declarations_cache<'a>(&'a self) -> &'a mut ApplicableDeclarationsCache {
|
||||
unsafe {
|
||||
let cached_context = &*self.cached_local_layout_context;
|
||||
mem::transmute(&cached_context.applicable_declarations_cache)
|
||||
let cached_context = &mut *self.cached_local_layout_context;
|
||||
&mut cached_context.applicable_declarations_cache
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn style_sharing_candidate_cache<'a>(&'a self) -> &'a mut StyleSharingCandidateCache {
|
||||
unsafe {
|
||||
let cached_context = &*self.cached_local_layout_context;
|
||||
mem::transmute(&cached_context.style_sharing_candidate_cache)
|
||||
let cached_context = &mut *self.cached_local_layout_context;
|
||||
&mut cached_context.style_sharing_candidate_cache
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,13 +55,9 @@ pub struct ApplicableDeclarationsCacheEntry {
|
|||
}
|
||||
|
||||
impl ApplicableDeclarationsCacheEntry {
|
||||
fn new(slice: &[DeclarationBlock]) -> ApplicableDeclarationsCacheEntry {
|
||||
let mut entry_declarations = Vec::new();
|
||||
for declarations in slice.iter() {
|
||||
entry_declarations.push(declarations.clone());
|
||||
}
|
||||
fn new(declarations: Vec<DeclarationBlock>) -> ApplicableDeclarationsCacheEntry {
|
||||
ApplicableDeclarationsCacheEntry {
|
||||
declarations: entry_declarations,
|
||||
declarations: declarations,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +134,7 @@ impl ApplicableDeclarationsCache {
|
|||
}
|
||||
}
|
||||
|
||||
fn insert(&mut self, declarations: &[DeclarationBlock], style: Arc<ComputedValues>) {
|
||||
fn insert(&mut self, declarations: Vec<DeclarationBlock>, style: Arc<ComputedValues>) {
|
||||
self.cache.insert(ApplicableDeclarationsCacheEntry::new(declarations), style)
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +434,7 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
|
|||
|
||||
// Cache the resolved style if it was cacheable.
|
||||
if cacheable {
|
||||
applicable_declarations_cache.insert(applicable_declarations, this_style.clone());
|
||||
applicable_declarations_cache.insert(applicable_declarations.to_vec(), this_style.clone());
|
||||
}
|
||||
|
||||
// Calculate style difference and write.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue