From d5074136e303544d108dc5615f96e92b854752ee Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sat, 18 Mar 2017 20:12:23 +0100 Subject: [PATCH] Rename ReadGuards to StylesheetGuards --- components/layout_thread/lib.rs | 8 ++++---- components/style/context.rs | 4 ++-- components/style/gecko/data.rs | 4 ++-- components/style/properties/properties.mako.rs | 4 ++-- components/style/rule_tree/mod.rs | 12 ++++++------ components/style/shared_lock.rs | 6 +++--- components/style/stylist.rs | 12 ++++++------ ports/geckolib/glue.rs | 8 ++++---- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 327089114843..1ebee7b5ead2 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -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, }; diff --git a/components/style/context.rs b/components/style/context.rs index 93dfde0932b5..3a2926672acc 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -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, /// Guards for pre-acquired locks - pub guards: ReadGuards<'a>, + pub guards: StylesheetGuards<'a>, /// The animations that are currently running. pub running_animations: Arc>>>, diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs index ad6a1d1629c0..a1ef6db3e2ee 100644 --- a/components/style/gecko/data.rs +++ b/components/style/gecko/data.rs @@ -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; } } diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 1ae30358efa8..f9c2cac07b64 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -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>, diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index 80aa88596d65..54cf785e4580 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -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(&self, guards: &ReadGuards, writer: &mut W) { + fn dump(&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>>, path: &StrongRuleNode, - guards: &ReadGuards) + guards: &StylesheetGuards) -> Option { 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(&self, guards: &ReadGuards, writer: &mut W, indent: usize) { + fn dump(&self, guards: &StylesheetGuards, writer: &mut W, indent: usize) { const INDENT_INCREMENT: usize = 4; for _ in 0..indent { diff --git a/components/style/shared_lock.rs b/components/style/shared_lock.rs index c92ab9efccf2..152e2b6ba826 100644 --- a/components/style/shared_lock.rs +++ b/components/style/shared_lock.rs @@ -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, } diff --git a/components/style/stylist.rs b/components/style/stylist.rs index d58e0dd0e856..27d3dd4b10b6 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -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], - 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>, 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) -> Arc { @@ -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(&self, - guards: &ReadGuards, + guards: &StylesheetGuards, element: &E, pseudo: &PseudoElement, parent: &Arc) @@ -544,7 +544,7 @@ impl Stylist { style_attribute: Option<&Arc>>, animation_rules: AnimationRules, pseudo_element: Option<&PseudoElement>, - guards: &ReadGuards, + guards: &StylesheetGuards, applicable_declarations: &mut V, flags: &mut ElementSelectorFlags) -> StyleRelations where E: TElement + diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 82cbd7aef74f..177a6c076e8f 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -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,