mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Properly deallocate PrivateStyleData.
In Servo_DropNodeData, we do Box::<NonOpaqueStyleData>::from_raw, which is off by one level of indirection with the current types.
This commit is contained in:
parent
f0f39904a2
commit
1e7307601d
1 changed files with 5 additions and 4 deletions
|
@ -49,7 +49,8 @@ use style::selector_impl::ElementExt;
|
||||||
use style::sink::Push;
|
use style::sink::Push;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
pub type NonOpaqueStyleData = *mut RefCell<PrivateStyleData>;
|
pub type NonOpaqueStyleData = RefCell<PrivateStyleData>;
|
||||||
|
pub type NonOpaqueStyleDataPtr = *mut NonOpaqueStyleData;
|
||||||
|
|
||||||
// Important: We don't currently refcount the DOM, because the wrapper lifetime
|
// Important: We don't currently refcount the DOM, because the wrapper lifetime
|
||||||
// magic guarantees that our LayoutFoo references won't outlive the root, and
|
// magic guarantees that our LayoutFoo references won't outlive the root, and
|
||||||
|
@ -74,16 +75,16 @@ impl<'ln> GeckoNode<'ln> {
|
||||||
GeckoNode::from_raw(n as *const RawGeckoNode as *mut RawGeckoNode)
|
GeckoNode::from_raw(n as *const RawGeckoNode as *mut RawGeckoNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_node_data(&self) -> NonOpaqueStyleData {
|
fn get_node_data(&self) -> NonOpaqueStyleDataPtr {
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_GetNodeData(self.node) as NonOpaqueStyleData
|
Gecko_GetNodeData(self.node) as NonOpaqueStyleDataPtr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn initialize_data(self) {
|
pub fn initialize_data(self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
if self.get_node_data().is_null() {
|
if self.get_node_data().is_null() {
|
||||||
let ptr: NonOpaqueStyleData = Box::into_raw(Box::new(RefCell::new(PrivateStyleData::new())));
|
let ptr: NonOpaqueStyleDataPtr = Box::into_raw(Box::new(RefCell::new(PrivateStyleData::new())));
|
||||||
Gecko_SetNodeData(self.node, ptr as *mut ServoNodeData);
|
Gecko_SetNodeData(self.node, ptr as *mut ServoNodeData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue