Skip to content

Commit

Permalink
Bug 1298588 part 14. Remove ComputedValues::initial_values for stylo.…
Browse files Browse the repository at this point in the history
… r=bholley
  • Loading branch information
bzbarsky committed Jan 5, 2017
1 parent 369fddd commit 8e2acee
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 51 deletions.
37 changes: 0 additions & 37 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -55,7 +55,6 @@ use properties::longhands;
use std::fmt::{self, Debug};
use std::mem::{transmute, zeroed};
use std::ptr;
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
use std::sync::Arc;
use std::cmp;

Expand Down Expand Up @@ -113,13 +112,6 @@ impl ComputedValues {
}
}

pub fn initial_values() -> &'static Self {
unsafe {
debug_assert!(!raw_initial_values().is_null());
&*raw_initial_values()
}
}

pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
Arc::new(ComputedValues {
custom_properties: None,
Expand All @@ -132,25 +124,6 @@ impl ComputedValues {
})
}

pub unsafe fn initialize() {
debug_assert!(raw_initial_values().is_null());
set_raw_initial_values(Box::into_raw(Box::new(ComputedValues {
% for style_struct in data.style_structs:
${style_struct.ident}: style_structs::${style_struct.name}::initial(),
% endfor
custom_properties: None,
shareable: true,
writing_mode: WritingMode::empty(),
root_font_size: longhands::font_size::get_initial_value(),
})));
}

pub unsafe fn shutdown() {
debug_assert!(!raw_initial_values().is_null());
let _ = Box::from_raw(raw_initial_values());
set_raw_initial_values(ptr::null_mut());
}

% for style_struct in data.style_structs:
#[inline]
pub fn clone_${style_struct.name_lower}(&self) -> Arc<style_structs::${style_struct.name}> {
Expand Down Expand Up @@ -2662,13 +2635,3 @@ pub unsafe extern "C" fn Servo_GetStyleVariables(_cv: ServoComputedValuesBorrowe
&*EMPTY_VARIABLES_STRUCT
}

// To avoid UB, we store the initial values as a atomic. It would be nice to
// store them as AtomicPtr, but we can't have static AtomicPtr without const
// fns, which aren't in stable Rust.
static INITIAL_VALUES_STORAGE: AtomicUsize = ATOMIC_USIZE_INIT;
unsafe fn raw_initial_values() -> *mut ComputedValues {
INITIAL_VALUES_STORAGE.load(Ordering::Relaxed) as *mut ComputedValues
}
unsafe fn set_raw_initial_values(v: *mut ComputedValues) {
INITIAL_VALUES_STORAGE.store(v as usize, Ordering::Relaxed);
}
14 changes: 0 additions & 14 deletions ports/geckolib/glue.rs
Expand Up @@ -82,17 +82,12 @@ pub extern "C" fn Servo_Initialize() -> () {
// See https://doc.rust-lang.org/log/env_logger/index.html for instructions.
env_logger::init().unwrap();

// Allocate our default computed values.
unsafe { ComputedValues::initialize(); }

// Pretend that we're a Servo Layout thread, to make some assertions happy.
thread_state::initialize(thread_state::LAYOUT);
}

#[no_mangle]
pub extern "C" fn Servo_Shutdown() -> () {
// Destroy our default computed values.
unsafe { ComputedValues::shutdown(); }
}

fn create_shared_context(per_doc_data: &PerDocumentStyleDataImpl) -> SharedStyleContext {
Expand All @@ -118,15 +113,6 @@ fn create_shared_context(per_doc_data: &PerDocumentStyleDataImpl) -> SharedStyle

fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed,
unstyled_children_only: bool) {
// Force the creation of our lazily-constructed initial computed values on
// the main thread, since it's not safe to call elsewhere.
//
// FIXME(bholley): this should move into Servo_Initialize as soon as we get
// rid of the HackilyFindSomeDeviceContext stuff that happens during
// initial_values computation, since that stuff needs to be called further
// along in startup than the sensible place to call Servo_Initialize.
ComputedValues::initial_values();

// When new content is inserted in a display:none subtree, we will call into
// servo to try to style it. Detect that here and bail out.
if let Some(parent) = element.parent_element() {
Expand Down

0 comments on commit 8e2acee

Please sign in to comment.