mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #15629 - heycam:variables-leak, r=bholley,emilio
stylo: Destroy static Variables struct on shutdown. Fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1340457. r? @emilio <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15629) <!-- Reviewable:end -->
This commit is contained in:
commit
58aa6ce7ae
2 changed files with 23 additions and 11 deletions
|
@ -26,6 +26,7 @@ use gecko_bindings::bindings::Gecko_CopyFontFamilyFrom;
|
||||||
use gecko_bindings::bindings::Gecko_CopyImageValueFrom;
|
use gecko_bindings::bindings::Gecko_CopyImageValueFrom;
|
||||||
use gecko_bindings::bindings::Gecko_CopyListStyleImageFrom;
|
use gecko_bindings::bindings::Gecko_CopyListStyleImageFrom;
|
||||||
use gecko_bindings::bindings::Gecko_CopyListStyleTypeFrom;
|
use gecko_bindings::bindings::Gecko_CopyListStyleTypeFrom;
|
||||||
|
use gecko_bindings::bindings::Gecko_Destroy_nsStyleVariables;
|
||||||
use gecko_bindings::bindings::Gecko_EnsureImageLayersLength;
|
use gecko_bindings::bindings::Gecko_EnsureImageLayersLength;
|
||||||
use gecko_bindings::bindings::Gecko_FontFamilyList_AppendGeneric;
|
use gecko_bindings::bindings::Gecko_FontFamilyList_AppendGeneric;
|
||||||
use gecko_bindings::bindings::Gecko_FontFamilyList_AppendNamed;
|
use gecko_bindings::bindings::Gecko_FontFamilyList_AppendNamed;
|
||||||
|
@ -3147,19 +3148,25 @@ ${impl_style_struct(style_struct)}
|
||||||
${define_ffi_struct_accessor(style_struct)}
|
${define_ffi_struct_accessor(style_struct)}
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
lazy_static! {
|
// This is only accessed from the Gecko main thread.
|
||||||
static ref EMPTY_VARIABLES_STRUCT: nsStyleVariables = {
|
static mut EMPTY_VARIABLES_STRUCT: Option<nsStyleVariables> = None;
|
||||||
unsafe {
|
|
||||||
let mut variables: nsStyleVariables = unsafe { zeroed() };
|
|
||||||
Gecko_Construct_nsStyleVariables(&mut variables);
|
|
||||||
variables
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub unsafe extern "C" fn Servo_GetStyleVariables(_cv: ServoComputedValuesBorrowedOrNull)
|
pub unsafe extern "C" fn Servo_GetStyleVariables(_cv: ServoComputedValuesBorrowedOrNull)
|
||||||
-> *const nsStyleVariables {
|
-> *const nsStyleVariables {
|
||||||
&*EMPTY_VARIABLES_STRUCT
|
EMPTY_VARIABLES_STRUCT.as_ref().unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn initialize() {
|
||||||
|
unsafe {
|
||||||
|
EMPTY_VARIABLES_STRUCT = Some(zeroed());
|
||||||
|
Gecko_Construct_nsStyleVariables(EMPTY_VARIABLES_STRUCT.as_mut().unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn shutdown() {
|
||||||
|
unsafe {
|
||||||
|
EMPTY_VARIABLES_STRUCT.take().as_mut().map(|v| Gecko_Destroy_nsStyleVariables(v));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ use style::gecko_bindings::structs::nsresult;
|
||||||
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasBoxFFI};
|
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasBoxFFI};
|
||||||
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
|
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
|
||||||
use style::gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
use style::gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||||
use style::gecko_properties::style_structs;
|
use style::gecko_properties::{self, style_structs};
|
||||||
use style::keyframes::KeyframesStepValue;
|
use style::keyframes::KeyframesStepValue;
|
||||||
use style::parallel;
|
use style::parallel;
|
||||||
use style::parser::{ParserContext, ParserContextExtraData};
|
use style::parser::{ParserContext, ParserContextExtraData};
|
||||||
|
@ -105,10 +105,15 @@ pub extern "C" fn Servo_Initialize() -> () {
|
||||||
|
|
||||||
// Perform some debug-only runtime assertions.
|
// Perform some debug-only runtime assertions.
|
||||||
restyle_hints::assert_restyle_hints_match();
|
restyle_hints::assert_restyle_hints_match();
|
||||||
|
|
||||||
|
// Initialize some static data.
|
||||||
|
gecko_properties::initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_Shutdown() -> () {
|
pub extern "C" fn Servo_Shutdown() -> () {
|
||||||
|
// Clear some static data to avoid shutdown leaks.
|
||||||
|
gecko_properties::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_shared_context(per_doc_data: &PerDocumentStyleDataImpl) -> SharedStyleContext {
|
fn create_shared_context(per_doc_data: &PerDocumentStyleDataImpl) -> SharedStyleContext {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue