mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
parent
02dc8b286a
commit
643545b87f
3 changed files with 25 additions and 28 deletions
|
@ -114,7 +114,6 @@ use style::error_reporting::StdoutErrorReporter;
|
|||
use style::logical_geometry::LogicalPoint;
|
||||
use style::media_queries::{Device, MediaType};
|
||||
use style::parser::ParserContextExtraData;
|
||||
use style::servo::AUTHOR_SHARED_LOCK;
|
||||
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
|
||||
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
|
||||
use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets};
|
||||
|
@ -190,6 +189,9 @@ pub struct LayoutThread {
|
|||
/// The root of the flow tree.
|
||||
root_flow: Option<FlowRef>,
|
||||
|
||||
/// The document-specific shared lock used for author-origin stylesheets
|
||||
document_shared_lock: Option<SharedRwLock>,
|
||||
|
||||
/// The list of currently-running animations.
|
||||
running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
|
||||
|
||||
|
@ -442,6 +444,7 @@ impl LayoutThread {
|
|||
new_animations_receiver: new_animations_receiver,
|
||||
outstanding_web_fonts: outstanding_web_fonts_counter,
|
||||
root_flow: None,
|
||||
document_shared_lock: None,
|
||||
running_animations: Arc::new(RwLock::new(HashMap::new())),
|
||||
expired_animations: Arc::new(RwLock::new(HashMap::new())),
|
||||
epoch: Epoch(0),
|
||||
|
@ -1020,7 +1023,9 @@ impl LayoutThread {
|
|||
|
||||
// Calculate the actual viewport as per DEVICE-ADAPT § 6
|
||||
|
||||
let author_guard = document.style_shared_lock().read();
|
||||
let document_shared_lock = document.style_shared_lock();
|
||||
self.document_shared_lock = Some(document_shared_lock.clone());
|
||||
let author_guard = document_shared_lock.read();
|
||||
let device = Device::new(MediaType::Screen, initial_viewport);
|
||||
Arc::get_mut(&mut rw_data.stylist).unwrap()
|
||||
.set_device(device, &author_guard, &data.document_stylesheets);
|
||||
|
@ -1349,12 +1354,16 @@ impl LayoutThread {
|
|||
println!("**** pipeline={}\tForDisplay\tSpecial\tAnimationTick", self.id);
|
||||
}
|
||||
|
||||
if let Some(mut root_flow) = self.root_flow.clone() {
|
||||
let reflow_info = Reflow {
|
||||
goal: ReflowGoal::ForDisplay,
|
||||
page_clip_rect: max_rect(),
|
||||
};
|
||||
|
||||
let author_guard = AUTHOR_SHARED_LOCK.read();
|
||||
// Unwrap here should not panic since self.root_flow is only ever set to Some(_)
|
||||
// in handle_reflow() where self.document_shared_lock is as well.
|
||||
let author_shared_lock = self.document_shared_lock.clone().unwrap();
|
||||
let author_guard = author_shared_lock.read();
|
||||
let ua_or_user_guard = UA_STYLESHEETS.shared_lock.read();
|
||||
let guards = StylesheetGuards {
|
||||
author: &author_guard,
|
||||
|
@ -1362,7 +1371,6 @@ impl LayoutThread {
|
|||
};
|
||||
let mut layout_context = self.build_layout_context(guards, &*rw_data, false);
|
||||
|
||||
if let Some(mut root_flow) = self.root_flow.clone() {
|
||||
{
|
||||
// Perform an abbreviated style recalc that operates without access to the DOM.
|
||||
let animations = self.running_animations.read();
|
||||
|
@ -1380,9 +1388,9 @@ impl LayoutThread {
|
|||
None,
|
||||
&mut *rw_data,
|
||||
&mut layout_context);
|
||||
}
|
||||
assert!(layout_context.pending_images.is_none());
|
||||
}
|
||||
}
|
||||
|
||||
fn perform_post_style_recalc_layout_passes(&mut self,
|
||||
root_flow: &mut FlowRef,
|
||||
|
|
|
@ -134,7 +134,6 @@ use style::attr::AttrValue;
|
|||
use style::context::{QuirksMode, ReflowGoal};
|
||||
use style::restyle_hints::{RestyleHint, RESTYLE_STYLE_ATTRIBUTE};
|
||||
use style::selector_parser::{RestyleDamage, Snapshot};
|
||||
use style::servo::AUTHOR_SHARED_LOCK;
|
||||
use style::shared_lock::SharedRwLock as StyleSharedRwLock;
|
||||
use style::str::{HTML_SPACE_CHARACTERS, split_html_space_chars, str_join};
|
||||
use style::stylesheets::Stylesheet;
|
||||
|
@ -2132,7 +2131,7 @@ impl Document {
|
|||
scripts: Default::default(),
|
||||
anchors: Default::default(),
|
||||
applets: Default::default(),
|
||||
style_shared_lock: AUTHOR_SHARED_LOCK.clone(),
|
||||
style_shared_lock: StyleSharedRwLock::new(),
|
||||
stylesheets: DOMRefCell::new(None),
|
||||
stylesheets_changed_since_reflow: Cell::new(false),
|
||||
stylesheet_list: MutNullableJS::new(None),
|
||||
|
|
|
@ -9,13 +9,3 @@
|
|||
pub mod media_queries;
|
||||
pub mod restyle_damage;
|
||||
pub mod selector_parser;
|
||||
|
||||
use shared_lock::SharedRwLock;
|
||||
|
||||
lazy_static! {
|
||||
/// Per-process shared lock for author-origin stylesheets
|
||||
///
|
||||
/// FIXME: make it per-document or per-pipeline instead:
|
||||
/// https://github.com/servo/servo/issues/16027
|
||||
pub static ref AUTHOR_SHARED_LOCK: SharedRwLock = SharedRwLock::new();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue