mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
layout: Stop doing unsafe transmutes between refcell references.
This commit splits the style and layout data in two separate refcells. These transmutes have been a source of trouble (for example on Android), and they feel like a hack anyway. Fixes #16982
This commit is contained in:
parent
bb310efbb9
commit
deaa935f5b
9 changed files with 79 additions and 94 deletions
|
@ -1,26 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 atomic_refcell::AtomicRefCell;
|
||||
use layout::PersistentLayoutData;
|
||||
use script_layout_interface::PartialPersistentLayoutData;
|
||||
use std::mem::align_of;
|
||||
|
||||
fn check_layout_alignment(expected: usize, current: usize) {
|
||||
if current != expected {
|
||||
panic!("Your changes have altered the mem alignment of the PartialPersistentLayoutData \
|
||||
struct to {}, but it must match the {}-alignment of PersistentLayoutData struct. \
|
||||
Please fix alignment in components/script_layout_interface/lib.rs",
|
||||
current, expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_persistent_layout_data_alignment() {
|
||||
check_layout_alignment(align_of::<PersistentLayoutData>(),
|
||||
align_of::<PartialPersistentLayoutData>());
|
||||
|
||||
check_layout_alignment(align_of::<AtomicRefCell<PersistentLayoutData>>(),
|
||||
align_of::<AtomicRefCell<PartialPersistentLayoutData>>());
|
||||
}
|
|
@ -7,5 +7,4 @@ extern crate layout;
|
|||
extern crate script_layout_interface;
|
||||
#[macro_use] extern crate size_of_test;
|
||||
|
||||
#[cfg(test)] mod align_of;
|
||||
#[cfg(all(test, target_pointer_width = "64"))] mod size_of;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue