mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Invoke the ctor/copy/dtor when managing gecko style structs from servo, and implement GeckoComputedValues::initial_values().
This commit is contained in:
parent
6db8dc218c
commit
899d6a9f64
2 changed files with 35 additions and 5 deletions
|
@ -22,6 +22,7 @@ use style::context::{ReflowGoal, StylistWrapper};
|
|||
use style::dom::{TDocument, TElement, TNode};
|
||||
use style::error_reporting::StdoutErrorReporter;
|
||||
use style::parallel;
|
||||
use style::properties::ComputedValues;
|
||||
use style::stylesheets::Origin;
|
||||
use traversal::RecalcStyleOnly;
|
||||
use url::Url;
|
||||
|
@ -45,6 +46,11 @@ pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *m
|
|||
};
|
||||
let data = unsafe { &mut *(raw_data as *mut PerDocumentStyleData) };
|
||||
|
||||
// Force the creation of our lazily-constructed initial computed values on
|
||||
// the main thread, since it's not safe to call elsewhere. This should move
|
||||
// into a runtime-wide init hook at some point.
|
||||
GeckoComputedValues::initial_values();
|
||||
|
||||
let _needs_dirtying = data.stylist.update(&data.stylesheets, data.stylesheets_changed);
|
||||
data.stylesheets_changed = false;
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@ use app_units::Au;
|
|||
% for style_struct in STYLE_STRUCTS:
|
||||
%if style_struct.gecko_name:
|
||||
use gecko_style_structs::${style_struct.gecko_name};
|
||||
use bindings::Gecko_Construct_${style_struct.gecko_name};
|
||||
use bindings::Gecko_CopyConstruct_${style_struct.gecko_name};
|
||||
use bindings::Gecko_Destroy_${style_struct.gecko_name};
|
||||
% endif
|
||||
% endfor
|
||||
use heapsize::HeapSizeOf;
|
||||
|
@ -58,7 +61,7 @@ impl ComputedValues for GeckoComputedValues {
|
|||
}
|
||||
}
|
||||
|
||||
fn initial_values() -> &'static Self { unimplemented!() }
|
||||
fn initial_values() -> &'static Self { &*INITIAL_GECKO_VALUES }
|
||||
|
||||
fn do_cascade_property<F: FnOnce(&Vec<Option<CascadePropertyFn<Self>>>)>(_: F) {
|
||||
unimplemented!()
|
||||
|
@ -104,8 +107,11 @@ impl Gecko${style_struct.name} {
|
|||
#[allow(dead_code, unused_variables)]
|
||||
fn initial() -> Self {
|
||||
% if style_struct.gecko_name:
|
||||
let result = Gecko${style_struct.name} { gecko: unsafe { zeroed() } };
|
||||
panic!("Need to invoke Gecko placement new");
|
||||
let mut result = Gecko${style_struct.name} { gecko: unsafe { zeroed() } };
|
||||
unsafe {
|
||||
Gecko_Construct_${style_struct.gecko_name}(&mut result.gecko);
|
||||
}
|
||||
result
|
||||
% else:
|
||||
Gecko${style_struct.name}
|
||||
% endif
|
||||
|
@ -114,12 +120,18 @@ impl Gecko${style_struct.name} {
|
|||
%if style_struct.gecko_name:
|
||||
impl Drop for Gecko${style_struct.name} {
|
||||
fn drop(&mut self) {
|
||||
panic!("Need to invoke Gecko destructor");
|
||||
unsafe {
|
||||
Gecko_Destroy_${style_struct.gecko_name}(&mut self.gecko);
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Clone for ${style_struct.gecko_name} {
|
||||
fn clone(&self) -> Self {
|
||||
panic!("Need to invoke Gecko copy constructor");
|
||||
unsafe {
|
||||
let mut result: Self = zeroed();
|
||||
Gecko_CopyConstruct_${style_struct.gecko_name}(&mut result, self);
|
||||
result
|
||||
}
|
||||
}
|
||||
}
|
||||
unsafe impl Send for ${style_struct.gecko_name} {}
|
||||
|
@ -205,3 +217,15 @@ ${impl_style_struct(style_struct)}
|
|||
<%self:raw_impl_trait style_struct="${style_struct}"></%self:raw_impl_trait>
|
||||
% endif
|
||||
% endfor
|
||||
|
||||
lazy_static! {
|
||||
pub static ref INITIAL_GECKO_VALUES: GeckoComputedValues = GeckoComputedValues {
|
||||
% for style_struct in STYLE_STRUCTS:
|
||||
${style_struct.ident}: Arc::new(Gecko${style_struct.name}::initial()),
|
||||
% endfor
|
||||
custom_properties: None,
|
||||
shareable: true,
|
||||
writing_mode: WritingMode::empty(),
|
||||
root_font_size: longhands::font_size::get_initial_value(),
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue