mirror of
https://github.com/servo/servo.git
synced 2025-08-15 18:35:33 +01:00
Store style system options in the global style data and shared style context.
I wanted to add an environmental variable to disable the style sharing cache for gecko, but the current pattern involves lazy_static!, which involves an atomic operation on lookup, which is a bit hot to do each time we try to share styles. This makes that work happen once per process.
This commit is contained in:
parent
3c5a21ebf3
commit
dc5dbd5542
7 changed files with 66 additions and 50 deletions
|
@ -22,7 +22,7 @@ use style::dom::{ShowSubtreeData, TElement, TNode};
|
|||
use style::error_reporting::StdoutErrorReporter;
|
||||
use style::font_metrics::get_metrics_provider_for_product;
|
||||
use style::gecko::data::{PerDocumentStyleData, PerDocumentStyleDataImpl};
|
||||
use style::gecko::global_style_data::GLOBAL_STYLE_DATA;
|
||||
use style::gecko::global_style_data::{GLOBAL_STYLE_DATA, GlobalStyleData};
|
||||
use style::gecko::restyle_damage::GeckoRestyleDamage;
|
||||
use style::gecko::selector_parser::{SelectorImpl, PseudoElement};
|
||||
use style::gecko::traversal::RecalcStyleOnly;
|
||||
|
@ -143,7 +143,8 @@ unsafe fn dummy_url_data() -> &'static RefPtr<URLExtraData> {
|
|||
RefPtr::from_ptr_ref(&DUMMY_URL_DATA)
|
||||
}
|
||||
|
||||
fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard,
|
||||
fn create_shared_context<'a>(global_style_data: &GlobalStyleData,
|
||||
guard: &'a SharedRwLockReadGuard,
|
||||
per_doc_data: &PerDocumentStyleDataImpl,
|
||||
traversal_flags: TraversalFlags) -> SharedStyleContext<'a> {
|
||||
let local_context_data =
|
||||
|
@ -151,6 +152,7 @@ fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard,
|
|||
|
||||
SharedStyleContext {
|
||||
stylist: per_doc_data.stylist.clone(),
|
||||
options: global_style_data.options.clone(),
|
||||
guards: StylesheetGuards::same(guard),
|
||||
running_animations: per_doc_data.running_animations.clone(),
|
||||
expired_animations: per_doc_data.expired_animations.clone(),
|
||||
|
@ -187,7 +189,10 @@ fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed,
|
|||
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let shared_style_context = create_shared_context(&guard, &per_doc_data, traversal_flags);
|
||||
let shared_style_context = create_shared_context(&global_style_data,
|
||||
&guard,
|
||||
&per_doc_data,
|
||||
traversal_flags);
|
||||
|
||||
let traversal_driver = if global_style_data.style_thread_pool.is_none() {
|
||||
TraversalDriver::Sequential
|
||||
|
@ -407,8 +412,10 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawSe
|
|||
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let shared_context = &create_shared_context(&guard, &doc_data, TraversalFlags::empty());
|
||||
|
||||
let shared_context = &create_shared_context(&global_style_data,
|
||||
&guard,
|
||||
&doc_data,
|
||||
TraversalFlags::empty());
|
||||
let element = GeckoElement(element);
|
||||
let element_data = element.borrow_data().unwrap();
|
||||
let styles = element_data.styles();
|
||||
|
@ -1691,7 +1698,10 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
|||
}
|
||||
|
||||
// We don't have the style ready. Go ahead and compute it as necessary.
|
||||
let shared = create_shared_context(&guard, &mut doc_data.borrow_mut(), TraversalFlags::empty());
|
||||
let shared = create_shared_context(&global_style_data,
|
||||
&guard,
|
||||
&mut doc_data.borrow_mut(),
|
||||
TraversalFlags::empty());
|
||||
let mut tlc = ThreadLocalStyleContext::new(&shared);
|
||||
let mut context = StyleContext {
|
||||
shared: &shared,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue