mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Use NonZeroUsize in script_layout_interface
This commit is contained in:
parent
ff23a8536e
commit
7ebedd02a9
8 changed files with 38 additions and 13 deletions
|
@ -10,7 +10,7 @@ name = "layout_thread"
|
|||
path = "lib.rs"
|
||||
|
||||
[features]
|
||||
unstable = ["parking_lot/nightly"]
|
||||
unstable = ["parking_lot/nightly", "nonzero/unstable"]
|
||||
|
||||
[dependencies]
|
||||
app_units = "0.5"
|
||||
|
@ -29,6 +29,7 @@ log = "0.3.5"
|
|||
metrics = {path = "../metrics"}
|
||||
msg = {path = "../msg"}
|
||||
net_traits = {path = "../net_traits"}
|
||||
nonzero = {path = "../nonzero"}
|
||||
parking_lot = "0.4"
|
||||
profile_traits = {path = "../profile_traits"}
|
||||
range = {path = "../range"}
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
#![allow(unsafe_code)]
|
||||
|
||||
use atomic_refcell::{AtomicRef, AtomicRefMut, AtomicRefCell};
|
||||
use core::nonzero::NonZero;
|
||||
use gfx_traits::ByteIndex;
|
||||
use html5ever::{LocalName, Namespace};
|
||||
use layout::data::StyleAndLayoutData;
|
||||
use layout::wrapper::GetRawData;
|
||||
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||
use nonzero::NonZeroUsize;
|
||||
use range::Range;
|
||||
use script::layout_exports::{CAN_BE_FRAGMENTED, HAS_DIRTY_DESCENDANTS, IS_IN_DOC};
|
||||
use script::layout_exports::{CharacterDataTypeId, ElementTypeId, HTMLElementTypeId, NodeTypeId};
|
||||
|
@ -79,7 +79,7 @@ use style::shared_lock::{SharedRwLock as StyleSharedRwLock, Locked as StyleLocke
|
|||
use style::str::is_whitespace;
|
||||
|
||||
pub unsafe fn drop_style_and_layout_data(data: OpaqueStyleAndLayoutData) {
|
||||
let ptr: *mut StyleData = data.ptr.get();
|
||||
let ptr = data.ptr.get() as *mut StyleData;
|
||||
let non_opaque: *mut StyleAndLayoutData = ptr as *mut _;
|
||||
let _ = Box::from_raw(non_opaque);
|
||||
}
|
||||
|
@ -235,7 +235,8 @@ impl<'ln> LayoutNode for ServoLayoutNode<'ln> {
|
|||
let ptr: *mut StyleAndLayoutData =
|
||||
Box::into_raw(Box::new(StyleAndLayoutData::new()));
|
||||
let opaque = OpaqueStyleAndLayoutData {
|
||||
ptr: NonZero::new_unchecked(ptr as *mut StyleData),
|
||||
ptr: NonZeroUsize::new_unchecked(ptr as usize),
|
||||
phantom: PhantomData,
|
||||
};
|
||||
self.init_style_and_layout_data(opaque);
|
||||
};
|
||||
|
@ -471,7 +472,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
|||
fn get_data(&self) -> Option<&AtomicRefCell<ElementData>> {
|
||||
unsafe {
|
||||
self.get_style_and_layout_data().map(|d| {
|
||||
&(*d.ptr.get()).element_data
|
||||
&(*(d.ptr.get() as *mut StyleData)).element_data
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -583,7 +584,7 @@ impl<'le> ServoLayoutElement<'le> {
|
|||
|
||||
fn get_style_data(&self) -> Option<&StyleData> {
|
||||
unsafe {
|
||||
self.get_style_and_layout_data().map(|d| &*d.ptr.get())
|
||||
self.get_style_and_layout_data().map(|d| &*(d.ptr.get() as *mut StyleData))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
//! painted.
|
||||
|
||||
#![feature(mpsc_select)]
|
||||
#![feature(nonzero)]
|
||||
#![cfg_attr(feature = "unstable", feature(nonzero))]
|
||||
|
||||
extern crate app_units;
|
||||
extern crate atomic_refcell;
|
||||
extern crate core;
|
||||
extern crate euclid;
|
||||
extern crate fnv;
|
||||
extern crate gfx;
|
||||
|
@ -29,6 +28,7 @@ extern crate log;
|
|||
extern crate metrics;
|
||||
extern crate msg;
|
||||
extern crate net_traits;
|
||||
extern crate nonzero;
|
||||
extern crate parking_lot;
|
||||
#[macro_use]
|
||||
extern crate profile_traits;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue