mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Rename ReadGuards to StylesheetGuards
This commit is contained in:
parent
2952ccfae2
commit
d5074136e3
8 changed files with 29 additions and 29 deletions
|
@ -116,7 +116,7 @@ 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, ReadGuards};
|
||||
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
|
||||
use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets};
|
||||
use style::stylist::Stylist;
|
||||
use style::thread_state;
|
||||
|
@ -500,7 +500,7 @@ impl LayoutThread {
|
|||
|
||||
// Create a layout context for use in building display lists, hit testing, &c.
|
||||
fn build_layout_context<'a>(&self,
|
||||
guards: ReadGuards<'a>,
|
||||
guards: StylesheetGuards<'a>,
|
||||
rw_data: &LayoutThreadData,
|
||||
request_images: bool)
|
||||
-> LayoutContext<'a> {
|
||||
|
@ -1069,7 +1069,7 @@ impl LayoutThread {
|
|||
// If the entire flow tree is invalid, then it will be reflowed anyhow.
|
||||
let ua_stylesheets = &*UA_STYLESHEETS;
|
||||
let ua_or_user_guard = ua_stylesheets.shared_lock.read();
|
||||
let guards = ReadGuards {
|
||||
let guards = StylesheetGuards {
|
||||
author: &author_guard,
|
||||
ua_or_user: &ua_or_user_guard,
|
||||
};
|
||||
|
@ -1353,7 +1353,7 @@ impl LayoutThread {
|
|||
|
||||
let author_guard = AUTHOR_SHARED_LOCK.read();
|
||||
let ua_or_user_guard = UA_STYLESHEETS.shared_lock.read();
|
||||
let guards = ReadGuards {
|
||||
let guards = StylesheetGuards {
|
||||
author: &author_guard,
|
||||
ua_or_user: &ua_or_user_guard,
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ use parking_lot::RwLock;
|
|||
use selector_parser::PseudoElement;
|
||||
use selectors::matching::ElementSelectorFlags;
|
||||
use servo_config::opts;
|
||||
use shared_lock::ReadGuards;
|
||||
use shared_lock::StylesheetGuards;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::fmt;
|
||||
|
@ -67,7 +67,7 @@ pub struct SharedStyleContext<'a> {
|
|||
pub stylist: Arc<Stylist>,
|
||||
|
||||
/// Guards for pre-acquired locks
|
||||
pub guards: ReadGuards<'a>,
|
||||
pub guards: StylesheetGuards<'a>,
|
||||
|
||||
/// The animations that are currently running.
|
||||
pub running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
|
||||
|
|
|
@ -13,7 +13,7 @@ use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
|||
use media_queries::Device;
|
||||
use parking_lot::RwLock;
|
||||
use properties::ComputedValues;
|
||||
use shared_lock::{ReadGuards, SharedRwLockReadGuard};
|
||||
use shared_lock::{StylesheetGuards, SharedRwLockReadGuard};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
|
@ -97,7 +97,7 @@ impl PerDocumentStyleDataImpl {
|
|||
pub fn flush_stylesheets(&mut self, guard: &SharedRwLockReadGuard) {
|
||||
if self.stylesheets_changed {
|
||||
let mut stylist = Arc::get_mut(&mut self.stylist).unwrap();
|
||||
stylist.update(&self.stylesheets, &ReadGuards::same(guard), None, true);
|
||||
stylist.update(&self.stylesheets, &StylesheetGuards::same(guard), None, true);
|
||||
self.stylesheets_changed = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ use parser::{Parse, ParserContext, ParserContextExtraData};
|
|||
use properties::animated_properties::TransitionProperty;
|
||||
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
|
||||
use servo_url::ServoUrl;
|
||||
use shared_lock::ReadGuards;
|
||||
use shared_lock::StylesheetGuards;
|
||||
use style_traits::ToCss;
|
||||
use stylesheets::Origin;
|
||||
#[cfg(feature = "servo")] use values::Either;
|
||||
|
@ -1861,7 +1861,7 @@ bitflags! {
|
|||
///
|
||||
pub fn cascade(device: &Device,
|
||||
rule_node: &StrongRuleNode,
|
||||
guards: &ReadGuards,
|
||||
guards: &StylesheetGuards,
|
||||
parent_style: Option<<&ComputedValues>,
|
||||
layout_parent_style: Option<<&ComputedValues>,
|
||||
cascade_info: Option<<&mut CascadeInfo>,
|
||||
|
|
|
@ -11,7 +11,7 @@ use arc_ptr_eq;
|
|||
#[cfg(feature = "servo")]
|
||||
use heapsize::HeapSizeOf;
|
||||
use properties::{Importance, PropertyDeclarationBlock};
|
||||
use shared_lock::{Locked, ReadGuards, SharedRwLockReadGuard};
|
||||
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
|
||||
use std::io::{self, Write};
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
||||
|
@ -110,13 +110,13 @@ impl RuleTree {
|
|||
self.root.clone()
|
||||
}
|
||||
|
||||
fn dump<W: Write>(&self, guards: &ReadGuards, writer: &mut W) {
|
||||
fn dump<W: Write>(&self, guards: &StylesheetGuards, writer: &mut W) {
|
||||
let _ = writeln!(writer, " + RuleTree");
|
||||
self.root.get().dump(guards, writer, 0);
|
||||
}
|
||||
|
||||
/// Dump the rule tree to stdout.
|
||||
pub fn dump_stdout(&self, guards: &ReadGuards) {
|
||||
pub fn dump_stdout(&self, guards: &StylesheetGuards) {
|
||||
let mut stdout = io::stdout();
|
||||
self.dump(guards, &mut stdout);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ impl RuleTree {
|
|||
level: CascadeLevel,
|
||||
pdb: Option<&Arc<Locked<PropertyDeclarationBlock>>>,
|
||||
path: &StrongRuleNode,
|
||||
guards: &ReadGuards)
|
||||
guards: &StylesheetGuards)
|
||||
-> Option<StrongRuleNode> {
|
||||
debug_assert!(level.is_unique_per_element());
|
||||
// TODO(emilio): Being smarter with lifetimes we could avoid a bit of
|
||||
|
@ -282,7 +282,7 @@ pub enum CascadeLevel {
|
|||
|
||||
impl CascadeLevel {
|
||||
/// Select a lock guard for this level
|
||||
pub fn guard<'a>(&self, guards: &'a ReadGuards<'a>) -> &'a SharedRwLockReadGuard<'a> {
|
||||
pub fn guard<'a>(&self, guards: &'a StylesheetGuards<'a>) -> &'a SharedRwLockReadGuard<'a> {
|
||||
match *self {
|
||||
CascadeLevel::UANormal |
|
||||
CascadeLevel::UserNormal |
|
||||
|
@ -435,7 +435,7 @@ impl RuleNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn dump<W: Write>(&self, guards: &ReadGuards, writer: &mut W, indent: usize) {
|
||||
fn dump<W: Write>(&self, guards: &StylesheetGuards, writer: &mut W, indent: usize) {
|
||||
const INDENT_INCREMENT: usize = 4;
|
||||
|
||||
for _ in 0..indent {
|
||||
|
|
|
@ -180,7 +180,7 @@ pub trait ToCssWithGuard {
|
|||
|
||||
/// Guards for a document
|
||||
#[derive(Clone)]
|
||||
pub struct ReadGuards<'a> {
|
||||
pub struct StylesheetGuards<'a> {
|
||||
/// For author-origin stylesheets
|
||||
pub author: &'a SharedRwLockReadGuard<'a>,
|
||||
|
||||
|
@ -188,10 +188,10 @@ pub struct ReadGuards<'a> {
|
|||
pub ua_or_user: &'a SharedRwLockReadGuard<'a>,
|
||||
}
|
||||
|
||||
impl<'a> ReadGuards<'a> {
|
||||
impl<'a> StylesheetGuards<'a> {
|
||||
/// Same guard for all origins
|
||||
pub fn same(guard: &'a SharedRwLockReadGuard<'a>) -> Self {
|
||||
ReadGuards {
|
||||
StylesheetGuards {
|
||||
author: guard,
|
||||
ua_or_user: guard,
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ use selectors::matching::{AFFECTED_BY_STYLE_ATTRIBUTE, AFFECTED_BY_PRESENTATIONA
|
|||
use selectors::matching::{ElementSelectorFlags, StyleRelations, matches_complex_selector};
|
||||
use selectors::parser::{Selector, SimpleSelector, LocalName as LocalNameSelector, ComplexSelector};
|
||||
use selectors::parser::SelectorMethods;
|
||||
use shared_lock::{Locked, SharedRwLockReadGuard, ReadGuards};
|
||||
use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
|
||||
use sink::Push;
|
||||
use smallvec::VecLike;
|
||||
use std::borrow::Borrow;
|
||||
|
@ -158,7 +158,7 @@ impl Stylist {
|
|||
/// device is dirty, which means we need to re-evaluate media queries.
|
||||
pub fn update(&mut self,
|
||||
doc_stylesheets: &[Arc<Stylesheet>],
|
||||
guards: &ReadGuards,
|
||||
guards: &StylesheetGuards,
|
||||
ua_stylesheets: Option<&UserAgentStylesheets>,
|
||||
stylesheets_changed: bool) -> bool {
|
||||
if !(self.is_device_dirty || stylesheets_changed) {
|
||||
|
@ -299,7 +299,7 @@ impl Stylist {
|
|||
/// values. The flow constructor uses this flag when constructing anonymous
|
||||
/// flows.
|
||||
pub fn precomputed_values_for_pseudo(&self,
|
||||
guards: &ReadGuards,
|
||||
guards: &StylesheetGuards,
|
||||
pseudo: &PseudoElement,
|
||||
parent: Option<&Arc<ComputedValues>>,
|
||||
cascade_flags: CascadeFlags)
|
||||
|
@ -345,7 +345,7 @@ impl Stylist {
|
|||
/// Returns the style for an anonymous box of the given type.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn style_for_anonymous_box(&self,
|
||||
guards: &ReadGuards,
|
||||
guards: &StylesheetGuards,
|
||||
pseudo: &PseudoElement,
|
||||
parent_style: &Arc<ComputedValues>)
|
||||
-> Arc<ComputedValues> {
|
||||
|
@ -382,7 +382,7 @@ impl Stylist {
|
|||
/// Check the documentation on lazy pseudo-elements in
|
||||
/// docs/components/style.md
|
||||
pub fn lazily_compute_pseudo_element_style<E>(&self,
|
||||
guards: &ReadGuards,
|
||||
guards: &StylesheetGuards,
|
||||
element: &E,
|
||||
pseudo: &PseudoElement,
|
||||
parent: &Arc<ComputedValues>)
|
||||
|
@ -544,7 +544,7 @@ impl Stylist {
|
|||
style_attribute: Option<&Arc<Locked<PropertyDeclarationBlock>>>,
|
||||
animation_rules: AnimationRules,
|
||||
pseudo_element: Option<&PseudoElement>,
|
||||
guards: &ReadGuards,
|
||||
guards: &StylesheetGuards,
|
||||
applicable_declarations: &mut V,
|
||||
flags: &mut ElementSelectorFlags) -> StyleRelations
|
||||
where E: TElement +
|
||||
|
|
|
@ -74,7 +74,7 @@ use style::properties::parse_one_declaration;
|
|||
use style::restyle_hints::{self, RestyleHint};
|
||||
use style::selector_parser::PseudoElementCascadeType;
|
||||
use style::sequential;
|
||||
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ReadGuards, ToCssWithGuard, Locked};
|
||||
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked};
|
||||
use style::string_cache::Atom;
|
||||
use style::stylesheets::{CssRule, CssRules, ImportRule, MediaRule, NamespaceRule};
|
||||
use style::stylesheets::{Origin, Stylesheet, StyleRule};
|
||||
|
@ -129,7 +129,7 @@ fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard,
|
|||
|
||||
SharedStyleContext {
|
||||
stylist: per_doc_data.stylist.clone(),
|
||||
guards: ReadGuards::same(guard),
|
||||
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.
|
||||
|
@ -642,7 +642,7 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
|||
-> ServoComputedValuesStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let guards = ReadGuards::same(&guard);
|
||||
let guards = StylesheetGuards::same(&guard);
|
||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||
let atom = Atom::from(pseudo_tag);
|
||||
let pseudo = PseudoElement::from_atom_unchecked(atom, /* anon_box = */ true);
|
||||
|
@ -699,7 +699,7 @@ fn get_pseudo_style(guard: &SharedRwLockReadGuard, element: GeckoElement, pseudo
|
|||
PseudoElementCascadeType::Lazy => {
|
||||
let d = doc_data.borrow_mut();
|
||||
let base = styles.primary.values();
|
||||
let guards = ReadGuards::same(guard);
|
||||
let guards = StylesheetGuards::same(guard);
|
||||
d.stylist.lazily_compute_pseudo_element_style(&guards,
|
||||
&element,
|
||||
&pseudo,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue