mirror of
https://github.com/servo/servo.git
synced 2025-09-04 20:18:21 +01:00
Auto merge of #16802 - emilio:slim-down-slc, r=bholley
style: Slim down SharedStyleContext, and do various other cleanups around the style crate. This slims down SharedStyleContext, in preparation for a few things. First, I would like to eventually move the stylist to the document in Servo, in order for it to hold the StyleSheetSet. Also, this gets rid of a fair amount of overhead while creating it in stylo. Fixes bug 1363245. <!-- 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/16802) <!-- Reviewable:end -->
This commit is contained in:
commit
eeb1ee9723
11 changed files with 171 additions and 141 deletions
|
@ -11,9 +11,8 @@ use std::borrow::Cow;
|
|||
use std::env;
|
||||
use std::fmt::Write;
|
||||
use std::ptr;
|
||||
use std::sync::Mutex;
|
||||
use style::context::{QuirksMode, SharedStyleContext, StyleContext};
|
||||
use style::context::{ThreadLocalStyleContext, ThreadLocalStyleContextCreationInfo};
|
||||
use style::context::ThreadLocalStyleContext;
|
||||
use style::data::{ElementData, ElementStyles, RestyleData};
|
||||
use style::dom::{AnimationOnlyDirtyDescendants, DirtyDescendants};
|
||||
use style::dom::{ShowSubtreeData, TElement, TNode};
|
||||
|
@ -149,24 +148,19 @@ unsafe fn dummy_url_data() -> &'static RefPtr<URLExtraData> {
|
|||
RefPtr::from_ptr_ref(&DUMMY_URL_DATA)
|
||||
}
|
||||
|
||||
static DEFAULT_ERROR_REPORTER: RustLogReporter = RustLogReporter;
|
||||
|
||||
fn create_shared_context<'a>(global_style_data: &GlobalStyleData,
|
||||
guard: &'a SharedRwLockReadGuard,
|
||||
per_doc_data: &PerDocumentStyleDataImpl,
|
||||
per_doc_data: &'a PerDocumentStyleDataImpl,
|
||||
traversal_flags: TraversalFlags,
|
||||
snapshot_map: &'a ServoElementSnapshotTable)
|
||||
-> SharedStyleContext<'a> {
|
||||
let local_context_data =
|
||||
ThreadLocalStyleContextCreationInfo::new(per_doc_data.new_animations_sender.clone());
|
||||
|
||||
SharedStyleContext {
|
||||
stylist: per_doc_data.stylist.clone(),
|
||||
stylist: &per_doc_data.stylist,
|
||||
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(),
|
||||
// FIXME(emilio): Stop boxing here.
|
||||
error_reporter: Box::new(RustLogReporter),
|
||||
local_context_creation_data: Mutex::new(local_context_data),
|
||||
error_reporter: &DEFAULT_ERROR_REPORTER,
|
||||
timer: Timer::new(),
|
||||
// FIXME Find the real QuirksMode information for this document
|
||||
quirks_mode: QuirksMode::NoQuirks,
|
||||
|
@ -2025,9 +2019,10 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
|||
}
|
||||
|
||||
// We don't have the style ready. Go ahead and compute it as necessary.
|
||||
let data = doc_data.borrow();
|
||||
let shared = create_shared_context(&global_style_data,
|
||||
&guard,
|
||||
&mut doc_data.borrow_mut(),
|
||||
&data,
|
||||
TraversalFlags::empty(),
|
||||
unsafe { &*snapshots });
|
||||
let mut tlc = ThreadLocalStyleContext::new(&shared);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue