mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Add infrastructure for non-eagerly-cascaded pseudo-elements
This commit also removes StylistWrapper and uses Arc::get_mut instead.
This commit is contained in:
parent
2dacbc6fb3
commit
b6402a81d0
11 changed files with 188 additions and 78 deletions
|
@ -108,7 +108,7 @@ pub struct LayoutContext<'a> {
|
|||
cached_local_layout_context: Rc<LocalLayoutContext>,
|
||||
}
|
||||
|
||||
impl<'a> StyleContext<'a, ServoSelectorImpl, ServoComputedValues> for LayoutContext<'a> {
|
||||
impl<'a> StyleContext<'a, ServoSelectorImpl> for LayoutContext<'a> {
|
||||
fn shared_context(&self) -> &'a SharedStyleContext {
|
||||
&self.shared.style_context
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
use construct::ConstructionResult;
|
||||
use incremental::RestyleDamage;
|
||||
use style::servo::PrivateStyleData;
|
||||
use std::sync::Arc;
|
||||
use style::servo::{PrecomputedStyleData, PrivateStyleData};
|
||||
|
||||
/// Data that layout associates with a node.
|
||||
pub struct PrivateLayoutData {
|
||||
|
@ -17,8 +18,9 @@ pub struct PrivateLayoutData {
|
|||
/// Description of how to account for recent style changes.
|
||||
pub restyle_damage: RestyleDamage,
|
||||
|
||||
/// The current results of flow construction for this node. This is either a flow or a
|
||||
/// `ConstructionItem`. See comments in `construct.rs` for more details.
|
||||
/// The current results of flow construction for this node. This is either a
|
||||
/// flow or a `ConstructionItem`. See comments in `construct.rs` for more
|
||||
/// details.
|
||||
pub flow_construction_result: ConstructionResult,
|
||||
|
||||
pub before_flow_construction_result: ConstructionResult,
|
||||
|
@ -35,9 +37,9 @@ pub struct PrivateLayoutData {
|
|||
|
||||
impl PrivateLayoutData {
|
||||
/// Creates new layout data.
|
||||
pub fn new() -> PrivateLayoutData {
|
||||
pub fn new(precomputed_style_data: Arc<PrecomputedStyleData>) -> PrivateLayoutData {
|
||||
PrivateLayoutData {
|
||||
style_data: PrivateStyleData::new(),
|
||||
style_data: PrivateStyleData::new(precomputed_style_data),
|
||||
restyle_damage: RestyleDamage::empty(),
|
||||
flow_construction_result: ConstructionResult::None,
|
||||
before_flow_construction_result: ConstructionResult::None,
|
||||
|
|
|
@ -67,14 +67,13 @@ use std::sync::mpsc::{channel, Sender, Receiver};
|
|||
use std::sync::{Arc, Mutex, MutexGuard, RwLock};
|
||||
use style::animation::Animation;
|
||||
use style::computed_values::{filter, mix_blend_mode};
|
||||
use style::context::{ReflowGoal, StylistWrapper};
|
||||
use style::context::{ReflowGoal};
|
||||
use style::dom::{TDocument, TElement, TNode};
|
||||
use style::error_reporting::ParseErrorReporter;
|
||||
use style::logical_geometry::LogicalPoint;
|
||||
use style::media_queries::{Device, MediaType};
|
||||
use style::parallel::WorkQueueData;
|
||||
use style::properties::ComputedValues;
|
||||
use style::selector_impl::ServoSelectorImpl;
|
||||
use style::selector_matching::USER_OR_USER_AGENT_STYLESHEETS;
|
||||
use style::servo::{SharedStyleContext, Stylesheet, Stylist};
|
||||
use style::stylesheets::CSSRuleIteratorExt;
|
||||
|
@ -107,7 +106,7 @@ pub struct LayoutThreadData {
|
|||
pub display_list: Option<Arc<DisplayList>>,
|
||||
|
||||
/// Performs CSS selector matching and style resolution.
|
||||
pub stylist: Box<Stylist>,
|
||||
pub stylist: Arc<Stylist>,
|
||||
|
||||
/// A queued response for the union of the content boxes of a node.
|
||||
pub content_box_response: Rect<Au>,
|
||||
|
@ -421,7 +420,7 @@ impl LayoutThread {
|
|||
let font_cache_receiver =
|
||||
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver);
|
||||
|
||||
let stylist = box Stylist::new(device);
|
||||
let stylist = Arc::new(Stylist::new(device));
|
||||
let outstanding_web_fonts_counter = Arc::new(AtomicUsize::new(0));
|
||||
for stylesheet in &*USER_OR_USER_AGENT_STYLESHEETS {
|
||||
add_font_face_rules(stylesheet,
|
||||
|
@ -510,7 +509,7 @@ impl LayoutThread {
|
|||
style_context: SharedStyleContext {
|
||||
viewport_size: self.viewport_size.clone(),
|
||||
screen_size_changed: screen_size_changed,
|
||||
stylist: StylistWrapper::<ServoSelectorImpl>(&*rw_data.stylist),
|
||||
stylist: rw_data.stylist.clone(),
|
||||
generation: self.generation,
|
||||
goal: goal,
|
||||
new_animations_sender: Mutex::new(self.new_animations_sender.clone()),
|
||||
|
@ -809,7 +808,7 @@ impl LayoutThread {
|
|||
/// Sets quirks mode for the document, causing the quirks mode stylesheet to be used.
|
||||
fn handle_set_quirks_mode<'a, 'b>(&self, possibly_locked_rw_data: &mut RwData<'a, 'b>) {
|
||||
let mut rw_data = possibly_locked_rw_data.lock();
|
||||
rw_data.stylist.set_quirks_mode(true);
|
||||
Arc::get_mut(&mut rw_data.stylist).unwrap().set_quirks_mode(true);
|
||||
possibly_locked_rw_data.block(rw_data);
|
||||
}
|
||||
|
||||
|
@ -1060,7 +1059,7 @@ impl LayoutThread {
|
|||
|
||||
// Calculate the actual viewport as per DEVICE-ADAPT § 6
|
||||
let device = Device::new(MediaType::Screen, initial_viewport);
|
||||
rw_data.stylist.set_device(device, &data.document_stylesheets);
|
||||
Arc::get_mut(&mut rw_data.stylist).unwrap().set_device(device, &data.document_stylesheets);
|
||||
|
||||
let constraints = rw_data.stylist.viewport_constraints().clone();
|
||||
self.viewport_size = match constraints {
|
||||
|
@ -1092,8 +1091,8 @@ impl LayoutThread {
|
|||
}
|
||||
|
||||
// If the entire flow tree is invalid, then it will be reflowed anyhow.
|
||||
needs_dirtying |= rw_data.stylist.update(&data.document_stylesheets,
|
||||
data.stylesheets_changed);
|
||||
needs_dirtying |= Arc::get_mut(&mut rw_data.stylist).unwrap().update(&data.document_stylesheets,
|
||||
data.stylesheets_changed);
|
||||
let needs_reflow = viewport_size_changed && !needs_dirtying;
|
||||
unsafe {
|
||||
if needs_dirtying {
|
||||
|
|
|
@ -72,7 +72,7 @@ use style::properties::{ComputedValues, ServoComputedValues};
|
|||
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
|
||||
use style::restyle_hints::ElementSnapshot;
|
||||
use style::selector_impl::{NonTSPseudoClass, PseudoElement, ServoSelectorImpl};
|
||||
use style::servo::PrivateStyleData;
|
||||
use style::servo::{PrecomputedStyleData, PrivateStyleData};
|
||||
use url::Url;
|
||||
use util::str::is_whitespace;
|
||||
|
||||
|
@ -168,11 +168,11 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
|||
OpaqueNodeMethods::from_jsmanaged(unsafe { self.get_jsmanaged() })
|
||||
}
|
||||
|
||||
fn initialize_data(self) {
|
||||
fn initialize_data(self, precomputed: &Arc<PrecomputedStyleData>) {
|
||||
let has_data = unsafe { self.borrow_data_unchecked().is_some() };
|
||||
if !has_data {
|
||||
let ptr: NonOpaqueStyleAndLayoutData =
|
||||
Box::into_raw(box RefCell::new(PrivateLayoutData::new()));
|
||||
Box::into_raw(box RefCell::new(PrivateLayoutData::new(precomputed.clone())));
|
||||
let opaque = OpaqueStyleAndLayoutData {
|
||||
ptr: unsafe { NonZero::new(ptr as *mut ()) }
|
||||
};
|
||||
|
@ -707,9 +707,10 @@ pub trait ThreadSafeLayoutNode : Clone + Copy + Sized + PartialEq {
|
|||
})
|
||||
}
|
||||
|
||||
// TODO(emilio): Since the ::-details-* pseudos are internal, just affecting one element, and
|
||||
// only changing `display` property when the element `open` attribute changes, this should be
|
||||
// eligible for not being cascaded eagerly, reading the display property from layout instead.
|
||||
// TODO(emilio): Since the ::-details-* pseudos are internal, just affecting
|
||||
// one element, and only changing `display` property when the element `open`
|
||||
// attribute changes, this should be eligible for not being cascaded
|
||||
// eagerly, reading the display property from layout instead.
|
||||
#[inline]
|
||||
fn get_details_summary_pseudo(&self) -> Option<Self> {
|
||||
if self.is_element() &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue