mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +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
|
@ -25,7 +25,6 @@ use selector_parser::{PseudoElement, RestyleDamage, SelectorImpl};
|
|||
use selectors::bloom::BloomFilter;
|
||||
use selectors::matching::{ElementSelectorFlags, StyleRelations};
|
||||
use selectors::matching::AFFECTED_BY_PSEUDO_ELEMENTS;
|
||||
#[cfg(feature = "servo")] use servo_config::opts;
|
||||
use sink::ForgetfulSink;
|
||||
use std::sync::Arc;
|
||||
use stylist::ApplicableDeclarationBlock;
|
||||
|
@ -727,16 +726,6 @@ pub enum StyleSharingBehavior {
|
|||
Disallow,
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
fn is_share_style_cache_disabled() -> bool {
|
||||
opts::get().disable_share_style_cache
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "servo"))]
|
||||
fn is_share_style_cache_disabled() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// The public API that elements expose for selector matching.
|
||||
pub trait MatchMethods : TElement {
|
||||
/// Performs selector matching and property cascading on an element and its eager pseudos.
|
||||
|
@ -1033,7 +1022,7 @@ pub trait MatchMethods : TElement {
|
|||
context: &mut StyleContext<Self>,
|
||||
data: &mut AtomicRefMut<ElementData>)
|
||||
-> StyleSharingResult {
|
||||
if is_share_style_cache_disabled() {
|
||||
if context.shared.options.disable_style_sharing_cache {
|
||||
debug!("{:?} Cannot share style: style sharing cache disabled", self);
|
||||
return StyleSharingResult::CannotShare
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue